feat: provinces and municipalities from the ISTAT list in the base data (#45)

New companies now get the 110 provinces and 7,894 municipalities in force
(ISTAT list of 26/02/2026, CC BY 4.0), so the tax code calculation and the
municipality lookups work without loading anything. The list lives in the
Italian pack behind a new IPlaceDirectory feature and is added by the base
seeder like the rest of the base data: missing codes only, never touching
existing rows. The pack data version moves to IT 2026.3 so existing
companies receive the lists at the next start.

Postal codes are left out: the only candidate source (comuni-json) has no
licence for them and stops at 2020 (ADR 0028).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Alby96andClaude Opus 5.5 committed 2026-11-12 09:07:12 +01:00
1 parent 07555de700
commit 321aae7e81
19 files changed
+8249 -25

No files matched your search

@@ -11,7 +11,8 @@ namespace Khaemhat.Application.Seeding;
/// The base tables of SPEC §14 available from M4: countries, currencies, units, VAT codes (from the fiscal pack),
/// payment methods and terms and document types (from the pack's <see cref="IBaseTablesTemplate"/>), transport tables,
/// warehouse reasons, the main warehouse, categories, the base price list, the numerators and the fiscal year of the
/// current year. Provinces, municipalities and banks come from datasets loaded separately (ADR 0026).
/// current year, and the provinces and municipalities of the pack's <see cref="IPlaceDirectory"/> (ADR 0028). Banks
/// come from a dataset loaded separately (ADR 0026).
/// </summary>
/// <param name="years">Creates the current fiscal year.</param>
public sealed class BaseTablesSeeder(FiscalYearService years) : ISeeder
@@ -58,6 +59,24 @@ public sealed class BaseTablesSeeder(FiscalYearService years) : ISeeder
{
ArgumentNullException.ThrowIfNull(context);
await context.EnsureAsync("countries", ReadCountries(), cancellationToken).ConfigureAwait(false);
if (context.Pack.GetFeature<IPlaceDirectory>() is { } places)
{
await context.EnsureAsync("provinces", places.Provinces.Select(p => new Province { Code = p.Code, Description = p.Name, Region = p.Region }), cancellationToken)
.ConfigureAwait(false);
await context.EnsureAsync(
"municipalities",
places.Municipalities.Select(m => new Municipality
{
Code = m.Code,
Description = m.Name,
ProvinceCode = m.ProvinceCode,
Region = m.Region,
IstatCode = m.StatisticalCode,
PostalCodes = m.PostalCodes,
}),
cancellationToken).ConfigureAwait(false);
}
await context.EnsureAsync("currencies", Currencies.Select(c => new Currency { Code = c.Code, Description = c.Name, Symbol = c.Symbol, Decimals = c.Decimals }), cancellationToken)
.ConfigureAwait(false);
await context.EnsureAsync("units_of_measure", Units(), cancellationToken).ConfigureAwait(false);