Files
Khaemhat/src/Khaemhat.Core/Accounting/Intrastat.cs
T
Alby96andClaude Opus 5.5 51007d68ca
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
feat: fixed assets, Intrastat, intent declarations, year-end closing and statements (#82 #83 #84 #85 #86 #87)
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>
2026-11-13 19:31:26 +01:00

223 lines
7.2 KiB
C#

using Khaemhat.Core.Documents;
using Khaemhat.Core.Entities;
namespace Khaemhat.Core.Accounting;
/// <summary>Sales to or purchases from the other member states.</summary>
public enum IntrastatFlow
{
/// <summary>Cessioni (INTRA-1).</summary>
Sales = 0,
/// <summary>Acquisti (INTRA-2).</summary>
Purchases = 1,
}
/// <summary>How often the lists are due.</summary>
public enum IntrastatPeriodicity
{
/// <summary>Every month.</summary>
Monthly = 0,
/// <summary>Every quarter.</summary>
Quarterly = 1,
/// <summary>Not due (purchases below the threshold).</summary>
NotDue = 2,
}
/// <summary>The section of a list.</summary>
public enum IntrastatSection
{
/// <summary>Goods (INTRA-1 bis, INTRA-2 bis).</summary>
Goods = 0,
/// <summary>Corrections of goods of earlier periods (ter).</summary>
GoodsCorrection = 1,
/// <summary>Services (INTRA-1 quater, INTRA-2 quater).</summary>
Services = 2,
/// <summary>Corrections of services of earlier periods (quinquies).</summary>
ServicesCorrection = 3,
}
/// <summary>The state of a list.</summary>
public enum IntrastatStatus
{
/// <summary>Being prepared: can be generated again.</summary>
Draft = 0,
/// <summary>The file was written.</summary>
Generated = 1,
/// <summary>Sent to the customs: read only.</summary>
Sent = 2,
}
/// <summary>What the check of a line found.</summary>
public enum IntrastatCheck
{
/// <summary>Complete.</summary>
Ok = 0,
/// <summary>The combined nomenclature code is missing or not of 8 digits.</summary>
MissingNomenclature = 1,
/// <summary>The net mass is missing.</summary>
MissingMass = 2,
/// <summary>The VAT number of the counterparty is missing.</summary>
MissingVatNumber = 3,
/// <summary>The counterparty is outside the European Union: left out.</summary>
OutsideEu = 4,
/// <summary>The service code (CPA) is missing.</summary>
MissingServiceCode = 5,
}
/// <summary>
/// An Intrastat list of a period (SPEC §11.7, mockup 049, <c>intrastat_lists</c>): the sales or purchases of goods and
/// services with the other member states, generated from the documents, completed by hand and written to the file
/// of the customs (SCAMBI.CEE).
/// </summary>
public sealed class IntrastatList : Entity<long>, IDemoMarkable
{
/// <summary>Sales or purchases.</summary>
public IntrastatFlow Flow { get; set; }
/// <summary>The year.</summary>
public int Year { get; set; }
/// <summary>The month (1-12) or the quarter (1-4).</summary>
public int Period { get; set; }
/// <summary>Monthly or quarterly.</summary>
public IntrastatPeriodicity Periodicity { get; set; }
/// <summary>The state.</summary>
public IntrastatStatus Status { get; set; }
/// <summary>The progressive number of the list in the year, for the file.</summary>
public int Progressive { get; set; } = 1;
/// <summary>The goods total.</summary>
public decimal GoodsAmount { get; set; }
/// <summary>The services total.</summary>
public decimal ServicesAmount { get; set; }
/// <summary>The lines with something missing.</summary>
public int Problems { get; set; }
/// <summary>The name of the file written.</summary>
public string? FileName { get; set; }
/// <summary>The protocol given by the customs.</summary>
public string? Protocol { get; set; }
/// <summary>When it was generated.</summary>
public DateTime? GeneratedAt { get; set; }
/// <inheritdoc />
public bool IsDemo { get; set; }
}
/// <summary>A line of an Intrastat list (<c>intrastat_list_lines</c>).</summary>
public sealed class IntrastatListLine : Entity<long>, IDemoMarkable
{
/// <summary>The list.</summary>
public long ListId { get; set; }
/// <summary>The section.</summary>
public IntrastatSection Section { get; set; }
/// <summary>The family of the document.</summary>
public DocumentFamily? SourceFamily { get; set; }
/// <summary>The document.</summary>
public long? SourceDocumentId { get; set; }
/// <summary>The number of the document.</summary>
public string? DocumentNumber { get; set; }
/// <summary>The date of the document.</summary>
public DateOnly? DocumentDate { get; set; }
/// <summary>The customer or supplier.</summary>
public long? PartyId { get; set; }
/// <summary>The member state of the counterparty.</summary>
public string CountryCode { get; set; } = string.Empty;
/// <summary>The VAT number of the counterparty, without the country.</summary>
public string? VatNumber { get; set; }
/// <summary>The amount in euro.</summary>
public decimal Amount { get; set; }
/// <summary>The amount in the currency of the document, when not euro (purchases).</summary>
public decimal? CurrencyAmount { get; set; }
/// <summary>The statistical value in euro.</summary>
public decimal? StatisticalValue { get; set; }
/// <summary>The combined nomenclature code (goods, 8 digits) or the CPA code (services, 5-6 digits).</summary>
public string? NomenclatureCode { get; set; }
/// <summary>What was sold or bought.</summary>
public string? Description { get; set; }
/// <summary>The nature of the transaction (table B, such as <c>11</c>).</summary>
public string? TransactionNature { get; set; }
/// <summary>The delivery terms (Incoterms, such as <c>DAP</c>).</summary>
public string? DeliveryTerms { get; set; }
/// <summary>The mode of transport (1 sea, 2 rail, 3 road, 4 air, 5 post, 7 fixed installations, 8 inland waterway, 9 own propulsion).</summary>
public string? TransportMode { get; set; }
/// <summary>The net mass in kilograms.</summary>
public decimal? NetMass { get; set; }
/// <summary>The supplementary units.</summary>
public decimal? SupplementaryUnits { get; set; }
/// <summary>The country of origin of the goods (purchases).</summary>
public string? OriginCountry { get; set; }
/// <summary>The province of origin (sales) or destination (purchases).</summary>
public string? Province { get; set; }
/// <summary>How the service is supplied: <c>I</c> once, <c>R</c> repeated.</summary>
public string? SupplyMode { get; set; }
/// <summary>How it is paid: <c>B</c> transfer, <c>A</c> direct debit, <c>X</c> other.</summary>
public string? PaymentMode { get; set; }
/// <summary>The country of the payment.</summary>
public string? PaymentCountry { get; set; }
/// <summary>For corrections: the year of the list corrected.</summary>
public int? CorrectedYear { get; set; }
/// <summary>For corrections: the period of the list corrected.</summary>
public int? CorrectedPeriod { get; set; }
/// <summary>For corrections: the sign, <c>+</c> or <c>-</c>.</summary>
public string? CorrectionSign { get; set; }
/// <summary>What the check found.</summary>
public IntrastatCheck Check { get; set; }
/// <summary>Typed or changed by hand: generating again keeps it.</summary>
public bool Manual { get; set; }
/// <inheritdoc />
public bool IsDemo { get; set; }
/// <summary>Whether it goes into the file and the totals.</summary>
public bool Included => Check != IntrastatCheck.OutsideEu;
}