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