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