UNPKG

@accounter/server

Version:
50 lines (49 loc) 2.03 kB
import type { charge_type } from '../../charges/types.js'; import type { ChargesMatcherModule } from '../types.js'; type ChargeMatchQueueMode = ChargesMatcherModule.ChargeMatchQueueMode; /** * Only COMMON and BUSINESS_TRIP charges (or charges with a not-yet-resolved * `null` type, which resolve to either COMMON or BUSINESS_TRIP) are expected to * hold both documents and transactions, so only they belong in the * awaiting-match queue. */ export declare function chargeRequiresMatch(charge: { type?: charge_type | null; }): boolean; /** * Max number of charges evaluated when sorting the queue BY_SCORE. Scoring is * calculated on the fly and each pass loads candidates, transactions and * documents, so the evaluation window is deliberately capped to bound request * latency and DB load. */ export declare const BY_SCORE_EVALUATION_CAP = 100; /** * The subset of enriched charge fields the queue filtering relies on. * Counts are int8 aggregates, surfaced by pgtyped as strings. */ export interface QueueChargeCounts { transactions_count: string | null; invoices_count: string | null; receipts_count: string | null; } /** * A charge is transaction-based when it has transactions but no receipt * documents (mirrors the auto-match unmatched-charge semantics) */ export declare function isTransactionBaseCharge(charge: QueueChargeCounts): boolean; /** * A charge is document-based when it has accounting documents but no * transactions */ export declare function isDocumentBaseCharge(charge: QueueChargeCounts): boolean; /** * A charge belongs in the awaiting-match queue when it is unmatched: * transaction-based XOR document-based. Charges with both sides (matched) or * neither (empty) are excluded. */ export declare function isUnmatchedBaseCharge(charge: QueueChargeCounts): boolean; /** * Apply the optional queue mode filter on top of the unmatched check */ export declare function matchesQueueMode(charge: QueueChargeCounts, mode?: ChargeMatchQueueMode | null): boolean; export {};