feat: fixed assets, Intrastat, intent declarations, year-end closing and statements (#82 #83 #84 #85 #86 #87)
CI / Build and test (SQLite) (pull_request) Successful in 4m35s
CI / PostgreSQL 16 integration (pull_request) Skipped
CI / PostgreSQL 17 integration (pull_request) Skipped
CI / YAML check (pull_request) Successful in 5s
CI / Docker image (pull_request) Successful in 1m24s

M10 gives the ledger its year end. Fixed assets get categories with the
ministerial coefficients, a civil and a fiscal plan, depreciation posted
per category and undoable, disposals with gain or loss and the register
print (ADR 0041). Intrastat lists are generated from confirmed invoices
with the due periodicity and the SCAMBI.CEE file; declarations of intent
get their own register and the N3.5 ceiling is checked when an invoice is
confirmed (ADR 0042). Accruals, deferrals and exchange differences feed a
nine-step guided closing that can repeat or undo its last step until the
final prints, reopens the next year and locks the closed one; the CEE
statements (ordinary, abbreviated, micro), the reclassified statements,
the ratios and the accountant export read the year's balances (ADR 0043).

The demo seed now opens the year with assets, stock, bank and capital, so
the integration test closes the demo year from the checks to the lock on
SQLite and PostgreSQL. Docs: wiki pages with screenshots, ADR 0041-0043,
MODULES, STATUS, DATA-MODEL and the 0.10.0 changelog.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Alby96andClaude Opus 5.5 committed 2026-11-13 19:31:26 +01:00
1 parent 836a316b05
commit 51007d68ca
84 files changed
+11701 -298

No files matched your search

@@ -0,0 +1,91 @@
using Khaemhat.Core.Entities;
namespace Khaemhat.Core.Parties;
/// <summary>Whether a declaration of intent was received from a customer or issued by the company.</summary>
public enum IntentDirection
{
/// <summary>Received from a habitual exporter customer: its sales go without VAT up to the ceiling.</summary>
Received = 0,
/// <summary>Issued by the company to a supplier, on its own ceiling (plafond).</summary>
Issued = 1,
}
/// <summary>The state of a declaration of intent.</summary>
public enum IntentStatus
{
/// <summary>In force.</summary>
Active = 0,
/// <summary>The ceiling is used up.</summary>
Exhausted = 1,
/// <summary>Revoked or replaced.</summary>
Revoked = 2,
}
/// <summary>
/// A declaration of intent (dichiarazione d'intento, SPEC §11.7, mockup 061, <c>intent_declarations</c>): a habitual
/// exporter buys without VAT (art. 8 c. 1 lett. c DPR 633/72) up to the ceiling it declares; the invoices carry the
/// protocol of the Agenzia delle Entrate and the nature N3.5. The register keeps the declarations received and issued
/// in chronological order with the ceiling used.
/// </summary>
public sealed class IntentDeclaration : Entity<long>, IDemoMarkable
{
/// <summary>Received or issued.</summary>
public IntentDirection Direction { get; set; }
/// <summary>The progressive of the chronological register in the year.</summary>
public int RegisterNumber { get; set; }
/// <summary>The year.</summary>
public int Year { get; set; }
/// <summary>The customer (received) or supplier (issued).</summary>
public long PartyId { get; set; }
/// <summary>The number given by the declarant, such as <c>12345/2026</c>.</summary>
public string Number { get; set; } = string.Empty;
/// <summary>The day of the declaration.</summary>
public DateOnly DeclarationDate { get; set; }
/// <summary>The protocol of the receipt of the Agenzia delle Entrate (17 digits, dash, 6 digits).</summary>
public string Protocol { get; set; } = string.Empty;
/// <summary>The ceiling declared.</summary>
public decimal Ceiling { get; set; }
/// <summary>The ceiling used by the invoices.</summary>
public decimal Used { get; set; }
/// <summary>The first day it covers.</summary>
public DateOnly ValidFrom { get; set; }
/// <summary>The last day it covers.</summary>
public DateOnly ValidTo { get; set; }
/// <summary>The VAT code the invoices use (nature N3.5).</summary>
public long? TaxCodeId { get; set; }
/// <summary>The state.</summary>
public IntentStatus Status { get; set; }
/// <summary>Notes.</summary>
public string? Notes { get; set; }
/// <inheritdoc />
public bool IsDemo { get; set; }
/// <summary>The ceiling left.</summary>
public decimal Remaining => Ceiling - Used;
/// <summary>The share used, percent.</summary>
public decimal UsedPercent => Ceiling <= 0m ? 0m : Math.Round(Used / Ceiling * 100m, 0, MidpointRounding.AwayFromZero);
/// <summary>Whether it covers a day.</summary>
/// <param name="date">The day.</param>
/// <returns><see langword="true"/> when active and the day is in its period.</returns>
public bool Covers(DateOnly date) => Status != IntentStatus.Revoked && ValidFrom <= date && date <= ValidTo;
}