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>
96 lines
3.3 KiB
C#
96 lines
3.3 KiB
C#
using Khaemhat.Data.Migrations;
|
|
using Khaemhat.Data.Schema;
|
|
|
|
namespace Khaemhat.Data.CompanyDatabase.Migrations;
|
|
|
|
/// <summary>Countries, provinces, municipalities, currencies, exchange rates and units of measure (SPEC §11.1).</summary>
|
|
[Migration(20261111_011, "create_geography_and_currencies")]
|
|
public sealed class M20261111_011_CreateGeographyAndCurrencies : IMigration
|
|
{
|
|
/// <inheritdoc />
|
|
public void Up(ISchemaBuilder schema)
|
|
{
|
|
ArgumentNullException.ThrowIfNull(schema);
|
|
schema.CreateTable("countries", t =>
|
|
{
|
|
t.Id();
|
|
t.String("code", 2).NotNull();
|
|
t.String("description", 100).NotNull();
|
|
t.Bool("disabled").NotNull().Default(false);
|
|
t.String("iso3", 3);
|
|
t.Bool("eu_member").NotNull().Default(false);
|
|
t.String("vat_prefix", 2);
|
|
t.String("currency_code", 3);
|
|
t.DemoColumn();
|
|
t.AuditColumns();
|
|
t.Unique("ux_countries_code", "code");
|
|
});
|
|
|
|
schema.CreateTable("provinces", t =>
|
|
{
|
|
t.Id();
|
|
t.String("code", 2).NotNull();
|
|
t.String("description", 100).NotNull();
|
|
t.Bool("disabled").NotNull().Default(false);
|
|
t.String("region", 60);
|
|
t.DemoColumn();
|
|
t.AuditColumns();
|
|
t.Unique("ux_provinces_code", "code");
|
|
});
|
|
|
|
schema.CreateTable("municipalities", t =>
|
|
{
|
|
t.Id();
|
|
t.String("code", 4).NotNull();
|
|
t.String("description", 100).NotNull();
|
|
t.Bool("disabled").NotNull().Default(false);
|
|
t.String("province_code", 2).NotNull();
|
|
t.String("region", 60);
|
|
t.String("istat_code", 6);
|
|
t.String("postal_codes", 400);
|
|
t.DemoColumn();
|
|
t.AuditColumns();
|
|
t.Unique("ux_municipalities_code", "code");
|
|
t.Index("ix_municipalities_description", "description");
|
|
t.Index("ix_municipalities_province_code", "province_code");
|
|
});
|
|
|
|
schema.CreateTable("currencies", t =>
|
|
{
|
|
t.Id();
|
|
t.String("code", 3).NotNull();
|
|
t.String("description", 100).NotNull();
|
|
t.Bool("disabled").NotNull().Default(false);
|
|
t.String("symbol", 5);
|
|
t.Int32("decimals").NotNull();
|
|
t.DemoColumn();
|
|
t.AuditColumns();
|
|
t.Unique("ux_currencies_code", "code");
|
|
});
|
|
|
|
schema.CreateTable("exchange_rates", t =>
|
|
{
|
|
t.Id();
|
|
t.String("currency_code", 3).NotNull();
|
|
t.Date("rate_date").NotNull();
|
|
t.Decimal("rate").NotNull();
|
|
t.String("source", 10).NotNull();
|
|
t.AuditColumns();
|
|
t.Unique("ux_exchange_rates_currency_code_rate_date", "currency_code", "rate_date");
|
|
});
|
|
|
|
schema.CreateTable("units_of_measure", t =>
|
|
{
|
|
t.Id();
|
|
t.String("code", 10).NotNull();
|
|
t.String("description", 100).NotNull();
|
|
t.Bool("disabled").NotNull().Default(false);
|
|
t.Int32("decimals").NotNull();
|
|
t.String("e_invoice_code", 10);
|
|
t.DemoColumn();
|
|
t.AuditColumns();
|
|
t.Unique("ux_units_of_measure_code", "code");
|
|
});
|
|
}
|
|
}
|