feat: e-invoice services, SDI channels, inbox, polling and conservation (#74 #75 #76 #77 #79)

Adds the company tables of the electronic invoice and the services that drive them:
the builder turns an issued document into the FatturaPA model, the service generates,
checks and sends the file through the channel chosen by the routing rules (with a
fallback) and applies the SDI notifications to the e-invoice and its document. The
channel settings keep their secrets protected and out of the audit trail; a job reads
the PEC mailbox and the intermediaries every 15 minutes, storing supplier invoices in
the inbox and acknowledging a message only once all its files are kept. The inbox
registers received invoices through the purchase import, and the conservation export
packs a period with a SHA-256 index. A rejected invoice can now be corrected and
generated again; the courtesy PDF embeds the XML.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Alby96andClaude Opus 5.5 committed 2026-11-13 12:20:59 +01:00
1 parent 709bb13532
commit fb12411404
24 files changed
+4016 -10

No files matched your search

@@ -64,7 +64,7 @@ public sealed class DocumentRulesTests
Assert.AreEqual(DocumentStatus.SdiDelivered, status);
CollectionAssert.AreEqual(new[] { DocumentAction.Copy }, DocumentStateMachine.Actions(Invoice, DocumentStatus.SdiDelivered).ToArray());
foreach (var issued in DocumentStateMachine.States(Invoice).Where(s => s != DocumentStatus.Draft))
foreach (var issued in DocumentStateMachine.States(Invoice).Where(s => s is not (DocumentStatus.Draft or DocumentStatus.SdiRejected)))
{
Assert.IsFalse(DocumentStateMachine.IsEditable(Invoice, issued), issued.ToString());
Assert.IsFalse(DocumentStateMachine.Allows(Invoice, issued, DocumentAction.Delete), issued.ToString());
@@ -72,6 +72,8 @@ public sealed class DocumentRulesTests
Assert.IsTrue(DocumentStateMachine.Allows(Invoice, DocumentStatus.SdiGenerated, DocumentAction.Cancel));
Assert.IsTrue(DocumentStateMachine.Allows(Invoice, DocumentStatus.SdiRejected, DocumentAction.Cancel));
Assert.IsTrue(DocumentStateMachine.IsEditable(Invoice, DocumentStatus.SdiRejected), "A rejected invoice is corrected and sent again.");
Assert.IsFalse(DocumentStateMachine.Allows(Invoice, DocumentStatus.SdiRejected, DocumentAction.Delete));
Assert.IsFalse(DocumentStateMachine.Allows(Invoice, DocumentStatus.SdiSent, DocumentAction.Cancel));
Assert.IsFalse(DocumentStateMachine.Allows(Invoice, DocumentStatus.Draft, DocumentAction.Confirm), "Invoices are issued, not confirmed.");
Assert.AreEqual(DocumentStatus.SdiGenerated, DocumentStateMachine.Apply(Invoice, DocumentStatus.SdiRejected, DocumentAction.GenerateXml));