export type PurchaseItem = {
    id: number;
    raw_material_price_id: number;
    quantity: number;
    unit_price: number;
    subtotal: number;
    variant_name: string;
};

export type Purchase = {
    id: number;
    supplier_id: number;
    created_by_id: number;
    subtotal: number;
    discount: number;
    shipping_cost: number;
    total: number;
    notes: string | null;
    photo_url: string | null;
    photo_conversion_url: string | null;
    created_at: string;
    supplier: {
        id: number;
        name: string;
    };
    created_by: {
        id: number;
        user_profile: {
            full_name: string;
        };
    };
    purchase_items: {
        id: number;
        raw_material_price_id: number;
        quantity: number;
        unit_price: number;
        subtotal: number;
        raw_material_price: {
            id: number;
            variant: string;
            price: number;
            stock: number;
            photo_url: string | null;
            photo_conversion_url: string | null;
            raw_material: {
                id: number;
                name: string;
                unit: string;
            };
        };
    }[];
};

export type PurchaseForEdit = {
    id: number;
    name: string;
    unit: string;
    supplier_id: number;
    discount: number;
    shipping_cost: number;
    notes: string | null;
    photo_key: string | null;
    photo_url: string | null;
    variants: {
        id: number;
        variant: string;
        price: number;
        stock: number;
        photo_key: string | null;
        photo_url: string | null;
    }[];
    default_mode: 'new' | 'existing';
    existing_material_name: string | null;
    existing_quantities: Record<string, number>;
};

export type Supplier = {
    id: number;
    name: string;
};

export type PurchaseCreateData = {
    suppliers: Supplier[];
    rawMaterials: {
        id: number;
        name: string;
        unit: string;
        is_active: boolean;
        raw_material_prices: {
            id: number;
            variant: string;
            price: number;
            stock: number;
            photo_url: string | null;
        }[];
    }[];
};
