/**
 * Sales Accounting Port
 * Handles accounting entries for sales invoices
 */

import type { SalesInvoicePaymentMethod } from '../domain/sales-invoice.model';

export type SalesInvoiceAccountingEntry = {
  invoiceId: string;
  invoiceNumber: string;
  documentType?: 'shipment' | 'tax_invoice';
  date: string;
  amount: number;
  baseCurrencyAmount?: number;
  taxAmount?: number;
  discountAmount?: number;
  exchangeRate?: number;
  description: string;
  customerId: string;
  customerName: string;
  secondaryCustomerId?: string;
  secondaryCustomerName?: string;
  primaryCoveragePercent?: number;
  secondaryCoveragePercent?: number;
  primaryCoverageAmount?: number;
  secondaryCoverageAmount?: number;
  paymentMethods?: SalesInvoicePaymentMethod[];
  status: 'posted' | 'draft' | 'reversed';
  createdBy: string;
};

export interface SalesAccountingPort {
  /**
   * Create accounting entry for a new invoice
   */
  createInvoiceEntry(entry: SalesInvoiceAccountingEntry): Promise<void>;

  /**
   * Post invoice to accounting (make it permanent)
   */
  postInvoice(invoiceId: string, invoiceNumber: string): Promise<void>;

  /**
   * Reverse invoice in accounting
   */
  reverseInvoice(invoiceId: string, invoiceNumber: string): Promise<void>;

  /**
   * Record payment received
   */
  recordPaymentReceived(
    invoiceId: string,
    invoiceNumber: string,
    amount: number,
    baseCurrencyAmount?: number,
    method?: string
  ): Promise<void>;
}
