export type LotListItem = {
  id: string;
  lot_code: string;
  supplier: string;
  grade: string;
  original_qty: number;
  available_qty: number;
  unit_cost: number;
  unit_code: string;
  warehouse: string;
  location: string | null;
  aging_days: number;
  status: string;
};

export type LotTransformationTrace = {
  id: string;
  transformation_no: string;
  transformation_type: string;
  transformation_date: string;
  status: string;
  notes: string | null;
  inputs: Array<{
    id: string;
    lot_id: string;
    lot_code: string;
    grade: string;
    qty_used: number;
    unit_cost_snapshot: number;
  }>;
  outputs: Array<{
    id: string;
    lot_id: string;
    lot_code: string;
    grade: string;
    qty_produced: number;
    available_qty: number;
    unit_cost: number;
    status: string;
  }>;
};

export type LotDetail = {
  id: string;
  lot_code: string;
  source_type: string;
  supplier: {
    id: string;
    name: string;
  } | null;
  grade: {
    id: string;
    name: string;
  } | null;
  original_qty: number;
  available_qty: number;
  reserved_qty: number;
  damaged_qty: number;
  shrinkage_qty: number;
  unit_code: string;
  unit_cost: number;
  warehouse: {
    id: string;
    name: string;
  };
  location: {
    id: string;
    name: string;
  } | null;
  status: string;
  parent_lot: {
    id: string;
    lot_code: string;
  } | null;
  buyout_info: {
    source_agent_name: string | null;
    mal_unit_price_snapshot: number;
    agent_share_percent: number;
    profit_amount: number;
    agent_commission: number;
    buyout_unit_price: number;
  } | null;
  child_lots: Array<{
    id: string;
    lot_code: string;
    status: string;
    available_qty: number;
    source_type: string;
  }>;
  produced_by_transformations: LotTransformationTrace[];
  used_in_transformations: LotTransformationTrace[];
  consignments: Array<{
    id: string;
    consignment_no: string;
    consignment_date: string;
    sales_name: string;
    buyer_name: string;
    status: string;
    qty_consigned: number;
    qty_sold: number;
    qty_returned: number;
    qty_shrinkage: number;
    selling_price: number | null;
    sales_commission: number;
    agent_commission: number;
    close_date: string | null;
  }>;
  labels: Array<{
    type: "QR" | "BARCODE";
    value: string;
  }>;
  purchase: {
    id: string;
    purchase_no: string;
    purchase_date: string | null;
  } | null;
  receipt: {
    id: string;
    receipt_no: string;
    receipt_date: string | null;
  } | null;
  received_at: string;
};
