export type ProcurementStatus = 'PENDING' | 'CONFIRMED' | 'IN_TRANSIT' | 'RECEIVED' | 'CANCELLED';
export type SupplierStatus = 'ACTIVE' | 'INACTIVE' | 'BLACKLISTED';
export type SupplierLevel = 'A' | 'B' | 'C' | 'D';
export type PaymentStatus = 'UNPAID' | 'PARTIAL' | 'PAID';
export type QualityStatus = 'PENDING' | 'PASSED' | 'FAILED' | 'PARTIAL';

export interface Supplier {
  id: string;
  tenant_id: string;
  name: string;
  code: string;
  contact_person: string;
  phone: string;
  email?: string;
  address: string;
  status: SupplierStatus;
  level: SupplierLevel;
  category: string[];
  payment_terms?: string;
  credit_limit?: number;
  credit_used?: number;
  lead_time_days?: number;
  min_order_amount?: number;
  rating: number;
  total_orders: number;
  total_amount: number;
  on_time_rate: number;
  quality_pass_rate: number;
  remarks?: string;
  created_at: string;
  updated_at: string;
}

export interface ProcurementItem {
  id: string;
  procurement_id: string;
  product_id: string;
  product_name: string;
  sku: string;
  quantity: number;
  unit: string;
  unit_price: number;
  total_price: number;
  received_quantity: number;
  quality_status: QualityStatus;
  remarks?: string;
}

export interface ProcurementRecord {
  id: string;
  tenant_id: string;
  supplier_id: string;
  supplier_name: string;
  order_no: string;
  status: ProcurementStatus;
  items: ProcurementItem[];
  total_quantity: number;
  total_amount: number;
  currency: string;
  payment_status: PaymentStatus;
  paid_amount: number;
  expected_date?: string;
  actual_date?: string;
  warehouse_id?: string;
  warehouse_name?: string;
  purchaser: string;
  approver?: string;
  approved_at?: string;
  remarks?: string;
  attachments?: string[];
  created_at: string;
  updated_at: string;
}

export interface ProcurementStats {
  total_orders: number;
  pending_orders: number;
  in_transit_orders: number;
  completed_orders: number;
  total_amount: number;
  pending_amount: number;
  supplier_count: number;
  active_supplier_count: number;
}

export interface SupplierPerformance {
  supplier_id: string;
  supplier_name: string;
  total_orders: number;
  on_time_rate: number;
  quality_pass_rate: number;
  return_rate: number;
  avg_lead_time: number;
  total_amount: number;
}
