M5 · Motore documenti e vendite (v0.5.0) #124

Merged
Alby96 merged 5 commits from feat/47-motore-documenti into main 2026-11-12 18:48:59 +01:00
Owner

Chiude la milestone M5 — Motore documenti e Vendite.

Cosa contiene

  • Motore documenti (#47, ADR 0032): generi e tipi, sei famiglie di tabelle con righe e document_links, macchina a stati, numerazione atomica alla conferma, copia e trasformazione con evasione riga per riga.
  • Totali e scadenze (#48, ADR 0033): sconti a cascata, castelletto IVA, esigibilità, bollo, cassa previdenza, ritenuta, ENASARCO, rate dalle condizioni di pagamento.
  • Maschere delle vendite (#49, #50): radar di preventivi, ordini, DDT, fatture e note; maschera unica con Righe, Testata, Trasporto, Totali, Scadenze, Note, Allegati, Collegamenti, Storico; Crea … con scelta di righe e residui.
  • Fatturazione differita guidata (#51): DDT del periodo, una fattura TD24 per cliente o per DDT, in bozza o emessa.
  • Stampa ed e-mail (#52, ADR 0034): anteprima e PDF dallo stesso modello, PDF come allegato versionato, invio con modello, client SMTP e coda in background scritti in casa, esito nel log E-mail/PEC.
  • Dati demo e documentazione (#53): profilo e un anno di vendite di esempio, log Documenti, wiki con la nuova Guida all'uso e le schermate reali, README.md come guida di installazione per sviluppatori.
  • Chiusura (#54): CHANGELOG.md 0.5.0, docs/STATUS.md, wiki aggiornata.

Verifica

  • dotnet build Khaemhat.sln -c Release -warnaserror: 0 avvisi, 0 errori.
  • dotnet test: 660 verdi in locale, 23 di PostgreSQL saltati (girano in CI).
  • Prova manuale sul server di sviluppo con i dati di esempio (schermate in docs/wiki/img/vendite-*.png): radar, fattura, Crea ordine, DDT, fatturazione differita, anteprima di stampa, finestra e-mail.

Closes #47
Closes #48
Closes #49
Closes #50
Closes #51
Closes #52
Closes #53
Closes #54

🤖 Generated with Claude Code

Chiude la milestone **M5 — Motore documenti e Vendite**. ## Cosa contiene - **Motore documenti** (#47, ADR 0032): generi e tipi, sei famiglie di tabelle con righe e `document_links`, macchina a stati, numerazione atomica alla conferma, copia e trasformazione con evasione riga per riga. - **Totali e scadenze** (#48, ADR 0033): sconti a cascata, castelletto IVA, esigibilità, bollo, cassa previdenza, ritenuta, ENASARCO, rate dalle condizioni di pagamento. - **Maschere delle vendite** (#49, #50): radar di preventivi, ordini, DDT, fatture e note; maschera unica con Righe, Testata, Trasporto, Totali, Scadenze, Note, Allegati, Collegamenti, Storico; *Crea …* con scelta di righe e residui. - **Fatturazione differita guidata** (#51): DDT del periodo, una fattura TD24 per cliente o per DDT, in bozza o emessa. - **Stampa ed e-mail** (#52, ADR 0034): anteprima e PDF dallo stesso modello, PDF come allegato versionato, invio con modello, client SMTP e coda in background scritti in casa, esito nel log *E-mail/PEC*. - **Dati demo e documentazione** (#53): profilo e un anno di vendite di esempio, log *Documenti*, wiki con la nuova *Guida all'uso* e le schermate reali, `README.md` come guida di installazione per sviluppatori. - **Chiusura** (#54): `CHANGELOG.md` 0.5.0, `docs/STATUS.md`, wiki aggiornata. ## Verifica - `dotnet build Khaemhat.sln -c Release -warnaserror`: 0 avvisi, 0 errori. - `dotnet test`: 660 verdi in locale, 23 di PostgreSQL saltati (girano in CI). - Prova manuale sul server di sviluppo con i dati di esempio (schermate in `docs/wiki/img/vendite-*.png`): radar, fattura, Crea ordine, DDT, fatturazione differita, anteprima di stampa, finestra e-mail. Closes #47 Closes #48 Closes #49 Closes #50 Closes #51 Closes #52 Closes #53 Closes #54 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Alby96 added this to the M5 — Motore documenti e Vendite · v0.5.0 milestone 2026-11-12 17:39:21 +01:00
Alby96 added 4 commits 2026-11-12 17:39:22 +01:00
One engine for sales, purchases and warehouse documents (ADR 0032). Each document
type now carries a kind that decides its family of tables, life cycle, effects,
accepted lines, the kinds it fulfils and its permissions, so company-defined types
work without code.

- Six families of header and line tables plus document_links; document_types gets
  document_kind (seeded types filled by the migration and the Italian template),
  document_numerators gets last_date.
- DocumentStateMachine with the order, invoice and simple life cycles and the
  actions each state admits; issued invoices are immutable and are cancelled with
  a reason only before the file reaches the exchange system.
- DocumentNumberingService numbers at confirmation inside the transaction under
  the numerator lock (advisory lock on PostgreSQL, write lock on SQLite): no
  duplicates, a rollback gives the number back, out-of-sequence dates refused on
  gap-free numerators, the new year's numerator created on first use, gap report.
- DocumentEngine, the generic DocumentService<THeader, TLine> and
  DocumentCopyService: save, confirm or issue, cancel, close, reopen, delete,
  duplicate and transform; links are recorded at confirmation and removed at
  cancellation, and FulfillmentCalculator recomputes quantities and states.
- Tests: rules in Core, concurrent numbering on SQLite and PostgreSQL (data tests,
  run on PostgreSQL 18 locally), order to delivery notes to deferred invoice on a
  real instance. Wiki (Vendite, Tabelle azienda), CHANGELOG, STATUS, DATA-MODEL.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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>
Quotations, orders, delivery notes, invoices and credit notes get their radars and
one document screen (lines, header, transport, links, attachments) with the
transformations of the engine, so a quotation reaches the invoice without
retyping. The deferred invoicing groups the open delivery notes of a period by
customer, payment and destination into one invoice each.

Every document prints from one model: an HTML preview on screen and a PDF drawn
by the in-house writer, kept among the attachments as a new version. "Invia per
e-mail" proposes recipient, subject and text from the templates, attaches the
PDF and hands it to a background queue that talks SMTP itself (no external
library); the outcome goes to the log, section E-mail/PEC.

The demo company now has a year of sales in every state, made through the
engine, and run-dev.sh no longer writes to a stray B:\b folder under Git Bash.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
docs: user guide with real screenshots, developer README and M5 closing (#53 #54)
CI / Build and test (SQLite) (pull_request) Canceled after 0s
CI / PostgreSQL 16 integration (pull_request) Canceled after 0s
CI / PostgreSQL 17 integration (pull_request) Canceled after 0s
CI / Docker image (pull_request) Canceled after 0s
CI / YAML check (pull_request) Canceled after 0s
4123ccacb2
The wiki becomes a guide for the people who use Khaemhat: a new "Guida all'uso"
page walks from sign-in to an invoice sent by e-mail, and Vendite is rewritten
around the real screens of 0.5.0 (radars, document mask, Crea …, deferred
invoicing, print preview, mail). Primi passi, Dati di esempio, Allegati, Log
and Impostazioni describe what this version does, including the SMTP variables.

README.md turns into the installation guide for developers: prerequisites,
run-dev, tests with PostgreSQL, migrations, image and wiki publishing.

The engine now writes confirmations, changes of state and deletions to the
Documents log section, the last step of #53. ADR 0034 records the print and
mail decisions; CHANGELOG 0.5.0 and STATUS close the milestone.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Alby96 added 1 commit 2026-11-12 17:39:47 +01:00
docs: record the M5 pull request in STATUS (#54)
CI / Build and test (SQLite) (pull_request) Successful in 4m7s
CI / PostgreSQL 16 integration (pull_request) Skipped
CI / PostgreSQL 17 integration (pull_request) Skipped
CI / YAML check (pull_request) Successful in 14s
CI / Docker image (pull_request) Successful in 1m49s
cd3e22e8c7
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Alby96 merged commit 2c56c0dff0 into main 2026-11-12 18:48:59 +01:00
Sign in to join this conversation.
No Reviewers
No labels
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: BalboSoft/Khaemhat#124