@page "/vendite/{Segment}/nuovo" @page "/vendite/{Segment}/{Id:long}" @attribute [Authorize] @inherits DocumentPage @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. *@ @if (!_loaded) {

@T["Common.Loading"]

} else if (Session.Company is null) {

@T["Sales.NoCompany"]

} else if (_denied) {

@T["Pages.AccessDenied.Title"]

@T["Pages.AccessDenied.Lead"]

} else if (Record is null || _section is null || _definition is null) {

@T["Sales.NotFound"]

@T["Sales.BackToList"]
} else { var h = Record.Header; @T["Sales.Fields.DocumentDate"] @T.Date(h.DocumentDate) @if (h.Kind == DocumentKind.Quotation && h.ValidUntil is { } until) { @T["Sales.Fields.ValidUntil"] @T.Date(until) } @if (h.DeliveryDate is { } delivery) { @T["Sales.Fields.DeliveryDate"] @T.Date(delivery) } @if (h.Revision > 0) { @T["Sales.Fields.Revision"] @h.Revision } @if (h.RelatedNumber is { } related) { @T["Sales.Fields.Related"] @related@(h.RelatedDate is { } rd ? " · " + T.Date(rd) : null) } @{ var state = SalesScreens.State(T, h.Kind, h.Status, h.ValidUntil, Today); } @state.Text @if (h.IsDemo) { @T["Sales.Demo"] } @if (IsModified) { @T["CompanyTables.Modified"] } @if (PartyScreens.Describe(_lookups.PaymentTerms, h.PaymentTermId) is { } payment) { } @if (PartyScreens.Describe(_lookups.PriceLists, h.PriceListId) is { } list) { } @if (PartyScreens.Describe(_lookups.Salespeople, h.SalespersonId) is { } agent) { } @if (h.SplitPayment) { } @switch (ActiveTab) { case TabIds.Lines: @if (h.PartyId is null && !IsReadOnly) {
@T["Sales.Hints.PartyFirst"]
} @if (Validation.Messages.Any(m => m.Field?.StartsWith("Lines.", StringComparison.Ordinal) == true)) {
    @foreach (var message in Validation.Messages.Where(m => m.Field?.StartsWith("Lines.", StringComparison.Ordinal) == true)) {
  • @LineErrorText(message.Field!, message.Message)
  • }
}
@TaxSummary @Installments @Totals
break; case TabIds.Header: @if (h.Kind == DocumentKind.Quotation) { } @if (h.Kind is DocumentKind.Quotation or DocumentKind.SalesOrder or DocumentKind.DeliveryNote or DocumentKind.ProForma) { } @if (IsNote) { } @if (h.PartyId is not null) {

@T["Sales.Hints.PartyDefaults"]

}
@if (IsInvoice) {

@T["Sales.Hints.Withholding"]

}
break; case SalesScreens.TransportTab:

@T["Sales.Hints.Transport"]

break; case TabIds.Totals:
@TaxSummary @Totals
break; case TabIds.DueDates:
@Installments

@T[Behavior.Has(DocumentEffects.Installments) ? "Sales.Hints.Installments" : "Sales.Hints.InstallmentsForecast"]

break; case TabIds.Notes: @if (h.CancelReason is { } reason) { } break; case TabIds.Attachments:
break; case TabIds.Links:
@if (_links.Count == 0) {

@T["Sales.Links.Empty"]

} else {
@foreach (var link in _links) { var linkState = SalesScreens.State(T, link.Kind, link.Status, null, Today); }
@T["Sales.Links.Relation"] @T["Sales.Radar.Kind"] @T["Sales.Fields.DocumentNumber"] @T["Sales.Fields.DocumentDate"] @T["Sales.Radar.State"] @T["Sales.Links.Quantity"] @T["Sales.Totals.Total"]
@T["Sales.Links." + link.Direction] @SalesScreens.KindName(T, link.Kind) @if (SalesScreens.RecordUrl(link.Kind, link.Id) is { } url) { @(link.DocumentNumber ?? T["Sales.DraftNumber"]) } else { @(link.DocumentNumber ?? T["Sales.DraftNumber"]) } @T.Date(link.Date) @linkState.Text @(link.Quantity > 0 ? T.Number(link.Quantity, 2) : null) @T.Money(link.Total)
}
break; case TabIds.History:
break; }
@if (_transform is { } t) {

@t.Lead

@if (t.Fulfils) { } @foreach (var line in t.Lines) { var id = line.Id; @if (t.Fulfils) { } }
@T["Sales.Lines.Description"] @T["Sales.Lines.Quantity"]@T["Sales.Lines.Residual"]@T["Sales.Lines.Amount"]
@line.Description @(DocumentLine.CarriesQuantity(line.Kind) ? T.Number(line.Quantity, 2) : null)@(DocumentLine.CarriesQuantity(line.Kind) ? T.Number(line.Residual, 2) : null)@(line.Kind == DocumentLineKind.Description ? null : T.Money(line.TaxableAmount))
}

@T[Behavior.Lifecycle == DocumentLifecycle.Invoice ? "Sales.Cancel.LeadInvoice" : "Sales.Cancel.Lead"]

@if (!Mails.IsConfigured) {
@T[DocumentMailErrors.NotConfigured]
}

@T["Sales.Mail.Lead"]

}