import type { PurchaseOrder, PurchaseOrderItem, PurchaseOrderPaymentMethod, ShipmentType } from '@/lib/types';

export type LinkedShipment = { id: string; shipmentType: ShipmentType } | null;

export interface PurchaseSideEffectsPort {
  endorseIncomingChecksForSupplier(input: {
    paymentMethods: PurchaseOrderPaymentMethod[];
    supplierId: string;
    supplierName: string;
    orderNumber: string;
  }): Promise<boolean>;

  applyInventoryForPostedOrder(input: {
    order: Pick<PurchaseOrder, 'id' | 'date'>;
    items: PurchaseOrderItem[];
    periodCloseDate?: string;
    inventoryCloseDate?: string;
  }): Promise<LinkedShipment>;

  createShelfDistributionTask(input: {
    order: Pick<PurchaseOrder, 'id' | 'orderNumber'>;
    items: PurchaseOrderItem[];
    supplierId: string;
    supplierName: string;
    warehouseId?: string;
    settings: Record<string, unknown>;
    createdBy: string;
    transferCreationMode?: 'direct_internal_transfer' | 'work_task' | 'none';
  }): Promise<void>;

  syncMaterialPricesFromPurchase(input: {
    processedItems: PurchaseOrderItem[];
    taxMethod: 'tax-inclusive' | 'invoice-level' | 'line-level' | 'tax-exempt';
    calculatedTaxAmount: number;
    discountedSubTotal: number;
    currencyCode?: string;
  }): Promise<void>;
}
