import { z } from "zod"

const relationFieldSchema = z
    .object({ value: z.string(), label: z.string() })
    .nullable()

const vendorCreditFormSchema = z.object({
    vendor: relationFieldSchema.refine((val) => !!val?.value, "Vendor is required"),
    bill: relationFieldSchema,
    department: relationFieldSchema,
    subject: z.string().min(1, "Subject is required"),
    vendor_credit_date: z.string().min(1, "Vendor credit date is required"),
    status: z.string().optional(),
    discount: z.string().optional(),
    notes: z.string().optional(),
})

type VendorCreditFormValues = z.infer<typeof vendorCreditFormSchema>

export { vendorCreditFormSchema, relationFieldSchema }
export type { VendorCreditFormValues }
