feat: company tables, profile, fiscal years and base data (#38, #39, #45)

Adds the company tables of SPEC 11.1 behind one generic service so that every
table gets the same rules, history, cache and CSV import/export, plus the
company profile, fiscal years with monthly lock and the base-data seeder.

- 26 coded tables, exchange rates, company profile, fiscal years and periods:
  entities, maps and migrations 010-014
- TableService + TableCatalog: unique codes, per-table rules (VAT codes are
  checked by the fiscal pack), delete or disable when in use, single default,
  CSV export/import all-or-nothing, cache with cross-instance invalidation
- CompanyProfileService (Italian identifiers through the pack),
  FiscalYearService with the date check used by every dated record
- EcbRatesClient and the ECB rates system task; CsvReader
- ISeeder/SeedRunner with the data version in company settings; base tables
  from the pack (IBaseTablesTemplate) and an embedded ISO country list

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Alby96andClaude Opus 5.5 committed 2026-11-11 22:33:37 +01:00
1 parent 25f8a7ad30
commit 34e196424f
33 files changed
+6049 -3

No files matched your search

@@ -0,0 +1,110 @@
using Khaemhat.Data.Migrations;
using Khaemhat.Data.Schema;
namespace Khaemhat.Data.CompanyDatabase.Migrations;
/// <summary>VAT codes, payment methods and terms, bank accounts and salespeople (SPEC §11.1, mockup 076).</summary>
[Migration(20261111_012, "create_tax_and_payment_tables")]
public sealed class M20261111_012_CreateTaxAndPaymentTables : IMigration
{
/// <inheritdoc />
public void Up(ISchemaBuilder schema)
{
ArgumentNullException.ThrowIfNull(schema);
schema.CreateTable("tax_codes", t =>
{
t.Id();
t.String("code", 10).NotNull();
t.String("description", 100).NotNull();
t.Bool("disabled").NotNull().Default(false);
t.Decimal("rate").NotNull();
t.String("nature", 5);
t.String("kind", 40).NotNull();
t.String("exigibility", 40).NotNull();
t.Decimal("non_deductible_percent").NotNull();
t.String("legal_reference", 200);
t.Date("valid_from");
t.Date("valid_to");
t.String("sales_account_code", 20);
t.String("purchase_account_code", 20);
t.DemoColumn();
t.AuditColumns();
t.Unique("ux_tax_codes_code", "code");
});
schema.CreateTable("payment_methods", t =>
{
t.Id();
t.String("code", 10).NotNull();
t.String("description", 100).NotNull();
t.Bool("disabled").NotNull().Default(false);
t.String("e_invoice_code", 4).NotNull();
t.Bool("needs_bank").NotNull().Default(false);
t.DemoColumn();
t.AuditColumns();
t.Unique("ux_payment_methods_code", "code");
});
schema.CreateTable("payment_terms", t =>
{
t.Id();
t.String("code", 10).NotNull();
t.String("description", 100).NotNull();
t.Bool("disabled").NotNull().Default(false);
t.Int64("payment_method_id");
t.String("condition", 4).NotNull();
t.Bool("vat_on_first_installment").NotNull().Default(false);
t.DemoColumn();
t.AuditColumns();
t.Unique("ux_payment_terms_code", "code");
t.ForeignKey("fk_payment_terms_payment_method", "payment_method_id", "payment_methods", ReferentialAction.Restrict);
});
schema.CreateTable("payment_term_lines", t =>
{
t.Id();
t.Int64("payment_term_id").NotNull();
t.Int32("number").NotNull();
t.Int32("days").NotNull();
t.Bool("end_of_month").NotNull().Default(false);
t.Int32("fixed_day");
t.Decimal("percent").NotNull();
t.AuditColumns();
t.Unique("ux_payment_term_lines_payment_term_id_number", "payment_term_id", "number");
t.ForeignKey("fk_payment_term_lines_payment_term", "payment_term_id", "payment_terms", ReferentialAction.Cascade);
});
schema.CreateTable("bank_accounts", t =>
{
t.Id();
t.String("code", 10).NotNull();
t.String("description", 100).NotNull();
t.Bool("disabled").NotNull().Default(false);
t.String("bank_name", 100);
t.String("iban", 34);
t.String("bic", 11);
t.String("sia_code", 5);
t.String("cuc_code", 8);
t.String("account_code", 20);
t.Bool("is_default").NotNull().Default(false);
t.DemoColumn();
t.AuditColumns();
t.Unique("ux_bank_accounts_code", "code");
});
schema.CreateTable("salespeople", t =>
{
t.Id();
t.String("code", 10).NotNull();
t.String("description", 100).NotNull();
t.Bool("disabled").NotNull().Default(false);
t.String("email", 254);
t.String("phone", 30);
t.Decimal("commission_percent").NotNull();
t.Bool("enasarco").NotNull().Default(false);
t.DemoColumn();
t.AuditColumns();
t.Unique("ux_salespeople_code", "code");
});
}
}