// ─── Purchase Request Item ──────────────────────────────────────

export interface PurchaseRequestItem {
  id: number;
  purchase_request_id: number;
  product_id: number;
  product_name: string;
  product_code: string;
  product_variant_id: number | null;
  variant_name: string | null;
  unit_id: number;
  unit_name: string;
  unit_symbol: string;
  description: string | null;
  description_ar: string | null;
  quantity: string;
  estimated_price: string;
  estimated_total: string;
  preferred_supplier_id: number | null;
  preferred_supplier_name: string | null;
  notes: string | null;
  sort_order: number;
}

export interface PurchaseRequestItemPayload {
  product_id: number;
  product_variant_id?: number | null;
  unit_id: number;
  description?: string | null;
  description_ar?: string | null;
  quantity: number;
  estimated_price?: number | null;
  preferred_supplier_id?: number | null;
  notes?: string | null;
  sort_order?: number;
}

// ─── Purchase Request ───────────────────────────────────────────

export interface PurchaseRequest {
  id: number;
  request_number: string;
  date: string;
  requested_by: number | null;
  requested_by_name: string | null;
  department: string | null;
  department_ar: string | null;
  needed_by: string | null;
  priority: 'low' | 'normal' | 'high' | 'urgent';
  reason: string | null;
  reason_ar: string | null;
  notes: string | null;
  notes_ar: string | null;
  cost_center_id: number | null;
  status: 'draft' | 'pending_approval' | 'approved' | 'rejected' | 'converted' | 'cancelled';
  subtotal: string;
  converted_to_order_id: number | null;
  items: PurchaseRequestItem[];
  approved_by: number | null;
  approved_at: string | null;
  approved_by_name: string | null;
  created_by: number | null;
  created_by_name: string | null;
  created_at: string;
  updated_at: string;
}

export interface CreatePurchaseRequest {
  date: string;
  department?: string | null;
  department_ar?: string | null;
  needed_by?: string | null;
  priority?: 'low' | 'normal' | 'high' | 'urgent';
  reason?: string | null;
  reason_ar?: string | null;
  notes?: string | null;
  notes_ar?: string | null;
  cost_center_id?: number | null;
  items: PurchaseRequestItemPayload[];
}

export interface UpdatePurchaseRequest extends Partial<CreatePurchaseRequest> {}
