@accounter/server
Version:
Accounter GraphQL server
36 lines (35 loc) • 1.52 kB
TypeScript
export type BusinessMatchData = {
id: string;
name: string | null;
hebrew_name: string | null;
vat_number: string | null;
suggestion_data: {
phrases?: string[];
priority?: number;
} | null;
locality: string | null;
};
export type OwnerMatchInfo = {
id: string;
locality: string | null;
};
/**
* A NULL extracted VAT amount is ambiguous: "not stated" vs "no VAT". When the
* counterparty is recognized and located in a different locality than the
* owner, the document carries no local VAT — resolve the amount to 0.
*
* In every other case (VAT already extracted, owner/counterparty unknown,
* locality missing or identical) the original value is returned unchanged.
*/
export declare function applyForeignCounterpartyVatDefault(vatAmount: number | null, owner: OwnerMatchInfo | undefined, suggestedIssuer: string | null, suggestedRecipient: string | null, businesses: BusinessMatchData[]): number | null;
/**
* Attempt to match an extracted name/VAT to a known business.
*
* Priority:
* 1. VAT exact match — definitive for Israeli invoices.
* 2. Name exact / substring match (case-insensitive, both Latin and Hebrew).
* 3. suggestion_data.phrases substring match, sorted by priority descending.
*
* Returns the matching business UUID, or null if no confident match.
*/
export declare function matchBusiness(extractedName: string | null | undefined, extractedVatNumber: string | null | undefined, businesses: BusinessMatchData[]): string | null;