Table of Contents

Class TaxCodeResolver

Namespace
Integrations.Application.Tax
Assembly
Integrations.Application.dll

Picks the tax code for a line: explicit override, else the most specific active mapping for entity / country / work type / sub type / trade / category, else the configured category default. Mappings are cached for CacheFor (by the business clock, so tests control it); admin changes on this replica call Invalidate(), other replicas pick them up when their copy expires.

public sealed class TaxCodeResolver
Inheritance
TaxCodeResolver
Inherited Members

Constructors

TaxCodeResolver(IAppDbContext, IMemoryCache, BusinessClock, IOptions<TaxOptions>)

Picks the tax code for a line: explicit override, else the most specific active mapping for entity / country / work type / sub type / trade / category, else the configured category default. Mappings are cached for CacheFor (by the business clock, so tests control it); admin changes on this replica call Invalidate(), other replicas pick them up when their copy expires.

public TaxCodeResolver(IAppDbContext db, IMemoryCache cache, BusinessClock clock, IOptions<TaxOptions> options)

Parameters

db IAppDbContext
cache IMemoryCache
clock BusinessClock
options IOptions<TaxOptions>

Fields

CacheFor

How long loaded mappings are reused.

public static readonly TimeSpan CacheFor

Field Value

TimeSpan

Methods

Invalidate()

Drops the cached mappings (after an admin change).

public void Invalidate()

ResolveAsync(string, string, LineCategory, string?, string?, string?, string?, DateOnly, CancellationToken)

The line's tax code: the override if given, else the most specific active mapping for the entity, country, category and work type on the date.

public Task<string> ResolveAsync(string entityId, string country, LineCategory category, string? workType, string? workSubType, string? trade, string? overrideCode, DateOnly date, CancellationToken ct)

Parameters

entityId string
country string
category LineCategory
workType string
workSubType string
trade string
overrideCode string
date DateOnly
ct CancellationToken

Returns

Task<string>