feat: purchase and warehouse documents on the document screens (#55 #56 #58)

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:
Alby96andClaude Opus 5.5 committed 2026-11-12 21:25:25 +01:00
1 parent eeabb12f96
commit f8b72f4d17
21 files changed
+823 -58

No files matched your search

@@ -1,5 +1,9 @@
@page "/vendite/{Segment}/nuovo"
@page "/vendite/{Segment}/{Id:long}"
@page "/acquisti/{Segment}/nuovo"
@page "/acquisti/{Segment}/{Id:long}"
@page "/magazzino/{Segment}/nuovo"
@page "/magazzino/{Segment}/{Id:long}"
@attribute [Authorize]
@inherits DocumentPage<DocumentRecord, DocumentLine>
@using Khaemhat.Application.Audit
@@ -11,8 +15,9 @@
@using Khaemhat.Web.Documents
@using Khaemhat.Web.Parties
@* The record of a sales document (SPEC §11.3, mockups 020-022 and 026-029): quotation, order, delivery note, invoice of
every kind, pro forma, credit and debit note. Righe first with the VAT summary, due dates and totals underneath, then
@* The record of a document (SPEC §11.3-§11.6, mockups 020-022, 026-029, 031-033, 035, 037): quotation, order, delivery
note, invoice of every kind, pro forma, credit and debit note; supplier order, receipt, supplier invoice and credit
note with protocol and VAT date, self-invoice; warehouse movement with reason and warehouses. Righe first with the VAT summary, due dates and totals underneath, then
Testata, Trasporto for the documents that move goods, Totali, Scadenze, Note, Allegati, Collegamenti, Storico. The
totals are computed while typing with the code of the save; the actions follow the state machine of the engine. *@
<KhPageTitle Text="@PageTitle" Icon="@(_section?.Icon ?? "file")" />
@@ -47,7 +52,7 @@ else
<KhRecordLayout Page="this">
<Heading>
<KhDocHead KindIcon="@_section.Icon" KindLabel="@_definition.Type.Description" Number="@(h.DocumentNumber ?? T["Sales.DraftNumber"])"
PartyName="@(_party?.Name ?? T["Sales.NoParty"])" PartyCode="@_party?.Code" PartyLines="PartyLines"
PartyName="@(IsInternal ? (PartyScreens.Describe(_lookups.InventoryReasons, h.InventoryReasonId) ?? T["Inventory.NoReason"]) : _party?.Name ?? T["Sales.NoParty"])" PartyCode="@_party?.Code" PartyLines="PartyLines"
TotalLabel="@T[ShowsNet ? "Sales.Totals.Net" : "Sales.Totals.Total"]" TotalValue="@T.Money(ShowsNet ? h.NetAmount : h.TotalAmount)" SubValues="HeadStats">
<Facts>
<span>@T["Sales.Fields.DocumentDate"] <b>@T.Date(h.DocumentDate)</b></span>
@@ -104,7 +109,7 @@ else
@switch (ActiveTab)
{
case TabIds.Lines:
@if (h.PartyId is null && !IsReadOnly)
@if (h.PartyId is null && !IsReadOnly && !IsInternal)
{
<div class="callout info kh-doc-callout"><KhIcon Name="info" /> <span>@T["Sales.Hints.PartyFirst"]</span>
<button type="button" class="btn" @onclick="() => ShowTabAsync(TabIds.Header)">@T["Sales.Actions.ChooseParty"]</button></div>
@@ -143,9 +148,17 @@ else
{
<KhDateBox Label="@T["Sales.Fields.DeliveryDate"]" Name="DeliveryDate" Value="h.DeliveryDate" ValueChanged="v => Change(() => h.DeliveryDate = v)" Span="4" />
}
<KhTextBox Label="@T["Sales.Fields.ExternalReference"]" Name="ExternalReference" Value="@h.ExternalReference" ValueChanged="v => Change(() => h.ExternalReference = v)"
Span="8" MaxLength="60" Hint="@T["Sales.Hints.ExternalReference"]" />
<KhDateBox Label="@T["Sales.Fields.ExternalDate"]" Name="ExternalDate" Value="h.ExternalDate" ValueChanged="v => Change(() => h.ExternalDate = v)" Span="4" />
<KhTextBox Label="@T[IsPurchase ? "Purchases.Fields.SupplierNumber" : "Sales.Fields.ExternalReference"]" Name="ExternalReference" Value="@h.ExternalReference"
ValueChanged="v => Change(() => h.ExternalReference = v)" Span="8" MaxLength="40" Required="@IsRegistered"
Hint="@T[IsPurchase ? "Purchases.Hints.SupplierNumber" : "Sales.Hints.ExternalReference"]" Mono="@IsPurchase" />
<KhDateBox Label="@T[IsPurchase ? "Purchases.Fields.SupplierDate" : "Sales.Fields.ExternalDate"]" Name="ExternalDate" Value="h.ExternalDate"
ValueChanged="v => Change(() => h.ExternalDate = v)" Span="4" Required="@IsRegistered" />
@if (IsRegistered)
{
<KhTextBox Label="@T["Purchases.Fields.Protocol"]" Name="VatProtocol" Value="@(h.VatProtocol?.ToString(T.Culture) ?? T["Sales.NumberOnConfirm"])" ReadOnly="true" Mono="true" Span="4" />
<KhDateBox Label="@T["Purchases.Fields.VatDate"]" Name="VatDate" Value="h.VatDate" ValueChanged="v => Change(() => h.VatDate = v)" Span="4"
Hint="@T["Purchases.Hints.VatDate"]" />
}
@if (IsNote)
{
<KhTextBox Label="@T["Sales.Fields.RelatedNumber"]" Name="RelatedNumber" Value="@h.RelatedNumber" ValueChanged="v => Change(() => h.RelatedNumber = v)"
@@ -153,11 +166,31 @@ else
<KhDateBox Label="@T["Sales.Fields.RelatedDate"]" Name="RelatedDate" Value="h.RelatedDate" ValueChanged="v => Change(() => h.RelatedDate = v)" Span="4" />
}
</KhFieldGroup>
@if (IsInternal)
{
<KhFieldGroup Title="@T["Inventory.Groups.Movement"]" Icon="layers">
<KhSelect TValue="string" Label="@T["Inventory.Fields.Reason"]" Name="InventoryReasonId" Options="_lookups.InventoryReasons" Empty="" Span="6" Required="true"
Value="@PartyScreens.Text(h.InventoryReasonId)" ValueChanged="v => Change(() => h.InventoryReasonId = PartyScreens.Id(v))" />
<KhSelect TValue="string" Label="@T[IsTransfer ? "Inventory.Fields.FromWarehouse" : "Inventory.Fields.Warehouse"]" Name="WarehouseId" Options="_lookups.Warehouses" Empty="" Span="6"
Value="@PartyScreens.Text(h.WarehouseId)" ValueChanged="v => Change(() => h.WarehouseId = PartyScreens.Id(v))" />
@if (IsTransfer)
{
<KhSelect TValue="string" Label="@T["Inventory.Fields.ToWarehouse"]" Name="ToWarehouseId" Options="_lookups.Warehouses" Empty="" Span="6" Required="true"
Value="@PartyScreens.Text(h.ToWarehouseId)" ValueChanged="v => Change(() => h.ToWarehouseId = PartyScreens.Id(v))" />
}
<p class="muted sm c12"><KhIcon Name="info" /> @T["Inventory.Hints.Movement"]</p>
</KhFieldGroup>
}
else
{
<KhFieldGroup Title="@T["Sales.Groups.Party"]" Icon="users">
<KhHotlink TItem="PartyRow" Label="@T["Sales.Fields.PartyId"]" Name="PartyId" Span="12" Required="true" Value="_party" ValueChanged="SetPartyAsync"
<KhHotlink TItem="PartyRow" Label="@T[SalesScreens.PartyLabel(_section.Direction)]" Name="PartyId" Span="12" Required="true" Value="_party" ValueChanged="SetPartyAsync"
Search="SearchPartiesAsync" CodeOf="r => r.Code" DescriptionOf="r => r.Name" OnOpen="OpenParty" ReadOnly="@(Record.Lines.Any(l => l.SourceLineId is not null))" />
<KhSelect TValue="string" Label="@T["Sales.Fields.SalespersonId"]" Name="SalespersonId" Options="_lookups.Salespeople" Empty="" Span="6"
Value="@PartyScreens.Text(h.SalespersonId)" ValueChanged="v => Change(() => h.SalespersonId = PartyScreens.Id(v))" />
@if (!IsPurchase)
{
<KhSelect TValue="string" Label="@T["Sales.Fields.SalespersonId"]" Name="SalespersonId" Options="_lookups.Salespeople" Empty="" Span="6"
Value="@PartyScreens.Text(h.SalespersonId)" ValueChanged="v => Change(() => h.SalespersonId = PartyScreens.Id(v))" />
}
<KhSelect TValue="string" Label="@T["Sales.Fields.CurrencyCode"]" Name="CurrencyCode" Options="_lookups.Currencies" Span="6"
Value="@h.CurrencyCode" ValueChanged="SetCurrency" />
@if (h.PartyId is not null)
@@ -203,6 +236,7 @@ else
<p class="muted sm c9">@T["Sales.Hints.Withholding"]</p>
</KhFieldGroup>
}
}
</KhForm>
break;
@@ -110,7 +110,10 @@ public sealed partial class SalesDocumentPage
? T["Shell.Menu.Sales"]
: _definition.Type.Description + " " + (Record.Header.DocumentNumber ?? T["Sales.DraftNumber"]);
private bool IsInvoice => Record is not null && (Behavior.Lifecycle == DocumentLifecycle.Invoice || H.Kind == DocumentKind.ProForma);
private bool IsInvoice => Record is not null && (Behavior.Lifecycle == DocumentLifecycle.Invoice || H.Kind == DocumentKind.ProForma || IsRegistered);
// A movement between two warehouses: its reason is a transfer.
private bool IsTransfer => Record is not null && H.InventoryReasonId is { } reason && _lookups.TransferReasons.Contains(reason);
private bool IsNote => Record is not null && H.Kind is DocumentKind.CreditNote or DocumentKind.DebitNote;
@@ -119,7 +122,17 @@ public sealed partial class SalesDocumentPage
private bool CanWrite => Record is not null && Session.Permissions.Allows(Behavior.WritePermission);
// The entity of the attachments, such as sales.saledocument.
private string AttachmentEntity => "sales." + Record!.Header.GetType().Name.ToLowerInvariant();
private string AttachmentEntity => DocumentPrintService.EntityOf(Record!.Family);
// Customers for sales, suppliers for purchases and self-invoices.
private PartyArchive Archive => _section?.Direction == DocumentDirection.Purchase ? PartyArchive.Suppliers : PartyArchive.Customers;
private bool IsPurchase => _section?.Direction == DocumentDirection.Purchase;
private bool IsInternal => _section?.Direction == DocumentDirection.Internal;
// A supplier invoice or credit note: registered with a protocol and a VAT date.
private bool IsRegistered => Record is not null && H.Kind is DocumentKind.PurchaseInvoice or DocumentKind.PurchaseCreditNote;
/// <inheritdoc />
public override bool IsReadOnly => Record is null || !CanWrite || !(IsNew || _actions.Contains(DocumentAction.Edit));
@@ -154,7 +167,7 @@ public sealed partial class SalesDocumentPage
TabOf(TabIds.Lines, "list", "Ui.Record.Tabs.Lines", Record.Lines.Count),
TabOf(TabIds.Header, "file", "Ui.Record.Tabs.Header"),
};
if (Behavior.Has(DocumentEffects.Inventory))
if (Behavior.Has(DocumentEffects.Inventory) && !IsInternal)
{
tabs.Add(TabOf(SalesScreens.TransportTab, "truck", "Sales.Tabs.Transport"));
}
@@ -214,7 +227,7 @@ public sealed partial class SalesDocumentPage
return;
}
_section = SalesScreens.Find(Segment);
_section = SalesScreens.Find(SalesScreens.AreaOf(Navigation.ToBaseRelativePath(Navigation.Uri)), Segment);
if (!_loaded)
{
_lookups = await DocumentLookups.ReadAsync(Tables, actor, company);
@@ -847,10 +860,10 @@ public sealed partial class SalesDocumentPage
private async Task<IReadOnlyList<PartyRow>> SearchPartiesAsync(string text, CancellationToken cancellationToken) =>
Session.Actor is { } actor && Session.Company?.Code is { } company && Session.Permissions.Allows(PartyService.ReadPermission)
? await Parties.SearchAsync(actor, company, PartyArchive.Customers, text, cancellationToken)
? await Parties.SearchAsync(actor, company, Archive, text, cancellationToken)
: [];
private void OpenParty(PartyRow row) => Navigation.NavigateTo(PartyScreens.RecordUrl(PartyArchive.Customers, row.Id));
private void OpenParty(PartyRow row) => Navigation.NavigateTo(PartyScreens.RecordUrl(Archive, row.Id));
private void Change(Action change)
{
@@ -1100,11 +1113,14 @@ public sealed partial class SalesDocumentPage
// An order-like document gives what is left to fulfil; an issued invoice gives its notes.
var open = H.Status is DocumentStatus.Confirmed or DocumentStatus.PartiallyFulfilled;
var issued = Behavior.Lifecycle == DocumentLifecycle.Invoice && DocumentStateMachine.IsInForce(H.Status);
// A registered supplier invoice gives its credit notes and self-invoices.
var registered = IsRegistered && DocumentStateMachine.IsInForce(H.Status);
var preferred = SalesScreens.Sections.SelectMany(s => s.NewTypes).ToList();
return _definitions
.Where(d => d.Behavior.Direction == DocumentDirection.Sale && d.Behavior.Fulfils(H.Kind) && preferred.Contains(d.Code)
.Where(d => d.Behavior.Direction == Behavior.Direction && d.Behavior.Fulfils(H.Kind) && preferred.Contains(d.Code)
&& Session.Permissions.Allows(d.Behavior.WritePermission)
&& (d.Kind is DocumentKind.CreditNote or DocumentKind.DebitNote ? issued : open))
&& (d.Kind is DocumentKind.CreditNote or DocumentKind.DebitNote or DocumentKind.PurchaseCreditNote or DocumentKind.SelfInvoice ? issued || registered : open))
.OrderBy(d => Preference(H.Kind, d.Kind))
.ThenBy(d => preferred.IndexOf(d.Code));
}
@@ -1117,6 +1133,9 @@ public sealed partial class SalesDocumentPage
(DocumentKind.DeliveryNote, DocumentKind.DeferredInvoice) => 0,
(DocumentKind.ProForma, DocumentKind.ImmediateInvoice) => 0,
(_, DocumentKind.CreditNote) => 0,
(DocumentKind.PurchaseOrder, DocumentKind.PurchaseDeliveryNote) => 0,
(DocumentKind.PurchaseDeliveryNote, DocumentKind.PurchaseInvoice) => 0,
(_, DocumentKind.PurchaseCreditNote) => 0,
_ => 1,
};
@@ -1,4 +1,6 @@
@page "/vendite/{Segment}"
@page "/acquisti/{Segment}"
@page "/magazzino/{Segment}"
@attribute [Authorize]
@using Khaemhat.Application.Documents
@using Khaemhat.Core.Documents
@@ -9,9 +11,10 @@
@inject NavigationManager Navigation
@inject TimeProvider Clock
@* The radar of a kind of sales documents (SPEC §11.3): quotations, orders, delivery notes, invoices (with pro forma
and fees), credit and debit notes. Search on number, reference and customer; filters for state, type and year;
totals of the page. Enter or double click opens the document. *@
@* The radar of a kind of documents (SPEC §11.3-§11.6): quotations, orders, delivery notes, invoices (with pro forma
and fees), credit and debit notes; supplier orders, receipts, supplier invoices, self-invoices; warehouse
movements. Search on number, reference and party; filters for state, type and year; totals of the page. Enter or
double click opens the document. *@
<KhPageTitle Text="@Title" Icon="@(_section?.Icon ?? "cart")" />
@if (!_loaded)
@@ -36,7 +39,7 @@ else if (!CanRead)
}
else
{
<KhRadar TItem="DocumentRow" @key="_section.Segment" Id="@("sales." + _section.Segment)" Columns="Columns" Source="ListAsync" KeyOf="r => r.Id" Selectable="false"
<KhRadar TItem="DocumentRow" @key="_section.Area + _section.Segment" Id="@(_section.Area == SalesScreens.BasePath ? "sales." + _section.Segment : _section.Area + "." + _section.Segment)" Columns="Columns" Source="ListAsync" KeyOf="r => r.Id" Selectable="false"
OnOpen="Open" QuickFilters="QuickFilters" RowClass="RowClassOf" SearchPlaceholder="@T["Sales.Radar.Search"]" ExportName="@_section.Segment"
Label="@Title">
<Toolbar>
@@ -44,7 +47,7 @@ else
{
<button type="button" class="btn primary" @onclick="New"><KhIcon Name="plus" /> @T["Sales.Sections." + _section.Key + ".New"]</button>
}
@if (_section.Segment == "fatture" && Session.Permissions.Allows("sales.invoice.write"))
@if (_section.Area == SalesScreens.BasePath && _section.Segment == "fatture" && Session.Permissions.Allows("sales.invoice.write"))
{
<a class="btn" href="@SalesScreens.DeferredInvoicingUrl"><KhIcon Name="layers" /> @T["Sales.Deferred.Title"]</a>
}
@@ -79,6 +82,8 @@ else
private string Title => _section is null ? T["Shell.Menu.Sales"] : T["Sales.Sections." + _section.Key + ".Title"];
private bool Internal => _section?.Direction == DocumentDirection.Internal;
private bool CanRead => _section is not null && Session.Permissions.Allows(DocumentBehaviors.Of(_section.Kinds[0]).ReadPermission);
private DateOnly Today => DateOnly.FromDateTime(TimeZoneInfo.ConvertTime(Clock.GetUtcNow(), TimeZoneInfo.Local).DateTime);
@@ -90,15 +95,15 @@ else
private IReadOnlyList<KhColumn<DocumentRow>> Columns =>
[
new("number", T["Sales.Fields.DocumentNumber"], r => r.DocumentNumber ?? T["Sales.DraftNumber"]) { Kind = KhColumnKind.Code, Width = "130px" },
new("number", T[_section?.Kinds.Contains(DocumentKind.PurchaseInvoice) == true ? "Purchases.Fields.Protocol" : "Sales.Fields.DocumentNumber"], r => r.DocumentNumber ?? T["Sales.DraftNumber"]) { Kind = KhColumnKind.Code, Width = "130px" },
new("date", T["Sales.Fields.DocumentDate"], r => r.Date) { Kind = KhColumnKind.Date, Width = "100px" },
new("type", T["Sales.Radar.Kind"], r => SalesScreens.KindName(T, r.Kind)) { Width = "150px", Sortable = false, Visible = _section?.Kinds.Count > 1 },
new("party", T["Sales.Fields.PartyId"], r => r.PartyName) { Sortable = false },
new("reference", T["Sales.Fields.ExternalReference"], r => r.Reference) { Width = "140px" },
new("party", T[SalesScreens.PartyLabel(_section?.Direction ?? DocumentDirection.Sale)], r => r.PartyName) { Sortable = false, Visible = !Internal },
new("reference", T[_section?.Direction == DocumentDirection.Purchase ? "Purchases.Fields.SupplierNumber" : "Sales.Fields.ExternalReference"], r => r.Reference) { Width = "140px" },
new("validUntil", T["Sales.Fields.ValidUntil"], r => r.ValidUntil) { Kind = KhColumnKind.Date, Width = "100px", Visible = _section?.Segment == "preventivi" },
new("delivery", T["Sales.Fields.DeliveryDate"], r => r.DeliveryDate) { Kind = KhColumnKind.Date, Width = "100px", Visible = _section?.Segment is "ordini" or "ddt" },
new("taxable", T["Sales.Totals.Taxable"], r => r.Taxable) { Kind = KhColumnKind.Money, Width = "120px" },
new("total", T["Sales.Totals.Total"], r => r.Total) { Kind = KhColumnKind.Money, Width = "120px" },
new("delivery", T["Sales.Fields.DeliveryDate"], r => r.DeliveryDate) { Kind = KhColumnKind.Date, Width = "100px", Visible = _section?.Segment is "ordini" or "ddt" or "ricevimenti" },
new("taxable", T["Sales.Totals.Taxable"], r => r.Taxable) { Kind = KhColumnKind.Money, Width = "120px", Visible = !Internal },
new("total", T["Sales.Totals.Total"], r => r.Total) { Kind = KhColumnKind.Money, Width = "120px", Visible = !Internal },
new("status", T["Sales.Radar.State"], r => StateOf(r).Text)
{
Width = "130px",
@@ -136,7 +141,7 @@ else
protected override async Task OnParametersSetAsync()
{
await Session.EnsureLoadedAsync();
_section = SalesScreens.Find(Segment);
_section = SalesScreens.Find(SalesScreens.AreaOf(Navigation.ToBaseRelativePath(Navigation.Uri)), Segment);
if (!_loaded && Session.Actor is { } actor && Session.Company?.Code is { } company)
{
_definitions = await Engine.DefinitionsAsync(actor, company);
@@ -1,4 +1,6 @@
@page "/vendite/{Segment}/{Id:long}/stampa"
@page "/acquisti/{Segment}/{Id:long}/stampa"
@page "/magazzino/{Segment}/{Id:long}/stampa"
@attribute [Authorize]
@using Khaemhat.Application.Documents
@using Khaemhat.Application.Security
@@ -9,6 +11,7 @@
@inject DocumentEngine Engine
@inject FileGenerationService Generation
@inject ToastService Toasts
@inject NavigationManager Navigation
@* The print preview of a sales document (SPEC §9.4, issue #52, mockup 025): the A4 sheet in HTML from the same model
as the PDF, with Stampa (the print of the browser), the PDF made by Khaemhat and "Salva come allegato", which keeps
@@ -172,13 +175,13 @@ else
private string Heading => _model is null ? T["Sales.Print.Title"] : T.Format("Sales.Print.Heading", _model.Title, _model.Number);
private string BackUrl => _section is null ? SalesScreens.BasePath : SalesScreens.BasePath + "/" + _section.Segment + "/" + Id.ToString(T.Culture);
private string BackUrl => _section is null ? SalesScreens.BasePath : SalesScreens.RadarUrl(_section) + "/" + Id.ToString(T.Culture);
/// <inheritdoc />
protected override async Task OnParametersSetAsync()
{
await Session.EnsureLoadedAsync();
_section = SalesScreens.Find(Segment);
_section = SalesScreens.Find(SalesScreens.AreaOf(Navigation.ToBaseRelativePath(Navigation.Uri)), Segment);
if (_section is null || Session.Actor is not { } actor || Session.Company?.Code is not { } company)
{
_missing = true;
@@ -33,6 +33,12 @@ public sealed class DocumentLookups
/// <summary>Warehouses.</summary>
public IReadOnlyList<KhOption<string>> Warehouses { get; private init; } = [];
/// <summary>Warehouse reasons (causali di magazzino).</summary>
public IReadOnlyList<KhOption<string>> InventoryReasons { get; private init; } = [];
/// <summary>The ids of the reasons that move goods between two warehouses.</summary>
public IReadOnlySet<long> TransferReasons { get; private init; } = new HashSet<long>();
/// <summary>Carriers.</summary>
public IReadOnlyList<KhOption<string>> Carriers { get; private init; } = [];
@@ -68,6 +74,8 @@ public sealed class DocumentLookups
Salespeople = await ReadAsync<Salesperson>(tables, actor, company, false, cancellationToken).ConfigureAwait(false),
BankAccounts = await ReadAsync<BankAccount>(tables, actor, company, false, cancellationToken).ConfigureAwait(false),
Warehouses = await ReadAsync<Warehouse>(tables, actor, company, false, cancellationToken).ConfigureAwait(false),
InventoryReasons = await ReadAsync<InventoryReason>(tables, actor, company, false, cancellationToken).ConfigureAwait(false),
TransferReasons = (await tables.ActiveAsync<InventoryReason>(actor, company, cancellationToken).ConfigureAwait(false)).Where(r => r.IsTransfer).Select(r => r.Id).ToHashSet(),
Carriers = await ReadAsync<Carrier>(tables, actor, company, false, cancellationToken).ConfigureAwait(false),
ShippingTerms = await ReadAsync<ShippingTerm>(tables, actor, company, false, cancellationToken).ConfigureAwait(false),
TransportReasons = await ReadAsync<TransportReason>(tables, actor, company, false, cancellationToken).ConfigureAwait(false),
+49 -8
View File
@@ -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>
@@ -147,6 +147,7 @@ internal static class KhaemhatServices
services.AddSingleton<Khaemhat.Application.Parties.PartyService>();
services.AddSingleton<Khaemhat.Application.Items.ItemService>();
services.AddSingleton<Khaemhat.Application.Inventory.InventoryService>();
services.AddSingleton<Khaemhat.Application.Purchases.PurchaseService>();
services.AddSingleton<Khaemhat.Application.Items.PriceListService>();
// The document engine (ADR 0032): one engine, the copies, a typed service per family.
@@ -41,6 +41,14 @@
"reason-required": "Per annullare una fattura indica il motivo.",
"has-followers": "Altri documenti evadono questo: annulla prima quelli."
},
"purchase": {
"number-required": "Indica il numero e la data che il fornitore ha scritto sul documento.",
"duplicate": "Questo fornitore ha già un documento con lo stesso numero nello stesso anno: controlla di non registrarlo due volte.",
"vat-date-before": "La data di registrazione IVA non può precedere la data del documento del fornitore."
},
"transfer": {
"destination": "Per un trasferimento indica il deposito d'arrivo, diverso da quello di partenza."
},
"copy": {
"direction": "Si trasforma solo in un documento della stessa direzione (vendita o acquisto).",
"nothing-left": "Non c'è più nulla da evadere.",
@@ -0,0 +1,17 @@
{
"Inventory": {
"NoReason": "Senza causale",
"Groups": {
"Movement": "Movimento"
},
"Fields": {
"Reason": "Causale",
"Warehouse": "Deposito",
"FromWarehouse": "Dal deposito",
"ToWarehouse": "Al deposito"
},
"Hints": {
"Movement": "La causale decide se il movimento carica, scarica o trasferisce; senza deposito vale quello dell’articolo."
}
}
}
@@ -0,0 +1,15 @@
{
"Purchases": {
"Fields": {
"Supplier": "Fornitore",
"SupplierNumber": "N. documento fornitore",
"SupplierDate": "Data documento fornitore",
"Protocol": "Protocollo",
"VatDate": "Data registrazione IVA"
},
"Hints": {
"SupplierNumber": "Il numero scritto dal fornitore sulla sua fattura o sul DDT.",
"VatDate": "Il mese in cui l’IVA entra in detrazione; vuota, vale la data di registrazione."
}
}
}
+13 -2
View File
@@ -13,7 +13,12 @@
"Orders": { "Title": "Ordini clienti", "New": "Nuovo ordine" },
"DeliveryNotes": { "Title": "Documenti di trasporto", "New": "Nuovo DDT" },
"Invoices": { "Title": "Fatture di vendita", "New": "Nuova fattura" },
"CreditNotes": { "Title": "Note di credito e di debito", "New": "Nuova nota" }
"CreditNotes": { "Title": "Note di credito e di debito", "New": "Nuova nota" },
"PurchaseOrders": { "Title": "Ordini fornitori", "New": "Nuovo ordine fornitore" },
"Receipts": { "Title": "Ricevimenti merce", "New": "Nuovo ricevimento" },
"PurchaseInvoices": { "Title": "Fatture passive", "New": "Registra fattura" },
"SelfInvoices": { "Title": "Autofatture e integrazioni", "New": "Nuova autofattura" },
"Movements": { "Title": "Movimenti di magazzino", "New": "Nuovo movimento" }
},
"Kinds": {
"Quotation": "Preventivo",
@@ -173,7 +178,13 @@
"CreditNote": "TD04, storna in tutto o in parte una fattura.",
"DebitNote": "TD05, aggiunge importi a una fattura.",
"Fee": "TD06, per i professionisti, con ritenuta e cassa.",
"ProForma": "Non fiscale: anticipa la fattura al cliente."
"ProForma": "Non fiscale: anticipa la fattura al cliente.",
"SelfInvoice": "TD16-TD29: integra la fattura del fornitore o regolarizza un acquisto.",
"PurchaseOrder": "Ordine al fornitore: la merce ordinata entra nelle disponibilità.",
"PurchaseDeliveryNote": "Carica il magazzino al costo della riga, dall’ordine o libero.",
"PurchaseInvoice": "Registrata con protocollo e data IVA; carica la merce non ricevuta con DDT.",
"PurchaseCreditNote": "Storna una fattura del fornitore; restituisce la merce resa.",
"InventoryEntry": "Carico, scarico o trasferimento manuale con la sua causale."
}
},
"Lines": {
+3 -1
View File
@@ -74,7 +74,9 @@
"_": "Acquisti",
"Orders": "Ordini fornitori",
"Receipts": "Ricevimenti merce",
"Invoices": "Fatture passive"
"Invoices": "Fatture passive",
"Import": "Importa fatture",
"SelfInvoices": "Autofatture"
},
"Inventory": {
"_": "Magazzino",
+4 -3
View File
@@ -63,9 +63,10 @@ public static class MenuCatalog
Area("Shell.Menu.Sales", "cart", "/vendite", ModuleCodes.Core, "sales.invoice.read", null,
("Shell.Menu.Sales.Quotes", "preventivi"), ("Shell.Menu.Sales.Orders", "ordini"), ("Shell.Menu.Sales.DeliveryNotes", "ddt"),
("Shell.Menu.Sales.Invoices", "fatture"), ("Shell.Menu.Sales.CreditNotes", "note-credito"), ("Shell.Menu.Sales.DeferredInvoicing", "fatturazione-differita")),
Area("Shell.Menu.Purchases", "truck", "/acquisti", ModuleCodes.Core, "purchases.order.read", "M6",
("Shell.Menu.Purchases.Orders", "ordini"), ("Shell.Menu.Purchases.Receipts", "ricevimenti"), ("Shell.Menu.Purchases.Invoices", "fatture")),
Area("Shell.Menu.Inventory", "box", "/magazzino", ModuleCodes.Core, "inventory.stock.read", "M6",
Area("Shell.Menu.Purchases", "truck", "/acquisti", ModuleCodes.Core, "purchases.order.read", null,
("Shell.Menu.Purchases.Orders", "ordini"), ("Shell.Menu.Purchases.Receipts", "ricevimenti"), ("Shell.Menu.Purchases.Invoices", "fatture"),
("Shell.Menu.Purchases.Import", "importa-fatture"), ("Shell.Menu.Purchases.SelfInvoices", "autofatture")),
Area("Shell.Menu.Inventory", "box", "/magazzino", ModuleCodes.Core, "inventory.stock.read", null,
("Shell.Menu.Inventory.Stock", "giacenze"), ("Shell.Menu.Inventory.Entries", "movimenti"), ("Shell.Menu.Inventory.StockTake", "inventario"),
("Shell.Menu.Inventory.Reorder", "riordino")),
Area("Shell.Menu.Ledger", "book", "/contabilita", ModuleCodes.Accounting, "ledger.entry.read", "M7",