UNPKG

@accounter/server

Version:
42 lines (41 loc) 1.42 kB
/** * Single-Match Provider * * Implements the core single-match logic for finding potential charge matches. * This is a pure function implementation without database dependencies. */ import type { Injector } from 'graphql-modules'; import type { DocumentCharge, TransactionCharge } from '../types.js'; /** * Match result with score and metadata */ export interface MatchResult { chargeId: string; confidenceScore: number; components: { amount: number; currency: number; business: number; date: number; }; dateProximity?: number; gentleMode?: boolean; } /** * Options for findMatches function */ export interface FindMatchesOptions { maxMatches?: number; dateWindowMonths?: number; } /** * Find top matches for an unmatched charge * * @param sourceCharge - The unmatched charge (transactions OR documents) * @param candidateCharges - All potential match candidates * @param userId - Current user ID * @param options - Optional configuration (maxMatches, dateWindowMonths, injector) * @returns Top matches sorted by confidence * @throws Error if source charge is matched or has validation issues */ export declare function findMatches(sourceCharge: TransactionCharge | DocumentCharge, candidateCharges: Array<TransactionCharge | DocumentCharge>, userId: string, injector: Injector, options?: FindMatchesOptions): Promise<MatchResult[]>;