import type { Customer, PurchaseOrder, Supplier } from '@/lib/types';

export type CreatePurchaseOrderRecord = Omit<
  PurchaseOrder,
  'orderNumber' | 'status' | 'createdAt' | 'lockedById' | 'lockedByName' | 'lockedAt' | 'cancelledAt' | 'cancelledBy' | 'cancelledReason'
> & {
  id: string;
  createdBy: string;
};

export interface PurchaseOrderRepository {
  findSupplierById(id: string): Promise<Supplier | null>;
  findCustomerById(id: string): Promise<Customer | null>;
  createSupplierFromCustomer(customer: Customer, supplierId: string): Promise<Supplier>;
  listPurchaseOrders(): Promise<PurchaseOrder[]>;
  getPurchaseOrderById(id: string): Promise<PurchaseOrder | null>;
  createPurchaseOrder(order: CreatePurchaseOrderRecord): Promise<PurchaseOrder>;
  updatePurchaseOrder(id: string, patch: Partial<Pick<PurchaseOrder, 'taxInvoiceId' | 'linkedShipmentIds' | 'documentType'>>): Promise<void>;
  addSupplierBalance(supplierId: string, delta: number): Promise<void>;
}
