export type PurchaseListItem = {
  id: string;
  purchase_no: string;
  purchase_date: string;
  received_at: string | null;
  agent: {
    id: string;
    name: string;
  } | null;
  status: string;
  line_count: number;
  receipt_count: number;
  lot_count: number;
  grand_total: number;
};

export type PurchaseDetail = {
  id: string;
  purchase_no: string;
  purchase_date: string;
  supplier_invoice_no: string | null;
  status: string;
  notes: string | null;
  received_at: string | null;
  received_by_employee: {
    id: string;
    name: string;
  } | null;
  agent: {
    id: string;
    name: string;
  } | null;
  profit_share_scheme: {
    id: string;
    name: string;
  } | null;
  courier: {
    id: string;
    name: string;
  } | null;
  moisture_buy_percent: number | null;
  moisture_received_percent: number | null;
  above_average_ratio_percent: number | null;
  mk_share_percent: number | null;
  non_mk_share_percent: number | null;
  shipping_cost: number | null;
  incoming_operational_cost: number | null;
  after_arrival_operational_cost: number | null;
  analysis: {
    id: string;
    status: string;
    weight_buy: number | null;
    weight_received: number | null;
    weight_final: number | null;
    average_price: number | null;
    modal_beli: number | null;
    modal_masuk: number | null;
    modal_jual: number | null;
    modal_barang: number | null;
    total_modal_beli: number | null;
    total_modal_mal: number | null;
    market_reference_price: number | null;
    cost_lines: Array<{
      id: string;
      cost_name: string;
      amount: number;
      notes: string | null;
      proof_file_url: string | null;
    }>;
  } | null;
  lines: Array<{
    id: string;
    grade: {
      id: string;
      name: string;
    } | null;
    qty_ordered: number;
    qty_received: number;
    qty_accepted: number;
    qty_rejected: number;
    purchase_moisture_percent: number | null;
    moisture_received_percent: number | null;
    unit_cost: number;
    mal_unit_price: number | null;
    unit: {
      id: string;
      code: string;
    };
    unit_price: number;
    subtotal: number;
    classification_status: string;
    warehouse: {
      id: string;
      code: string;
      name: string;
    } | null;
    warehouse_location: {
      id: string;
      code: string;
      name: string;
    } | null;
    notes: string | null;
  }>;
};
