feat: document totals, VAT summary, stamp duty, withholding and installments (#48)

The engine now computes the totals of every document it saves: line amounts with
cascaded discounts, footer discount on goods, VAT summary per tax code with the tax
on the group total, prices with VAT split back once per group, split payment and
cash-basis exigibility, stamp duty above the threshold of the fiscal pack, social
security contribution, withholding (also on part of the amount) and ENASARCO taken
off the amount to pay. Installments come from the payment terms with end of month,
fixed day, the customer's excluded months and VAT on the first installment.

The figures live in two shared tables keyed by family (ADR 0033) and are rewritten
in the same transaction as the document. DocumentEditor serves the screens: radars,
values proposed by party and item, totals preview without saving, linked documents
and open documents to fulfil. The copy service can merge several documents of one
party, the base of deferred invoicing.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Alby96andClaude Opus 5.5 committed 2026-11-12 15:55:58 +01:00
1 parent ddd2273f7e
commit f12848865d
21 files changed
+1916 -31

No files matched your search

@@ -151,6 +151,7 @@ internal static class KhaemhatServices
// The document engine (ADR 0032): one engine, the copies, a typed service per family.
services.AddSingleton<Khaemhat.Application.Documents.DocumentEngine>();
services.AddSingleton<Khaemhat.Application.Documents.DocumentCopyService>();
services.AddSingleton<Khaemhat.Application.Documents.DocumentEditor>();
services.AddSingleton(typeof(Khaemhat.Application.Documents.DocumentService<,>));
// Guided import and export (ADR 0031): the entities in the order of the screen.
@@ -27,7 +27,8 @@
"item-required": "Una riga articolo ha bisogno dell'articolo.",
"below-fulfilled": "La quantità non può scendere sotto quella già evasa.",
"fulfilled-removed": "Una riga già evasa da altri documenti non si può togliere.",
"source-invalid": "La riga d'origine non esiste o non può essere evasa da questo documento."
"source-invalid": "La riga d'origine non esiste o non può essere evasa da questo documento.",
"discount-invalid": "Lo sconto si scrive come percentuali separate da +, ad esempio 10+5."
},
"cancel": {
"reason-required": "Per annullare una fattura indica il motivo.",
@@ -36,7 +37,8 @@
"copy": {
"direction": "Si trasforma solo in un documento della stessa direzione (vendita o acquisto).",
"nothing-left": "Non c'è più nulla da evadere.",
"source-not-open": "Il documento non è confermato o è chiuso o annullato: non si può evadere."
"source-not-open": "Il documento non è confermato o è chiuso o annullato: non si può evadere.",
"parties": "I documenti scelti sono di clienti o fornitori diversi: si uniscono solo documenti della stessa controparte."
},
"number": {
"date-before-last": "La data è anteriore a quella dell'ultimo documento numerato: con questo numeratore non sono ammessi documenti fuori sequenza.",