/** Documento abierto con saldo. `installments_paid` = parcialidades previas vigentes. */ export interface OpenDocument { id: string; number: string; issued_at: string; due_at?: string | null; total: number; balance: number; currency: string; /** `PPD` / `PUE` u otro: el núcleo no lo interpreta; fiscal_mexico sí. */ payment_method?: string | null; installments_paid?: number; /** Extensiones de país (UUID, serie…). Pasan intactas a la línea. */ extra?: Record; } export interface Allocation { document_id: string; amount: number; /** Saldo anterior / pagado / insoluto: lo que pide el DoctoRelacionado del REP y el estado de cuenta. */ balance_before: number; balance_after: number; /** Número de parcialidad de ESTE pago para el documento (1-based). */ installment: number; } export type AllocationStrategy = 'oldest_due_first' | 'oldest_issued_first' | 'manual'; export interface AllocationResult { allocations: Allocation[]; applied: number; unapplied: number; } /** Reparte `amount` sobre `docs` según la estrategia. `manual` respeta `manual[id]`. */ export declare function allocatePayment(amount: number, docs: readonly OpenDocument[], strategy?: AllocationStrategy, manual?: Readonly>): AllocationResult; export interface AllocationIssue { code: 'over_balance' | 'over_amount' | 'currency_mismatch' | 'unapplied' | 'non_positive'; document_id?: string; severity: 'error' | 'warning'; } /** Revisión previa a guardar (la UI la pinta en ValidationChecklist; el backend la repite). */ export declare function validateAllocation(amount: number, currency: string, docs: readonly OpenDocument[], allocations: readonly Allocation[], opts?: { allowUnapplied?: boolean; }): AllocationIssue[]; //# sourceMappingURL=allocation.d.ts.map