@accounter/server
Version:
Accounter GraphQL server
28 lines (27 loc) • 1.47 kB
TypeScript
import type { Injector } from 'graphql-modules';
import { DocumentType } from '../../../shared/enums.js';
import type { AggregatedTransaction, DocumentCharge, MatchScore, TransactionCharge } from '../types.js';
/**
* Select appropriate transaction date based on document type
* Per specification:
* - INVOICE/CREDIT_INVOICE: Use event_date
* - RECEIPT/INVOICE_RECEIPT: Use debit_date (debit_timestamp or debit_date)
* - OTHER/PROFORMA/UNPROCESSED: Calculate both and use better score
*
* @param transaction - Aggregated transaction data
* @param documentType - Document type being matched
* @returns The date to use for matching
*/
export declare function selectTransactionDate(transaction: AggregatedTransaction, documentType: DocumentType): Date;
/**
* Score a potential match between transaction charge and document charge
* Aggregates data from both charges and calculates confidence score
*
* @param txCharge - Transaction charge to match
* @param docCharge - Document charge candidate
* @param userId - Current user UUID for business extraction
* @param injector - Optional GraphQL modules injector for provider access (for client matching)
* @returns Match score with confidence and component breakdown
* @throws Error if aggregation fails (mixed currencies, multiple businesses, etc.)
*/
export declare function scoreMatch(txCharge: TransactionCharge, docCharge: DocumentCharge, userId: string, injector: Injector): Promise<MatchScore>;