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>
This commit is contained in:
1 parent
f12848865d
commit
826042f828
31 files changed
+5682
-16
No files matched your search
@@ -29,13 +29,14 @@ public sealed class DocumentEngineTests
|
||||
var sales = app.Services.GetRequiredService<DocumentService<SaleDocument, SaleDocumentLine>>();
|
||||
var copies = app.Services.GetRequiredService<DocumentCopyService>();
|
||||
var customer = await CustomerAsync(app, company);
|
||||
var vat = await VatAsync(app, company);
|
||||
var year = DateTime.Now.Year;
|
||||
|
||||
var order = await orders.NewAsync(Root, company, "OC");
|
||||
Assert.AreEqual(DocumentKind.SalesOrder, order.Header.Kind);
|
||||
order.Header.PartyId = customer;
|
||||
order.Lines.Add(new SaleOrderLine { Kind = DocumentLineKind.Free, Description = "Valvola a sfera 1/2\"", Quantity = 10m, Price = 5m });
|
||||
order.Lines.Add(new SaleOrderLine { Kind = DocumentLineKind.Free, Description = "Raccordo a T", Quantity = 4m, Price = 2m });
|
||||
order.Lines.Add(new SaleOrderLine { Kind = DocumentLineKind.Free, Description = "Valvola a sfera 1/2\"", Quantity = 10m, Price = 5m, TaxCodeId = vat });
|
||||
order.Lines.Add(new SaleOrderLine { Kind = DocumentLineKind.Free, Description = "Raccordo a T", Quantity = 4m, Price = 2m, TaxCodeId = vat });
|
||||
order.Lines.Add(new SaleOrderLine { Kind = DocumentLineKind.Description, Description = "Consegna in cantiere" });
|
||||
order = await orders.SaveAsync(Root, company, order);
|
||||
Assert.AreEqual(DocumentStatus.Draft, order.Header.Status);
|
||||
@@ -120,6 +121,7 @@ public sealed class DocumentEngineTests
|
||||
var engine = app.Services.GetRequiredService<DocumentEngine>();
|
||||
var sales = app.Services.GetRequiredService<DocumentService<SaleDocument, SaleDocumentLine>>();
|
||||
var customer = await CustomerAsync(app, company);
|
||||
var vat = await VatAsync(app, company);
|
||||
var year = DateTime.Now.Year;
|
||||
|
||||
var definitions = await engine.DefinitionsAsync(Root, company);
|
||||
@@ -142,9 +144,9 @@ public sealed class DocumentEngineTests
|
||||
var expense = await Assert.ThrowsExactlyAsync<ValidationFailedException>(() => sales.SaveAsync(Root, company, delivery));
|
||||
Assert.AreEqual("Lines.0.Kind:" + DocumentErrors.LineKindNotAllowed, expense.Errors.Single());
|
||||
|
||||
var later = await InvoiceAsync(sales, company, customer, new DateOnly(year, 3, 10));
|
||||
var earlier = await InvoiceAsync(sales, company, customer, new DateOnly(year, 3, 9));
|
||||
var empty = await sales.SaveAsync(Root, company, await NewInvoiceAsync(sales, company, customer, new DateOnly(year, 3, 11), lines: false));
|
||||
var later = await InvoiceAsync(sales, company, customer, vat, new DateOnly(year, 3, 10));
|
||||
var earlier = await InvoiceAsync(sales, company, customer, vat, new DateOnly(year, 3, 9));
|
||||
var empty = await sales.SaveAsync(Root, company, await NewInvoiceAsync(sales, company, customer, vat, new DateOnly(year, 3, 11), lines: false));
|
||||
var noLines = await Assert.ThrowsExactlyAsync<ValidationFailedException>(() => sales.ConfirmAsync(Root, company, empty.Header.Id));
|
||||
Assert.AreEqual("Lines:" + DocumentErrors.LinesRequired, noLines.Errors.Single());
|
||||
|
||||
@@ -195,26 +197,29 @@ public sealed class DocumentEngineTests
|
||||
}
|
||||
|
||||
private static async Task<DocumentRecord<SaleDocument, SaleDocumentLine>> NewInvoiceAsync(
|
||||
DocumentService<SaleDocument, SaleDocumentLine> sales, string company, long customer, DateOnly date, bool lines = true)
|
||||
DocumentService<SaleDocument, SaleDocumentLine> sales, string company, long customer, long vat, DateOnly date, bool lines = true)
|
||||
{
|
||||
var invoice = await sales.NewAsync(Root, company, "FI");
|
||||
invoice.Header.PartyId = customer;
|
||||
invoice.Header.DocumentDate = date;
|
||||
if (lines)
|
||||
{
|
||||
invoice.Lines.Add(new SaleDocumentLine { Kind = DocumentLineKind.Free, Description = "Assistenza tecnica", Quantity = 2m, Price = 40m });
|
||||
invoice.Lines.Add(new SaleDocumentLine { Kind = DocumentLineKind.Free, Description = "Assistenza tecnica", Quantity = 2m, Price = 40m, TaxCodeId = vat });
|
||||
}
|
||||
|
||||
return invoice;
|
||||
}
|
||||
|
||||
private static async Task<DocumentRecord<SaleDocument, SaleDocumentLine>> InvoiceAsync(
|
||||
DocumentService<SaleDocument, SaleDocumentLine> sales, string company, long customer, DateOnly date) =>
|
||||
await sales.SaveAsync(Root, company, await NewInvoiceAsync(sales, company, customer, date));
|
||||
DocumentService<SaleDocument, SaleDocumentLine> sales, string company, long customer, long vat, DateOnly date) =>
|
||||
await sales.SaveAsync(Root, company, await NewInvoiceAsync(sales, company, customer, vat, date));
|
||||
|
||||
private static DocumentRecord<SaleDocument, SaleDocumentLine> Typed(DocumentRecord record) =>
|
||||
new() { Header = (SaleDocument)record.Header, Lines = [.. record.Lines.Cast<SaleDocumentLine>()] };
|
||||
|
||||
private static async Task<long> VatAsync(WebApplication app, string company) =>
|
||||
(await app.Services.GetRequiredService<TableService>().ActiveAsync<TaxCode>(Root, company)).Single(t => t.Code == "22").Id;
|
||||
|
||||
private static async Task<long> CustomerAsync(WebApplication app, string company)
|
||||
{
|
||||
var parties = app.Services.GetRequiredService<PartyService>();
|
||||
|
||||
Reference in new issue
Block a user