Themia.ETax.Data
0.35.2
dotnet add package Themia.ETax.Data --version 0.35.2
NuGet\Install-Package Themia.ETax.Data -Version 0.35.2
<PackageReference Include="Themia.ETax.Data" Version="0.35.2" />
<PackageVersion Include="Themia.ETax.Data" Version="0.35.2" />
<PackageReference Include="Themia.ETax.Data" />
paket add Themia.ETax.Data --version 0.35.2
#r "nuget: Themia.ETax.Data, 0.35.2"
#:package Themia.ETax.Data@0.35.2
#addin nuget:?package=Themia.ETax.Data&version=0.35.2
#tool nuget:?package=Themia.ETax.Data&version=0.35.2
Themia.ETax.Data
Database helpers for Themia.ETax. Apps own their tax document table and its migration; this package supplies the parts every app must get
right, so all of them get them the same way. PostgreSQL today. net10.0 (it needs the framework's transactional sequence allocator).
The required guards (TaxDocumentGuards)
Call both from your own FluentMigrator migration, after the table exists:
var map = new TaxDocumentTableMap { Table = "tax_documents", SentStateValue = 3, CancelledStateValue = 5 };
TaxDocumentGuards.ApplyImmutability(this, map);
TaxDocumentGuards.ApplySameSellerReplacementKey(this, map);
ApplyImmutabilitycreates a row trigger and a truncate trigger. Once a row has a snapshot, its key, seller, number, kind, issue date and the four snapshot columns can never change, including by setting the snapshot to NULL (the guard reads the OLD row). Nothing is ever deleted or truncated, legacy rows without a snapshot included. A Sent document can only become Cancelled together with a replacement id, a Cancelled document never changes state again, and once a replacement id is set it cannot be changed or cleared. Legacy rows (no snapshot) may still be updated, so an app can backfill them; they are guarded from the moment they gain a snapshot.ApplySameSellerReplacementKeyadds a unique index on (id, seller) and a composite foreign key (replaced-by, seller) to (id, seller), so a document can only be replaced by one of the same seller. It isDEFERRABLE INITIALLY DEFERREDbecauseTaxDocumentServicecancels the old document, naming its replacement, before it inserts the replacement.Names:
TaxDocumentTableMaptakes your table and column names (PascalCase works); identifiers are validated, then quoted. The table name may be at most 39 characters, so every name derived from it (function, triggers, index,fk_<table>_replaced_same_seller) stays within PostgreSQL's 63; a longer one would be silently truncated and the replay check would never find it.State values: integers, enums (stored as their NUMBER, so the column must be an integer type) or plain strings of letters, digits and underscores (a text, character or native enum column). The migration checks the column's type and fails at migration time if it does not fit, rather than at the first UPDATE. Strings are limited to that alphabet because they are written into a function body.
Adoptable and repeatable: functions are created-or-replaced, triggers dropped and recreated, the index and constraint are created only if missing, so a migration may adopt a database that already has some of it or run twice. An existing constraint of the same name is left as it is.
search_path: objects are created unqualified (in the first schema of the connection's
search_path) unless you setSchema. Nothing is hardcoded topublic.Other engines: the migration throws
NotSupportedExceptioninstead of silently leaving issued tax documents editable.Run the application as a role that does NOT own the table. The trigger stops application bugs, not someone with DDL rights: the table's owner (or a superuser) can
ALTER TABLE ... DISABLE TRIGGERor drop it. Let the migration role own the table and the guards, and give the application role only row access, so disabling the trigger needs the migration credentials:-- run by the migration role (the owner of tax_documents): GRANT SELECT, INSERT, UPDATE ON tax_documents TO app_role; -- no DELETE, TRUNCATE, TRIGGER or REFERENCESRow guards still apply to the application role;
ALTER TABLEandDROPare refused to it because it is not the owner. Roles withsession_replication_role = replica(superuser) also bypass triggers, so never connect the application as a superuser.
Document numbers (SequenceTaxDocumentNumberSource)
services.AddThemiaETaxSequenceNumbers() (after AddThemiaSequences) registers an ITaxDocumentNumberSource over
ITransactionalSequenceAllocator: the number is drawn inside the issue transaction, so commit keeps it and rollback returns it. One run per seller,
kind and (by default) year, formatted TAX-2026-000001. Prefixes, period, padding and tenant-or-host counters are options; anything else is your own
ITaxDocumentNumberSource. Seller ids must be short enough for the allocator's 100-character key. The caller's transaction must be READ COMMITTED.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net10.0
- Dapper (>= 2.1.79)
- FluentMigrator (>= 8.0.1)
- Handlebars.Net (>= 2.1.6)
- Microsoft.Data.SqlClient (>= 6.1.5)
- Microsoft.Extensions.Caching.Memory (>= 10.0.9)
- Microsoft.Extensions.DependencyInjection (>= 10.0.9)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 10.0.9)
- Microsoft.Extensions.Logging (>= 10.0.9)
- Microsoft.Extensions.Logging.Abstractions (>= 10.0.9)
- Microsoft.Extensions.Options (>= 10.0.9)
- Microsoft.IdentityModel.JsonWebTokens (>= 8.19.1)
- Microsoft.IdentityModel.Logging (>= 8.19.1)
- Microsoft.IdentityModel.Protocols (>= 8.19.1)
- Microsoft.IdentityModel.Protocols.OpenIdConnect (>= 8.19.1)
- Microsoft.IdentityModel.Tokens (>= 8.19.1)
- MySqlConnector (>= 2.6.0)
- Npgsql (>= 10.0.3)
- PuppeteerSharp (>= 25.1.2)
- System.IdentityModel.Tokens.Jwt (>= 8.19.1)
- System.Security.Cryptography.Pkcs (>= 10.0.13)
- Themia.ETax (>= 0.35.2)
- Themia.Framework.Data.Sequences (>= 0.35.2)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on Themia.ETax.Data:
| Package | Downloads |
|---|---|
|
Themia.ETax.Withholding.Data
Database helpers for Themia.ETax.Withholding: the required immutability trigger, same-payer replacement key and issue-key uniqueness (FluentMigrator, PostgreSQL) for an app's own withholding certificate table, and the gapless certificate-number source over Themia's transactional sequence allocator. |
GitHub repositories
This package is not used by any popular GitHub repositories.