import { z } from "zod";

const officeBuyoutLineSchema = z.object({
  source_lot_id: z.string().trim().min(1, "Lot sumber wajib dipilih"),
  qty_buyout: z.coerce.number().positive("Qty buyout harus lebih besar dari 0"),
  buyout_unit_price: z.coerce.number().nonnegative("Harga buyout tidak boleh negatif"),
  notes: z.string().trim().optional().nullable().or(z.literal(""))
});

export const officeBuyoutInputSchema = z.object({
  buyout_source_agent_id: z.string().trim().min(1, "Agen sumber wajib dipilih"),
  purchase_date: z.string().trim().min(1, "Tanggal buyout wajib diisi"),
  notes: z.string().trim().optional().nullable().or(z.literal("")),
  lines: z.array(officeBuyoutLineSchema).min(1, "Minimal satu lot untuk buyout")
});

export type OfficeBuyoutInput = z.infer<typeof officeBuyoutInputSchema>;
