feat: warehouse and purchase screens, e-invoice import, demo purchases (#55 #56 #57 #58 #60)

Stock, stock take and reorder screens under /magazzino, with valuation, rebuild and the
movements of an item; the understock dashboard widget. Supplier e-invoices (XML, p7m, ZIP)
become draft purchase invoices with supplier, items and tax codes matched, the file attached
and duplicates refused; the TD code mapping stays in the Italian fiscal pack. Purchase
invoices show price differences against the order and the self-invoice still to issue,
with a pending list on the self-invoice screen. The opening stock import now writes an
opening movement. The demo company gets purchases, an opening stock, a pending
self-invoice and a stock take being counted.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Alby96andClaude Opus 5.5 committed 2026-11-12 22:01:32 +01:00
1 parent eb301fa570
commit ced689b297
31 files changed
+3478 -110

No files matched your search

@@ -148,13 +148,14 @@ public sealed class ImportServiceTests
}
[TestMethod]
public async Task OpeningStock_IsOnlyChecked_UntilTheStockEntriesExist()
public async Task OpeningStock_LoadsTheWarehouse_WithAnOpeningMovement()
{
var (app, _, company) = await TestInstance.StartAsync(CancellationToken.None);
await using (app)
{
var imports = app.Services.GetRequiredService<ImportService>();
var tables = app.Services.GetRequiredService<TableService>();
var stockService = app.Services.GetRequiredService<Khaemhat.Application.Inventory.InventoryService>();
await tables.SaveAsync(Root, company, new ItemCategory { Code = "VALV", Description = "Valvolame" });
var items = Csv("codice;descrizione;categoria;tipo", "A-1;Valvola;VALV;merce", "S-1;Manodopera;VALV;servizio");
await imports.ImportAsync(Root, company, "articoli", items, ImportService.SuggestMapping(imports.Target("articoli"), items.Headers), new ImportOptions());
@@ -162,13 +163,16 @@ public sealed class ImportServiceTests
var stock = Csv("articolo;deposito;quantita;costo_unitario", "A-1;;5;3,20", "S-1;;1;", "A-1;;0;", "B-9;;1;");
var mapping = ImportService.SuggestMapping(imports.Target("giacenze-iniziali"), stock.Headers);
var preview = await imports.PreviewAsync(Root, company, "giacenze-iniziali", stock, mapping, new ImportOptions());
Assert.IsFalse(preview.CanApply);
Assert.IsTrue(preview.CanApply);
Assert.AreEqual(ImportOutcome.Ok, preview.Rows[0].Outcome, string.Join("; ", preview.Rows[0].Messages.Select(m => m.Field + ":" + m.Code)));
Assert.AreEqual(ImportErrors.NotStocked, preview.Rows[1].Messages.Single().Code);
CollectionAssert.Contains(preview.Rows[2].Messages.Select(m => m.Code).ToList(), ImportErrors.Positive);
Assert.AreEqual(ImportErrors.CodeUnknown, preview.Rows[3].Messages.Single().Code);
var refused = await Assert.ThrowsExactlyAsync<ImportFileException>(() => imports.ImportAsync(Root, company, "giacenze-iniziali", stock, mapping, new ImportOptions()));
Assert.AreEqual(ImportErrors.CheckOnly, refused.Code);
var report = await imports.ImportAsync(Root, company, "giacenze-iniziali", stock, mapping, new ImportOptions());
Assert.AreEqual(1, report.Created);
var row = (await stockService.StockAsync(Root, company, new Khaemhat.Application.Inventory.StockFilter())).Single();
Assert.AreEqual((5m, 3.2m), (row.OnHand, row.AverageCost));
await app.StopAsync();
}
}