Menu ▾ ▴

#98 feat(dbt): ISO 4217 currency seed + FX validation (#91 part A)

closed
nobody
None
2026-06-24
2026-06-23
Anonymous
No

Originally created by: grynn-in

Part A of [#91] — the always-needed foundation. (Parts B & C tracked as remaining below.)

Problem

No ISO 4217 reference existed: from_currency / to_currency in silver_exchange_rates and entity accounting/reporting currencies were unvalidated free strings with no names.

This PR

  • seeds/currencies.csv — ISO 4217 reference (currency_code, currency_name, symbol, minor_unit), covering reserve / G20 / EU currencies plus every currency in the demo FX data (44 rows; extensible to the full ~180).
  • _seeds.yml — register currencies with unique + not_null on currency_code.
  • tests/assert_exchange_rate_currencies_are_iso.sql — every FX currency must be a known ISO code. Uses NOT IN (ClickHouse left joins fill a miss with '', not NULL). Verified 0 violations against the live demo (CHF/EUR/USD all covered).

Remaining on [#91] (follow-ups — issue stays open)

  • B. Read-only surface of D365 rates in the app (query silver_exchange_rates via the existing clickhouse.execute read pattern; join ISO names from this seed).
  • C. Manual Exchange Rate doctype → epm_staging.manual_exchange_rates, UNIONed into stg_exchange_rates as a new erp_source. Builds on the sync_doctype docstatus fix in grynn-in/konsol#48 (#92 [#1]) so it won't inherit the draft/cancel leak.

Verification

  • currencies.csv: 44 unique 3-letter codes, valid minor_units; _seeds.yml valid YAML.
  • Relationships query returns 0 rows on live epm_silver.silver_exchange_rates.
  • ⚠️ dbt seed/test run pending CI (isolated worktree, not the mounted project).

Refs grynn-in/konsolidat#91

🤖 Generated with Claude Code

Related

Tickets: #1
Tickets: #91

Discussion

  • Anonymous

    Anonymous - 2026-06-23

    Originally posted by: grynn-in

    Code review (×2 independent passes) — both SHIP, no changes

    Review A — ISO 4217 data accuracy: all 44 minor_unit values verified correct against ISO 4217 (zero-decimal CLP/ISK/JPY/KRW/VND; three-decimal BHD/KWD/OMR; the deceptive 2-decimal ones HUF/COP/TWD/IDR all right). No code/name typos. All G20 + the full SDR basket covered. No omissions.

    Review B — dbt/ClickHouse wiring: installed dbt-core 1.11.11 / dbt-clickhouse 1.10.0 → data_tests is the canonical key, so the unique/not_null tests do run (not silently skipped). column_types match the CSV header exactly; minor_unit UInt8-safe (0/2/3); singular test uses ref() so the seed builds first; union distinct + not in (subquery) valid ClickHouse. Consistent with existing seed config.column_types pattern.

    Note (no action): repo model schemas use legacy tests:; seeds had no prior test precedent, and both keys function identically on 1.11. No fixes required.

    Part A complete; [#91] stays open for B (read surface) + C (manual Exchange Rate doctype).

     

    Related

    Tickets: #91

  • Anonymous

    Anonymous - 2026-06-24

    Ticket changed by: grynn-in

    • status: open --> closed
     

Log in to post a comment.