Quotations, orders, delivery notes, invoices and credit notes get their radars and one document screen (lines, header, transport, links, attachments) with the transformations of the engine, so a quotation reaches the invoice without retyping. The deferred invoicing groups the open delivery notes of a period by customer, payment and destination into one invoice each. Every document prints from one model: an HTML preview on screen and a PDF drawn by the in-house writer, kept among the attachments as a new version. "Invia per e-mail" proposes recipient, subject and text from the templates, attaches the PDF and hands it to a background queue that talks SMTP itself (no external library); the outcome goes to the log, section E-mail/PEC. The demo company now has a year of sales in every state, made through the engine, and run-dev.sh no longer writes to a stray B:\b folder under Git Bash. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
410 lines
30 KiB
Plaintext
410 lines
30 KiB
Plaintext
@page "/vendite/{Segment}/nuovo"
|
|
@page "/vendite/{Segment}/{Id:long}"
|
|
@attribute [Authorize]
|
|
@inherits DocumentPage<DocumentRecord, DocumentLine>
|
|
@using Khaemhat.Application.Audit
|
|
@using Khaemhat.Application.Documents
|
|
@using Khaemhat.Application.Items
|
|
@using Khaemhat.Application.Parties
|
|
@using Khaemhat.Core.Documents
|
|
@using Khaemhat.Core.Tax
|
|
@using Khaemhat.Web.Documents
|
|
@using Khaemhat.Web.Parties
|
|
|
|
@* The record of a sales document (SPEC §11.3, mockups 020-022 and 026-029): quotation, order, delivery note, invoice of
|
|
every kind, pro forma, credit and debit note. Righe first with the VAT summary, due dates and totals underneath, then
|
|
Testata, Trasporto for the documents that move goods, Totali, Scadenze, Note, Allegati, Collegamenti, Storico. The
|
|
totals are computed while typing with the code of the save; the actions follow the state machine of the engine. *@
|
|
<KhPageTitle Text="@PageTitle" Icon="@(_section?.Icon ?? "file")" />
|
|
|
|
@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["Sales.NoCompany"]</h1></div>
|
|
}
|
|
else if (_denied)
|
|
{
|
|
<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 || _section is null || _definition is null)
|
|
{
|
|
<div class="kh-message">
|
|
<KhIcon Name="alert" Class="lg" />
|
|
<h1>@T["Sales.NotFound"]</h1>
|
|
<a class="btn" href="@(_section is null ? SalesScreens.BasePath : SalesScreens.RadarUrl(_section))">@T["Sales.BackToList"]</a>
|
|
</div>
|
|
}
|
|
else
|
|
{
|
|
var h = Record.Header;
|
|
<KhRecordLayout Page="this">
|
|
<Heading>
|
|
<KhDocHead KindIcon="@_section.Icon" KindLabel="@_definition.Type.Description" Number="@(h.DocumentNumber ?? T["Sales.DraftNumber"])"
|
|
PartyName="@(_party?.Name ?? T["Sales.NoParty"])" PartyCode="@_party?.Code" PartyLines="PartyLines"
|
|
TotalLabel="@T[ShowsNet ? "Sales.Totals.Net" : "Sales.Totals.Total"]" TotalValue="@T.Money(ShowsNet ? h.NetAmount : h.TotalAmount)" SubValues="HeadStats">
|
|
<Facts>
|
|
<span>@T["Sales.Fields.DocumentDate"] <b>@T.Date(h.DocumentDate)</b></span>
|
|
@if (h.Kind == DocumentKind.Quotation && h.ValidUntil is { } until)
|
|
{
|
|
<span>@T["Sales.Fields.ValidUntil"] <b>@T.Date(until)</b></span>
|
|
}
|
|
@if (h.DeliveryDate is { } delivery)
|
|
{
|
|
<span>@T["Sales.Fields.DeliveryDate"] <b>@T.Date(delivery)</b></span>
|
|
}
|
|
@if (h.Revision > 0)
|
|
{
|
|
<span>@T["Sales.Fields.Revision"] <b>@h.Revision</b></span>
|
|
}
|
|
@if (h.RelatedNumber is { } related)
|
|
{
|
|
<span>@T["Sales.Fields.Related"] <b>@related</b>@(h.RelatedDate is { } rd ? " · " + T.Date(rd) : null)</span>
|
|
}
|
|
</Facts>
|
|
<State>
|
|
@{ var state = SalesScreens.State(T, h.Kind, h.Status, h.ValidUntil, Today); }
|
|
<KhBadge Tone="state.Tone">@state.Text</KhBadge>
|
|
@if (h.IsDemo)
|
|
{
|
|
<KhBadge Tone="KhTone.Info">@T["Sales.Demo"]</KhBadge>
|
|
}
|
|
@if (IsModified)
|
|
{
|
|
<KhBadge Tone="KhTone.Warning">@T["CompanyTables.Modified"]</KhBadge>
|
|
}
|
|
</State>
|
|
<Chips>
|
|
@if (PartyScreens.Describe(_lookups.PaymentTerms, h.PaymentTermId) is { } payment)
|
|
{
|
|
<KhChip Icon="coins" Text="@T["Sales.Fields.PaymentTermId"]" Value="@payment" />
|
|
}
|
|
@if (PartyScreens.Describe(_lookups.PriceLists, h.PriceListId) is { } list)
|
|
{
|
|
<KhChip Icon="tag" Text="@T["Sales.Fields.PriceListId"]" Value="@list" />
|
|
}
|
|
@if (PartyScreens.Describe(_lookups.Salespeople, h.SalespersonId) is { } agent)
|
|
{
|
|
<KhChip Icon="user" Text="@T["Sales.Fields.SalespersonId"]" Value="@agent" />
|
|
}
|
|
@if (h.SplitPayment)
|
|
{
|
|
<KhChip Icon="shield" Text="@T["Sales.Fields.SplitPayment"]" Value="@T["Common.Yes"]" />
|
|
}
|
|
</Chips>
|
|
</KhDocHead>
|
|
</Heading>
|
|
<ChildContent>
|
|
@switch (ActiveTab)
|
|
{
|
|
case TabIds.Lines:
|
|
@if (h.PartyId is null && !IsReadOnly)
|
|
{
|
|
<div class="callout info kh-doc-callout"><KhIcon Name="info" /> <span>@T["Sales.Hints.PartyFirst"]</span>
|
|
<button type="button" class="btn" @onclick="() => ShowTabAsync(TabIds.Header)">@T["Sales.Actions.ChooseParty"]</button></div>
|
|
}
|
|
<KhLinesGrid TLine="DocumentLine" @ref="_grid" Lines="Record.Lines" Columns="LineColumns" NewLine="NewLine" IsEmpty="IsEmptyLine"
|
|
IsDescriptive="l => l.Kind == DocumentLineKind.Description" NewDescriptive="NewDescriptionLine" DescriptionColumn="LineColumns[1]"
|
|
ReadOnly="IsReadOnly" OnChanged="LinesChangedAsync" Label="@T["Sales.Lines.Title"]" />
|
|
@if (Validation.Messages.Any(m => m.Field?.StartsWith("Lines.", StringComparison.Ordinal) == true))
|
|
{
|
|
<ul class="kh-doc-errors">
|
|
@foreach (var message in Validation.Messages.Where(m => m.Field?.StartsWith("Lines.", StringComparison.Ordinal) == true))
|
|
{
|
|
<li><KhIcon Name="alert-circle" /> @LineErrorText(message.Field!, message.Message)</li>
|
|
}
|
|
</ul>
|
|
}
|
|
<div class="kh-doc-panels">
|
|
<KhPanel Title="@T["Sales.Totals.Summary"]" Icon="euro" Tight="true">@TaxSummary</KhPanel>
|
|
<KhPanel Title="@T["Sales.Totals.Installments"]" Icon="calendar" Tight="true">@Installments</KhPanel>
|
|
<KhPanel Title="@T["Sales.Totals.Title"]" Icon="coins" Tight="true">@Totals</KhPanel>
|
|
</div>
|
|
break;
|
|
|
|
case TabIds.Header:
|
|
<KhForm Validation="Validation" ReadOnly="IsReadOnly" Layout="KhFormLayout.Groups" @ref="Form">
|
|
<KhFieldGroup Title="@T["Sales.Groups.Document"]" Icon="file">
|
|
<KhTextBox Label="@T["Sales.Fields.DocumentTypeId"]" Name="DocumentTypeId" Value="@(_definition.Code + " · " + _definition.Type.Description)" ReadOnly="true" Span="6" />
|
|
<KhTextBox Label="@T["Sales.Fields.DocumentNumber"]" Name="DocumentNumber" Value="@(h.DocumentNumber ?? T["Sales.NumberOnConfirm"])" ReadOnly="true" Mono="true" Span="6" />
|
|
<KhDateBox Label="@T["Sales.Fields.DocumentDate"]" Name="DocumentDate" Value="h.DocumentDate" Required="true" Span="4" ReadOnly="@(h.Number is not null)"
|
|
ValueChanged="v => ChangeAsync(() => { if (v is { } d) { h.DocumentDate = d; h.Year = d.Year; } })" />
|
|
@if (h.Kind == DocumentKind.Quotation)
|
|
{
|
|
<KhDateBox Label="@T["Sales.Fields.ValidUntil"]" Name="ValidUntil" Value="h.ValidUntil" ValueChanged="v => Change(() => h.ValidUntil = v)" Span="4" />
|
|
}
|
|
@if (h.Kind is DocumentKind.Quotation or DocumentKind.SalesOrder or DocumentKind.DeliveryNote or DocumentKind.ProForma)
|
|
{
|
|
<KhDateBox Label="@T["Sales.Fields.DeliveryDate"]" Name="DeliveryDate" Value="h.DeliveryDate" ValueChanged="v => Change(() => h.DeliveryDate = v)" Span="4" />
|
|
}
|
|
<KhTextBox Label="@T["Sales.Fields.ExternalReference"]" Name="ExternalReference" Value="@h.ExternalReference" ValueChanged="v => Change(() => h.ExternalReference = v)"
|
|
Span="8" MaxLength="60" Hint="@T["Sales.Hints.ExternalReference"]" />
|
|
<KhDateBox Label="@T["Sales.Fields.ExternalDate"]" Name="ExternalDate" Value="h.ExternalDate" ValueChanged="v => Change(() => h.ExternalDate = v)" Span="4" />
|
|
@if (IsNote)
|
|
{
|
|
<KhTextBox Label="@T["Sales.Fields.RelatedNumber"]" Name="RelatedNumber" Value="@h.RelatedNumber" ValueChanged="v => Change(() => h.RelatedNumber = v)"
|
|
Span="8" MaxLength="30" Mono="true" Hint="@T["Sales.Hints.Related"]" />
|
|
<KhDateBox Label="@T["Sales.Fields.RelatedDate"]" Name="RelatedDate" Value="h.RelatedDate" ValueChanged="v => Change(() => h.RelatedDate = v)" Span="4" />
|
|
}
|
|
</KhFieldGroup>
|
|
<KhFieldGroup Title="@T["Sales.Groups.Party"]" Icon="users">
|
|
<KhHotlink TItem="PartyRow" Label="@T["Sales.Fields.PartyId"]" Name="PartyId" Span="12" Required="true" Value="_party" ValueChanged="SetPartyAsync"
|
|
Search="SearchPartiesAsync" CodeOf="r => r.Code" DescriptionOf="r => r.Name" OnOpen="OpenParty" ReadOnly="@(Record.Lines.Any(l => l.SourceLineId is not null))" />
|
|
<KhSelect TValue="string" Label="@T["Sales.Fields.SalespersonId"]" Name="SalespersonId" Options="_lookups.Salespeople" Empty="" Span="6"
|
|
Value="@PartyScreens.Text(h.SalespersonId)" ValueChanged="v => Change(() => h.SalespersonId = PartyScreens.Id(v))" />
|
|
<KhSelect TValue="string" Label="@T["Sales.Fields.CurrencyCode"]" Name="CurrencyCode" Options="_lookups.Currencies" Span="6"
|
|
Value="@h.CurrencyCode" ValueChanged="SetCurrency" />
|
|
@if (h.PartyId is not null)
|
|
{
|
|
<p class="muted sm c12"><KhIcon Name="info" /> @T["Sales.Hints.PartyDefaults"]</p>
|
|
}
|
|
</KhFieldGroup>
|
|
<KhFieldGroup Title="@T["Sales.Groups.Conditions"]" Icon="coins">
|
|
<KhSelect TValue="string" Label="@T["Sales.Fields.PriceListId"]" Name="PriceListId" Options="_lookups.PriceLists" Empty="" Span="6"
|
|
Value="@PartyScreens.Text(h.PriceListId)" ValueChanged="v => Change(() => h.PriceListId = PartyScreens.Id(v))" />
|
|
<KhTextBox Label="@T["Sales.Fields.FooterDiscount"]" Name="FooterDiscount" Value="@h.FooterDiscount" ValueChanged="v => ChangeAsync(() => h.FooterDiscount = v)"
|
|
Span="3" Mono="true" MaxLength="30" Placeholder="10+5" />
|
|
<KhCheck Label="@T["Sales.Fields.PricesIncludeTax"]" Name="PricesIncludeTax" Value="h.PricesIncludeTax" ValueChanged="v => ChangeAsync(() => h.PricesIncludeTax = v)" Span="3" />
|
|
<KhSelect TValue="string" Label="@T["Sales.Fields.PaymentTermId"]" Name="PaymentTermId" Options="_lookups.PaymentTerms" Empty="" Span="6"
|
|
Value="@PartyScreens.Text(h.PaymentTermId)" ValueChanged="v => ChangeAsync(() => h.PaymentTermId = PartyScreens.Id(v))" />
|
|
<KhSelect TValue="string" Label="@T["Sales.Fields.PaymentMethodId"]" Name="PaymentMethodId" Options="_lookups.PaymentMethods" Empty="" Span="6"
|
|
Value="@PartyScreens.Text(h.PaymentMethodId)" ValueChanged="v => Change(() => h.PaymentMethodId = PartyScreens.Id(v))" />
|
|
<KhSelect TValue="string" Label="@T["Sales.Fields.BankAccountId"]" Name="BankAccountId" Options="_lookups.BankAccounts" Empty="" Span="12"
|
|
Value="@PartyScreens.Text(h.BankAccountId)" ValueChanged="v => Change(() => h.BankAccountId = PartyScreens.Id(v))" />
|
|
</KhFieldGroup>
|
|
@if (IsInvoice)
|
|
{
|
|
<KhFieldGroup Title="@T["Sales.Groups.Tax"]" Icon="shield">
|
|
<KhSelect TValue="string" Label="@T["Sales.Fields.Exigibility"]" Name="Exigibility" Options="ExigibilityChoices" Empty="" Span="6"
|
|
Value="@h.Exigibility?.ToString()" ValueChanged="SetExigibilityAsync" />
|
|
<KhCheck Label="@T["Sales.Fields.SplitPayment"]" Name="SplitPayment" Value="h.SplitPayment" ValueChanged="v => ChangeAsync(() => h.SplitPayment = v)" Span="3" />
|
|
<KhCheck Label="@T["Sales.Fields.StampDutyCharged"]" Name="StampDutyCharged" Value="h.StampDutyCharged" ValueChanged="v => ChangeAsync(() => h.StampDutyCharged = v)" Span="3" />
|
|
<KhTextBox Label="@T["Sales.Fields.Cig"]" Name="Cig" Value="@h.Cig" ValueChanged="v => Change(() => h.Cig = v)" Span="6" Mono="true" MaxLength="15" />
|
|
<KhTextBox Label="@T["Sales.Fields.Cup"]" Name="Cup" Value="@h.Cup" ValueChanged="v => Change(() => h.Cup = v)" Span="6" Mono="true" MaxLength="15" />
|
|
</KhFieldGroup>
|
|
<KhFieldGroup Title="@T["Sales.Groups.Withholding"]" Icon="coins">
|
|
<KhNumberBox Label="@T["Sales.Fields.WithholdingRate"]" Name="WithholdingRate" Value="h.WithholdingRate" ValueChanged="v => ChangeAsync(() => h.WithholdingRate = v)" Min="0" Max="100" Span="3" />
|
|
<KhNumberBox Label="@T["Sales.Fields.WithholdingBasePercent"]" Name="WithholdingBasePercent" Value="h.WithholdingBasePercent"
|
|
ValueChanged="v => ChangeAsync(() => h.WithholdingBasePercent = v ?? 100m)" Min="0" Max="100" Span="3" />
|
|
<KhTextBox Label="@T["Sales.Fields.WithholdingType"]" Name="WithholdingType" Value="@h.WithholdingType" ValueChanged="v => Change(() => h.WithholdingType = v)" Span="3" Mono="true" MaxLength="4" Placeholder="RT01" />
|
|
<KhTextBox Label="@T["Sales.Fields.WithholdingReason"]" Name="WithholdingReason" Value="@h.WithholdingReason" ValueChanged="v => Change(() => h.WithholdingReason = v)" Span="3" Mono="true" MaxLength="2" Placeholder="A" />
|
|
<KhTextBox Label="@T["Sales.Fields.SocialSecurityFund"]" Name="SocialSecurityFund" Value="@h.SocialSecurityFund" ValueChanged="v => Change(() => h.SocialSecurityFund = v)" Span="3" Mono="true" MaxLength="4" Placeholder="TC22" />
|
|
<KhNumberBox Label="@T["Sales.Fields.SocialSecurityRate"]" Name="SocialSecurityRate" Value="h.SocialSecurityRate" ValueChanged="v => ChangeAsync(() => h.SocialSecurityRate = v)" Min="0" Max="100" Span="3" />
|
|
<KhSelect TValue="string" Label="@T["Sales.Fields.SocialSecurityTaxCodeId"]" Name="SocialSecurityTaxCodeId" Options="_lookups.TaxCodes" Empty="" Span="3"
|
|
Value="@PartyScreens.Text(h.SocialSecurityTaxCodeId)" ValueChanged="v => ChangeAsync(() => h.SocialSecurityTaxCodeId = PartyScreens.Id(v))" />
|
|
<KhCheck Label="@T["Sales.Fields.SocialSecurityWithheld"]" Name="SocialSecurityWithheld" Value="h.SocialSecurityWithheld" ValueChanged="v => ChangeAsync(() => h.SocialSecurityWithheld = v)" Span="3" />
|
|
<KhNumberBox Label="@T["Sales.Fields.EnasarcoRate"]" Name="EnasarcoRate" Value="h.EnasarcoRate" ValueChanged="v => ChangeAsync(() => h.EnasarcoRate = v)" Min="0" Max="100" Span="3" />
|
|
<p class="muted sm c9">@T["Sales.Hints.Withholding"]</p>
|
|
</KhFieldGroup>
|
|
}
|
|
</KhForm>
|
|
break;
|
|
|
|
case SalesScreens.TransportTab:
|
|
<KhForm Validation="Validation" ReadOnly="IsReadOnly" Layout="KhFormLayout.Groups" @ref="Form">
|
|
<KhFieldGroup Title="@T["Sales.Groups.Transport"]" Icon="truck">
|
|
<KhSelect TValue="string" Label="@T["Sales.Fields.TransportReasonId"]" Name="TransportReasonId" Options="_lookups.TransportReasons" Empty="" Span="6"
|
|
Value="@PartyScreens.Text(h.TransportReasonId)" ValueChanged="v => Change(() => h.TransportReasonId = PartyScreens.Id(v))" />
|
|
<KhSelect TValue="string" Label="@T["Sales.Fields.TransportBy"]" Name="TransportBy" Options="TransportChoices" Empty="" Span="6"
|
|
Value="@h.TransportBy?.ToString()" ValueChanged="SetTransportBy" />
|
|
<KhSelect TValue="string" Label="@T["Sales.Fields.CarrierId"]" Name="CarrierId" Options="_lookups.Carriers" Empty="" Span="6"
|
|
Value="@PartyScreens.Text(h.CarrierId)" ValueChanged="v => Change(() => h.CarrierId = PartyScreens.Id(v))" />
|
|
<KhSelect TValue="string" Label="@T["Sales.Fields.ShippingTermId"]" Name="ShippingTermId" Options="_lookups.ShippingTerms" Empty="" Span="6"
|
|
Value="@PartyScreens.Text(h.ShippingTermId)" ValueChanged="v => Change(() => h.ShippingTermId = PartyScreens.Id(v))" />
|
|
<KhDateBox Label="@T["Sales.Fields.TransportStartDate"]" Name="TransportStart" Value="TransportDate" ValueChanged="SetTransportDate" Span="4" />
|
|
<KhTextBox Label="@T["Sales.Fields.TransportStartTime"]" Name="TransportStartTime" Type="time" Value="@TransportTime" ValueChanged="SetTransportTime" Span="2" />
|
|
<KhSelect TValue="string" Label="@T["Sales.Fields.WarehouseId"]" Name="WarehouseId" Options="_lookups.Warehouses" Empty="" Span="6"
|
|
Value="@PartyScreens.Text(h.WarehouseId)" ValueChanged="v => Change(() => h.WarehouseId = PartyScreens.Id(v))" />
|
|
</KhFieldGroup>
|
|
<KhFieldGroup Title="@T["Sales.Groups.Goods"]" Icon="box">
|
|
<KhSelect TValue="string" Label="@T["Sales.Fields.GoodsAppearanceId"]" Name="GoodsAppearanceId" Options="_lookups.GoodsAppearances" Empty="" Span="12"
|
|
Value="@PartyScreens.Text(h.GoodsAppearanceId)" ValueChanged="v => Change(() => h.GoodsAppearanceId = PartyScreens.Id(v))" />
|
|
<KhNumberBox Label="@T["Sales.Fields.Packages"]" Name="Packages" Value="h.Packages" ValueChanged="v => Change(() => h.Packages = (int?)v)" Min="0" Decimals="0" Span="4" />
|
|
<KhNumberBox Label="@T["Sales.Fields.GrossWeight"]" Name="GrossWeight" Value="h.GrossWeight" ValueChanged="v => Change(() => h.GrossWeight = v)" Min="0" Decimals="3" Span="4" />
|
|
<KhNumberBox Label="@T["Sales.Fields.NetWeight"]" Name="NetWeight" Value="h.NetWeight" ValueChanged="v => Change(() => h.NetWeight = v)" Min="0" Decimals="3" Span="4" />
|
|
<p class="muted sm c12">@T["Sales.Hints.Transport"]</p>
|
|
</KhFieldGroup>
|
|
</KhForm>
|
|
break;
|
|
|
|
case TabIds.Totals:
|
|
<div class="kh-doc-panels wide">
|
|
<KhPanel Title="@T["Sales.Totals.Summary"]" Icon="euro" Tight="true">@TaxSummary</KhPanel>
|
|
<KhPanel Title="@T["Sales.Totals.Title"]" Icon="coins" Tight="true">@Totals</KhPanel>
|
|
</div>
|
|
break;
|
|
|
|
case TabIds.DueDates:
|
|
<div class="kh-doc-panels single">
|
|
<KhPanel Title="@T["Sales.Totals.Installments"]" Icon="calendar" Tight="true">@Installments</KhPanel>
|
|
</div>
|
|
<p class="muted sm kh-pad"><KhIcon Name="info" /> @T[Behavior.Has(DocumentEffects.Installments) ? "Sales.Hints.Installments" : "Sales.Hints.InstallmentsForecast"]</p>
|
|
break;
|
|
|
|
case TabIds.Notes:
|
|
<KhForm Validation="Validation" ReadOnly="IsReadOnly" Layout="KhFormLayout.Groups" @ref="Form">
|
|
<KhFieldGroup Title="@T["Sales.Groups.Notes"]" Icon="edit" Wide="true">
|
|
<KhTextArea Label="@T["Sales.Fields.Notes"]" Name="Notes" Value="@h.Notes" ValueChanged="v => Change(() => h.Notes = v)" Span="12" Rows="6"
|
|
Hint="@T["Sales.Hints.Notes"]" />
|
|
</KhFieldGroup>
|
|
@if (h.CancelReason is { } reason)
|
|
{
|
|
<KhFieldGroup Title="@T["Sales.Groups.Cancelled"]" Icon="x-circle" Wide="true">
|
|
<KhTextArea Label="@T["Sales.Fields.CancelReason"]" Name="CancelReason" Value="@reason" ReadOnly="true" Span="12" Rows="2" />
|
|
</KhFieldGroup>
|
|
}
|
|
</KhForm>
|
|
break;
|
|
|
|
case TabIds.Attachments:
|
|
<div class="kh-tab-body"><KhAttachmentList Entity="@AttachmentEntity" EntityId="h.Id" OnCountChanged="SetAttachments" /></div>
|
|
break;
|
|
|
|
case TabIds.Links:
|
|
<div class="kh-tab-body">
|
|
@if (_links.Count == 0)
|
|
{
|
|
<p class="muted">@T["Sales.Links.Empty"]</p>
|
|
}
|
|
else
|
|
{
|
|
<div class="gridwrap">
|
|
<table class="grid" aria-label="@T["Ui.Record.Tabs.Links"]">
|
|
<thead>
|
|
<tr>
|
|
<th scope="col">@T["Sales.Links.Relation"]</th>
|
|
<th scope="col">@T["Sales.Radar.Kind"]</th>
|
|
<th scope="col">@T["Sales.Fields.DocumentNumber"]</th>
|
|
<th scope="col">@T["Sales.Fields.DocumentDate"]</th>
|
|
<th scope="col">@T["Sales.Radar.State"]</th>
|
|
<th scope="col" class="num">@T["Sales.Links.Quantity"]</th>
|
|
<th scope="col" class="num">@T["Sales.Totals.Total"]</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
@foreach (var link in _links)
|
|
{
|
|
var linkState = SalesScreens.State(T, link.Kind, link.Status, null, Today);
|
|
<tr>
|
|
<td>@T["Sales.Links." + link.Direction]</td>
|
|
<td>@SalesScreens.KindName(T, link.Kind)</td>
|
|
<td class="code">
|
|
@if (SalesScreens.RecordUrl(link.Kind, link.Id) is { } url)
|
|
{
|
|
<a href="@url">@(link.DocumentNumber ?? T["Sales.DraftNumber"])</a>
|
|
}
|
|
else
|
|
{
|
|
@(link.DocumentNumber ?? T["Sales.DraftNumber"])
|
|
}
|
|
</td>
|
|
<td>@T.Date(link.Date)</td>
|
|
<td><KhBadge Tone="linkState.Tone">@linkState.Text</KhBadge></td>
|
|
<td class="num">@(link.Quantity > 0 ? T.Number(link.Quantity, 2) : null)</td>
|
|
<td class="num">@T.Money(link.Total)</td>
|
|
</tr>
|
|
}
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
}
|
|
</div>
|
|
break;
|
|
|
|
case TabIds.History:
|
|
<div class="kh-tab-body"><KhAuditList Items="_history" FieldName="FieldLabel" /></div>
|
|
break;
|
|
}
|
|
</ChildContent>
|
|
</KhRecordLayout>
|
|
|
|
<KhRadarDialog TItem="ItemRow" Id="sales.items" Open="_lookupLine is not null" Title="@T["Sales.Lines.ItemRadar"]" Columns="ItemColumns" Source="ListItemsAsync"
|
|
KeyOf="i => i.Id" InitialSearch="@_lookupText" OnPick="PickItemAsync" OnClose="CloseLookup" />
|
|
|
|
<KhDialog Open="_transform is not null" Title="@_transform?.Title" Icon="copy" Size="lg" OnClose="() => _transform = null">
|
|
<ChildContent>
|
|
@if (_transform is { } t)
|
|
{
|
|
<p class="muted">@t.Lead</p>
|
|
<div class="gridwrap">
|
|
<table class="grid" aria-label="@T["Sales.Lines.Title"]">
|
|
<thead>
|
|
<tr>
|
|
<th scope="col" class="kh-check"><input type="checkbox" checked="@(t.Selected.Count == t.Lines.Count)" aria-label="@T["Sales.Transform.All"]" @onchange="ToggleAllLines" /></th>
|
|
<th scope="col">@T["Sales.Lines.Description"]</th>
|
|
<th scope="col" class="num">@T["Sales.Lines.Quantity"]</th>
|
|
@if (t.Fulfils)
|
|
{
|
|
<th scope="col" class="num">@T["Sales.Lines.Residual"]</th>
|
|
}
|
|
<th scope="col" class="num">@T["Sales.Lines.Amount"]</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
@foreach (var line in t.Lines)
|
|
{
|
|
var id = line.Id;
|
|
<tr class="@(line.Kind == DocumentLineKind.Description ? "kh-desc" : null)">
|
|
<td class="kh-check"><input type="checkbox" checked="@t.Selected.Contains(id)" aria-label="@line.Description" @onchange="e => ToggleLine(id, e.Value is true)" /></td>
|
|
<td>@line.Description</td>
|
|
<td class="num">@(DocumentLine.CarriesQuantity(line.Kind) ? T.Number(line.Quantity, 2) : null)</td>
|
|
@if (t.Fulfils)
|
|
{
|
|
<td class="num">@(DocumentLine.CarriesQuantity(line.Kind) ? T.Number(line.Residual, 2) : null)</td>
|
|
}
|
|
<td class="num">@(line.Kind == DocumentLineKind.Description ? null : T.Money(line.TaxableAmount))</td>
|
|
</tr>
|
|
}
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
}
|
|
</ChildContent>
|
|
<Footer>
|
|
<button type="button" class="btn" @onclick="() => _transform = null">@T["Common.Cancel"]</button>
|
|
<button type="button" class="btn primary" disabled="@(_transform?.Selected.Count == 0 || _busy)" @onclick="TransformAsync"><KhIcon Name="copy" /> @T["Sales.Transform.Create"]</button>
|
|
</Footer>
|
|
</KhDialog>
|
|
|
|
<KhDialog Open="_cancelling" Title="@T["Sales.Actions.Cancel"]" Icon="x-circle" OnClose="() => _cancelling = false">
|
|
<ChildContent>
|
|
<p>@T[Behavior.Lifecycle == DocumentLifecycle.Invoice ? "Sales.Cancel.LeadInvoice" : "Sales.Cancel.Lead"]</p>
|
|
<KhForm Validation="_cancelValidation" Layout="KhFormLayout.Groups">
|
|
<KhTextArea Label="@T["Sales.Fields.CancelReason"]" Name="CancelReason" Value="@_cancelReason" ValueChanged="v => _cancelReason = v" Span="12" Rows="3"
|
|
Required="@(Behavior.Lifecycle == DocumentLifecycle.Invoice)" />
|
|
</KhForm>
|
|
</ChildContent>
|
|
<Footer>
|
|
<button type="button" class="btn" @onclick="() => _cancelling = false">@T["Common.Cancel"]</button>
|
|
<button type="button" class="btn danger" disabled="@_busy" @onclick="CancelDocumentAsync"><KhIcon Name="x-circle" /> @T["Sales.Actions.Cancel"]</button>
|
|
</Footer>
|
|
</KhDialog>
|
|
|
|
<KhDialog Open="_mailing" Title="@T["Sales.Mail.Title"]" Icon="mail" Size="lg" OnClose="() => _mailing = false">
|
|
<ChildContent>
|
|
@if (!Mails.IsConfigured)
|
|
{
|
|
<div class="callout warn kh-doc-callout"><KhIcon Name="alert" /> <span>@T[DocumentMailErrors.NotConfigured]</span></div>
|
|
}
|
|
<p class="muted">@T["Sales.Mail.Lead"]</p>
|
|
<div class="kh-mail-form">
|
|
<KhForm Validation="_mailValidation" Layout="KhFormLayout.Groups">
|
|
<KhTextBox Label="@T["Sales.Mail.To"]" Name="To" Value="@_mailTo" ValueChanged="v => _mailTo = v" Span="12" Required="true" Hint="@T["Sales.Mail.ToHint"]" />
|
|
<KhTextBox Label="@T["Sales.Mail.Subject"]" Name="Subject" Value="@_mailSubject" ValueChanged="v => _mailSubject = v" Span="12" Required="true" />
|
|
<KhTextArea Label="@T["Sales.Mail.Body"]" Name="Body" Value="@_mailBody" ValueChanged="v => _mailBody = v" Span="12" Rows="9" />
|
|
</KhForm>
|
|
</div>
|
|
</ChildContent>
|
|
<Footer>
|
|
<button type="button" class="btn" @onclick="() => _mailing = false">@T["Common.Cancel"]</button>
|
|
<button type="button" class="btn primary" disabled="@(_busy || !Mails.IsConfigured)" @onclick="SendMailAsync"><KhIcon Name="send" /> @T["Sales.Mail.Send"]</button>
|
|
</Footer>
|
|
</KhDialog>
|
|
}
|