import { z } from "zod"

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

export const expenseItemFormSchema = z.object({
    item_type: z.string().min(1, "Item type is required"),
    item_name: z.string().min(1, "Item name is required"),
    sku: z.string().optional(),
    item_code: z.string().optional(),
    description: z.string().optional(),
    category: relationFieldSchema,
    unit_type: relationFieldSchema,
    department: relationFieldSchema,
    // Purchase
    purchase_information: z.boolean().default(true),
    purchase_price: z.coerce.number().min(0).optional(),
    purchase_chart_of_account: z.string().optional(),
    purchase_preferred_vendor: relationFieldSchema,
    // Sales
    sales_information: z.boolean().default(false),
    selling_price: z.coerce.number().min(0).optional(),
    sales_chart_of_account: z.string().optional(),
    // Status
    is_active: z.boolean().default(true),
})

export type ExpenseItemFormValues = z.infer<typeof expenseItemFormSchema>
