M6 · Acquisti e Magazzino (v0.6.0) #125

Merged
Alby96 merged 9 commits from feat/55-acquisti-magazzino into main 2026-11-12 22:38:11 +01:00
10 changed files with 57 additions and 33 deletions
Showing only changes of commit cd4cb85562 - Show all commits

No files matched your search

@@ -72,7 +72,7 @@ else
}
else
{
<div class="gridwrap">
<div class="gridwrap kh-scrollx">
<table class="grid" aria-label="@T["Inventory.Reorder.Lines"]">
<thead>
<tr>
@@ -109,10 +109,10 @@ else
{
<tr>
<td>@T.Date(move.Date)</td>
<td class="code">
<td>
@if (move.Kind is { } kind && move.DocumentId is { } document)
{
<a href="@SalesScreens.RecordUrl(kind, document)">@T["Sales.Kinds." + kind] @move.Number</a>
<a href="@SalesScreens.RecordUrl(kind, document)">@T["Sales.Kinds." + kind] <span class="mono">@move.Number</span></a>
}
</td>
<td class="code">@move.ReasonCode</td>
@@ -146,29 +146,29 @@ else
<div class="kh-import-main">
<KhStrip Items="Stats" Label="@T["Inventory.StockTake.Procedure"]" />
<KhPanel Title="@T["Inventory.StockTake.Lines"]" Icon="list">
<Actions>
<input type="search" class="in kh-searchbox" placeholder="@T["Inventory.Stock.Search"]" aria-label="@T["Inventory.Stock.Search"]"
value="@_search" @oninput="e => _search = e.Value?.ToString()" />
<select class="in" aria-label="@T["Inventory.StockTake.Show"]" @onchange="e => _show = e.Value?.ToString() ?? string.Empty">
<option value="" selected="@(_show.Length == 0)">@T["Inventory.StockTake.ShowAll"]</option>
<option value="todo" selected="@(_show == "todo")">@T["Inventory.StockTake.ShowToCount"]</option>
<option value="diff" selected="@(_show == "diff")">@T["Inventory.StockTake.ShowDifferences"]</option>
</select>
@if (IsOpen && CanWrite)
{
<label class="btn kh-filebtn">
<KhIcon Name="upload" /> @T["Inventory.StockTake.Import"]
<InputFile OnChange="ImportAsync" accept=".csv,.txt,text/csv,text/plain" disabled="@_busy" />
</label>
<button type="button" class="btn" disabled="@(_busy || _counts.Count == 0)" @onclick="SaveAsync"><KhIcon Name="save" /> @T["Inventory.StockTake.Save"]</button>
@if (Session.Permissions.Allows(InventoryService.PostPermission))
{
<button type="button" class="btn primary" disabled="@_busy" @onclick="PostAsync"><KhIcon Name="check-circle" /> @T["Inventory.StockTake.Post"]</button>
}
}
</Actions>
<ChildContent>
<div class="gridwrap kh-taketable">
<div class="kh-taketools">
<input type="search" class="in kh-searchbox" placeholder="@T["Inventory.Stock.Search"]" aria-label="@T["Inventory.Stock.Search"]"
value="@_search" @oninput="e => _search = e.Value?.ToString()" />
<select class="in" aria-label="@T["Inventory.StockTake.Show"]" @onchange="e => _show = e.Value?.ToString() ?? string.Empty">
<option value="" selected="@(_show.Length == 0)">@T["Inventory.StockTake.ShowAll"]</option>
<option value="todo" selected="@(_show == "todo")">@T["Inventory.StockTake.ShowToCount"]</option>
<option value="diff" selected="@(_show == "diff")">@T["Inventory.StockTake.ShowDifferences"]</option>
</select>
@if (IsOpen && CanWrite)
{
<label class="btn kh-filebtn">
<KhIcon Name="upload" /> @T["Inventory.StockTake.Import"]
<InputFile OnChange="ImportAsync" accept=".csv,.txt,text/csv,text/plain" disabled="@_busy" />
</label>
<button type="button" class="btn" disabled="@(_busy || _counts.Count == 0)" @onclick="SaveAsync"><KhIcon Name="save" /> @T["Inventory.StockTake.Save"]</button>
@if (Session.Permissions.Allows(InventoryService.PostPermission))
{
<button type="button" class="btn primary" disabled="@_busy" @onclick="PostAsync"><KhIcon Name="check-circle" /> @T["Inventory.StockTake.Post"]</button>
}
}
</div>
<div class="gridwrap kh-scrollx">
<table class="grid" aria-label="@T["Inventory.StockTake.Lines"]">
<thead>
<tr>
@@ -52,7 +52,7 @@ else
var h = Record.Header;
<KhRecordLayout Page="this">
<Heading>
<KhDocHead KindIcon="@_section.Icon" KindLabel="@_definition.Type.Description" Number="@(h.DocumentNumber ?? T["Sales.DraftNumber"])"
<KhDocHead KindIcon="@_section.Icon" KindLabel="@_definition.Type.Description" Number="@SalesScreens.Number(T, h.DocumentNumber, h.Status)"
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>
@@ -113,7 +113,7 @@ else
@if (_differences.Count > 0)
{
<div class="callout warn kh-doc-callout"><KhIcon Name="alert" />
<span>@T.Format("Purchases.PriceDifferences.Summary", _differences.Count, T.Money(_differences.Sum(d => d.Amount)))
<span>@(_differences.Count == 1 ? T.Format("Purchases.PriceDifferences.SummaryOne", T.Money(_differences[0].Amount)) : T.Format("Purchases.PriceDifferences.Summary", _differences.Count, T.Money(_differences.Sum(d => d.Amount))))
@foreach (var difference in _differences.Take(5))
{
<br /><span class="sm">@T.Format("Purchases.PriceDifferences.Line", difference.LineNumber, difference.Description, difference.SourceNumber ?? string.Empty,
@@ -125,7 +125,7 @@ else
@if (_selfAdvice is { } advice)
{
<div class="callout info kh-doc-callout"><KhIcon Name="refresh" />
<span>@T.Format("Purchases.SelfInvoices.Advice", advice.DocumentTypeCode, advice.Reason, T.Date(advice.Deadline))</span>
<span>@T.Format("Purchases.SelfInvoices.Advice", advice.DocumentTypeCode, Sentence(advice.Reason), T.Date(advice.Deadline))</span>
@if (Session.Permissions.Allows(PurchaseService.WritePermission) && DocumentStateMachine.IsInForce(h.Status))
{
<button type="button" class="btn" @onclick="CreateSelfInvoiceAsync"><KhIcon Name="plus" /> @T["Purchases.SelfInvoices.Create"]</button>
@@ -354,11 +354,11 @@ else
<td class="code">
@if (SalesScreens.RecordUrl(link.Kind, link.Id) is { } url)
{
<a href="@url">@(link.DocumentNumber ?? T["Sales.DraftNumber"])</a>
<a href="@url">@SalesScreens.Number(T, link.DocumentNumber, link.Status)</a>
}
else
{
@(link.DocumentNumber ?? T["Sales.DraftNumber"])
@SalesScreens.Number(T, link.DocumentNumber, link.Status)
}
</td>
<td>@T.Date(link.Date)</td>
@@ -115,7 +115,7 @@ public sealed partial class SalesDocumentPage
private string PageTitle => Record is null || _definition is null
? T["Shell.Menu.Sales"]
: _definition.Type.Description + " " + (Record.Header.DocumentNumber ?? T["Sales.DraftNumber"]);
: _definition.Type.Description + " " + SalesScreens.Number(T, Record.Header.DocumentNumber, Record.Header.Status);
private bool IsInvoice => Record is not null && (Behavior.Lifecycle == DocumentLifecycle.Invoice || H.Kind == DocumentKind.ProForma || IsRegistered);
@@ -336,6 +336,9 @@ public sealed partial class SalesDocumentPage
}
// A supplier invoice: the prices that differ from its order or receipt, and the self-invoice it needs.
// A reason ends with one full stop, whether the fiscal pack wrote it or not.
private static string Sentence(string text) => text.EndsWith('.') ? text : text + ".";
private async Task LoadPurchaseChecksAsync(Actor actor, string company)
{
_differences = [];
@@ -103,7 +103,7 @@ else
private IReadOnlyList<KhColumn<DocumentRow>> Columns =>
[
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("number", T[_section?.Kinds.Contains(DocumentKind.PurchaseInvoice) == true ? "Purchases.Fields.Protocol" : "Sales.Fields.DocumentNumber"], r => SalesScreens.Number(T, r.DocumentNumber, r.Status)) { 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[SalesScreens.PartyLabel(_section?.Direction ?? DocumentDirection.Sale)], r => r.PartyName) { Sortable = false, Visible = !Internal },
@@ -134,6 +134,20 @@ public static class SalesScreens
return texts["Sales.Kinds." + kind];
}
/// <summary>
/// The number shown for a document: its own number, else "Bozza" for a draft and "Senza numero" for a confirmed
/// document of a type without numerator (a supplier delivery note, which keeps the supplier's number).
/// </summary>
/// <param name="texts">The texts.</param>
/// <param name="number">The document number.</param>
/// <param name="status">The state.</param>
/// <returns>The text.</returns>
public static string Number(ITexts texts, string? number, DocumentStatus status)
{
ArgumentNullException.ThrowIfNull(texts);
return number ?? texts[status == DocumentStatus.Draft ? "Sales.DraftNumber" : "Sales.NoNumber"];
}
/// <summary>The label and tone of a state; a quotation shows its outcome (accepted, refused, expired).</summary>
/// <param name="texts">The texts.</param>
/// <param name="kind">The kind.</param>
@@ -56,10 +56,11 @@
"Reason": "Motivo",
"Deadline": "Entro il",
"Create": "Crea autofattura",
"Advice": "Serve un'autofattura {0}: {1}. Da emettere entro il {2}."
"Advice": "Serve un'autofattura {0}: {1} Da emettere entro il {2}."
},
"PriceDifferences": {
"Summary": "{0} righe hanno un prezzo diverso dall'ordine o dal ricevimento: differenza totale {1}.",
"SummaryOne": "Una riga ha un prezzo diverso dall'ordine o dal ricevimento: differenza {0}.",
"Line": "Riga {0}, {1}: {2} a {3}, in fattura {4}."
}
},
@@ -4,6 +4,7 @@
"NotFound": "Documento non trovato",
"BackToList": "Torna all'elenco",
"DraftNumber": "Bozza",
"NoNumber": "Senza numero",
"NumberOnConfirm": "Assegnato alla conferma",
"NoParty": "Cliente da scegliere",
"Demo": "Dato dimostrativo",
+5
View File
@@ -409,10 +409,15 @@ h1[tabindex="-1"]:focus { outline: none; box-shadow: none; }
/* Warehouse (M6): filters above a radar, count boxes, file picker as a button, grids inside dialogs. */
.kh-pagefilters { margin: 10px 0 4px; }
.kh-searchbox { width: 220px; }
.kh-taketools { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 10px 12px; border-bottom: 1px solid var(--kh-border); }
.kh-taketools .in { width: auto; }
.kh-taketools .kh-searchbox { flex: 1 1 200px; max-width: 320px; }
.kh-scrollx { overflow-x: auto; }
.in.kh-countbox { width: 96px; height: 26px; text-align: right; }
.kh-filebtn { position: relative; overflow: hidden; cursor: pointer; }
.kh-filebtn input[type=file] { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.kh-dialoggrid { max-height: 52vh; overflow: auto; margin-top: 10px; }
.kh-dialoggrid .mono { font-family: var(--kh-mono); font-size: 12px; }
.kh-cellpick { min-width: 220px; }
.kh-cellpick .f > label:empty { display: none; }
.kh-plainlist { margin: 4px 0 0; padding-left: 18px; }