using Khaemhat.Core.Entities;
using Khaemhat.Core.Tax;
namespace Khaemhat.Core.Tables;
/// The data of the company itself, one row per company database (SPEC §11.1, mockup 075).
public sealed class CompanyProfile : Entity
{
/// The company name.
public string LegalName { get; set; } = string.Empty;
/// The name written on fiscal documents, when different.
public string? FiscalName { get; set; }
/// The VAT number, without the country prefix.
public string? VatNumber { get; set; }
/// The tax code.
public string? TaxCode { get; set; }
/// The province of the business register (REA).
public string? ReaOffice { get; set; }
/// The number in the business register (REA).
public string? ReaNumber { get; set; }
/// The share capital.
public decimal? ShareCapital { get; set; }
/// Sole shareholder: SU one, SM more; empty when it does not apply.
public string? Shareholders { get; set; }
/// Liquidation: LN not in liquidation, LS in liquidation.
public string? LiquidationStatus { get; set; }
/// The street.
public string? Address { get; set; }
/// The street number.
public string? StreetNumber { get; set; }
/// The postal code.
public string? PostalCode { get; set; }
/// The town.
public string? City { get; set; }
/// The province abbreviation.
public string? ProvinceCode { get; set; }
/// The country of the address (ISO 3166-1).
public string? AddressCountry { get; set; }
/// The phone.
public string? Phone { get; set; }
/// The e-mail address.
public string? Email { get; set; }
/// The certified e-mail address.
public string? Pec { get; set; }
/// The web site.
public string? Website { get; set; }
/// The tax regime, such as RF01.
public string TaxRegime { get; set; } = "RF01";
/// The company's own recipient code for incoming e-invoices.
public string? RecipientCode { get; set; }
/// The logo (an attachment of entity company_profile).
public long? LogoAttachmentId { get; set; }
/// The bank account proposed on documents.
public long? DefaultBankAccountId { get; set; }
/// The accounting currency (ISO 4217).
public string CurrencyCode { get; set; } = "EUR";
/// The country whose fiscal pack applies (ISO 3166-1), from KHAEMHAT_COUNTRY at creation.
public string Country { get; set; } = "IT";
/// The VAT settlement periodicity.
public VatPeriodicity VatPeriodicity { get; set; }
/// The deductible share for companies with exempt operations (pro-rata), in percent; 100 when it does not apply.
public decimal ProRataPercent { get; set; } = 100m;
/// VAT on cash basis (art. 32-bis DL 83/2012).
public bool CashVat { get; set; }
/// The first month of the fiscal year (1 for calendar years).
public int FiscalYearStartMonth { get; set; } = 1;
/// The transmitter of e-invoices, when not the company: country.
public string? TransmitterCountry { get; set; }
/// The transmitter of e-invoices: tax identifier.
public string? TransmitterId { get; set; }
/// The intermediary that sends the returns (LIPE, F24): name.
public string? IntermediaryName { get; set; }
/// The intermediary: tax code.
public string? IntermediaryTaxCode { get; set; }
/// The text printed at the bottom of documents.
public string? FooterNotes { get; set; }
}
/// The state of a fiscal year (SPEC §11.1, mockup 052).
public enum FiscalYearStatus
{
/// Entries allowed.
Open = 0,
/// Closing entries in progress: only closing entries.
Closing = 1,
/// Read only.
Closed = 2,
}
/// A fiscal year.
public sealed class FiscalYear : Entity
{
/// The code, such as 2026 or 2026/27.
public string Code { get; set; } = string.Empty;
/// The first day.
public DateOnly StartDate { get; set; }
/// The last day.
public DateOnly EndDate { get; set; }
/// The state.
public FiscalYearStatus Status { get; set; }
/// The first page number of the journal printed for this year.
public int JournalFirstPage { get; set; } = 1;
/// The number of the last final journal entry.
public long LastFinalEntryNumber { get; set; }
/// The date of the last final journal entry.
public DateOnly? LastFinalEntryDate { get; set; }
}
/// The state of a fiscal period.
public enum FiscalPeriodStatus
{
/// Documents and entries allowed.
Open = 0,
/// The VAT of the period was settled: no new entries with VAT.
Settled = 1,
/// Locked: no new documents or entries dated in the period.
Locked = 2,
}
/// A month of a fiscal year.
public sealed class FiscalPeriod : Entity
{
/// The fiscal year.
public long FiscalYearId { get; set; }
/// The number in the year, from 1.
public int Number { get; set; }
/// The first day.
public DateOnly StartDate { get; set; }
/// The last day.
public DateOnly EndDate { get; set; }
/// The state.
public FiscalPeriodStatus Status { get; set; }
}