export type PurchaseReturnStatus = "draft" | "completed" | "cancelled";

export interface PurchaseReturnItem {
    id?: number;
    purchase_return_id?: number;
    product_id: number;
    quantity_returned: number;
    unit_price: number;
    total_amount: number;
    batch_number?: string | null;
    product_code?: string;
    product_name?: string;
    product?: any; // 當有關聯商品時
}

export interface PurchaseReturn {
    id: number;
    code: string;
    vendor_id: number;
    warehouse_id: number;
    user_id: number;
    return_date: string;
    status: PurchaseReturnStatus;
    total_amount: number;
    tax_amount: number;
    grand_total: number;
    remarks?: string | null;
    created_at: string;
    updated_at: string;

    // 關聯資料
    vendor?: {
        id: number;
        name: string;
    };
    user?: {
        id: number;
        name: string;
    };
    items?: PurchaseReturnItem[];
    warehouse_name?: string;
}

export const PURCHASE_RETURN_STATUS_CONFIG: Record<PurchaseReturnStatus, { label: string; color: string }> = {
    draft: { label: "草稿", color: "bg-gray-100 text-gray-800" },
    completed: { label: "已完成", color: "bg-green-100 text-green-800" },
    cancelled: { label: "已作廢", color: "bg-red-100 text-red-800" },
};
