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:
1 parent
709bb13532
commit
fb12411404
24 files changed
+4016
-10
No files matched your search
@@ -52,7 +52,24 @@ public sealed class DocumentPdfGenerator(DocumentPrintService prints, Attachment
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(context);
|
||||
var model = await ModelAsync(context, cancellationToken).ConfigureAwait(false);
|
||||
await WriteAsync(model, context, output, cancellationToken).ConfigureAwait(false);
|
||||
await WriteAsync(model, context, output, [], cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The courtesy copy of an e-invoice (SPEC §11.9, issue #79): the print of the document with the XML sent to the
|
||||
/// exchange system embedded as an associated file (structure of PDF/A-3, <c>/AF</c>).
|
||||
/// </summary>
|
||||
/// <param name="context">The document.</param>
|
||||
/// <param name="xmlName">The name of the XML file.</param>
|
||||
/// <param name="xml">The XML file.</param>
|
||||
/// <param name="output">The stream that receives the PDF.</param>
|
||||
/// <param name="cancellationToken">Cancellation.</param>
|
||||
/// <returns>A task.</returns>
|
||||
public async Task CourtesyCopyAsync(FileGenerationContext context, string xmlName, byte[] xml, Stream output, CancellationToken cancellationToken)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(context);
|
||||
var model = await ModelAsync(context, cancellationToken).ConfigureAwait(false);
|
||||
await WriteAsync(model, context, output, [(xmlName, xml)], cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
// The file name follows the document (number and kind); without the logo, which the name does not need.
|
||||
@@ -95,7 +112,8 @@ public sealed class DocumentPdfGenerator(DocumentPrintService prints, Attachment
|
||||
}
|
||||
}
|
||||
|
||||
private static async Task WriteAsync(DocumentPrintModel model, FileGenerationContext context, Stream output, CancellationToken cancellationToken)
|
||||
private static async Task WriteAsync(
|
||||
DocumentPrintModel model, FileGenerationContext context, Stream output, IReadOnlyList<(string Name, byte[] Content)> embedded, CancellationToken cancellationToken)
|
||||
{
|
||||
var info = new PdfDocumentInfo
|
||||
{
|
||||
@@ -111,6 +129,11 @@ public sealed class DocumentPdfGenerator(DocumentPrintService prints, Attachment
|
||||
await sheet.LinesAsync().ConfigureAwait(false);
|
||||
await sheet.FooterBlocksAsync().ConfigureAwait(false);
|
||||
sheet.Finish();
|
||||
foreach (var (name, content) in embedded)
|
||||
{
|
||||
pdf.AddAttachment(name, "application/xml", content, "Fattura elettronica " + model.Number, "Source");
|
||||
}
|
||||
|
||||
await pdf.CloseAsync(cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user