/** What we know about a buyer from a Stripe charge. */ export interface BuyerInput { name: string | null; email: string | null; /** Billing country (ISO-2) from Stripe; usually "" for Luma checkouts. */ country: string | null; /** Company name the buyer entered on the Stripe Customer/Invoice — the strongest signal. */ companyName?: string | null; /** EU VAT id from the Stripe Customer/Invoice tax ids, when present. */ vatId?: string | null; } /** One Estonian business-register entity. */ export interface AriregCompany { name: string; regNo: string; legalForm: string; vat: string | null; active: boolean; } /** Why a candidate matched and how strongly. */ export type MatchReason = "override" | "stripe-vat" | "stripe-name" | "buyer-name-exact" | "name-exact" | "name-startswith" | "name-contains"; export interface CompanyCandidate extends AriregCompany { matchReason: MatchReason; } /** Outcome of a VIES VAT check. */ export interface ViesResult { checked: boolean; /** true/false from VIES; null when the member state was unavailable (NOT a real "invalid"). */ valid: boolean | null; name: string | null; note?: string; } /** Resolution tier — drives whether the charge is invoiced or summarized. */ export type ResolutionTier = "confirmed" | "review" | "private"; export interface Resolution { tier: ResolutionTier; reason: string; emailDomain: string | null; freeMail: boolean; /** The chosen entity when tier === "confirmed"; otherwise null. */ company: CompanyCandidate | null; /** All candidates considered (top-ranked first) — shown in the review list. */ candidates: CompanyCandidate[]; vies?: ViesResult; }