feat: items and price lists with dated prices, derived lists and demo catalogue (#42)
Items get their own archive and record (mockup 017): codes from the per-category mask, EAN and NC8 checks, alternative units and bar codes, suppliers with the usual one, substitutes, notes and history. Only goods can be stocked; stock itself comes with the warehouse in M6. Costs are hidden from users without items.cost.read and kept as they were when those users save. A used item is disabled instead of deleted. Prices live in one item_prices table, either for a price list or as a customer's net price, each valid from a date, so documents keep the price of their day. Derived lists compute a price from their base list with markup and rounding when they have none of their own. The price grid (mockup 018) edits every list at one validity date, keeps changes pending and highlighted until saved, and computes mass updates as a preview. PriceListService.QuoteAsync gives documents (M5) the price search order net, list, base, item price with its source. Parties get the "Articoli e codici" tab: the codes a customer or supplier uses for our items, found by the item search in that party's documents. Demo data adds 120 items of a plumbing wholesaler, the PUBB and RIV lists, last year's prices, suppliers, units, codes and a customer's net prices; seed --demo [--scale N] loads them from the command line and repeats the catalogue for performance tests. ADR 0030 records the decisions; wiki, data model, CHANGELOG and STATUS are updated. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
c8241a414e
commit
3dbbaba86e
46 files changed
+5318
-144
No files matched your search
@@ -0,0 +1,10 @@
|
||||
@page "/anagrafiche/categorie"
|
||||
@attribute [Authorize]
|
||||
@using Khaemhat.Web.Items
|
||||
@inject NavigationManager Navigation
|
||||
|
||||
@* The menu entry Anagrafiche > Categorie: the item categories are a company table, kept with the others. *@
|
||||
@code {
|
||||
/// <inheritdoc />
|
||||
protected override void OnInitialized() => Navigation.NavigateTo(ItemScreens.CategoriesUrl, new NavigationOptions { ReplaceHistoryEntry = true });
|
||||
}
|
||||
@@ -0,0 +1,782 @@
|
||||
@page "/anagrafiche/articoli/nuovo"
|
||||
@page "/anagrafiche/articoli/{Id:long}"
|
||||
@attribute [Authorize]
|
||||
@inherits MasterDataPage<ItemRecord>
|
||||
@using Khaemhat.Application.Audit
|
||||
@using Khaemhat.Application.Items
|
||||
@using Khaemhat.Application.Parties
|
||||
@using Khaemhat.Application.Security
|
||||
@using Khaemhat.Application.Tables
|
||||
@using Khaemhat.Core.Common
|
||||
@using Khaemhat.Core.Items
|
||||
@using Khaemhat.Web.Items
|
||||
@using Khaemhat.Web.Parties
|
||||
@using Khaemhat.Web.Components.Pages.Parties
|
||||
@using Khaemhat.Web.Tables
|
||||
@inject ShellSession Session
|
||||
@inject ItemService Items
|
||||
@inject PriceListService PriceLists
|
||||
@inject PartyService Parties
|
||||
@inject TableService Tables
|
||||
@inject AttachmentService Attachments
|
||||
|
||||
@* The record of an item (SPEC §11.2, mockup 017): header with code, description and the base price today, tabs for
|
||||
main data, alternative units, alternative codes, prices of the lists and net prices of the customers, suppliers,
|
||||
substitutes, notes with attachments, history. Stock and movements per warehouse arrive with the warehouse (M6). The
|
||||
checks are those of ItemService: errors stop the save and open the tab of the first one, warnings show after saving. *@
|
||||
<KhPageTitle Text="@PageTitle" Icon="box" />
|
||||
|
||||
@if (!_loaded)
|
||||
{
|
||||
<p class="muted kh-pad">@T["Common.Loading"]</p>
|
||||
}
|
||||
else if (Session.Company is null)
|
||||
{
|
||||
<div class="kh-message"><KhIcon Name="building" Class="lg" /><h1>@T["Items.NoCompany"]</h1></div>
|
||||
}
|
||||
else if (!Session.Permissions.Allows(ItemService.ReadPermission))
|
||||
{
|
||||
<div class="kh-message">
|
||||
<KhIcon Name="lock" Class="lg" />
|
||||
<h1>@T["Pages.AccessDenied.Title"]</h1>
|
||||
<p class="lead">@T["Pages.AccessDenied.Lead"]</p>
|
||||
</div>
|
||||
}
|
||||
else if (Record is null)
|
||||
{
|
||||
<div class="kh-message">
|
||||
<KhIcon Name="alert" Class="lg" />
|
||||
<h1>@T["Items.NotFound"]</h1>
|
||||
<a class="btn" href="@ItemScreens.RadarUrl">@T["Items.Title"]</a>
|
||||
</div>
|
||||
}
|
||||
else
|
||||
{
|
||||
<KhRecordLayout Page="this">
|
||||
<Heading>
|
||||
<KhDocHead KindIcon="box" KindLabel="@T["Items.Kinds." + I.Kind]" Number="@(I.Code.Length > 0 ? I.Code : T["Items.CodeAuto"])"
|
||||
PartyName="@(I.Description.Length > 0 ? I.Description : T["Items.NewTitle"])" PartyLines="HeadLines"
|
||||
TotalLabel="@BaseLabel" TotalValue="@(BasePrice is { } price ? T.Money(price) : null)" SubValues="HeadStats">
|
||||
<State>
|
||||
@if (I.Disabled)
|
||||
{
|
||||
<KhBadge Tone="KhTone.Neutral">@T["Items.States.Disabled"]</KhBadge>
|
||||
}
|
||||
else if (!IsNew)
|
||||
{
|
||||
<KhBadge Tone="KhTone.Ok">@T["Items.States.Active"]</KhBadge>
|
||||
}
|
||||
@if (!I.Stocked)
|
||||
{
|
||||
<KhBadge Tone="KhTone.Info">@T["Items.States.NotStocked"]</KhBadge>
|
||||
}
|
||||
@if (I.IsDemo)
|
||||
{
|
||||
<KhBadge Tone="KhTone.Info">@T["Items.States.Demo"]</KhBadge>
|
||||
}
|
||||
@if (IsModified)
|
||||
{
|
||||
<KhBadge Tone="KhTone.Warning">@T["CompanyTables.Modified"]</KhBadge>
|
||||
}
|
||||
</State>
|
||||
<Chips>
|
||||
@if (PartyScreens.Describe(_lookups.Categories, I.CategoryId, full: true) is { } category)
|
||||
{
|
||||
<KhChip Icon="folder" Text="@T["Items.Fields.CategoryId"]" Value="@category" />
|
||||
}
|
||||
@if (PartyScreens.Describe(_lookups.Units, I.UnitOfMeasureId) is { } unit)
|
||||
{
|
||||
<KhChip Icon="layers" Text="@T["Items.Fields.UnitOfMeasureId"]" Value="@unit" />
|
||||
}
|
||||
@if (PartyScreens.Describe(_lookups.TaxCodes, I.SalesTaxCodeId) is { } tax)
|
||||
{
|
||||
<KhChip Icon="euro" Text="@T["Items.Fields.SalesTaxCodeId"]" Value="@tax" />
|
||||
}
|
||||
@if (Record.Suppliers.FirstOrDefault(s => s.IsDefault) is { } supplier && _parties.TryGetValue(supplier.PartyId, out var party))
|
||||
{
|
||||
<KhChip Icon="truck" Text="@T["Items.Fields.Supplier"]" Value="@party.Name" />
|
||||
}
|
||||
</Chips>
|
||||
</KhDocHead>
|
||||
</Heading>
|
||||
<ChildContent>
|
||||
<KhForm Validation="Validation" ReadOnly="IsReadOnly" Layout="KhFormLayout.Groups" @ref="Form">
|
||||
@switch (ActiveTab)
|
||||
{
|
||||
case ItemScreens.Tabs.Main:
|
||||
<KhFieldGroup Title="@T["Items.Groups.Identity"]" Icon="box">
|
||||
<KhTextBox Label="@T["Items.Fields.Code"]" Name="Code" Value="@I.Code" ValueChanged="v => Change(() => I.Code = v ?? string.Empty)" Mono="true"
|
||||
Placeholder="@T["Items.CodeAuto"]" Span="4" MaxLength="30" />
|
||||
<KhSelect TValue="string" Label="@T["Items.Fields.Kind"]" Name="Kind" Options="KindChoices" Value="@I.Kind.ToString()" Span="4" ValueChanged="SetKind" />
|
||||
<KhSelect TValue="string" Label="@T["Items.Fields.CategoryId"]" Name="CategoryId" Options="_lookups.Categories" Empty="" Span="4"
|
||||
Value="@PartyScreens.Text(I.CategoryId)" ValueChanged="v => Change(() => I.CategoryId = PartyScreens.Id(v))" />
|
||||
<KhTextBox Label="@T["Items.Fields.Description"]" Name="Description" Value="@I.Description" ValueChanged="v => Change(() => I.Description = v ?? string.Empty)"
|
||||
Span="12" MaxLength="200" Required="true" />
|
||||
<KhTextArea Label="@T["Items.Fields.ExtendedDescription"]" Name="ExtendedDescription" Value="@I.ExtendedDescription"
|
||||
ValueChanged="v => Change(() => I.ExtendedDescription = v)" Span="12" Rows="3" />
|
||||
<KhTextBox Label="@T["Items.Fields.Brand"]" Name="Brand" Value="@I.Brand" ValueChanged="v => Change(() => I.Brand = v)" Span="6" MaxLength="100" />
|
||||
<KhTextBox Label="@T["Items.Fields.Manufacturer"]" Name="Manufacturer" Value="@I.Manufacturer" ValueChanged="v => Change(() => I.Manufacturer = v)" Span="6" MaxLength="100" />
|
||||
<KhCheck Label="@T["Items.Fields.Disabled"]" Name="Disabled" Value="I.Disabled" ValueChanged="v => Change(() => I.Disabled = v)" Span="4" />
|
||||
</KhFieldGroup>
|
||||
<KhFieldGroup Title="@T["Items.Groups.Codes"]" Icon="key">
|
||||
<KhSelect TValue="string" Label="@T["Items.Fields.UnitOfMeasureId"]" Name="UnitOfMeasureId" Options="_lookups.Units" Empty="" Span="4"
|
||||
Value="@PartyScreens.Text(I.UnitOfMeasureId)" ValueChanged="v => Change(() => I.UnitOfMeasureId = PartyScreens.Id(v))" />
|
||||
<KhTextBox Label="@T["Items.Fields.Barcode"]" Name="Barcode" Value="@I.Barcode" ValueChanged="v => Change(() => I.Barcode = v)" Mono="true" Span="4" MaxLength="20" />
|
||||
<KhTextBox Label="@T["Items.Fields.CustomsCode"]" Name="CustomsCode" Value="@I.CustomsCode" ValueChanged="v => Change(() => I.CustomsCode = v)" Mono="true" Span="4" MaxLength="10" />
|
||||
<KhSelect TValue="string" Label="@T["Items.Fields.SalesTaxCodeId"]" Name="SalesTaxCodeId" Options="_lookups.TaxCodes" Empty="" Span="6"
|
||||
Value="@PartyScreens.Text(I.SalesTaxCodeId)" ValueChanged="v => Change(() => I.SalesTaxCodeId = PartyScreens.Id(v))" />
|
||||
<KhSelect TValue="string" Label="@T["Items.Fields.PurchaseTaxCodeId"]" Name="PurchaseTaxCodeId" Options="_lookups.TaxCodes" Empty="" Span="6"
|
||||
Value="@PartyScreens.Text(I.PurchaseTaxCodeId)" ValueChanged="v => Change(() => I.PurchaseTaxCodeId = PartyScreens.Id(v))" />
|
||||
<KhNumberBox Label="@T["Items.Fields.NetWeight"]" Name="NetWeight" Value="I.NetWeight" ValueChanged="v => Change(() => I.NetWeight = v)" Min="0" Decimals="3" Span="6" />
|
||||
<KhNumberBox Label="@T["Items.Fields.GrossWeight"]" Name="GrossWeight" Value="I.GrossWeight" ValueChanged="v => Change(() => I.GrossWeight = v)" Min="0" Decimals="3" Span="6" />
|
||||
</KhFieldGroup>
|
||||
<KhFieldGroup Title="@T["Items.Groups.Prices"]" Icon="euro">
|
||||
<KhNumberBox Label="@T["Items.Fields.ItemPrice"]" Name="Price" Value="I.Price" ValueChanged="v => Change(() => I.Price = v)" Min="0" Span="6"
|
||||
Hint="@T["Items.Hints.ItemPrice"]" />
|
||||
@if (_costs)
|
||||
{
|
||||
<KhNumberBox Label="@T["Items.Fields.StandardCost"]" Name="StandardCost" Value="I.StandardCost" ValueChanged="v => Change(() => I.StandardCost = v)" Min="0" Span="6" />
|
||||
<KhNumberBox Label="@T["Items.Fields.LastCost"]" Name="LastCost" Value="I.LastCost" ReadOnly="true" Span="4" />
|
||||
<KhNumberBox Label="@T["Items.Fields.AverageCost"]" Name="AverageCost" Value="I.AverageCost" ReadOnly="true" Span="4" />
|
||||
<KhTextBox Label="@T["Items.Fields.Margin"]" Name="Margin" Value="@ItemScreens.MarginText(BasePrice, Cost, T.Culture)" ReadOnly="true" Span="4" />
|
||||
<p class="muted sm c12">@T["Items.Hints.Costs"]</p>
|
||||
}
|
||||
else
|
||||
{
|
||||
<p class="muted sm c6">@T["Items.Hints.CostsHidden"]</p>
|
||||
}
|
||||
</KhFieldGroup>
|
||||
<KhFieldGroup Title="@T["Items.Groups.Stock"]" Icon="layers">
|
||||
<KhCheck Label="@T["Items.Fields.Stocked"]" Name="Stocked" Value="I.Stocked" ValueChanged="v => Change(() => I.Stocked = v)" Span="6"
|
||||
Disabled="@(I.Kind != ItemKind.Goods)" />
|
||||
<KhSelect TValue="string" Label="@T["Items.Fields.WarehouseId"]" Name="WarehouseId" Options="_lookups.Warehouses" Empty="" Span="6"
|
||||
Value="@PartyScreens.Text(I.WarehouseId)" ValueChanged="v => Change(() => I.WarehouseId = PartyScreens.Id(v))" Disabled="@(!I.Stocked)" />
|
||||
<KhNumberBox Label="@T["Items.Fields.MinimumStock"]" Name="MinimumStock" Value="I.MinimumStock" ValueChanged="v => Change(() => I.MinimumStock = v)" Min="0" Decimals="3" Span="4" />
|
||||
<KhNumberBox Label="@T["Items.Fields.ReorderPoint"]" Name="ReorderPoint" Value="I.ReorderPoint" ValueChanged="v => Change(() => I.ReorderPoint = v)" Min="0" Decimals="3" Span="4" />
|
||||
<KhNumberBox Label="@T["Items.Fields.ReorderLot"]" Name="ReorderLot" Value="I.ReorderLot" ValueChanged="v => Change(() => I.ReorderLot = v)" Min="0" Decimals="3" Span="4" />
|
||||
<p class="muted sm c12">@T[I.Kind == ItemKind.Goods ? "Items.Hints.Stock" : "Items.Hints.NotStocked"]</p>
|
||||
</KhFieldGroup>
|
||||
<KhFieldGroup Title="@T["Items.Groups.Accounts"]" Icon="book" Wide="true">
|
||||
<KhTextBox Label="@T["Items.Fields.RevenueAccountCode"]" Name="RevenueAccountCode" Value="@I.RevenueAccountCode" ValueChanged="v => Change(() => I.RevenueAccountCode = v)"
|
||||
Mono="true" Span="3" MaxLength="20" />
|
||||
<KhTextBox Label="@T["Items.Fields.CostAccountCode"]" Name="CostAccountCode" Value="@I.CostAccountCode" ValueChanged="v => Change(() => I.CostAccountCode = v)"
|
||||
Mono="true" Span="3" MaxLength="20" />
|
||||
</KhFieldGroup>
|
||||
break;
|
||||
|
||||
case ItemScreens.Tabs.Units:
|
||||
<p class="muted kh-pad sm"><KhIcon Name="info" /> @T["Items.Hints.Units"]</p>
|
||||
@for (var i = 0; i < Record.Units.Count; i++)
|
||||
{
|
||||
var index = i;
|
||||
var u = Record.Units[i];
|
||||
<KhFieldGroup Title="@(PartyScreens.Describe(_lookups.Units, u.UnitOfMeasureId, full: true) ?? T["Items.Actions.AddUnit"])" Icon="layers" Wide="true">
|
||||
<KhSelect TValue="string" Label="@T["Items.Fields.UnitOfMeasureId"]" Name="@Key("Units", index, "UnitOfMeasureId")" Options="_lookups.Units" Empty="" Span="4" Required="true"
|
||||
Value="@PartyScreens.Text(u.UnitOfMeasureId is 0 ? null : u.UnitOfMeasureId)" ValueChanged="v => Change(() => u.UnitOfMeasureId = PartyScreens.Id(v) ?? 0)" />
|
||||
<KhNumberBox Label="@T["Items.Fields.Factor"]" Name="@Key("Units", index, "Factor")" Value="u.Factor" ValueChanged="v => Change(() => u.Factor = v ?? 0)" Min="0" Decimals="4" Span="3" />
|
||||
<KhTextBox Label="@T["Items.Fields.Barcode"]" Name="@Key("Units", index, "Barcode")" Value="@u.Barcode" ValueChanged="v => Change(() => u.Barcode = v)" Mono="true" Span="3" MaxLength="20" />
|
||||
@if (!IsReadOnly)
|
||||
{
|
||||
<div class="c2 kh-endrow">
|
||||
<button type="button" class="btn danger" @onclick="() => Remove(Record.Units, index)"><KhIcon Name="trash" /> @T["Items.Actions.Remove"]</button>
|
||||
</div>
|
||||
}
|
||||
</KhFieldGroup>
|
||||
}
|
||||
<DetailFooter Empty="@(Record.Units.Count == 0 ? T["Items.Empty.Units"] : null)" CanAdd="!IsReadOnly" AddText="@T["Items.Actions.AddUnit"]"
|
||||
OnAdd="() => Add(Record.Units, new ItemUnit())" />
|
||||
break;
|
||||
|
||||
case ItemScreens.Tabs.Barcodes:
|
||||
<p class="muted kh-pad sm"><KhIcon Name="info" /> @T["Items.Hints.Barcodes"]</p>
|
||||
@for (var i = 0; i < Record.Barcodes.Count; i++)
|
||||
{
|
||||
var index = i;
|
||||
var b = Record.Barcodes[i];
|
||||
<KhFieldGroup Title="@(b.Code.Length > 0 ? b.Code : T["Items.Actions.AddBarcode"])" Icon="key" Wide="true">
|
||||
<KhTextBox Label="@T["Items.Fields.Code"]" Name="@Key("Barcodes", index, "Code")" Value="@b.Code" ValueChanged="v => Change(() => b.Code = v ?? string.Empty)"
|
||||
Mono="true" Span="4" Required="true" MaxLength="40" />
|
||||
<KhTextBox Label="@T["Items.Fields.Description"]" Name="@Key("Barcodes", index, "Description")" Value="@b.Description" ValueChanged="v => Change(() => b.Description = v)"
|
||||
Span="6" MaxLength="100" />
|
||||
@if (!IsReadOnly)
|
||||
{
|
||||
<div class="c2 kh-endrow">
|
||||
<button type="button" class="btn danger" @onclick="() => Remove(Record.Barcodes, index)"><KhIcon Name="trash" /> @T["Items.Actions.Remove"]</button>
|
||||
</div>
|
||||
}
|
||||
</KhFieldGroup>
|
||||
}
|
||||
<DetailFooter Empty="@(Record.Barcodes.Count == 0 ? T["Items.Empty.Barcodes"] : null)" CanAdd="!IsReadOnly" AddText="@T["Items.Actions.AddBarcode"]"
|
||||
OnAdd="() => Add(Record.Barcodes, new ItemBarcode())" />
|
||||
break;
|
||||
|
||||
case ItemScreens.Tabs.Prices:
|
||||
@if (_today is { } today && !IsNew)
|
||||
{
|
||||
<KhFieldGroup Title="@T["Items.Groups.Today"]" Icon="tag" Wide="true">
|
||||
<table class="kh-table c12">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>@T["Items.Fields.PriceListId"]</th>
|
||||
<th class="num">@T["Items.Fields.Price"]</th>
|
||||
<th>@T["Items.Fields.ValidFrom"]</th>
|
||||
<th>@T["Items.Fields.Source"]</th>
|
||||
@if (_costs)
|
||||
{
|
||||
<th class="num">@T["Items.Fields.Margin"]</th>
|
||||
}
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach (var list in _columns)
|
||||
{
|
||||
var cell = today.Prices.GetValueOrDefault(list.Id) ?? PriceCell.Empty;
|
||||
<tr>
|
||||
<td><span class="code">@list.Code</span> @list.Description</td>
|
||||
<td class="num">@(cell.Price is { } p ? T.Money(p) : "-")</td>
|
||||
<td>@(cell.ValidFrom is { } from ? T.Date(from) : null)</td>
|
||||
<td class="muted sm">@(cell.Derived ? T["Items.Hints.Derived"] : null)</td>
|
||||
@if (_costs)
|
||||
{
|
||||
<td class="num">@ItemScreens.MarginText(cell.Price, Cost, T.Culture)</td>
|
||||
}
|
||||
</tr>
|
||||
}
|
||||
</tbody>
|
||||
</table>
|
||||
</KhFieldGroup>
|
||||
}
|
||||
<p class="muted kh-pad sm"><KhIcon Name="info" /> @T["Items.Hints.Prices"]</p>
|
||||
<KhFieldGroup Title="@T["Items.Groups.ListPrices"]" Icon="tag" Wide="true">
|
||||
@foreach (var index in PriceRows(net: false))
|
||||
{
|
||||
var p = Record.Prices[index];
|
||||
<KhSelect TValue="string" Label="@T["Items.Fields.PriceListId"]" Name="@Key("Prices", index, "PriceListId")" Options="_lookups.PriceLists" Empty="" Span="5" Required="true"
|
||||
Value="@PartyScreens.Text(p.PriceListId is 0 ? null : p.PriceListId)" ValueChanged="v => Change(() => p.PriceListId = PartyScreens.Id(v) ?? 0)" />
|
||||
<KhNumberBox Label="@T["Items.Fields.Price"]" Name="@Key("Prices", index, "Price")" Value="p.Price" ValueChanged="v => Change(() => p.Price = v ?? 0)" Min="0" Span="3" />
|
||||
<KhDateBox Label="@T["Items.Fields.ValidFrom"]" Name="@Key("Prices", index, "ValidFrom")" Value="p.ValidFrom" ValueChanged="v => Change(() => p.ValidFrom = v)" Span="2" />
|
||||
@if (!IsReadOnly)
|
||||
{
|
||||
<div class="c2 kh-endrow">
|
||||
<button type="button" class="btn danger" @onclick="() => Remove(Record.Prices, index)"><KhIcon Name="trash" /> @T["Items.Actions.Remove"]</button>
|
||||
</div>
|
||||
}
|
||||
}
|
||||
@if (!Record.Prices.Any(p => p.PartyId is null))
|
||||
{
|
||||
<p class="muted sm c12">@T["Items.Empty.ListPrices"]</p>
|
||||
}
|
||||
@if (!IsReadOnly)
|
||||
{
|
||||
<div class="c12">
|
||||
<button type="button" class="btn" @onclick="AddListPrice"><KhIcon Name="plus" /> @T["Items.Actions.AddPrice"]</button>
|
||||
</div>
|
||||
}
|
||||
</KhFieldGroup>
|
||||
<KhFieldGroup Title="@T["Items.Groups.NetPrices"]" Icon="users" Wide="true">
|
||||
@foreach (var index in PriceRows(net: true))
|
||||
{
|
||||
var p = Record.Prices[index];
|
||||
<KhHotlink TItem="PartyRow" Label="@T["Items.Fields.PartyId"]" Name="@Key("Prices", index, "PartyId")" Span="5" Required="true"
|
||||
Value="PartyOf(p.PartyId)" ValueChanged="v => SetParty(v, id => p.PartyId = id ?? 0)"
|
||||
Search="SearchCustomersAsync" CodeOf="r => r.Code" DescriptionOf="r => r.Name" OnOpen="OpenCustomer" />
|
||||
<KhNumberBox Label="@T["Items.Fields.Price"]" Name="@Key("Prices", index, "Price")" Value="p.Price" ValueChanged="v => Change(() => p.Price = v ?? 0)" Min="0" Span="3" />
|
||||
<KhDateBox Label="@T["Items.Fields.ValidFrom"]" Name="@Key("Prices", index, "ValidFrom")" Value="p.ValidFrom" ValueChanged="v => Change(() => p.ValidFrom = v)" Span="2" />
|
||||
@if (!IsReadOnly)
|
||||
{
|
||||
<div class="c2 kh-endrow">
|
||||
<button type="button" class="btn danger" @onclick="() => Remove(Record.Prices, index)"><KhIcon Name="trash" /> @T["Items.Actions.Remove"]</button>
|
||||
</div>
|
||||
}
|
||||
}
|
||||
@if (!Record.Prices.Any(p => p.PartyId is not null))
|
||||
{
|
||||
<p class="muted sm c12">@T["Items.Empty.NetPrices"]</p>
|
||||
}
|
||||
@if (!IsReadOnly)
|
||||
{
|
||||
<div class="c12">
|
||||
<button type="button" class="btn" @onclick="AddNetPrice"><KhIcon Name="plus" /> @T["Items.Actions.AddNetPrice"]</button>
|
||||
</div>
|
||||
}
|
||||
</KhFieldGroup>
|
||||
break;
|
||||
|
||||
case ItemScreens.Tabs.Suppliers:
|
||||
@for (var i = 0; i < Record.Suppliers.Count; i++)
|
||||
{
|
||||
var index = i;
|
||||
var s = Record.Suppliers[i];
|
||||
<KhFieldGroup Title="@(PartyOf(s.PartyId)?.Name ?? T["Items.Actions.AddSupplier"])" Icon="truck" Wide="true">
|
||||
<KhHotlink TItem="PartyRow" Label="@T["Items.Fields.Supplier"]" Name="@Key("Suppliers", index, "PartyId")" Span="5" Required="true"
|
||||
Value="PartyOf(s.PartyId)" ValueChanged="v => SetParty(v, id => s.PartyId = id ?? 0)"
|
||||
Search="SearchSuppliersAsync" CodeOf="r => r.Code" DescriptionOf="r => r.Name" OnOpen="OpenSupplier" />
|
||||
<KhTextBox Label="@T["Items.Fields.SupplierCode"]" Name="@Key("Suppliers", index, "SupplierCode")" Value="@s.SupplierCode" ValueChanged="v => Change(() => s.SupplierCode = v)"
|
||||
Mono="true" Span="4" MaxLength="40" />
|
||||
<KhCheck Label="@T["Items.Fields.IsDefault"]" Name="@Key("Suppliers", index, "IsDefault")" Value="s.IsDefault" ValueChanged="v => Change(() => s.IsDefault = v)" Span="3" />
|
||||
<KhNumberBox Label="@T["Items.Fields.Price"]" Name="@Key("Suppliers", index, "Price")" Value="s.Price" ValueChanged="v => Change(() => s.Price = v)" Min="0" Span="3" />
|
||||
<KhNumberBox Label="@T["Items.Fields.LeadTimeDays"]" Name="@Key("Suppliers", index, "LeadTimeDays")" Value="s.LeadTimeDays" ValueChanged="v => Change(() => s.LeadTimeDays = (int?)v)"
|
||||
Min="0" Decimals="0" Span="3" />
|
||||
<KhNumberBox Label="@T["Items.Fields.MinimumQuantity"]" Name="@Key("Suppliers", index, "MinimumQuantity")" Value="s.MinimumQuantity" ValueChanged="v => Change(() => s.MinimumQuantity = v)"
|
||||
Min="0" Decimals="3" Span="3" />
|
||||
@if (!IsReadOnly)
|
||||
{
|
||||
<div class="c3 kh-endrow">
|
||||
<button type="button" class="btn danger" @onclick="() => Remove(Record.Suppliers, index)"><KhIcon Name="trash" /> @T["Items.Actions.Remove"]</button>
|
||||
</div>
|
||||
}
|
||||
</KhFieldGroup>
|
||||
}
|
||||
<DetailFooter Empty="@(Record.Suppliers.Count == 0 ? T["Items.Empty.Suppliers"] : null)" CanAdd="!IsReadOnly" AddText="@T["Items.Actions.AddSupplier"]"
|
||||
OnAdd="() => Add(Record.Suppliers, new ItemSupplier { IsDefault = Record.Suppliers.Count == 0 })" />
|
||||
break;
|
||||
|
||||
case ItemScreens.Tabs.Substitutes:
|
||||
@for (var i = 0; i < Record.Substitutes.Count; i++)
|
||||
{
|
||||
var index = i;
|
||||
var s = Record.Substitutes[i];
|
||||
<KhFieldGroup Title="@(ItemOf(s.SubstituteId)?.Description ?? T["Items.Actions.AddSubstitute"])" Icon="refresh" Wide="true">
|
||||
<KhHotlink TItem="ItemRow" Label="@T["Items.Fields.SubstituteId"]" Name="@Key("Substitutes", index, "SubstituteId")" Span="5" Required="true"
|
||||
Value="ItemOf(s.SubstituteId)" ValueChanged="v => SetItem(v, id => s.SubstituteId = id ?? 0)"
|
||||
Search="SearchItemsAsync" CodeOf="r => r.Code" DescriptionOf="r => r.Description" OnOpen="OpenItem" />
|
||||
<KhTextBox Label="@T["Items.Fields.Notes"]" Name="@Key("Substitutes", index, "Notes")" Value="@s.Notes" ValueChanged="v => Change(() => s.Notes = v)" Span="5" MaxLength="200" />
|
||||
@if (!IsReadOnly)
|
||||
{
|
||||
<div class="c2 kh-endrow">
|
||||
<button type="button" class="btn danger" @onclick="() => Remove(Record.Substitutes, index)"><KhIcon Name="trash" /> @T["Items.Actions.Remove"]</button>
|
||||
</div>
|
||||
}
|
||||
</KhFieldGroup>
|
||||
}
|
||||
<DetailFooter Empty="@(Record.Substitutes.Count == 0 ? T["Items.Empty.Substitutes"] : null)" CanAdd="!IsReadOnly" AddText="@T["Items.Actions.AddSubstitute"]"
|
||||
OnAdd="() => Add(Record.Substitutes, new ItemSubstitute())" />
|
||||
break;
|
||||
|
||||
case ItemScreens.Tabs.Notes:
|
||||
<KhFieldGroup Title="@T["Items.Groups.Notes"]" Icon="edit" Wide="true">
|
||||
<KhTextArea Label="@T["Items.Fields.Notes"]" Name="Notes" Value="@I.Notes" ValueChanged="v => Change(() => I.Notes = v)" Span="12" Rows="6" />
|
||||
</KhFieldGroup>
|
||||
break;
|
||||
}
|
||||
</KhForm>
|
||||
@if (ActiveTab == ItemScreens.Tabs.Notes && !IsNew && Session.Permissions.Allows(AttachmentService.ReadPermission))
|
||||
{
|
||||
<div class="kh-tab-body"><KhAttachmentList Entity="@ItemService.Entity" EntityId="I.Id" OnCountChanged="c => _attachments = c" /></div>
|
||||
}
|
||||
@if (ActiveTab == ItemScreens.Tabs.History)
|
||||
{
|
||||
<div class="kh-tab-body"><KhAuditList Items="_history" FieldName="FieldLabel" /></div>
|
||||
}
|
||||
</ChildContent>
|
||||
</KhRecordLayout>
|
||||
}
|
||||
|
||||
@code {
|
||||
private ItemLookups _lookups = ItemLookups.Empty;
|
||||
private IReadOnlyList<AuditItem> _history = [];
|
||||
private IReadOnlyList<PriceListColumn> _columns = [];
|
||||
private readonly Dictionary<long, PartyRow> _parties = [];
|
||||
private readonly Dictionary<long, ItemRow> _items = [];
|
||||
private PriceGridRow? _today;
|
||||
private int _attachments;
|
||||
private bool _costs;
|
||||
private bool _loaded;
|
||||
private bool _busy;
|
||||
|
||||
/// <summary>The item, absent for a new one.</summary>
|
||||
[Parameter]
|
||||
public long? Id { get; set; }
|
||||
|
||||
private Item I => Record!.Item;
|
||||
|
||||
private bool CanWrite => Session.Permissions.Allows(ItemService.WritePermission);
|
||||
|
||||
private string PageTitle => Record is null ? T["Items.Title"] : IsNew ? T["Items.NewTitle"] : (Record.Item.Code + " · " + Record.Item.Description);
|
||||
|
||||
private PriceListColumn? BaseList => _columns.FirstOrDefault(c => c.IsBase);
|
||||
|
||||
private decimal? BasePrice => BaseList is { } list && _today?.Prices.GetValueOrDefault(list.Id) is { Price: { } price } ? price : I.Price;
|
||||
|
||||
private string BaseLabel => BaseList is { } list ? T["Items.Radar.BasePrice"] + " · " + list.Code : T["Items.Fields.ItemPrice"];
|
||||
|
||||
private decimal? Cost => I.AverageCost ?? I.StandardCost;
|
||||
|
||||
private IReadOnlyList<KhStat>? HeadStats => !_costs || IsNew ? null :
|
||||
[
|
||||
new(T["Items.Fields.AverageCost"], Cost is { } cost ? T.Money(cost) : "-"),
|
||||
new(T["Items.Fields.Margin"], ItemScreens.MarginText(BasePrice, Cost, T.Culture) ?? "-"),
|
||||
];
|
||||
|
||||
private IReadOnlyList<string> HeadLines
|
||||
{
|
||||
get
|
||||
{
|
||||
var lines = new List<string>();
|
||||
if (string.Join(" · ", new[] { I.Brand, I.Manufacturer }.Where(s => !string.IsNullOrWhiteSpace(s)).Distinct()) is { Length: > 0 } brand)
|
||||
{
|
||||
lines.Add(brand);
|
||||
}
|
||||
|
||||
if (I.Barcode is { } barcode)
|
||||
{
|
||||
lines.Add(T["Items.Fields.Barcode"] + " " + barcode);
|
||||
}
|
||||
|
||||
return lines;
|
||||
}
|
||||
}
|
||||
|
||||
private IReadOnlyList<KhOption<string>> KindChoices => ItemScreens.Choices<ItemKind>(T, "Kinds");
|
||||
|
||||
/// <inheritdoc />
|
||||
public override bool IsReadOnly => !CanWrite;
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override bool IsNew => Record is { Item.Id: 0 };
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override bool CanDelete => base.CanDelete && Session.Permissions.Allows(ItemService.DeletePermission);
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override string? NewUrl => CanWrite ? ItemScreens.NewUrl : null;
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override int? AttachmentCount => IsNew || Record is null ? null : _attachments;
|
||||
|
||||
/// <inheritdoc />
|
||||
public override IReadOnlyList<KhTabItem> Tabs => Record is null ? [] :
|
||||
[
|
||||
TabOf(ItemScreens.Tabs.Main, "box", "Main"),
|
||||
TabOf(ItemScreens.Tabs.Units, "layers", "Units", Record.Units.Count),
|
||||
TabOf(ItemScreens.Tabs.Barcodes, "key", "Barcodes", Record.Barcodes.Count),
|
||||
TabOf(ItemScreens.Tabs.Prices, "tag", "Prices", Record.Prices.Count),
|
||||
TabOf(ItemScreens.Tabs.Suppliers, "truck", "Suppliers", Record.Suppliers.Count),
|
||||
TabOf(ItemScreens.Tabs.Substitutes, "refresh", "Substitutes", Record.Substitutes.Count),
|
||||
TabOf(ItemScreens.Tabs.Notes, "paperclip", "Notes", IsNew ? null : _attachments),
|
||||
TabOf(ItemScreens.Tabs.History, "history", "History"),
|
||||
];
|
||||
|
||||
private KhTabItem TabOf(string id, string icon, string text, int? count = null)
|
||||
{
|
||||
// A tab with errors shows how many; otherwise how many details it holds.
|
||||
var errors = Validation.Messages.Count(m => ItemScreens.TabOf(m.Field) == id);
|
||||
return new(id, icon, T["Items.Tabs." + text], errors > 0 ? errors : count is > 0 ? count : null);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override async Task OnParametersSetAsync()
|
||||
{
|
||||
await Session.EnsureLoadedAsync();
|
||||
if (Session.Actor is { } actor && Session.Company?.Code is { } company && Session.Permissions.Allows(ItemService.ReadPermission))
|
||||
{
|
||||
if (!_loaded)
|
||||
{
|
||||
_lookups = await ItemLookups.ForRecordAsync(Tables, actor, company);
|
||||
_costs = await Items.CanSeeCostsAsync(actor, company);
|
||||
}
|
||||
|
||||
if (Record is null || Record.Item.Id != (Id ?? 0))
|
||||
{
|
||||
await ReloadAsync();
|
||||
MarkSaved();
|
||||
}
|
||||
}
|
||||
|
||||
_loaded = true;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override async Task ReloadAsync()
|
||||
{
|
||||
if (Session.Actor is not { } actor || Session.Company?.Code is not { } company)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Validation.Clear();
|
||||
if (Id is { } id)
|
||||
{
|
||||
Record = await Items.GetAsync(actor, company, id);
|
||||
await LoadSideAsync(actor, company);
|
||||
}
|
||||
else
|
||||
{
|
||||
Record = await Items.NewAsync(actor, company);
|
||||
_history = [];
|
||||
_attachments = 0;
|
||||
_today = null;
|
||||
_columns = await PriceLists.ListsAsync(actor, company);
|
||||
}
|
||||
}
|
||||
|
||||
private async Task LoadSideAsync(Actor actor, string company)
|
||||
{
|
||||
if (Record is not { Item.Id: > 0 } record)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
_history = [.. (await Items.HistoryAsync(actor, company, record.Item.Id)).Select(AuditTrailService.Item)];
|
||||
_attachments = Session.Permissions.Allows(AttachmentService.ReadPermission)
|
||||
? await Attachments.CountAsync(actor, company, ItemService.Entity, record.Item.Id)
|
||||
: 0;
|
||||
var grid = await PriceLists.GridAsync(actor, company,
|
||||
new ListQuery { Filters = [ListFilter.Of("code", ListFilterOperator.Equals, record.Item.Code)], Limit = 1 }, Today, null);
|
||||
_columns = grid.Lists;
|
||||
_today = grid.Page.Items.FirstOrDefault(r => r.ItemId == record.Item.Id);
|
||||
|
||||
// The names shown by the links: customers of the net prices, suppliers, substitutes.
|
||||
long[] parties = [.. record.Prices.Where(p => p.PartyId is not null).Select(p => p.PartyId!.Value).Concat(record.Suppliers.Select(s => s.PartyId)).Where(p => !_parties.ContainsKey(p))];
|
||||
if (parties.Length > 0 && Session.Permissions.Allows(PartyService.ReadPermission))
|
||||
{
|
||||
foreach (var row in await Parties.RowsAsync(actor, company, parties))
|
||||
{
|
||||
_parties[row.Id] = row;
|
||||
}
|
||||
}
|
||||
|
||||
long[] items = [.. record.Substitutes.Select(s => s.SubstituteId).Where(i => !_items.ContainsKey(i))];
|
||||
if (items.Length > 0)
|
||||
{
|
||||
foreach (var row in await Items.RowsAsync(actor, company, items))
|
||||
{
|
||||
_items[row.Id] = row;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static DateOnly Today => DateOnly.FromDateTime(DateTime.Today);
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override async Task<bool> SaveCoreAsync()
|
||||
{
|
||||
if (Record is null || Session.Actor is not { } actor || Session.Company?.Code is not { } company || _busy)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
_busy = true;
|
||||
Validation.Clear();
|
||||
try
|
||||
{
|
||||
var wasNew = IsNew;
|
||||
var problems = await Items.ValidateAsync(actor, company, Record);
|
||||
if (problems.Any(p => !p.IsWarning))
|
||||
{
|
||||
Refuse(problems.Where(p => !p.IsWarning).Select(p => ((string?)p.Field, p.Code)));
|
||||
return false;
|
||||
}
|
||||
|
||||
Record = await Items.SaveAsync(actor, company, Record);
|
||||
await LoadSideAsync(actor, company);
|
||||
if (problems.Count > 0)
|
||||
{
|
||||
Toasts.Show(ToastKind.Warning, T.Format("Items.Actions.Warnings", string.Join(" ", problems.Select(p => Message(p.Code)))));
|
||||
}
|
||||
|
||||
if (wasNew)
|
||||
{
|
||||
MarkSaved();
|
||||
Navigation.NavigateTo(ItemScreens.RecordUrl(Record.Item.Id), new NavigationOptions { ReplaceHistoryEntry = true });
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
catch (ValidationFailedException ex)
|
||||
{
|
||||
Refuse(ex.Errors.Select(TableValues.SplitError));
|
||||
return false;
|
||||
}
|
||||
catch (ConcurrencyException)
|
||||
{
|
||||
Toasts.Show(ToastKind.Error, T["CompanyTables.NotSaved"], T["CompanyTables.Concurrency"]);
|
||||
return false;
|
||||
}
|
||||
finally
|
||||
{
|
||||
_busy = false;
|
||||
}
|
||||
}
|
||||
|
||||
private void Refuse(IEnumerable<(string? Field, string Code)> errors)
|
||||
{
|
||||
foreach (var (field, code) in errors)
|
||||
{
|
||||
Validation.Add(field, Message(code));
|
||||
}
|
||||
|
||||
// Show the tab of the first error when the open one has none.
|
||||
if (!Validation.Messages.Any(m => ItemScreens.TabOf(m.Field) == ActiveTab) && Validation.Messages.FirstOrDefault() is { } first)
|
||||
{
|
||||
_ = ShowTabAsync(ItemScreens.TabOf(first.Field));
|
||||
}
|
||||
}
|
||||
|
||||
private string Message(string code) => T.Contains(code) ? T[code] : T["CompanyTables.UnknownError"];
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override async Task DeleteCoreAsync()
|
||||
{
|
||||
if (Record is not { Item.Id: > 0 } record || Session.Actor is not { } actor || Session.Company?.Code is not { } company)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (await Items.DeleteAsync(actor, company, record.Item.Id) == ItemDeleteOutcome.Disabled)
|
||||
{
|
||||
Toasts.Show(ToastKind.Info, T["Items.Actions.DeletedInstead"]);
|
||||
}
|
||||
|
||||
Navigation.NavigateTo(ItemScreens.RadarUrl);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override Task RadarAsync()
|
||||
{
|
||||
Navigation.NavigateTo(ItemScreens.RadarUrl);
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override Task AttachmentsAsync() => ShowTabAsync(ItemScreens.Tabs.Notes);
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override IEnumerable<ToolbarItem> ContextActions()
|
||||
{
|
||||
if (Record is null || IsNew)
|
||||
{
|
||||
yield break;
|
||||
}
|
||||
|
||||
yield return new ToolbarItem("pricelists", "tag", T["Items.Actions.PriceLists"])
|
||||
{
|
||||
Kind = ToolbarKind.Action, OnClick = () =>
|
||||
{
|
||||
Navigation.NavigateTo(ItemScreens.PriceListsUrl);
|
||||
return Task.CompletedTask;
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override IEnumerable<ToolbarItem> MenuCommands()
|
||||
{
|
||||
if (Record is null || IsNew || !CanWrite)
|
||||
{
|
||||
yield break;
|
||||
}
|
||||
|
||||
yield return new ToolbarItem("disable", I.Disabled ? "check-circle" : "x-circle", T[I.Disabled ? "Items.Actions.Enable" : "Items.Actions.Disable"])
|
||||
{
|
||||
Kind = ToolbarKind.Menu, Disabled = IsModified || _busy, OnClick = ToggleDisabledAsync,
|
||||
};
|
||||
}
|
||||
|
||||
private async Task ToggleDisabledAsync()
|
||||
{
|
||||
if (Record is null || Session.Actor is not { } actor || Session.Company?.Code is not { } company)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var disabled = !I.Disabled;
|
||||
await Items.SetDisabledAsync(actor, company, [I.Id], disabled);
|
||||
Toasts.Show(ToastKind.Success, T.Format(disabled ? "Items.Actions.Disabled" : "Items.Actions.Enabled", 1));
|
||||
Record = await Items.GetAsync(actor, company, I.Id) ?? Record;
|
||||
await LoadSideAsync(actor, company);
|
||||
StateHasChanged();
|
||||
}
|
||||
|
||||
private void Change(Action change)
|
||||
{
|
||||
change();
|
||||
MarkModified();
|
||||
}
|
||||
|
||||
private static string Key(string list, int index, string field) => list + "." + index.ToString(System.Globalization.CultureInfo.InvariantCulture) + "." + field;
|
||||
|
||||
private void Add<TDetail>(List<TDetail> list, TDetail detail)
|
||||
{
|
||||
list.Add(detail);
|
||||
MarkModified();
|
||||
}
|
||||
|
||||
private void Remove<TDetail>(List<TDetail> list, int index)
|
||||
{
|
||||
if (index < list.Count)
|
||||
{
|
||||
list.RemoveAt(index);
|
||||
Validation.Clear();
|
||||
MarkModified();
|
||||
}
|
||||
}
|
||||
|
||||
// The positions of the list prices or of the net prices: the errors name a row by its position in Prices.
|
||||
private List<int> PriceRows(bool net) => [.. Enumerable.Range(0, Record!.Prices.Count).Where(i => Record.Prices[i].PartyId is not null == net)];
|
||||
|
||||
private void AddListPrice() => Add(Record!.Prices, new ItemPrice { PriceListId = BaseList?.Id ?? 0, ValidFrom = Today });
|
||||
|
||||
private void AddNetPrice() => Add(Record!.Prices, new ItemPrice { PartyId = 0, ValidFrom = Today });
|
||||
|
||||
private void SetKind(string? value) => Change(() =>
|
||||
{
|
||||
I.Kind = Enum.Parse<ItemKind>(value!);
|
||||
// Only goods go in stock.
|
||||
if (I.Kind != ItemKind.Goods)
|
||||
{
|
||||
I.Stocked = false;
|
||||
}
|
||||
});
|
||||
|
||||
private PartyRow? PartyOf(long? id) => id is { } key && _parties.TryGetValue(key, out var row) ? row : null;
|
||||
|
||||
private ItemRow? ItemOf(long id) => _items.TryGetValue(id, out var row) ? row : null;
|
||||
|
||||
private void SetParty(PartyRow? row, Action<long?> set) => Change(() =>
|
||||
{
|
||||
if (row is not null)
|
||||
{
|
||||
_parties[row.Id] = row;
|
||||
}
|
||||
|
||||
set(row?.Id);
|
||||
});
|
||||
|
||||
private void SetItem(ItemRow? row, Action<long?> set) => Change(() =>
|
||||
{
|
||||
if (row is not null)
|
||||
{
|
||||
_items[row.Id] = row;
|
||||
}
|
||||
|
||||
set(row?.Id);
|
||||
});
|
||||
|
||||
private async Task<IReadOnlyList<PartyRow>> SearchCustomersAsync(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)
|
||||
: [];
|
||||
|
||||
private async Task<IReadOnlyList<PartyRow>> SearchSuppliersAsync(string text, CancellationToken cancellationToken) =>
|
||||
Session.Actor is { } actor && Session.Company?.Code is { } company && Session.Permissions.Allows(PartyService.ReadPermission)
|
||||
? await Parties.SearchAsync(actor, company, PartyArchive.Suppliers, text, cancellationToken)
|
||||
: [];
|
||||
|
||||
private async Task<IReadOnlyList<ItemRow>> SearchItemsAsync(string text, CancellationToken cancellationToken) =>
|
||||
Session.Actor is { } actor && Session.Company?.Code is { } company
|
||||
? [.. (await Items.SearchAsync(actor, company, text, null, cancellationToken)).Where(r => r.Id != I.Id)]
|
||||
: [];
|
||||
|
||||
private void OpenCustomer(PartyRow row) => Navigation.NavigateTo(PartyScreens.RecordUrl(PartyArchive.Customers, row.Id));
|
||||
|
||||
private void OpenSupplier(PartyRow row) => Navigation.NavigateTo(PartyScreens.RecordUrl(PartyArchive.Suppliers, row.Id));
|
||||
|
||||
private void OpenItem(ItemRow row) => Navigation.NavigateTo(ItemScreens.RecordUrl(row.Id));
|
||||
|
||||
private string? FieldLabel(string field)
|
||||
{
|
||||
var key = "Items.Fields." + field.Split('.')[^1];
|
||||
return T.Contains(key) ? T[key] : null;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,151 @@
|
||||
@page "/anagrafiche/articoli"
|
||||
@attribute [Authorize]
|
||||
@using Khaemhat.Application.Items
|
||||
@using Khaemhat.Application.Tables
|
||||
@using Khaemhat.Core.Items
|
||||
@using Khaemhat.Web.Items
|
||||
@using Khaemhat.Web.Parties
|
||||
@inject ShellSession Session
|
||||
@inject ItemService Items
|
||||
@inject TableService Tables
|
||||
@inject ToastService Toasts
|
||||
@inject NavigationManager Navigation
|
||||
|
||||
@* The radar of the items (SPEC §11.2): search on code, description, bar code, brand and producer; filters for kind,
|
||||
category, stock and state; the price of the base list today and, for who may see it, the average cost. Selection to
|
||||
disable or enable; Enter or double click opens the record. Stock arrives with the warehouse (M6). *@
|
||||
<KhPageTitle Text="@T["Items.Title"]" Icon="box" />
|
||||
|
||||
@if (!_loaded)
|
||||
{
|
||||
<p class="muted kh-pad">@T["Common.Loading"]</p>
|
||||
}
|
||||
else if (Session.Company is null)
|
||||
{
|
||||
<div class="kh-message"><KhIcon Name="building" Class="lg" /><h1>@T["Items.NoCompany"]</h1></div>
|
||||
}
|
||||
else if (!Session.Permissions.Allows(ItemService.ReadPermission))
|
||||
{
|
||||
<div class="kh-message">
|
||||
<KhIcon Name="lock" Class="lg" />
|
||||
<h1>@T["Pages.AccessDenied.Title"]</h1>
|
||||
<p class="lead">@T["Pages.AccessDenied.Lead"]</p>
|
||||
</div>
|
||||
}
|
||||
else
|
||||
{
|
||||
<KhRadar TItem="ItemRow" @ref="_radar" Id="items" Columns="Columns" Source="ListAsync" KeyOf="r => r.Id" Selectable="CanWrite" SelectionChanged="SetSelection"
|
||||
OnOpen="Open" QuickFilters="QuickFilters" InitialFilters="InitialFilters" RowClass="RowClassOf" SearchPlaceholder="@T["Items.Radar.Search"]"
|
||||
ExportName="articoli" Label="@T["Items.Title"]">
|
||||
<Toolbar>
|
||||
@if (CanWrite)
|
||||
{
|
||||
<button type="button" class="btn primary" @onclick="New"><KhIcon Name="plus" /> @T["Items.New"]</button>
|
||||
<button type="button" class="btn" disabled="@(_selected.Count == 0 || _busy)" @onclick="() => SetDisabledAsync(true)">
|
||||
<KhIcon Name="x-circle" /> @T["Items.Actions.Disable"]
|
||||
</button>
|
||||
<button type="button" class="btn" disabled="@(_selected.Count == 0 || _busy)" @onclick="() => SetDisabledAsync(false)">
|
||||
<KhIcon Name="check-circle" /> @T["Items.Actions.Enable"]
|
||||
</button>
|
||||
}
|
||||
<a class="btn" href="@ItemScreens.PriceListsUrl"><KhIcon Name="tag" /> @T["Items.Actions.PriceLists"]</a>
|
||||
</Toolbar>
|
||||
</KhRadar>
|
||||
}
|
||||
|
||||
@code {
|
||||
private ItemLookups _lookups = ItemLookups.Empty;
|
||||
private KhRadar<ItemRow>? _radar;
|
||||
private List<long> _selected = [];
|
||||
private bool _costs;
|
||||
private bool _loaded;
|
||||
private bool _busy;
|
||||
|
||||
private bool CanWrite => Session.Permissions.Allows(ItemService.WritePermission);
|
||||
|
||||
private static IReadOnlyList<ListFilter> InitialFilters => [ListFilter.Of("disabled", ListFilterOperator.Equals, "false")];
|
||||
|
||||
private IReadOnlyList<KhColumn<ItemRow>> Columns =>
|
||||
[
|
||||
new("code", T["Items.Fields.Code"], r => r.Code) { Kind = KhColumnKind.Code, Width = "130px" },
|
||||
new("description", T["Items.Fields.Description"], r => r.Description),
|
||||
new("category", T["Items.Radar.Category"], r => PartyScreens.Describe(_lookups.Categories, r.CategoryId)) { Width = "110px" },
|
||||
new("unit", T["Items.Radar.Unit"], r => PartyScreens.Describe(_lookups.Units, r.UnitOfMeasureId)) { Width = "60px" },
|
||||
new("barcode", T["Items.Fields.Barcode"], r => r.Barcode) { Width = "140px", Visible = false },
|
||||
new("brand", T["Items.Fields.Brand"], r => r.Brand) { Width = "130px" },
|
||||
new("kind", T["Items.Radar.Kind"], r => T["Items.Kinds." + r.Kind]) { Width = "100px" },
|
||||
new("averageCost", T["Items.Radar.AverageCost"], r => r.AverageCost) { Kind = KhColumnKind.Money, Width = "110px", Sortable = false, Visible = _costs, Export = _costs },
|
||||
new("basePrice", T["Items.Radar.BasePrice"], r => r.BasePrice) { Kind = KhColumnKind.Money, Width = "110px", Sortable = false },
|
||||
new("state", T["Items.Radar.State"], r => StateOf(r).Text)
|
||||
{
|
||||
Sortable = false, Width = "130px",
|
||||
Template = r => @<KhBadge Tone="StateOf(r).Tone">@StateOf(r).Text</KhBadge>,
|
||||
},
|
||||
];
|
||||
|
||||
private IReadOnlyList<KhQuickFilter> QuickFilters =>
|
||||
[
|
||||
new("kind", T["Items.Radar.Kind"], [new(string.Empty, T["Items.Radar.All"]), .. ItemScreens.Choices<ItemKind>(T, "Kinds")]),
|
||||
new("category", T["Items.Radar.Category"], [new(string.Empty, T["Items.Radar.All"]), .. _lookups.Categories]),
|
||||
new("stocked", T["Items.Radar.Stocked"],
|
||||
[new(string.Empty, T["Items.Radar.All"]), new("true", T["Items.Fields.Stocked"]), new("false", T["Items.States.NotStocked"])]),
|
||||
new("disabled", T["Items.Radar.State"],
|
||||
[new(string.Empty, T["Items.Radar.All"]), new("false", T["Items.Radar.Active"]), new("true", T["Items.Radar.Disabled"])]),
|
||||
];
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override async Task OnParametersSetAsync()
|
||||
{
|
||||
await Session.EnsureLoadedAsync();
|
||||
if (!_loaded && Session.Actor is { } actor && Session.Company?.Code is { } company && Session.Permissions.Allows(ItemService.ReadPermission))
|
||||
{
|
||||
_lookups = await ItemLookups.ForRadarAsync(Tables, actor, company);
|
||||
_costs = await Items.CanSeeCostsAsync(actor, company);
|
||||
}
|
||||
|
||||
_loaded = true;
|
||||
}
|
||||
|
||||
private (string Text, KhTone Tone) StateOf(ItemRow row) => row switch
|
||||
{
|
||||
{ Disabled: true } => (T["Items.States.Disabled"], KhTone.Neutral),
|
||||
{ Stocked: false } => (T["Items.States.NotStocked"], KhTone.Info),
|
||||
_ => (T["Items.States.Active"], KhTone.Ok),
|
||||
};
|
||||
|
||||
private Task<ListPage<ItemRow>> ListAsync(ListQuery query, CancellationToken cancellationToken) =>
|
||||
Session.Actor is { } actor && Session.Company?.Code is { } company
|
||||
? Items.ListAsync(actor, company, query, cancellationToken)
|
||||
: Task.FromResult(new ListPage<ItemRow>([], 0, new Dictionary<string, decimal>()));
|
||||
|
||||
private void SetSelection(IReadOnlyCollection<object> keys) => _selected = [.. keys.OfType<long>()];
|
||||
|
||||
private static string? RowClassOf(ItemRow row) => row.Disabled ? "muted" : null;
|
||||
|
||||
private void Open(ItemRow row) => Navigation.NavigateTo(ItemScreens.RecordUrl(row.Id));
|
||||
|
||||
private void New() => Navigation.NavigateTo(ItemScreens.NewUrl);
|
||||
|
||||
private async Task SetDisabledAsync(bool disabled)
|
||||
{
|
||||
if (Session.Actor is not { } actor || Session.Company?.Code is not { } company || _selected.Count == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
_busy = true;
|
||||
try
|
||||
{
|
||||
var count = await Items.SetDisabledAsync(actor, company, _selected, disabled);
|
||||
Toasts.Show(ToastKind.Success, T.Format(disabled ? "Items.Actions.Disabled" : "Items.Actions.Enabled", count));
|
||||
if (_radar is not null)
|
||||
{
|
||||
await _radar.ReloadAsync();
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
_busy = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,431 @@
|
||||
@page "/anagrafiche/listini"
|
||||
@attribute [Authorize]
|
||||
@using Khaemhat.Application.Items
|
||||
@using Khaemhat.Application.Parties
|
||||
@using Khaemhat.Application.Security
|
||||
@using Khaemhat.Application.Tables
|
||||
@using Khaemhat.Core.Items
|
||||
@using Khaemhat.Web.Items
|
||||
@using Khaemhat.Web.Parties
|
||||
@using Khaemhat.Web.Tables
|
||||
@inject ShellSession Session
|
||||
@inject PriceListService PriceLists
|
||||
@inject ItemService Items
|
||||
@inject PartyService Parties
|
||||
@inject TableService Tables
|
||||
@inject ToastService Toasts
|
||||
@inject DialogService Dialogs
|
||||
@inject NavigationManager Navigation
|
||||
|
||||
@* The price grid (SPEC §11.2, mockup 018): one row per item, one column per active price list with the price in effect
|
||||
at the validity date, the net prices of a customer and the margin. A price is changed in its cell (double click or
|
||||
F2) and a mass update computes many at once: the changed cells stay highlighted until saved, and every saved price
|
||||
starts at the validity date, so older documents keep the price of their day (ADR 0030). *@
|
||||
<KhPageTitle Text="@T["Items.PriceLists.Title"]" Icon="tag" />
|
||||
|
||||
@if (!_loaded)
|
||||
{
|
||||
<p class="muted kh-pad">@T["Common.Loading"]</p>
|
||||
}
|
||||
else if (Session.Company is null)
|
||||
{
|
||||
<div class="kh-message"><KhIcon Name="building" Class="lg" /><h1>@T["Items.NoCompany"]</h1></div>
|
||||
}
|
||||
else if (!Session.Permissions.Allows(ItemService.ReadPermission))
|
||||
{
|
||||
<div class="kh-message">
|
||||
<KhIcon Name="lock" Class="lg" />
|
||||
<h1>@T["Pages.AccessDenied.Title"]</h1>
|
||||
<p class="lead">@T["Pages.AccessDenied.Lead"]</p>
|
||||
</div>
|
||||
}
|
||||
else if (_lists.Count == 0)
|
||||
{
|
||||
<div class="kh-message">
|
||||
<KhIcon Name="tag" Class="lg" />
|
||||
<h1>@T["Items.PriceLists.NoLists"]</h1>
|
||||
<a class="btn" href="tabelle/listini">@T["Items.PriceLists.NewList"]</a>
|
||||
</div>
|
||||
}
|
||||
else
|
||||
{
|
||||
<div class="kh-pricebar">
|
||||
<div class="f">
|
||||
<label for="kh-pl-list">@T["Items.PriceLists.List"]</label>
|
||||
<select id="kh-pl-list" class="in" @onchange="e => _onlyList = PartyScreens.Id(e.Value as string)">
|
||||
<option value="" selected="@(_onlyList is null)">@T["Items.PriceLists.All"]</option>
|
||||
@foreach (var list in _lists)
|
||||
{
|
||||
<option value="@list.Id" selected="@(_onlyList == list.Id)">@list.Code · @list.Description</option>
|
||||
}
|
||||
</select>
|
||||
</div>
|
||||
<div class="kh-pricebar-date">
|
||||
<KhDateBox Label="@T["Items.PriceLists.Validity"]" Name="validity" Value="_date" ValueChanged="SetDateAsync" Span="12" />
|
||||
</div>
|
||||
@if (Session.Permissions.Allows(PartyService.ReadPermission))
|
||||
{
|
||||
<div class="kh-pricebar-party">
|
||||
<KhHotlink TItem="PartyRow" Label="@T["Items.PriceLists.Net"]" Name="party" Span="12" Value="_party" ValueChanged="SetPartyAsync"
|
||||
Search="SearchCustomersAsync" CodeOf="r => r.Code" DescriptionOf="r => r.Name" />
|
||||
</div>
|
||||
}
|
||||
@if (_costs)
|
||||
{
|
||||
<label class="kh-pricebar-check"><input type="checkbox" checked="@_showMargin" @onchange="e => _showMargin = e.Value is true" /> @T["Items.PriceLists.ShowMargin"]</label>
|
||||
}
|
||||
<span class="grow"></span>
|
||||
<KhBadge Tone="KhTone.Info">@(_party is null ? T.Format("Items.PriceLists.Count", _lists.Count) : T.Format("Items.PriceLists.CountNet", _lists.Count))</KhBadge>
|
||||
</div>
|
||||
|
||||
<KhRadar TItem="PriceGridRow" @ref="_radar" Id="pricelists" Columns="Columns" Source="ListAsync" KeyOf="r => r.ItemId" Selectable="CanWrite"
|
||||
SelectionChanged="SetSelection" OnOpen="Open" QuickFilters="QuickFilters" InitialFilters="InitialFilters" RowClass="RowClassOf"
|
||||
SearchPlaceholder="@T["Items.PriceLists.Search"]" ExportName="listini" Label="@T["Items.PriceLists.Title"]" Class="kh-pricegrid">
|
||||
<Toolbar>
|
||||
@if (CanWrite)
|
||||
{
|
||||
<button type="button" class="btn primary" disabled="@(_pending.Count == 0 || _busy)" @onclick="SaveAsync"><KhIcon Name="save" /> @T["Items.PriceLists.Save"]</button>
|
||||
<button type="button" class="btn" disabled="@(_pending.Count == 0 || _busy)" @onclick="UndoAsync"><KhIcon Name="undo" /> @T["Items.PriceLists.Undo"]</button>
|
||||
<button type="button" class="btn" disabled="@_busy" @onclick="OpenBulk"><KhIcon Name="zap" /> @T["Items.PriceLists.Bulk"]</button>
|
||||
}
|
||||
@if (Session.Permissions.Allows(TableService.WritePermission))
|
||||
{
|
||||
<a class="btn" href="tabelle/listini"><KhIcon Name="plus" /> @T["Items.PriceLists.NewList"]</a>
|
||||
}
|
||||
</Toolbar>
|
||||
<Summary>
|
||||
<span class="kh-pricefoot">@T.Format("Items.PriceLists.Footer", _pending.Count, T.Date(_date))</span>
|
||||
</Summary>
|
||||
</KhRadar>
|
||||
|
||||
<div class="callout info kh-pricehint"><KhIcon Name="info" /> <span>@T["Items.PriceLists.Hint"]</span></div>
|
||||
|
||||
<KhDialog Open="_bulkOpen" Title="@T["Items.Bulk.Title"]" Icon="zap" Size="md" OnClose="() => _bulkOpen = false">
|
||||
<ChildContent>
|
||||
<KhForm Validation="_bulkValidation" Layout="KhFormLayout.Grid">
|
||||
<KhSelect TValue="string" Label="@T["Items.Bulk.List"]" Name="PriceListId" Options="ListChoices" Value="@PartyScreens.Text(_bulk.PriceListId)" Span="6" Required="true"
|
||||
ValueChanged="v => _bulk = _bulk with { PriceListId = PartyScreens.Id(v) ?? 0 }" />
|
||||
<KhSelect TValue="string" Label="@T["Items.Bulk.Source"]" Name="SourcePriceListId" Options="ListChoices" Empty="@T["Items.Bulk.SourceSame"]" Span="6"
|
||||
Value="@PartyScreens.Text(_bulk.SourcePriceListId)" ValueChanged="v => _bulk = _bulk with { SourcePriceListId = PartyScreens.Id(v) }" />
|
||||
<KhNumberBox Label="@T["Items.Bulk.Percent"]" Name="Percent" Value="_bulk.Percent" ValueChanged="v => _bulk = _bulk with { Percent = v ?? 0 }" Min="-99" Max="1000" Span="4" />
|
||||
<KhSelect TValue="string" Label="@T["Items.Bulk.Step"]" Name="RoundingStep" Options="StepChoices" Value="@StepText(_bulk.RoundingStep)" Span="4"
|
||||
ValueChanged="SetStep" />
|
||||
<KhSelect TValue="string" Label="@T["Items.Bulk.Direction"]" Name="Direction" Options="DirectionChoices" Value="@_bulk.Direction.ToString()" Span="4"
|
||||
ValueChanged="SetDirection" />
|
||||
<KhSelect TValue="string" Label="@T["Items.Fields.CategoryId"]" Name="CategoryId" Options="_lookups.Categories" Empty="@T["Items.Bulk.ScopeAll"]" Span="6"
|
||||
Value="@PartyScreens.Text(_bulk.CategoryId)" ValueChanged="v => _bulk = _bulk with { CategoryId = PartyScreens.Id(v) }" />
|
||||
<KhDateBox Label="@T["Items.Bulk.Date"]" Name="Date" Value="_bulk.Date" ValueChanged="v => _bulk = _bulk with { Date = v ?? _date }" Span="6" Required="true" />
|
||||
@if (_selected.Count > 0)
|
||||
{
|
||||
<KhCheck Label="@T.Format("Items.Bulk.ScopeSelected", _selected.Count)" Name="Selected" Value="_bulkSelected" ValueChanged="v => _bulkSelected = v" Span="12" />
|
||||
}
|
||||
</KhForm>
|
||||
</ChildContent>
|
||||
<Footer>
|
||||
<button type="button" class="btn" @onclick="() => _bulkOpen = false">@T["Common.Cancel"]</button>
|
||||
<button type="button" class="btn primary" disabled="@_busy" @onclick="ApplyBulkAsync"><KhIcon Name="zap" /> @T["Items.Bulk.Apply"]</button>
|
||||
</Footer>
|
||||
</KhDialog>
|
||||
}
|
||||
|
||||
@code {
|
||||
private readonly Dictionary<Target, Pending> _pending = [];
|
||||
private readonly KhValidation _bulkValidation = new();
|
||||
private IReadOnlyList<PriceListColumn> _lists = [];
|
||||
private ItemLookups _lookups = ItemLookups.Empty;
|
||||
private KhRadar<PriceGridRow>? _radar;
|
||||
private List<long> _selected = [];
|
||||
private PartyRow? _party;
|
||||
private long? _onlyList;
|
||||
private DateOnly _date = DateOnly.FromDateTime(DateTime.Today);
|
||||
private BulkUpdate _bulk = new();
|
||||
private bool _bulkOpen;
|
||||
private bool _bulkSelected;
|
||||
private bool _showMargin = true;
|
||||
private bool _costs;
|
||||
private bool _loaded;
|
||||
private bool _busy;
|
||||
|
||||
/// <summary>A cell of the grid: a list price, or the net price of a customer.</summary>
|
||||
private readonly record struct Target(long ItemId, long? PriceListId, long? PartyId);
|
||||
|
||||
/// <summary>A price changed and not saved: none removes the price of that day.</summary>
|
||||
private readonly record struct Pending(decimal? Price, DateOnly ValidFrom);
|
||||
|
||||
private bool CanWrite => Session.Permissions.Allows(ItemService.WritePermission);
|
||||
|
||||
private static IReadOnlyList<ListFilter> InitialFilters => [ListFilter.Of("disabled", ListFilterOperator.Equals, "false")];
|
||||
|
||||
private PriceListColumn? MarginList => _lists.FirstOrDefault(l => l.Id == _onlyList) ?? _lists.FirstOrDefault(l => l.IsBase) ?? _lists.FirstOrDefault();
|
||||
|
||||
private IReadOnlyList<KhOption<string>> ListChoices => [.. _lists.Select(l => new KhOption<string>(PartyScreens.Text(l.Id)!, l.Code + " · " + l.Description))];
|
||||
|
||||
private IReadOnlyList<KhOption<string>> DirectionChoices => ItemScreens.Choices<RoundingDirection>(T, "Directions");
|
||||
|
||||
private IReadOnlyList<KhOption<string>> StepChoices =>
|
||||
[.. new[] { 0.01m, 0.10m, 0.50m, 1.00m }.Select(s => new KhOption<string>(StepText(s), s.ToString("0.00", T.Culture)))];
|
||||
|
||||
private void SetStep(string? value) =>
|
||||
_bulk = _bulk with { RoundingStep = decimal.TryParse(value, System.Globalization.NumberStyles.Number, System.Globalization.CultureInfo.InvariantCulture, out var step) ? step : 0.01m };
|
||||
|
||||
private void SetDirection(string? value) => _bulk = _bulk with { Direction = Enum.TryParse<RoundingDirection>(value, out var direction) ? direction : RoundingDirection.Nearest };
|
||||
|
||||
private static string StepText(decimal step) => step.ToString("0.00", System.Globalization.CultureInfo.InvariantCulture);
|
||||
|
||||
private IReadOnlyList<KhColumn<PriceGridRow>> Columns
|
||||
{
|
||||
get
|
||||
{
|
||||
var columns = new List<KhColumn<PriceGridRow>>
|
||||
{
|
||||
new("code", T["Items.Fields.Code"], r => r.Code) { Kind = KhColumnKind.Code, Width = "120px" },
|
||||
new("description", T["Items.Fields.Description"], r => r.Description),
|
||||
new("unit", T["Items.Radar.Unit"], r => PartyScreens.Describe(_lookups.Units, r.UnitOfMeasureId)) { Width = "60px" },
|
||||
};
|
||||
if (_costs)
|
||||
{
|
||||
columns.Add(new("averageCost", T["Items.Radar.AverageCost"], r => r.AverageCost) { Kind = KhColumnKind.Money, Width = "110px", Sortable = false });
|
||||
}
|
||||
|
||||
foreach (var list in _lists.Where(l => _onlyList is null || l.Id == _onlyList))
|
||||
{
|
||||
var id = list.Id;
|
||||
columns.Add(new("list-" + PartyScreens.Text(id), list.Code + " " + list.Description, r => PriceOf(r, id))
|
||||
{
|
||||
Kind = KhColumnKind.Money, Width = "120px", Sortable = false,
|
||||
CellClass = r => CellClassOf(r, new Target(r.ItemId, id, null)),
|
||||
Edit = CanWrite ? (r, text) => EditAsync(new Target(r.ItemId, id, null), CurrentOf(r, id), text) : null,
|
||||
});
|
||||
}
|
||||
|
||||
if (_party is { } party)
|
||||
{
|
||||
var partyId = party.Id;
|
||||
columns.Add(new("net", T.Format("Items.PriceLists.NetColumn", party.Name), r => NetOf(r, partyId))
|
||||
{
|
||||
Kind = KhColumnKind.Money, Width = "140px", Sortable = false,
|
||||
CellClass = r => CellClassOf(r, new Target(r.ItemId, null, partyId)),
|
||||
Edit = CanWrite ? (r, text) => EditAsync(new Target(r.ItemId, null, partyId), r.Net?.Price, text) : null,
|
||||
});
|
||||
}
|
||||
|
||||
if (_costs && _showMargin && MarginList is { } marginList)
|
||||
{
|
||||
var id = marginList.Id;
|
||||
columns.Add(new("margin", T.Format("Items.PriceLists.Margin", marginList.Code), r => ItemScreens.MarginText(PriceOf(r, id), r.AverageCost, T.Culture))
|
||||
{
|
||||
Width = "100px", Sortable = false, CellClass = _ => "num",
|
||||
});
|
||||
}
|
||||
|
||||
return columns;
|
||||
}
|
||||
}
|
||||
|
||||
private IReadOnlyList<KhQuickFilter> QuickFilters =>
|
||||
[
|
||||
new("category", T["Items.Radar.Category"], [new(string.Empty, T["Items.Radar.All"]), .. _lookups.Categories]),
|
||||
new("disabled", T["Items.Radar.State"],
|
||||
[new(string.Empty, T["Items.Radar.All"]), new("false", T["Items.Radar.Active"]), new("true", T["Items.Radar.Disabled"])]),
|
||||
];
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override async Task OnParametersSetAsync()
|
||||
{
|
||||
await Session.EnsureLoadedAsync();
|
||||
if (!_loaded && Session.Actor is { } actor && Session.Company?.Code is { } company && Session.Permissions.Allows(ItemService.ReadPermission))
|
||||
{
|
||||
_lookups = await ItemLookups.ForRadarAsync(Tables, actor, company);
|
||||
_lists = await PriceLists.ListsAsync(actor, company);
|
||||
_costs = await Items.CanSeeCostsAsync(actor, company);
|
||||
}
|
||||
|
||||
_loaded = true;
|
||||
}
|
||||
|
||||
private async Task<ListPage<PriceGridRow>> ListAsync(ListQuery query, CancellationToken cancellationToken)
|
||||
{
|
||||
if (Session.Actor is not { } actor || Session.Company?.Code is not { } company)
|
||||
{
|
||||
return new ListPage<PriceGridRow>([], 0, new Dictionary<string, decimal>());
|
||||
}
|
||||
|
||||
var grid = await PriceLists.GridAsync(actor, company, query, _date, _party?.Id, cancellationToken);
|
||||
return grid.Page;
|
||||
}
|
||||
|
||||
private decimal? CurrentOf(PriceGridRow row, long listId) => row.Prices.GetValueOrDefault(listId)?.Price;
|
||||
|
||||
private decimal? PriceOf(PriceGridRow row, long listId) =>
|
||||
_pending.TryGetValue(new Target(row.ItemId, listId, null), out var pending) ? pending.Price : CurrentOf(row, listId);
|
||||
|
||||
private decimal? NetOf(PriceGridRow row, long partyId) =>
|
||||
_pending.TryGetValue(new Target(row.ItemId, null, partyId), out var pending) ? pending.Price : row.Net?.Price;
|
||||
|
||||
private string? CellClassOf(PriceGridRow row, Target target)
|
||||
{
|
||||
if (_pending.ContainsKey(target))
|
||||
{
|
||||
return "kh-changed";
|
||||
}
|
||||
|
||||
return target.PriceListId is { } list && row.Prices.GetValueOrDefault(list) is { Derived: true } ? "kh-derived" : null;
|
||||
}
|
||||
|
||||
private Task<string?> EditAsync(Target target, decimal? current, string text)
|
||||
{
|
||||
if (!ItemScreens.TryParsePrice(text, T.Culture, out var price))
|
||||
{
|
||||
return Task.FromResult<string?>(T["Items.PriceLists.Invalid"]);
|
||||
}
|
||||
|
||||
// Back to the price in effect: nothing to save for this cell.
|
||||
if (price == current)
|
||||
{
|
||||
_pending.Remove(target);
|
||||
}
|
||||
else
|
||||
{
|
||||
_pending[target] = new Pending(price, _date);
|
||||
}
|
||||
|
||||
// The grid calls this as a plain delegate: the page renders again for Save and Undo to follow the count.
|
||||
StateHasChanged();
|
||||
return Task.FromResult<string?>(null);
|
||||
}
|
||||
|
||||
private static string? RowClassOf(PriceGridRow row) => null;
|
||||
|
||||
private void SetSelection(IReadOnlyCollection<object> keys) => _selected = [.. keys.OfType<long>()];
|
||||
|
||||
private void Open(PriceGridRow row) => Navigation.NavigateTo(ItemScreens.RecordUrl(row.ItemId));
|
||||
|
||||
private async Task SetDateAsync(DateOnly? value)
|
||||
{
|
||||
if (_pending.Count > 0)
|
||||
{
|
||||
Toasts.Show(ToastKind.Warning, T["Items.PriceLists.Leave"]);
|
||||
return;
|
||||
}
|
||||
|
||||
_date = value ?? DateOnly.FromDateTime(DateTime.Today);
|
||||
await ReloadAsync();
|
||||
}
|
||||
|
||||
private async Task SetPartyAsync(PartyRow? value)
|
||||
{
|
||||
if (_pending.Keys.Any(k => k.PartyId is not null))
|
||||
{
|
||||
Toasts.Show(ToastKind.Warning, T["Items.PriceLists.Leave"]);
|
||||
return;
|
||||
}
|
||||
|
||||
_party = value;
|
||||
await ReloadAsync();
|
||||
}
|
||||
|
||||
private async Task<IReadOnlyList<PartyRow>> SearchCustomersAsync(string text, CancellationToken cancellationToken) =>
|
||||
Session.Actor is { } actor && Session.Company?.Code is { } company
|
||||
? await Parties.SearchAsync(actor, company, PartyArchive.Customers, text, cancellationToken)
|
||||
: [];
|
||||
|
||||
private async Task ReloadAsync()
|
||||
{
|
||||
StateHasChanged();
|
||||
if (_radar is not null)
|
||||
{
|
||||
await _radar.ReloadAsync();
|
||||
}
|
||||
}
|
||||
|
||||
private async Task SaveAsync()
|
||||
{
|
||||
if (Session.Actor is not { } actor || Session.Company?.Code is not { } company)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (_pending.Count == 0)
|
||||
{
|
||||
Toasts.Show(ToastKind.Info, T["Items.PriceLists.NoChanges"]);
|
||||
return;
|
||||
}
|
||||
|
||||
_busy = true;
|
||||
try
|
||||
{
|
||||
IReadOnlyList<PriceEdit> edits = [.. _pending.Select(p => new PriceEdit(p.Key.ItemId, p.Key.PriceListId, p.Key.PartyId, p.Value.Price, p.Value.ValidFrom))];
|
||||
var written = await PriceLists.SaveAsync(actor, company, edits);
|
||||
_pending.Clear();
|
||||
Toasts.Show(ToastKind.Success, T.Format("Items.PriceLists.Saved", written));
|
||||
await ReloadAsync();
|
||||
}
|
||||
catch (ValidationFailedException ex)
|
||||
{
|
||||
Toasts.Show(ToastKind.Error, T["CompanyTables.NotSaved"],
|
||||
string.Join(" ", ex.Errors.Select(TableValues.SplitError).Select(e => e.Code).Distinct().Select(c => T.Contains(c) ? T[c] : T["CompanyTables.UnknownError"])));
|
||||
}
|
||||
finally
|
||||
{
|
||||
_busy = false;
|
||||
}
|
||||
}
|
||||
|
||||
private async Task UndoAsync()
|
||||
{
|
||||
if (_pending.Count == 0
|
||||
|| !await Dialogs.ConfirmAsync(new(T["Items.PriceLists.UndoTitle"], T["Items.PriceLists.UndoText"], T["Items.PriceLists.Undo"], T["Common.Cancel"], Danger: true)))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
_pending.Clear();
|
||||
await ReloadAsync();
|
||||
}
|
||||
|
||||
private void OpenBulk()
|
||||
{
|
||||
_bulkValidation.Clear();
|
||||
_bulk = new BulkUpdate
|
||||
{
|
||||
PriceListId = _onlyList ?? _lists.FirstOrDefault(l => l.IsBase)?.Id ?? _lists[0].Id, RoundingStep = 0.10m, Direction = RoundingDirection.Nearest, Date = _date,
|
||||
};
|
||||
_bulkSelected = _selected.Count > 0;
|
||||
_bulkOpen = true;
|
||||
}
|
||||
|
||||
private async Task ApplyBulkAsync()
|
||||
{
|
||||
if (Session.Actor is not { } actor || Session.Company?.Code is not { } company)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
_busy = true;
|
||||
try
|
||||
{
|
||||
var update = _bulk with { ItemIds = _bulkSelected && _selected.Count > 0 ? [.. _selected] : null };
|
||||
var edits = await PriceLists.PreviewAsync(actor, company, update);
|
||||
foreach (var edit in edits)
|
||||
{
|
||||
_pending[new Target(edit.ItemId, edit.PriceListId, edit.PartyId)] = new Pending(edit.Price, edit.ValidFrom ?? update.Date);
|
||||
}
|
||||
|
||||
_bulkOpen = false;
|
||||
Toasts.Show(edits.Count == 0 ? ToastKind.Info : ToastKind.Success, edits.Count == 0 ? T["Items.Bulk.None"] : T.Format("Items.Bulk.Result", edits.Count));
|
||||
await ReloadAsync();
|
||||
}
|
||||
catch (ValidationFailedException ex)
|
||||
{
|
||||
_bulkValidation.Clear();
|
||||
foreach (var (field, code) in ex.Errors.Select(TableValues.SplitError))
|
||||
{
|
||||
_bulkValidation.Add(field, T.Contains(code) ? T[code] : T["CompanyTables.UnknownError"]);
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
_busy = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -7,17 +7,21 @@
|
||||
@attribute [Authorize]
|
||||
@inherits MasterDataPage<PartyRecord>
|
||||
@using Khaemhat.Application.Audit
|
||||
@using Khaemhat.Application.Items
|
||||
@using Khaemhat.Application.Parties
|
||||
@using Khaemhat.Application.Security
|
||||
@using Khaemhat.Application.Tables
|
||||
@using Khaemhat.Core.Common
|
||||
@using Khaemhat.Core.Items
|
||||
@using Khaemhat.Core.Parties
|
||||
@using Khaemhat.Fiscal.Abstractions
|
||||
@using Khaemhat.Infrastructure.Http
|
||||
@using Khaemhat.Web.Items
|
||||
@using Khaemhat.Web.Parties
|
||||
@using Khaemhat.Web.Tables
|
||||
@inject ShellSession Session
|
||||
@inject PartyService Parties
|
||||
@inject ItemService Items
|
||||
@inject TableService Tables
|
||||
@inject AutoFillService AutoFill
|
||||
@inject AttachmentService Attachments
|
||||
@@ -388,6 +392,32 @@ else
|
||||
OnAdd="() => Add(Record.BankAccounts, new PartyBankAccount { IsDefault = Record.BankAccounts.Count == 0 })" />
|
||||
break;
|
||||
|
||||
case PartyScreens.Tabs.ItemCodes:
|
||||
<p class="muted kh-pad sm"><KhIcon Name="info" /> @T["Parties.ItemCodesHint"]</p>
|
||||
@for (var i = 0; i < Record.ItemCodes.Count; i++)
|
||||
{
|
||||
var index = i;
|
||||
var c = Record.ItemCodes[i];
|
||||
<KhFieldGroup Title="@(c.Code.Length > 0 ? c.Code : T["Parties.Actions.AddItemCode"])" Icon="box" Wide="true">
|
||||
<KhTextBox Label="@T["Parties.Fields.ItemCode"]" Name="@Key("ItemCodes", index, "Code")" Value="@c.Code" ValueChanged="v => Change(() => c.Code = v ?? string.Empty)"
|
||||
Mono="true" Span="3" Required="true" MaxLength="40" />
|
||||
<KhHotlink TItem="ItemRow" Label="@T["Parties.Fields.ItemId"]" Name="@Key("ItemCodes", index, "ItemId")" Span="4" Required="true"
|
||||
Value="ItemOf(c.ItemId)" ValueChanged="v => SetItem(c, v)" Search="SearchItemsAsync" CodeOf="r => r.Code" DescriptionOf="r => r.Description"
|
||||
OnOpen="OpenItem" />
|
||||
<KhTextBox Label="@T["Parties.Fields.ItemDescription"]" Name="@Key("ItemCodes", index, "Description")" Value="@c.Description" ValueChanged="v => Change(() => c.Description = v)"
|
||||
Span="3" MaxLength="200" />
|
||||
@if (!IsReadOnly)
|
||||
{
|
||||
<div class="c2 kh-endrow">
|
||||
<button type="button" class="btn danger" @onclick="() => Remove(Record.ItemCodes, index)"><KhIcon Name="trash" /> @T["Parties.Actions.Remove"]</button>
|
||||
</div>
|
||||
}
|
||||
</KhFieldGroup>
|
||||
}
|
||||
<DetailFooter Empty="@(Record.ItemCodes.Count == 0 ? T["Parties.Empty.ItemCodes"] : null)" CanAdd="@(!IsReadOnly && CanReadItems)" AddText="@T["Parties.Actions.AddItemCode"]"
|
||||
OnAdd="() => Add(Record.ItemCodes, new PartyItemCode())" />
|
||||
break;
|
||||
|
||||
case PartyScreens.Tabs.Notes:
|
||||
<KhFieldGroup Title="@T["Parties.Groups.Notes"]" Icon="edit" Wide="true">
|
||||
<KhTextArea Label="@T["Parties.Fields.Notes"]" Name="Notes" Value="@P.Notes" ValueChanged="v => Change(() => P.Notes = v)" Span="12" Rows="6" />
|
||||
@@ -412,6 +442,7 @@ else
|
||||
private PartyLookups _lookups = PartyLookups.Empty;
|
||||
private IReadOnlyList<AuditItem> _history = [];
|
||||
private IReadOnlyList<PlaceSuggestion> _places = [];
|
||||
private readonly Dictionary<long, ItemRow> _items = [];
|
||||
private int _attachments;
|
||||
private bool _loaded;
|
||||
private bool _busy;
|
||||
@@ -431,6 +462,8 @@ else
|
||||
|
||||
private bool CanWrite => Session.Permissions.Allows(PartyService.WritePermission);
|
||||
|
||||
private bool CanReadItems => Session.Permissions.Allows(ItemService.ReadPermission);
|
||||
|
||||
private string KindIcon => Record?.Party.Kind switch
|
||||
{
|
||||
PartyKind.Supplier => "truck",
|
||||
@@ -517,6 +550,7 @@ else
|
||||
TabOf(PartyScreens.Tabs.Terms, "coins", "Terms"),
|
||||
TabOf(PartyScreens.Tabs.Fiscal, "file-check", "Fiscal"),
|
||||
TabOf(PartyScreens.Tabs.Banks, "euro", "Banks", Record.BankAccounts.Count),
|
||||
TabOf(PartyScreens.Tabs.ItemCodes, "box", "ItemCodes", Record.ItemCodes.Count),
|
||||
TabOf(PartyScreens.Tabs.Notes, "paperclip", "Notes", IsNew ? null : _attachments),
|
||||
TabOf(PartyScreens.Tabs.History, "history", "History"),
|
||||
];
|
||||
@@ -581,6 +615,15 @@ else
|
||||
}
|
||||
|
||||
_history = [.. (await Parties.HistoryAsync(actor, company, record.Party.Id)).Select(AuditTrailService.Item)];
|
||||
long[] items = [.. record.ItemCodes.Select(c => c.ItemId).Where(i => i > 0 && !_items.ContainsKey(i))];
|
||||
if (items.Length > 0 && CanReadItems)
|
||||
{
|
||||
foreach (var row in await Items.RowsAsync(actor, company, items))
|
||||
{
|
||||
_items[row.Id] = row;
|
||||
}
|
||||
}
|
||||
|
||||
_attachments = Session.Permissions.Allows(AttachmentService.ReadPermission)
|
||||
? await Attachments.CountAsync(actor, company, PartyService.Entity, record.Party.Id)
|
||||
: 0;
|
||||
@@ -807,6 +850,26 @@ else
|
||||
}
|
||||
}
|
||||
|
||||
private ItemRow? ItemOf(long id) => _items.TryGetValue(id, out var row) ? row : null;
|
||||
|
||||
private void SetItem(PartyItemCode code, ItemRow? row) => Change(() =>
|
||||
{
|
||||
if (row is not null)
|
||||
{
|
||||
_items[row.Id] = row;
|
||||
}
|
||||
|
||||
code.ItemId = row?.Id ?? 0;
|
||||
code.Description ??= row?.Description;
|
||||
});
|
||||
|
||||
private async Task<IReadOnlyList<ItemRow>> SearchItemsAsync(string text, CancellationToken cancellationToken) =>
|
||||
Session.Actor is { } actor && Session.Company?.Code is { } company && CanReadItems
|
||||
? await Items.SearchAsync(actor, company, text, null, cancellationToken)
|
||||
: [];
|
||||
|
||||
private void OpenItem(ItemRow row) => Navigation.NavigateTo(ItemScreens.RecordUrl(row.Id));
|
||||
|
||||
private void SetKind(string? value) => Change(() => P.Kind = Enum.Parse<PartyKind>(value!));
|
||||
|
||||
private void SetAddressKind(PartyAddress address, string? value) => Change(() => address.Kind = Enum.Parse<PartyAddressKind>(value!));
|
||||
|
||||
@@ -145,12 +145,15 @@ internal static class KhaemhatServices
|
||||
services.AddSingleton<CodeRuleService>();
|
||||
services.AddSingleton<AutoFillService>();
|
||||
services.AddSingleton<Khaemhat.Application.Parties.PartyService>();
|
||||
services.AddSingleton<Khaemhat.Application.Items.ItemService>();
|
||||
services.AddSingleton<Khaemhat.Application.Items.PriceListService>();
|
||||
services.AddSingleton<ExchangeRateService>();
|
||||
services.AddHttpClient<EcbRatesClient>(c => c.Timeout = TimeSpan.FromSeconds(30));
|
||||
services.AddHttpClient<ViesClient>(c => c.Timeout = TimeSpan.FromSeconds(20));
|
||||
services.AddSingleton<IScheduledJob, EcbRatesJob>();
|
||||
services.AddSingleton<ISeeder, BaseTablesSeeder>();
|
||||
services.AddSingleton<ISeeder, DemoPartiesSeeder>();
|
||||
services.AddSingleton<ISeeder, DemoItemsSeeder>();
|
||||
services.AddSingleton<SeedRunner>();
|
||||
|
||||
// Companies and start.
|
||||
|
||||
@@ -8,10 +8,17 @@ using Khaemhat.Infrastructure.Logging;
|
||||
|
||||
namespace Khaemhat.Web.Hosting;
|
||||
|
||||
/// <summary>What <c>seed</c> was asked to do.</summary>
|
||||
/// <param name="Demo">Add the demo data too, after the base data, to the tables still empty.</param>
|
||||
/// <param name="Scale">How many times the demo catalogues are repeated.</param>
|
||||
/// <param name="Company">The company, or <see langword="null"/> for every active one.</param>
|
||||
public sealed record SeedOptions(bool Demo, int Scale, string? Company);
|
||||
|
||||
/// <summary>
|
||||
/// The command line of <c>scripts/seed.sh</c> (SPEC §4, §14): <c>seed --base [--company CODE]</c> runs the start
|
||||
/// sequence without serving anything (migrations, first company), then adds the missing base data to one company or to
|
||||
/// every active one, and prints what it added. Rows already there are never changed (ADR 0026).
|
||||
/// The command line of <c>scripts/seed.sh</c> (SPEC §4, §14): <c>seed --base|--demo [--scale N] [--company CODE]</c>
|
||||
/// runs the start sequence without serving anything (migrations, first company), then adds the missing base data, and
|
||||
/// with <c>--demo</c> the demo data, to one company or to every active one, and prints what it added. Rows already there
|
||||
/// are never changed (ADR 0026); each demo seeder fills only its tables still empty.
|
||||
/// </summary>
|
||||
public static class SeedCommand
|
||||
{
|
||||
@@ -21,6 +28,9 @@ public static class SeedCommand
|
||||
/// <summary>Exit code of a wrong command line.</summary>
|
||||
public const int UsageError = 64;
|
||||
|
||||
/// <summary>The largest <c>--scale</c>.</summary>
|
||||
public const int MaxScale = 100;
|
||||
|
||||
/// <summary>Whether the arguments ask for this command.</summary>
|
||||
/// <param name="args">The arguments.</param>
|
||||
/// <returns><see langword="true"/> for <c>seed ...</c>.</returns>
|
||||
@@ -28,15 +38,18 @@ public static class SeedCommand
|
||||
|
||||
/// <summary>Reads the options after the verb.</summary>
|
||||
/// <param name="args">The arguments, verb included.</param>
|
||||
/// <param name="company">The company, or <see langword="null"/> for every active one.</param>
|
||||
/// <param name="options">What to do, when the line is valid.</param>
|
||||
/// <param name="error">The problem, or <see langword="null"/>.</param>
|
||||
/// <returns><see langword="true"/> when the line is valid.</returns>
|
||||
public static bool TryParse(string[] args, out string? company, out string? error)
|
||||
public static bool TryParse(string[] args, out SeedOptions? options, out string? error)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(args);
|
||||
company = null;
|
||||
options = null;
|
||||
error = null;
|
||||
var wantsBase = false;
|
||||
var wantsDemo = false;
|
||||
int? scale = null;
|
||||
string? company = null;
|
||||
for (var i = 1; i < args.Length; i++)
|
||||
{
|
||||
switch (args[i])
|
||||
@@ -44,9 +57,13 @@ public static class SeedCommand
|
||||
case "--base":
|
||||
wantsBase = true;
|
||||
break;
|
||||
case "--demo" or "--scale":
|
||||
error = "seed --demo: i dati dimostrativi arrivano con anagrafiche e articoli (M4, issue #41 e #42).";
|
||||
return false;
|
||||
case "--demo":
|
||||
wantsDemo = true;
|
||||
break;
|
||||
case "--scale" when i + 1 < args.Length && int.TryParse(args[i + 1], NumberStyles.None, CultureInfo.InvariantCulture, out var n) && n is >= 1 and <= MaxScale:
|
||||
scale = n;
|
||||
i++;
|
||||
break;
|
||||
case "--company" when i + 1 < args.Length && CompanyCodes.IsValid(CompanyCodes.Normalize(args[i + 1])):
|
||||
company = CompanyCodes.Normalize(args[++i]);
|
||||
break;
|
||||
@@ -56,12 +73,20 @@ public static class SeedCommand
|
||||
}
|
||||
}
|
||||
|
||||
if (!wantsBase)
|
||||
if (!wantsBase && !wantsDemo)
|
||||
{
|
||||
error = "Uso: seed --base [--company CODICE]";
|
||||
error = "Uso: seed --base | --demo [--scale N] [--company CODICE]";
|
||||
return false;
|
||||
}
|
||||
|
||||
return error is null;
|
||||
if (scale is not null && !wantsDemo)
|
||||
{
|
||||
error = "--scale vale solo con --demo.";
|
||||
return false;
|
||||
}
|
||||
|
||||
options = new SeedOptions(wantsDemo, scale ?? 1, company);
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>Runs the command.</summary>
|
||||
@@ -69,7 +94,7 @@ public static class SeedCommand
|
||||
/// <returns>The exit code: 0 done, 1 failed, 64 wrong command line.</returns>
|
||||
public static async Task<int> RunAsync(string[] args)
|
||||
{
|
||||
if (!TryParse(args, out var company, out var error))
|
||||
if (!TryParse(args, out var options, out var error) || options is null)
|
||||
{
|
||||
await Console.Error.WriteLineAsync(error).ConfigureAwait(false);
|
||||
return UsageError;
|
||||
@@ -84,6 +109,7 @@ public static class SeedCommand
|
||||
{
|
||||
await services.GetRequiredService<StartupOrchestrator>().RunAsync().ConfigureAwait(false);
|
||||
var registry = services.GetRequiredService<ICompanyRegistry>();
|
||||
var company = options.Company;
|
||||
IReadOnlyList<string> codes = company is null
|
||||
? [.. (await registry.ListAsync().ConfigureAwait(false)).Where(c => c.Status == CompanyStatus.Active).Select(c => c.Code)]
|
||||
: await registry.FindAsync(company).ConfigureAwait(false) is { } found ? [found.Code] : [];
|
||||
@@ -96,11 +122,13 @@ public static class SeedCommand
|
||||
var runner = services.GetRequiredService<SeedRunner>();
|
||||
foreach (var code in codes)
|
||||
{
|
||||
// The demo data need the base tables: --demo runs the base seeders first.
|
||||
var report = await runner.RunAsync(code, SeedKind.Base).ConfigureAwait(false);
|
||||
Console.WriteLine(string.Create(CultureInfo.InvariantCulture, $"{code}: dati di base {report.DataVersion}, {report.Total} righe aggiunte."));
|
||||
foreach (var (table, count) in report.Added.Where(a => a.Value > 0).OrderBy(a => a.Key, StringComparer.Ordinal))
|
||||
Print(code, "dati di base " + report.DataVersion, report);
|
||||
if (options.Demo)
|
||||
{
|
||||
Console.WriteLine(string.Create(CultureInfo.InvariantCulture, $" {table}: {count}"));
|
||||
Print(code, "dati dimostrativi, scala " + options.Scale.ToString(CultureInfo.InvariantCulture),
|
||||
await runner.RunAsync(code, SeedKind.Demo, options.Scale).ConfigureAwait(false));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -112,4 +140,13 @@ public static class SeedCommand
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void Print(string company, string what, SeedReport report)
|
||||
{
|
||||
Console.WriteLine(string.Create(CultureInfo.InvariantCulture, $"{company}: {what}, {report.Total} righe aggiunte."));
|
||||
foreach (var (table, count) in report.Added.Where(a => a.Value > 0).OrderBy(a => a.Key, StringComparer.Ordinal))
|
||||
{
|
||||
Console.WriteLine(string.Create(CultureInfo.InvariantCulture, $" {table}: {count}"));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
using Khaemhat.Application.Security;
|
||||
using Khaemhat.Application.Tables;
|
||||
using Khaemhat.Core.Tables;
|
||||
using Khaemhat.Web.Tables;
|
||||
using Khaemhat.Web.Ui;
|
||||
|
||||
namespace Khaemhat.Web.Items;
|
||||
|
||||
/// <summary>The company tables an item points to, read once per page as choices (<c>code · description</c>).</summary>
|
||||
public sealed class ItemLookups
|
||||
{
|
||||
/// <summary>Nothing loaded.</summary>
|
||||
public static ItemLookups Empty { get; } = new();
|
||||
|
||||
/// <summary>Item categories, by id.</summary>
|
||||
public IReadOnlyList<KhOption<string>> Categories { get; private init; } = [];
|
||||
|
||||
/// <summary>Units of measure, by id.</summary>
|
||||
public IReadOnlyList<KhOption<string>> Units { get; private init; } = [];
|
||||
|
||||
/// <summary>VAT codes, by id.</summary>
|
||||
public IReadOnlyList<KhOption<string>> TaxCodes { get; private init; } = [];
|
||||
|
||||
/// <summary>Warehouses, by id.</summary>
|
||||
public IReadOnlyList<KhOption<string>> Warehouses { get; private init; } = [];
|
||||
|
||||
/// <summary>Price lists, by id.</summary>
|
||||
public IReadOnlyList<KhOption<string>> PriceLists { get; private init; } = [];
|
||||
|
||||
/// <summary>Reads the choices the radar and the price grid need.</summary>
|
||||
/// <param name="tables">The tables.</param>
|
||||
/// <param name="actor">Who reads.</param>
|
||||
/// <param name="company">The company.</param>
|
||||
/// <param name="cancellationToken">Cancellation.</param>
|
||||
/// <returns>The choices.</returns>
|
||||
public static async Task<ItemLookups> ForRadarAsync(TableService tables, Actor actor, string company, CancellationToken cancellationToken = default) => new()
|
||||
{
|
||||
Categories = await ReadAsync<ItemCategory>(tables, actor, company, cancellationToken).ConfigureAwait(false),
|
||||
Units = await ReadAsync<UnitOfMeasure>(tables, actor, company, cancellationToken).ConfigureAwait(false),
|
||||
};
|
||||
|
||||
/// <summary>Reads every choice of the record page.</summary>
|
||||
/// <param name="tables">The tables.</param>
|
||||
/// <param name="actor">Who reads.</param>
|
||||
/// <param name="company">The company.</param>
|
||||
/// <param name="cancellationToken">Cancellation.</param>
|
||||
/// <returns>The choices.</returns>
|
||||
public static async Task<ItemLookups> ForRecordAsync(TableService tables, Actor actor, string company, CancellationToken cancellationToken = default) => new()
|
||||
{
|
||||
Categories = await ReadAsync<ItemCategory>(tables, actor, company, cancellationToken).ConfigureAwait(false),
|
||||
Units = await ReadAsync<UnitOfMeasure>(tables, actor, company, cancellationToken).ConfigureAwait(false),
|
||||
TaxCodes = await ReadAsync<TaxCode>(tables, actor, company, cancellationToken).ConfigureAwait(false),
|
||||
Warehouses = await ReadAsync<Warehouse>(tables, actor, company, cancellationToken).ConfigureAwait(false),
|
||||
PriceLists = await ReadAsync<PriceList>(tables, actor, company, cancellationToken).ConfigureAwait(false),
|
||||
};
|
||||
|
||||
private static async Task<IReadOnlyList<KhOption<string>>> ReadAsync<T>(TableService tables, Actor actor, string company, CancellationToken cancellationToken)
|
||||
{
|
||||
var choices = await TableValues.LookupAsync(tables, typeof(T), false, actor, company, cancellationToken).ConfigureAwait(false);
|
||||
return [.. choices.Select(c => new KhOption<string>(c.Value, c.Text))];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,120 @@
|
||||
using System.Globalization;
|
||||
using Khaemhat.Application.Localization;
|
||||
using Khaemhat.Core.Items;
|
||||
using Khaemhat.Web.Ui;
|
||||
|
||||
namespace Khaemhat.Web.Items;
|
||||
|
||||
/// <summary>
|
||||
/// Addresses, tabs and choices of the item screens (SPEC §11.2, mockups 017 and 018): the radar
|
||||
/// <c>/anagrafiche/articoli</c>, the record of an item under it, and the price grid <c>/anagrafiche/listini</c>.
|
||||
/// </summary>
|
||||
public static class ItemScreens
|
||||
{
|
||||
/// <summary>The radar of the items.</summary>
|
||||
public const string RadarUrl = "anagrafiche/articoli";
|
||||
|
||||
/// <summary>A new item.</summary>
|
||||
public const string NewUrl = RadarUrl + "/nuovo";
|
||||
|
||||
/// <summary>The price grid.</summary>
|
||||
public const string PriceListsUrl = "anagrafiche/listini";
|
||||
|
||||
/// <summary>The table of the item categories, where <c>/anagrafiche/categorie</c> leads.</summary>
|
||||
public const string CategoriesUrl = "tabelle/categorie-articoli";
|
||||
|
||||
/// <summary>The tab ids of the record page, in order.</summary>
|
||||
public static class Tabs
|
||||
{
|
||||
/// <summary>Main data.</summary>
|
||||
public const string Main = "dati";
|
||||
|
||||
/// <summary>Alternative units.</summary>
|
||||
public const string Units = "um";
|
||||
|
||||
/// <summary>Alternative codes.</summary>
|
||||
public const string Barcodes = "codici";
|
||||
|
||||
/// <summary>Prices of the lists and net prices of the customers.</summary>
|
||||
public const string Prices = "listini";
|
||||
|
||||
/// <summary>Suppliers.</summary>
|
||||
public const string Suppliers = "fornitori";
|
||||
|
||||
/// <summary>Substitutes.</summary>
|
||||
public const string Substitutes = "sostitutivi";
|
||||
|
||||
/// <summary>Notes and attachments.</summary>
|
||||
public const string Notes = "note";
|
||||
|
||||
/// <summary>History.</summary>
|
||||
public const string History = "storico";
|
||||
}
|
||||
|
||||
/// <summary>The record of an item.</summary>
|
||||
/// <param name="id">The item.</param>
|
||||
/// <returns>The address, relative to the base.</returns>
|
||||
public static string RecordUrl(long id) => RadarUrl + "/" + id.ToString(CultureInfo.InvariantCulture);
|
||||
|
||||
/// <summary>The tab that holds a field of the service (<c>Prices.0.Price</c>, <c>Suppliers.1.PartyId</c>).</summary>
|
||||
/// <param name="field">The field.</param>
|
||||
/// <returns>The tab id.</returns>
|
||||
public static string TabOf(string? field)
|
||||
{
|
||||
var head = (field ?? string.Empty).Split('.')[0];
|
||||
return head switch
|
||||
{
|
||||
"Units" => Tabs.Units,
|
||||
"Barcodes" => Tabs.Barcodes,
|
||||
"Prices" => Tabs.Prices,
|
||||
"Suppliers" => Tabs.Suppliers,
|
||||
"Substitutes" => Tabs.Substitutes,
|
||||
nameof(Item.Notes) => Tabs.Notes,
|
||||
_ => Tabs.Main,
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>The choices of an enum, with the texts <c>Items.<group>.<value></c>.</summary>
|
||||
/// <typeparam name="TEnum">The enum.</typeparam>
|
||||
/// <param name="texts">The texts.</param>
|
||||
/// <param name="group">The group of texts.</param>
|
||||
/// <returns>The choices.</returns>
|
||||
public static IReadOnlyList<KhOption<string>> Choices<TEnum>(ITexts texts, string group)
|
||||
where TEnum : struct, Enum
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(texts);
|
||||
return [.. Enum.GetValues<TEnum>().Select(v => new KhOption<string>(v.ToString(), texts["Items." + group + "." + v]))];
|
||||
}
|
||||
|
||||
/// <summary>The margin on the price as text, such as <c>45%</c>; none without both values.</summary>
|
||||
/// <param name="price">The price.</param>
|
||||
/// <param name="cost">The cost.</param>
|
||||
/// <param name="culture">The culture of the texts.</param>
|
||||
/// <returns>The text.</returns>
|
||||
public static string? MarginText(decimal? price, decimal? cost, CultureInfo culture) =>
|
||||
PriceRounding.Margin(price, cost) is { } margin ? margin.ToString("0.#", culture) + "%" : null;
|
||||
|
||||
/// <summary>Reads a price typed in a cell: empty means no price, otherwise a number not below zero.</summary>
|
||||
/// <param name="text">The text typed.</param>
|
||||
/// <param name="culture">The culture of the texts.</param>
|
||||
/// <param name="price">The price, or <see langword="null"/> for none.</param>
|
||||
/// <returns>Whether the text is valid.</returns>
|
||||
public static bool TryParsePrice(string? text, CultureInfo culture, out decimal? price)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(culture);
|
||||
price = null;
|
||||
var clean = (text ?? string.Empty).Replace("€", string.Empty, StringComparison.Ordinal).Trim();
|
||||
if (clean.Length == 0)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!decimal.TryParse(clean, NumberStyles.Number, culture, out var value) || value < 0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
price = Math.Round(value, 4, MidpointRounding.AwayFromZero);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -36,6 +36,9 @@ public static class PartyScreens
|
||||
/// <summary>Bank accounts.</summary>
|
||||
public const string Banks = "banche";
|
||||
|
||||
/// <summary>The codes the party uses for our items.</summary>
|
||||
public const string ItemCodes = "articoli";
|
||||
|
||||
/// <summary>Notes and attachments.</summary>
|
||||
public const string Notes = "note";
|
||||
|
||||
@@ -124,6 +127,7 @@ public static class PartyScreens
|
||||
"Addresses" => Tabs.Addresses,
|
||||
"Contacts" => Tabs.Contacts,
|
||||
"BankAccounts" => Tabs.Banks,
|
||||
"ItemCodes" => Tabs.ItemCodes,
|
||||
"Sales" or "Purchase" => Tabs.Terms,
|
||||
"Fiscal" => Tabs.Fiscal,
|
||||
nameof(Party.Notes) => Tabs.Notes,
|
||||
|
||||
@@ -0,0 +1,234 @@
|
||||
{
|
||||
"Items": {
|
||||
"Title": "Articoli",
|
||||
"NoCompany": "Scegli un'azienda per vedere gli articoli.",
|
||||
"NotFound": "Articolo non trovato",
|
||||
"CodeAuto": "Automatico",
|
||||
"NewTitle": "Nuovo articolo",
|
||||
"New": "Nuovo articolo",
|
||||
"Radar": {
|
||||
"Search": "Cerca per codice, descrizione, codice a barre, marca",
|
||||
"All": "Tutti",
|
||||
"Active": "Attivi",
|
||||
"Disabled": "Disattivati",
|
||||
"Kind": "Tipo",
|
||||
"Category": "Categoria",
|
||||
"Unit": "UM",
|
||||
"BasePrice": "Prezzo base",
|
||||
"AverageCost": "Costo medio",
|
||||
"Stocked": "Magazzino",
|
||||
"State": "Stato"
|
||||
},
|
||||
"States": {
|
||||
"Active": "Attivo",
|
||||
"Disabled": "Disattivato",
|
||||
"Demo": "Esempio",
|
||||
"NotStocked": "Non a magazzino"
|
||||
},
|
||||
"Kinds": {
|
||||
"Goods": "Merce",
|
||||
"Service": "Servizio",
|
||||
"Expense": "Spesa",
|
||||
"Text": "Descrittivo",
|
||||
"Asset": "Cespite"
|
||||
},
|
||||
"Directions": {
|
||||
"Nearest": "Al più vicino",
|
||||
"Up": "Per eccesso",
|
||||
"Down": "Per difetto"
|
||||
},
|
||||
"Tabs": {
|
||||
"Main": "Dati principali",
|
||||
"Units": "UM alternative",
|
||||
"Barcodes": "Codici alternativi",
|
||||
"Prices": "Listini",
|
||||
"Suppliers": "Fornitori",
|
||||
"Substitutes": "Sostitutivi",
|
||||
"Notes": "Note e allegati",
|
||||
"History": "Storico"
|
||||
},
|
||||
"Groups": {
|
||||
"Identity": "Identità",
|
||||
"Codes": "Unità, codici e IVA",
|
||||
"Prices": "Prezzi e costi",
|
||||
"Stock": "Magazzino e riordino",
|
||||
"Accounts": "Contabilità",
|
||||
"Today": "Prezzi in vigore oggi",
|
||||
"ListPrices": "Prezzi di listino",
|
||||
"NetPrices": "Prezzi netti dei clienti",
|
||||
"Notes": "Note"
|
||||
},
|
||||
"Fields": {
|
||||
"Code": "Codice",
|
||||
"Kind": "Tipo",
|
||||
"Description": "Descrizione",
|
||||
"ExtendedDescription": "Descrizione estesa",
|
||||
"CategoryId": "Categoria",
|
||||
"UnitOfMeasureId": "Unità di misura",
|
||||
"SalesTaxCodeId": "IVA vendite",
|
||||
"PurchaseTaxCodeId": "IVA acquisti",
|
||||
"Barcode": "Codice a barre",
|
||||
"CustomsCode": "Nomenclatura combinata",
|
||||
"Manufacturer": "Produttore",
|
||||
"Brand": "Marca",
|
||||
"NetWeight": "Peso netto (kg)",
|
||||
"GrossWeight": "Peso lordo (kg)",
|
||||
"Stocked": "Gestito a magazzino",
|
||||
"WarehouseId": "Deposito preferito",
|
||||
"MinimumStock": "Scorta minima",
|
||||
"ReorderPoint": "Punto di riordino",
|
||||
"ReorderLot": "Lotto di riordino",
|
||||
"Price": "Prezzo",
|
||||
"ItemPrice": "Prezzo dell'articolo",
|
||||
"StandardCost": "Costo standard",
|
||||
"LastCost": "Ultimo costo",
|
||||
"AverageCost": "Costo medio",
|
||||
"Margin": "Margine",
|
||||
"RevenueAccountCode": "Conto ricavi",
|
||||
"CostAccountCode": "Conto costi",
|
||||
"Notes": "Note",
|
||||
"Disabled": "Disattivato",
|
||||
"Factor": "Fattore di conversione",
|
||||
"PriceListId": "Listino",
|
||||
"PartyId": "Cliente",
|
||||
"ValidFrom": "Valido dal",
|
||||
"SupplierCode": "Codice del fornitore",
|
||||
"Supplier": "Fornitore",
|
||||
"LeadTimeDays": "Giorni di consegna",
|
||||
"MinimumQuantity": "Quantità minima",
|
||||
"IsDefault": "Preferito",
|
||||
"SubstituteId": "Articolo sostitutivo",
|
||||
"ItemId": "Articolo",
|
||||
"Source": "Origine"
|
||||
},
|
||||
"Hints": {
|
||||
"Costs": "Ultimo costo e costo medio arrivano dai carichi di magazzino, con gli acquisti (M6).",
|
||||
"CostsHidden": "I costi sono visibili solo a chi ha il permesso di vederli.",
|
||||
"Stock": "Giacenze, impegni e movimenti per deposito arrivano con il magazzino (M6).",
|
||||
"NotStocked": "Servizi, spese, righe descrittive e cespiti non vanno a magazzino.",
|
||||
"ItemPrice": "Vale solo quando nessun listino ha un prezzo per l'articolo.",
|
||||
"Prices": "Ogni prezzo vale dalla sua data fino al prezzo successivo dello stesso listino o cliente: i documenti già fatti conservano il prezzo di allora.",
|
||||
"Derived": "Calcolato dal listino di partenza con ricarico e arrotondamento",
|
||||
"Units": "Il fattore dice quante unità base vale una unità alternativa: una scatola da 10 pezzi ha fattore 10.",
|
||||
"Barcodes": "Codici a barre dei produttori e codici dei vecchi gestionali: la ricerca li trova esattamente."
|
||||
},
|
||||
"Empty": {
|
||||
"Units": "Nessuna unità alternativa.",
|
||||
"Barcodes": "Nessun codice alternativo.",
|
||||
"ListPrices": "Nessun prezzo di listino scritto: valgono i listini derivati e il prezzo dell'articolo.",
|
||||
"NetPrices": "Nessun prezzo netto per un cliente.",
|
||||
"Suppliers": "Nessun fornitore abituale.",
|
||||
"Substitutes": "Nessun articolo sostitutivo."
|
||||
},
|
||||
"Actions": {
|
||||
"Disable": "Disattiva",
|
||||
"Enable": "Riattiva",
|
||||
"Disabled": "{0} articoli disattivati",
|
||||
"Enabled": "{0} articoli riattivati",
|
||||
"DeletedInstead": "Articolo usato da altri dati: è stato disattivato invece che eliminato.",
|
||||
"Remove": "Rimuovi",
|
||||
"AddUnit": "Aggiungi unità",
|
||||
"AddBarcode": "Aggiungi codice",
|
||||
"AddPrice": "Aggiungi prezzo di listino",
|
||||
"AddNetPrice": "Aggiungi prezzo netto",
|
||||
"AddSupplier": "Aggiungi fornitore",
|
||||
"AddSubstitute": "Aggiungi sostitutivo",
|
||||
"PriceLists": "Listini",
|
||||
"Warnings": "Salvato con avvisi: {0}"
|
||||
},
|
||||
"PriceLists": {
|
||||
"Title": "Listini",
|
||||
"Search": "Cerca articolo",
|
||||
"List": "Listino",
|
||||
"All": "Tutti",
|
||||
"Validity": "Validità",
|
||||
"Net": "Prezzi netti di",
|
||||
"NetColumn": "{0} (netto)",
|
||||
"ShowMargin": "Mostra margine",
|
||||
"Margin": "Margine {0}",
|
||||
"Count": "{0} listini",
|
||||
"CountNet": "{0} listini + prezzi netti cliente",
|
||||
"Footer": "Modifiche non salvate: {0} · validità nuovi prezzi dal {1}",
|
||||
"Hint": "Aggiornamento massivo: scegli listino, categoria o selezione, variazione % (anche negativa) o da altro listino, arrotondamento (0,10 / 0,50 / 1,00, per eccesso o per difetto) e data di validità; le righe aggiornate restano evidenziate finché non salvi.",
|
||||
"Save": "Salva",
|
||||
"Undo": "Annulla modifiche",
|
||||
"UndoTitle": "Annullare le modifiche?",
|
||||
"UndoText": "I prezzi cambiati e non salvati tornano come prima.",
|
||||
"Bulk": "Aggiornamento massivo",
|
||||
"NewList": "Nuovo listino",
|
||||
"Saved": "{0} prezzi salvati",
|
||||
"NoChanges": "Nessuna modifica da salvare.",
|
||||
"Invalid": "Prezzo non valido: scrivi un numero non negativo, o lascia vuoto per togliere il prezzo.",
|
||||
"Derived": "Calcolato da {0}",
|
||||
"Pending": "Da salvare",
|
||||
"Leave": "Ci sono prezzi non salvati: salvali o annulla le modifiche prima di cambiare validità o cliente.",
|
||||
"NoLists": "Nessun listino attivo: creane uno nelle tabelle dell'azienda."
|
||||
},
|
||||
"Bulk": {
|
||||
"Title": "Aggiornamento massivo",
|
||||
"List": "Listino da aggiornare",
|
||||
"Source": "Calcola da",
|
||||
"SourceSame": "Prezzi attuali dello stesso listino",
|
||||
"Percent": "Variazione %",
|
||||
"Step": "Arrotondamento",
|
||||
"Direction": "Verso",
|
||||
"Date": "Valido dal",
|
||||
"Scope": "Articoli",
|
||||
"ScopeCategory": "Tutti quelli della categoria scelta",
|
||||
"ScopeAll": "Tutti gli articoli",
|
||||
"ScopeSelected": "Solo i selezionati ({0})",
|
||||
"Apply": "Calcola i prezzi",
|
||||
"Result": "{0} prezzi calcolati: restano evidenziati finché non salvi.",
|
||||
"None": "Nessun prezzo da cambiare."
|
||||
}
|
||||
},
|
||||
"items": {
|
||||
"description": {
|
||||
"required": "La descrizione è obbligatoria."
|
||||
},
|
||||
"code": {
|
||||
"duplicate": "Codice già usato da un altro articolo."
|
||||
},
|
||||
"category": {
|
||||
"required": "Il codice usa la categoria: scegline una."
|
||||
},
|
||||
"barcode": {
|
||||
"invalid": "Codice a barre EAN non valido: controlla le cifre e il carattere di controllo.",
|
||||
"duplicate": "Un altro articolo ha lo stesso codice a barre."
|
||||
},
|
||||
"customs-code": {
|
||||
"invalid": "La nomenclatura combinata ha 8 cifre."
|
||||
},
|
||||
"value": {
|
||||
"negative": "Il valore non può essere negativo."
|
||||
},
|
||||
"factor": {
|
||||
"invalid": "Il fattore di conversione deve essere maggiore di zero."
|
||||
},
|
||||
"unit": {
|
||||
"duplicate": "Unità già presente, o uguale all'unità base."
|
||||
},
|
||||
"detail": {
|
||||
"required": "Campo obbligatorio.",
|
||||
"duplicate": "Già presente nell'elenco."
|
||||
},
|
||||
"supplier": {
|
||||
"invalid": "Scegli un fornitore."
|
||||
},
|
||||
"substitute": {
|
||||
"self": "Un articolo non può sostituire sé stesso."
|
||||
},
|
||||
"price": {
|
||||
"target": "Un prezzo va su un listino oppure su un cliente.",
|
||||
"party": "I prezzi netti vanno su un cliente.",
|
||||
"duplicate": "Esiste già un prezzo per lo stesso listino o cliente e la stessa data."
|
||||
},
|
||||
"party-code": {
|
||||
"duplicate": "Codice già usato per un altro articolo di questa anagrafica."
|
||||
},
|
||||
"not-found": "Articolo non trovato.",
|
||||
"price-list": {
|
||||
"unknown": "Listino non trovato."
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -61,7 +61,8 @@
|
||||
"TaxCodeDone": "Codice fiscale calcolato",
|
||||
"TaxCodeMissing": "Servono cognome, nome, data, sesso e comune di nascita.",
|
||||
"Places": "{0} comuni con questo CAP: scegli quello giusto.",
|
||||
"Warnings": "Salvato con avvisi: {0}"
|
||||
"Warnings": "Salvato con avvisi: {0}",
|
||||
"AddItemCode": "Aggiungi codice articolo"
|
||||
},
|
||||
"Vies": {
|
||||
"Valid": "Partita IVA valida nel VIES",
|
||||
@@ -78,6 +79,7 @@
|
||||
"Terms": "Condizioni",
|
||||
"Fiscal": "Fiscale e SDI",
|
||||
"Banks": "Banche",
|
||||
"ItemCodes": "Articoli e codici",
|
||||
"Notes": "Note e allegati",
|
||||
"History": "Storico"
|
||||
},
|
||||
@@ -198,7 +200,10 @@
|
||||
"BranchCode": "CAB",
|
||||
"BirthDate": "Data di nascita",
|
||||
"Sex": "Sesso",
|
||||
"BirthPlace": "Comune di nascita (codice catastale)"
|
||||
"BirthPlace": "Comune di nascita (codice catastale)",
|
||||
"ItemCode": "Codice dell'anagrafica",
|
||||
"ItemId": "Nostro articolo",
|
||||
"ItemDescription": "Descrizione dell'anagrafica"
|
||||
},
|
||||
"Kinds": {
|
||||
"Customer": "Cliente",
|
||||
@@ -237,12 +242,14 @@
|
||||
"Empty": {
|
||||
"Addresses": "Nessun altro indirizzo: la sede legale è nei dati principali.",
|
||||
"Contacts": "Nessun contatto.",
|
||||
"Banks": "Nessun conto corrente."
|
||||
"Banks": "Nessun conto corrente.",
|
||||
"ItemCodes": "Nessun codice articolo di questa anagrafica."
|
||||
},
|
||||
"TermsHint": "Le condizioni si propongono nei documenti; nel documento si possono cambiare.",
|
||||
"NoTerms": "Un prospect o un lead non ha condizioni: si impostano quando diventa cliente.",
|
||||
"IntentHint": "Il residuo scende con le fatture emesse in esenzione (arriva con la fatturazione, M5).",
|
||||
"AccountsHint": "I sottoconti del partitario si creano alla prima registrazione (M7)."
|
||||
"AccountsHint": "I sottoconti del partitario si creano alla prima registrazione (M7).",
|
||||
"ItemCodesHint": "I codici con cui il cliente o il fornitore chiama i nostri articoli: nei suoi documenti la ricerca dell'articolo li trova."
|
||||
},
|
||||
"parties": {
|
||||
"name": {
|
||||
|
||||
@@ -269,7 +269,8 @@
|
||||
"GapsAllowed": "Ammessi buchi di numerazione",
|
||||
"CurrencyCode": "Valuta",
|
||||
"VatIncluded": "IVA inclusa",
|
||||
"BasePriceListId": "Listino base",
|
||||
"IsBase": "Listino base",
|
||||
"BasePriceListId": "Derivato da",
|
||||
"MarkupPercent": "% ricarico",
|
||||
"RoundingStep": "Arrotondamento",
|
||||
"Formula": "Formula",
|
||||
@@ -451,6 +452,9 @@
|
||||
"number": {
|
||||
"range": "Numero fuori intervallo."
|
||||
},
|
||||
"price-list": {
|
||||
"base-duplicate": "Un altro listino è già il listino base: toglilo da quello prima."
|
||||
},
|
||||
"inventory-reason": {
|
||||
"transfer": "Un trasferimento non ha effetto di carico o scarico."
|
||||
},
|
||||
|
||||
@@ -220,7 +220,8 @@ public static class TableScreens
|
||||
Fields =
|
||||
[
|
||||
new(nameof(PriceList.CurrencyCode), TableFieldKind.Lookup) { Lookup = typeof(Currency), ByCode = true, Required = true, InGrid = true, Width = "80px", Span = 4 },
|
||||
new(nameof(PriceList.VatIncluded), TableFieldKind.Bool) { InGrid = true, Width = "90px", Span = 8 },
|
||||
new(nameof(PriceList.VatIncluded), TableFieldKind.Bool) { InGrid = true, Width = "90px", Span = 4 },
|
||||
new(nameof(PriceList.IsBase), TableFieldKind.Bool) { InGrid = true, Width = "90px", Span = 4 },
|
||||
new(nameof(PriceList.ValidFrom), TableFieldKind.Date),
|
||||
new(nameof(PriceList.ValidTo), TableFieldKind.Date),
|
||||
new(nameof(PriceList.BasePriceListId), TableFieldKind.Lookup) { Lookup = typeof(PriceList) },
|
||||
|
||||
@@ -316,3 +316,19 @@ h1[tabindex="-1"]:focus { outline: none; box-shadow: none; }
|
||||
.kh-sheet, .kh-sheet * { visibility: visible; }
|
||||
.kh-sheet { position: absolute; left: 0; top: 0; zoom: 1 !important; width: 210mm; min-height: 0; box-shadow: none; margin: 0; }
|
||||
}
|
||||
|
||||
/* Price grid (mockup 018): filter bar, cells changed and not saved, prices derived from another list. */
|
||||
.kh-pricebar { display: flex; align-items: flex-end; gap: 12px; flex-wrap: wrap; margin-bottom: 10px; }
|
||||
.kh-pricebar .grow { flex: 1; }
|
||||
.kh-pricebar > .f { min-width: 200px; }
|
||||
.kh-pricebar-date { width: 160px; }
|
||||
.kh-pricebar-party { width: 340px; max-width: 100%; }
|
||||
.kh-pricebar-check { display: flex; gap: 6px; align-items: center; height: 30px; font-size: 12.5px; }
|
||||
/* The filter bar and the hint take room: the grid is shorter than in the other radars and the radar does not shrink under the hint. */
|
||||
.kh-radar.kh-pricegrid { flex: none; }
|
||||
.kh-pricegrid .kh-radarpanel .kh-gridwrap { height: calc(100vh - 470px); min-height: 240px; }
|
||||
.kh-pricehint { margin-top: 10px; }
|
||||
.kh-pricefoot { margin-left: 14px; }
|
||||
/* Stronger than the striped and hovered rows, so every pending cell shows. */
|
||||
.grid tbody tr td.kh-changed { background: var(--kh-warn-soft); font-weight: 600; }
|
||||
.grid td.kh-derived { color: var(--kh-text-2); font-style: italic; }
|
||||
Reference in new issue
Block a user