M7 adds the double-entry ledger so that the documents of M5 and M6 reach the accounts without retyping, and the Italian VAT obligations can be prepared from the same data. - Chart of accounts on three levels with the Italian "PMI standard" model in the fiscal pack, journal templates with proposed lines, VAT registers; the chart import now writes the accounts and exports them (#62, ADR 0036). - Journal entries: draft, posted, final with the libro giornale number, reversal; recurring entries with the nightly ledger.recurring job (#63). - Documents post their entry inside the document transaction (PostingEngine, LedgerPoster) with VAT lines, open items and withholdings; a change rewrites the same entry, a cancellation removes or reverses it (#64, ADR 0037). - VAT registers with final print, monthly or quarterly settlement with pro rata, interest, minimum and advance, confirmation with the LIQ entry, period lock and F24 line, LIPE file and F24 data (#65). - Operated and suffered withholdings, CU data, stamp duty by quarter with the 5,000 euro threshold, F24 summary with its payment entry (#66). - Party ledgers, account ledgers, trial balance and libro giornale (#67). - Demo accounting with the settlements of the past months confirmed and checked by hand in a test; wiki Contabilita, IVA, Fiscalita italiana completed with screenshots; CHANGELOG 0.7.0, STATUS, ADR 0036-0037 (#68). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
228 lines
9.6 KiB
Plaintext
228 lines
9.6 KiB
Plaintext
@page "/contabilita/bollo"
|
|
@attribute [Authorize]
|
|
@using Khaemhat.Application.Ledger
|
|
@using Khaemhat.Application.Security
|
|
@using Khaemhat.Web.Ledger
|
|
@inject ShellSession Session
|
|
@inject TaxService Taxes
|
|
@inject ToastService Toasts
|
|
@inject IJSRuntime JS
|
|
@inject TimeProvider Clock
|
|
|
|
@* The virtual stamp duty on e-invoices (SPEC §11.7, mockup 060): the invoices of a quarter with the duty, the amount,
|
|
the payment code and the due date (a small first quarter goes with the second, the first two with the third), the
|
|
F24 line, its data file and its payment. *@
|
|
<KhPageTitle Text="@T["Ledger.StampDuty.Title"]" Icon="file-check" />
|
|
|
|
<LedgerGuard Permission="@LedgerPermissions.SettlementRead">
|
|
<div class="phead">
|
|
<div>
|
|
<div class="crumbs"><a href="@LedgerScreens.BasePath">@T["Shell.Menu.Ledger"]</a> / @T["Ledger.StampDuty.Title"]</div>
|
|
<h1>@T["Ledger.StampDuty.Heading"]</h1>
|
|
<div class="sub">@T["Ledger.StampDuty.Hint"]</div>
|
|
</div>
|
|
<div class="grow"></div>
|
|
<div class="toolbar">
|
|
@if (Current is { } q)
|
|
{
|
|
<KhBadge Tone="KhTone.Info">@T.Format("Ledger.StampDuty.QuarterBadge", q.Quarter, q.Year)</KhBadge>
|
|
}
|
|
@if (CanConfirm)
|
|
{
|
|
<button type="button" class="btn primary" disabled="@(_busy || Current is null || Current.Amount == 0m || Current.Payment?.PaidOn is not null)" @onclick="RecordAsync"><KhIcon Name="check" /> @T["Ledger.StampDuty.Record"]</button>
|
|
}
|
|
<button type="button" class="btn" disabled="@(_busy || Current?.Payment is null)" @onclick="ExportAsync"><KhIcon Name="download" /> @T["Ledger.StampDuty.Export"]</button>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="filters kh-ledger-filters">
|
|
<KhSelect TValue="int" Label="@T["Ledger.Settlement.Year"]" Name="year" Options="YearChoices" Value="_year" ValueChanged="SetYearAsync" />
|
|
<KhSelect TValue="int" Label="@T["Ledger.StampDuty.Quarter"]" Name="quarter" Options="QuarterChoices" Value="_quarter" ValueChanged="SetQuarterAsync" />
|
|
</div>
|
|
|
|
@if (Current is { } current)
|
|
{
|
|
<KhStrip Items="Stats(current)" Label="@T["Ledger.StampDuty.Title"]" />
|
|
}
|
|
|
|
<KhPanel Tight="true">
|
|
@if (_documents.Count == 0)
|
|
{
|
|
<p class="kh-wempty">@T["Ledger.StampDuty.None"]</p>
|
|
}
|
|
else
|
|
{
|
|
<table class="grid" aria-label="@T["Ledger.StampDuty.Title"]">
|
|
<thead>
|
|
<tr>
|
|
<th scope="col">@T["Ledger.Fields.Document"]</th>
|
|
<th scope="col">@T["Ledger.Fields.DocumentDate"]</th>
|
|
<th scope="col">@T["Ledger.Fields.Party"]</th>
|
|
<th scope="col" class="num">@T["Ledger.Fields.Taxable"]</th>
|
|
<th scope="col" class="num">@T["Ledger.StampDuty.Duty"]</th>
|
|
<th scope="col">@T["Ledger.StampDuty.Charge"]</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
@foreach (var d in _documents)
|
|
{
|
|
<tr>
|
|
<td class="code"><a href="@Khaemhat.Web.Documents.SalesScreens.RecordUrl(d.Kind, d.DocumentId)">@d.DocumentNumber</a></td>
|
|
<td>@T.Date(d.DocumentDate)</td>
|
|
<td>@d.PartyName</td>
|
|
<td class="num">@T.Money(d.Taxable)</td>
|
|
<td class="num">@T.Money(d.StampDuty)</td>
|
|
<td><KhBadge Tone="@(d.Charged ? KhTone.Info : KhTone.Neutral)">@T[d.Charged ? "Ledger.StampDuty.Charged" : "Ledger.StampDuty.Borne"]</KhBadge></td>
|
|
</tr>
|
|
}
|
|
</tbody>
|
|
</table>
|
|
}
|
|
<div class="filters"><span class="muted sm">@T["Ledger.StampDuty.Footer"]</span></div>
|
|
</KhPanel>
|
|
|
|
<KhPanel Title="@T.Format("Ledger.StampDuty.Year", _year)" Icon="calendar" Tight="true">
|
|
<table class="grid" aria-label="@T.Format("Ledger.StampDuty.Year", _year)">
|
|
<thead>
|
|
<tr>
|
|
<th scope="col">@T["Ledger.StampDuty.Quarter"]</th>
|
|
<th scope="col" class="num">@T["Ledger.StampDuty.Invoices"]</th>
|
|
<th scope="col" class="num">@T["Ledger.Fields.Amount"]</th>
|
|
<th scope="col">@T["Ledger.Settlement.DueDate"]</th>
|
|
<th scope="col">@T["Ledger.Fields.Status"]</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
@foreach (var q in _quarters)
|
|
{
|
|
<tr class="@(q.Quarter == _quarter ? "sel" : null)" style="cursor:pointer" @onclick="() => SetQuarterAsync(q.Quarter)">
|
|
<td>@T.Format("Ledger.StampDuty.QuarterBadge", q.Quarter, q.Year)</td>
|
|
<td class="num">@q.Documents</td>
|
|
<td class="num">@T.Money(q.Amount)</td>
|
|
<td>@T.Date(q.DueDate)</td>
|
|
<td>
|
|
@if (q.Payment is { PaidOn: { } paid })
|
|
{
|
|
<KhBadge Tone="KhTone.Ok">@T.Format("Ledger.StampDuty.PaidOn", T.Date(paid))</KhBadge>
|
|
}
|
|
else if (q.Payment is not null)
|
|
{
|
|
<KhBadge Tone="KhTone.Warning">@T["Ledger.StampDuty.InF24"]</KhBadge>
|
|
}
|
|
else if (q.Amount > 0m)
|
|
{
|
|
<KhBadge Tone="KhTone.Neutral">@T["Ledger.StampDuty.ToRecord"]</KhBadge>
|
|
}
|
|
</td>
|
|
</tr>
|
|
}
|
|
</tbody>
|
|
</table>
|
|
</KhPanel>
|
|
</LedgerGuard>
|
|
|
|
@code {
|
|
private int _year;
|
|
private int _quarter;
|
|
private IReadOnlyList<StampDutyQuarter> _quarters = [];
|
|
private IReadOnlyList<StampDutyDocument> _documents = [];
|
|
private bool _busy;
|
|
|
|
private DateOnly Today => DateOnly.FromDateTime(Clock.GetLocalNow().DateTime);
|
|
|
|
private bool CanConfirm => Session.Permissions.Allows(LedgerPermissions.SettlementConfirm);
|
|
|
|
private StampDutyQuarter? Current => _quarters.FirstOrDefault(q => q.Quarter == _quarter);
|
|
|
|
private IReadOnlyList<KhOption<int>> YearChoices => [.. Enumerable.Range(Today.Year - 3, 5).Select(y => new KhOption<int>(y, y.ToString(System.Globalization.CultureInfo.InvariantCulture)))];
|
|
|
|
private IReadOnlyList<KhOption<int>> QuarterChoices => [.. Enumerable.Range(1, 4).Select(q => new KhOption<int>(q, T.Format("Ledger.StampDuty.QuarterBadge", q, _year)))];
|
|
|
|
private IReadOnlyList<KhStat> Stats(StampDutyQuarter q)
|
|
{
|
|
var previous = q.Quarter > 1 ? _quarters.FirstOrDefault(p => p.Quarter == q.Quarter - 1) : null;
|
|
return
|
|
[
|
|
new(T["Ledger.StampDuty.Invoices"], T.Number(q.Documents)),
|
|
new(T["Ledger.Fields.Amount"], T.Money(q.Amount)),
|
|
new(T["Ledger.Settlement.PaymentCode"], q.Payment?.PaymentCode ?? "-"),
|
|
new(T["Ledger.Settlement.DueDate"], T.Date(q.DueDate)),
|
|
new(T["Ledger.StampDuty.Previous"], previous is null ? "-" : T.Money(previous.Amount) + (previous.Payment?.PaidOn is { } paid ? " · " + T.Format("Ledger.StampDuty.PaidOn", T.Date(paid)) : string.Empty),
|
|
previous?.Payment?.PaidOn is not null ? KhTone.Ok : KhTone.Neutral),
|
|
];
|
|
}
|
|
|
|
/// <inheritdoc />
|
|
protected override async Task OnInitializedAsync()
|
|
{
|
|
await Session.EnsureLoadedAsync();
|
|
_year = Today.Year;
|
|
_quarter = ((Today.Month - 1) / 3) + 1;
|
|
if (Session.Actor is { } && Session.Company is { } && Session.Permissions.Allows(LedgerPermissions.SettlementRead)
|
|
&& Session.Licenses.IsModuleActive(Khaemhat.Application.Modules.ModuleCodes.Accounting))
|
|
{
|
|
await LoadAsync();
|
|
}
|
|
}
|
|
|
|
private async Task LoadAsync()
|
|
{
|
|
if (Session.Actor is not { } actor || Session.Company?.Code is not { } company)
|
|
{
|
|
return;
|
|
}
|
|
|
|
_quarters = await Taxes.StampDutyAsync(actor, company, _year);
|
|
_documents = await Taxes.StampDutyDocumentsAsync(actor, company, _year, _quarter);
|
|
}
|
|
|
|
private async Task SetYearAsync(int year)
|
|
{
|
|
_year = year;
|
|
await LoadAsync();
|
|
}
|
|
|
|
private async Task SetQuarterAsync(int quarter)
|
|
{
|
|
_quarter = quarter;
|
|
await LoadAsync();
|
|
}
|
|
|
|
private async Task RecordAsync() => await RunAsync(async (actor, company) =>
|
|
{
|
|
var payment = await Taxes.StampDutyPaymentAsync(actor, company, _year, _quarter);
|
|
Toasts.Show(ToastKind.Success, payment is null ? T["Ledger.StampDuty.NoneDue"] : T.Format("Ledger.StampDuty.Recorded", T.Money(payment.Amount), T.Date(payment.DueDate)));
|
|
await LoadAsync();
|
|
});
|
|
|
|
private async Task ExportAsync() => await RunAsync(async (actor, company) =>
|
|
{
|
|
if (Current?.Payment is { } payment)
|
|
{
|
|
await LedgerScreens.DownloadAsync(JS, await Taxes.ExportFormAsync(actor, company, payment.DueDate));
|
|
}
|
|
});
|
|
|
|
private async Task RunAsync(Func<Actor, string, Task> action)
|
|
{
|
|
if (Session.Actor is not { } actor || Session.Company?.Code is not { } company)
|
|
{
|
|
return;
|
|
}
|
|
|
|
_busy = true;
|
|
try
|
|
{
|
|
await action(actor, company);
|
|
}
|
|
catch (ValidationFailedException ex)
|
|
{
|
|
Toasts.Show(ToastKind.Error, T["Ledger.NotDone"], LedgerScreens.Errors(T, ex));
|
|
}
|
|
finally
|
|
{
|
|
_busy = false;
|
|
}
|
|
}
|
|
}
|