feat: post documents to the warehouse at weighted average cost (#59)

Confirmed delivery notes, invoices that move goods, supplier receipts and
warehouse movements now write stock movements in the same transaction;
cancelling removes them. Each change re-runs the history of the items
touched, so balances per warehouse, committed and ordered quantities and
the average and last cost stay consistent even when an old document is
cancelled. Supplier invoices give their cost to the receipts they invoice.
Immediate invoices, supplier invoices and credit notes get their warehouse
reasons; the self-invoice types TD20-TD29 join the base tables.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Alby96andClaude Opus 5.5 committed 2026-11-12 21:13:27 +01:00
1 parent 20b2421eea
commit eeabb12f96
14 files changed
+1753 -5

No files matched your search

@@ -125,7 +125,7 @@ public sealed class DocumentEngineTests
var year = DateTime.Now.Year;
var definitions = await engine.DefinitionsAsync(Root, company);
Assert.HasCount(20, definitions, "Every seeded type has its kind.");
Assert.HasCount(26, definitions, "Every seeded type has its kind.");
Assert.AreEqual(DocumentKind.DeferredInvoice, definitions.Single(d => d.Code == "FD").Kind);
Assert.AreEqual(DocumentAction.Issue, definitions.Single(d => d.Code == "FI").ConfirmAction);
await Assert.ThrowsExactlyAsync<ValidationFailedException>(() => sales.NewAsync(Root, company, "OC"), "An order is not a sale document.");