Menu ▾ ▴

#201 Closing periods translate at the year's last Regular period's rates; YTD-vs-annual on the declared calendar (konsolidat#199)

closed
nobody
None
2026-09-14
2026-09-14
Anonymous
No

Originally created by: grynn-in

Follow-up to [#200] (konsolidat#199), from the first full build on the stack after it merged.

What the build showed

  • The balance sheet no longer double-counts: for a parent's share-capital account the balance sheet's cumulative equals the declared year-end balance in every year (2010–2014 checked exactly), and each year's close posted in P13, netting to zero.
  • One error: gold_consolidated_trial_balance's governed-rate guard refused the close rows — "AED->USD FY2013 P13 missing", 205 currency-years — because no Group Exchange Rate exists for the Closing period. A Closing period has no market of its own.
  • One new warning: assert_ytd_p12_equals_annual on 10,643 rows — its "annual" summed the Closing period's close.

What changed

  • D9 — a Closing-type period translates at its fiscal year's last Regular period's rates. One macro, rate_period_map() (macros/governed_rates.sql), maps (fiscal_year, fiscal_period) → the period whose rates apply, from epm_staging.fiscal_periods; the guard requires the rate at that key and gold_consolidated_trial_balance joins rates on it. A period the calendar does not know maps to itself, so a genuinely missing rate still stops the build. Declared rule, not a fallback.
  • D10 — assert_ytd_at_last_regular_period_equals_annual (renamed, still warn): YTD at the year's last Regular period equals the sum of the year's non-Closing periods, both from the declared calendar (no hardcoded 12).

Evidence (test first, scratch schemas inside the stack)

  • D9 fixture (EUR entity, balance files for two years, rates at P12 only): on main the pre_hook fails EUR->USD FY2025 P13 missing (e5da529); with the map the model builds and the P13 rows carry P12's rates 1.1 / 1.05 (952d8b5). Must-flag: without FY2026 P12 rates the guard still refuses. Live clone of the stack's data: gold_consolidated_trial_balance builds, ERROR=0.
  • D10 fixture: WARN 1 on the old logic (f86f1d0) → PASS (724f900). Live clone: 0 rows (was 10,643).

🤖 Generated with Claude Code

https://claude.ai/code/session_013WewQKFQgG7o2M3mUDPRR5

Related

Tickets: #200
Tickets: #202

Discussion

  • Anonymous

    Anonymous - 2026-09-14

    Originally posted by: grynn-in

    Review round 1: no blocking findings; the hardening note taken — rate_period_map() now carries an explicit mapped flag and both the guard and the model branch on it instead of rate_period = 0 (an Opening period is legitimately P0). D9's three gates re-run: fixture builds (ERROR=0), must-flag still refuses, live clone builds (ERROR=0).

     
  • Anonymous

    Anonymous - 2026-09-14

    Ticket changed by: grynn-in

    • status: open --> closed
     

Log in to post a comment.