namespace LedgerFlow.Core.Matching; /// /// Per-supplier tolerance overrides. Finance teams trust suppliers unevenly: a strategic partner /// with clean invoices can carry a looser price band, while a supplier with a history of /// over-billing gets zero headroom. Unknown suppliers fall back to the default policy. /// public sealed class SupplierPolicies { private readonly MatchTolerances _default; private readonly IReadOnlyDictionary _overrides; public SupplierPolicies( MatchTolerances? defaultTolerances = null, IReadOnlyDictionary? overrides = null) { _default = defaultTolerances ?? MatchTolerances.Default; _overrides = overrides is null ? new Dictionary() : new Dictionary(overrides, StringComparer.OrdinalIgnoreCase); } public MatchTolerances For(string supplierId) => _overrides.TryGetValue(supplierId.Trim(), out var specific) ? specific : _default; /// A matcher configured for the given supplier. public ThreeWayMatcher MatcherFor(string supplierId) => new(For(supplierId)); }