The document radars and records now serve /acquisti and /magazzino too: supplier orders, receipts, supplier invoices and credit notes, self-invoices and warehouse movements, with the supplier in place of the customer, the supplier's number and date, the protocol and VAT date of registered invoices, and reason and warehouses of a movement. Supplier invoices take their protocol from the purchase numbering, refuse a second document with the same supplier number in the same year and show price differences against their order or receipt. The Italian pack advises the self-invoice a received invoice needs (TD16-TD19, TD28) with its deadline, and the purchase service drafts it with the ordinary rate. A credit note of an invoice now moves its goods back instead of being skipped as already moved. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
eeabb12f96
commit
f8b72f4d17
21 files changed
+823
-58
No files matched your search
@@ -5,24 +5,37 @@ using Khaemhat.Web.Ui;
|
||||
|
||||
namespace Khaemhat.Web.Documents;
|
||||
|
||||
/// <summary>A radar of the sales menu and the document types it holds.</summary>
|
||||
/// <summary>A radar of the documents menus (sales, purchases, warehouse) and the document types it holds.</summary>
|
||||
/// <param name="Segment">The path segment, such as <c>fatture</c>.</param>
|
||||
/// <param name="Family">The family of the documents.</param>
|
||||
/// <param name="Kinds">The kinds shown.</param>
|
||||
/// <param name="NewTypes">The document types a user can create from the radar, the first being the usual one.</param>
|
||||
/// <param name="Icon">The icon.</param>
|
||||
/// <param name="Key">The key of the texts under <c>Sales.Sections</c>.</param>
|
||||
public sealed record SalesSection(string Segment, DocumentFamily Family, IReadOnlyList<DocumentKind> Kinds, IReadOnlyList<string> NewTypes, string Icon, string Key);
|
||||
/// <param name="Area">The menu area, such as <c>vendite</c> or <c>acquisti</c>.</param>
|
||||
public sealed record SalesSection(
|
||||
string Segment, DocumentFamily Family, IReadOnlyList<DocumentKind> Kinds, IReadOnlyList<string> NewTypes, string Icon, string Key, string Area = SalesScreens.BasePath)
|
||||
{
|
||||
/// <summary>Whose documents: customers, suppliers or nobody.</summary>
|
||||
public DocumentDirection Direction => DocumentBehaviors.Of(Kinds[0]).Direction;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Addresses and labels of the sales screens (SPEC §11.3, mockups 020-030): one radar per menu entry under
|
||||
/// <c>/vendite</c>, the record of a document under it, and the deferred invoicing.
|
||||
/// Addresses and labels of the document screens (SPEC §11.3-§11.6, mockups 020-037): one radar per menu entry under
|
||||
/// <c>/vendite</c>, <c>/acquisti</c> and <c>/magazzino</c>, the record of a document under it, and the deferred
|
||||
/// invoicing. The screens are the same for every area; the labels follow the direction (customer or supplier).
|
||||
/// </summary>
|
||||
public static class SalesScreens
|
||||
{
|
||||
/// <summary>The menu area.</summary>
|
||||
/// <summary>The sales area.</summary>
|
||||
public const string BasePath = "vendite";
|
||||
|
||||
/// <summary>The purchases area.</summary>
|
||||
public const string PurchasesPath = "acquisti";
|
||||
|
||||
/// <summary>The warehouse area.</summary>
|
||||
public const string InventoryPath = "magazzino";
|
||||
|
||||
/// <summary>The deferred invoicing of the delivery notes.</summary>
|
||||
public const string DeferredInvoicingUrl = BasePath + "/fatturazione-differita";
|
||||
|
||||
@@ -39,12 +52,40 @@ public static class SalesScreens
|
||||
[DocumentKind.ImmediateInvoice, DocumentKind.AccompanyingInvoice, DocumentKind.DeferredInvoice, DocumentKind.DownPaymentInvoice, DocumentKind.Fee, DocumentKind.ProForma],
|
||||
["FI", "FA", "FD", "FACC", "PAR", "PF"], "euro", "Invoices"),
|
||||
new("note-credito", DocumentFamily.SaleDocument, [DocumentKind.CreditNote, DocumentKind.DebitNote], ["NC", "ND"], "undo", "CreditNotes"),
|
||||
new("ordini", DocumentFamily.PurchaseOrder, [DocumentKind.PurchaseOrder], ["OF"], "file-check", "PurchaseOrders", PurchasesPath),
|
||||
new("ricevimenti", DocumentFamily.PurchaseDocument, [DocumentKind.PurchaseDeliveryNote], ["DDTF"], "truck", "Receipts", PurchasesPath),
|
||||
new("fatture", DocumentFamily.PurchaseDocument, [DocumentKind.PurchaseInvoice, DocumentKind.PurchaseCreditNote], ["FF", "NCF"], "euro", "PurchaseInvoices", PurchasesPath),
|
||||
new("autofatture", DocumentFamily.SaleDocument, [DocumentKind.SelfInvoice],
|
||||
["AF16", "AF17", "AF18", "AF19", "AF20", "AF21", "AF22", "AF23", "AF28", "AF29"], "refresh", "SelfInvoices", PurchasesPath),
|
||||
new("movimenti", DocumentFamily.InventoryDocument, [DocumentKind.InventoryEntry], ["MM"], "layers", "Movements", InventoryPath),
|
||||
];
|
||||
|
||||
/// <summary>The radar of a path segment.</summary>
|
||||
/// <summary>The sales radar of a path segment.</summary>
|
||||
/// <param name="segment">The segment.</param>
|
||||
/// <returns>The radar, or <see langword="null"/>.</returns>
|
||||
public static SalesSection? Find(string? segment) => Sections.FirstOrDefault(s => string.Equals(s.Segment, segment, StringComparison.OrdinalIgnoreCase));
|
||||
public static SalesSection? Find(string? segment) => Find(BasePath, segment);
|
||||
|
||||
/// <summary>The radar of an area and a path segment.</summary>
|
||||
/// <param name="area">The area, such as <c>acquisti</c>.</param>
|
||||
/// <param name="segment">The segment.</param>
|
||||
/// <returns>The radar, or <see langword="null"/>.</returns>
|
||||
public static SalesSection? Find(string? area, string? segment) =>
|
||||
Sections.FirstOrDefault(s => string.Equals(s.Area, area, StringComparison.OrdinalIgnoreCase) && string.Equals(s.Segment, segment, StringComparison.OrdinalIgnoreCase));
|
||||
|
||||
/// <summary>The area of a relative address: its first segment.</summary>
|
||||
/// <param name="relativePath">The address relative to the base, such as <c>acquisti/fatture/3</c>.</param>
|
||||
/// <returns>The area.</returns>
|
||||
public static string AreaOf(string? relativePath)
|
||||
{
|
||||
var path = relativePath ?? string.Empty;
|
||||
var end = path.IndexOfAny(['/', '?', '#']);
|
||||
return end < 0 ? path : path[..end];
|
||||
}
|
||||
|
||||
/// <summary>The key of the label of the party for a direction: customer, supplier.</summary>
|
||||
/// <param name="direction">The direction.</param>
|
||||
/// <returns>The key of the text.</returns>
|
||||
public static string PartyLabel(DocumentDirection direction) => direction == DocumentDirection.Purchase ? "Purchases.Fields.Supplier" : "Sales.Fields.PartyId";
|
||||
|
||||
/// <summary>The radar that holds a kind of document.</summary>
|
||||
/// <param name="kind">The kind.</param>
|
||||
@@ -57,7 +98,7 @@ public static class SalesScreens
|
||||
public static string RadarUrl(SalesSection section)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(section);
|
||||
return BasePath + "/" + section.Segment;
|
||||
return section.Area + "/" + section.Segment;
|
||||
}
|
||||
|
||||
/// <summary>The address of a document.</summary>
|
||||
|
||||
Reference in new issue
Block a user