The rules the warehouse enforces
This page is a projection of the dbt test files, not a source. scripts/extract_assertion_rules.py in the konsolidat repository (konsol#305 V32) lifts the leading comment of every dbt_project/tests/assert_*.sql file into docs/design/rules.md; scripts/sync-from-repo.sh in the docs repository copies it here. Source last changed in konsolidat f728d59 (2026-11-08).
Do not edit this page by hand. Edit the test, run the script in the product repo, then run the sync.
Coverage: the script globs assert_*.sql at the top of dbt_project/tests/, which is 139 of the 144 singular tests. Not on this page (5 files, by path under dbt_project/): tests/staging/test_canonical_gl_entries_not_null.sql, tests/staging/test_canonical_gl_entries_schema.sql, tests/staging/test_canonical_gl_journals_balance.sql, tests/staging/test_dimension_mappings_unique.sql, tests/staging/test_erp_source_valid.sql. The testing guide lists all 144. Schema tests (not_null, accepted_values, unique, relationships in the models' YAML) are not singular tests and are not here either.
Generated by scripts/extract_assertion_rules.py. Do not edit this file —
edit the test it came from and run the script again.
Every rule below is a singular dbt test. Each one exists because a wrong number reached someone once. The test is the fix; this page is the reason, lifted out of the file so the set can be read as a body of knowledge rather than found one assertion at a time.
A rebuild that re-derived the models but not these rules would be a consolidation engine with every defect this one has already paid for.
| assertions | 139 |
| carrying their reasoning | 121 |
| citing the issue that caused them | 103 |
severity warn (reports, does not stop a build) | 22 |
severity error (stops the build, and its children) | 117 |
warn is not a weaker rule — it is a different kind. An error says the
number is wrong; a warning says it is unexplained. See konsol#247.
Contents
- Trial balance intake — 19
- Currency and translation — 22
- Ownership and the consolidated result — 21
- Acquisitions and disposals — 14
- Intercompany — 11
- Equity method — 4
- Cash flow — 3
- Reporting hierarchies — 8
- Budget, forecast and variance — 9
- The chart of accounts — 7
- Calendar and periods — 4
- Platform and data integrity — 14
- Other — 3
Trial balance intake
entity_has_one_amount_basis
An entity's claimed trial-balance batches all declare the SAME amount basis (konsolidat#199).
silver_tb_movements normalises each batch to period movements from its declared basis, and the rules for 'Year-to-date movement' and 'Period-end balance' difference a period against the entity's previous period. That difference only means something when both periods speak the same language: a balance minus a movement is nothing. The model does not try to reconcile a mixed history; it computes each period with that period's own basis, so a mix would be wrong quietly. This is an error: the build stops and names the entity and its bases until every batch declares one basis (re-upload the odd batches with the right one). Empty bases are not counted here; assert_tb_submission_has_basis names them.
<sub>error · tests/assert_entity_has_one_amount_basis.sql · konsolidat#199</sub>
entity_less_gl_bounded
<sub>warn · tests/assert_entity_less_gl_bounded.sql · konsolidat#105 konsolidat#110</sub>
every_tb_entity_has_a_currency
konsol#110 — every entity with trial-balance rows must resolve a currency.
gold_consolidated_trial_balance joins only entities whose currency silver_entity_currencies resolved, so an entity that is not in konsol's Entity master, or is in it with no Functional Currency, is left out of consolidation (konsolidat#255: there is no ERP fallback). Leaving it out is deliberate (joining it with '' would translate at the 1.0 parity fallback); this test is what stops that being silent. Replaces assert_tb_submission_entities_consolidatable, the interim guard F8 shipped: it checked submitted entities against silver_legal_entities alone, because the ERP was then the only place a currency could come from. Submitted batches are checked as well as gold_trial_balance, so an entity lost between bronze and gold is still caught. NOT IN rather than a LEFT JOIN: with join_use_nulls=0 an unmatched row fills with '' and where x is null never fires.
<sub>error (default) · tests/assert_every_tb_entity_has_a_currency.sql · konsol#110 konsolidat#255</sub>
fctb_entity_layer_ties
Entity layer in fully_consolidated_tb should tie to consolidated_trial_balance Sum of entity-layer amounts in FCTB must equal sum in consolidated TB
ted TB
<sub>error (default) · tests/assert_fctb_entity_layer_ties.sql</sub>
silver_gl_debit_credit_balance
Total debits should equal total credits across all GL entries.
tries. Since konsolidat#112, silver derives debit/credit from the SIGN of the (already-balanced) accounting amount, every voucher nets to zero by construction. Escalated to error (konsolidat#118) — verified PASS against live data 2026-06-29. An unbalanced entity now fails the governed build.
<sub>error · tests/assert_silver_gl_debit_credit_balance.sql · konsolidat#112 konsolidat#118</sub>
tb_movements_balance
Normalised trial-balance movements balance within every entity-period (konsolidat#199).
Every claimed batch balances (assert_tb_submission_batches_balance), and silver_tb_movements turns balances or year-to-date figures into period movements by differencing against the previous period over a spine that also carries the keys that vanished. A difference of two balanced sets is balanced, so a non-zero sum here means the spine or the differencing dropped or double-counted a key — an error that would unbalance every downstream statement. Aliases are defined once and reused — the displayed total is by construction the number the HAVING fired on.
<sub>error · tests/assert_tb_movements_balance.sql · konsolidat#199</sub>
tb_movements_cumulate_to_source
Normalised movements add back up to what the batch declared (konsolidat#199).
silver_tb_movements rewrites every batch as period movements from its declared amount_basis. Undoing that rewrite must give the source figure back, per key (entity, account, partner, <the declared dimensions>) and period: 'Period movement' movement = source net 'Year-to-date movement' running sum within the fiscal year = source net 'Period-end balance' running sum over every period = source net A key that vanished from a later batch has a row here only because the model's spine put one there (source net 0, movement minus the previous figure), and that row's running sum comes back to 0 as any other. This test judges the rows that exist; a spine that MISSED the vanished key would leave no row to judge, and it is assert_tb_movements_balance that catches that (the period no longer sums to 0). The synthetic year-end close of a period-end-balance file (PR 200 finding 1) passes for the same reason: its rows carry the post-close balance as source_net_amount (0 for a P&L key, the year's result added to retained earnings), so the running sum over every period still equals the source figure at each row. Rows whose basis is not one of the three strings are not judged here: assert_tb_submission_has_basis names them at the bronze layer and stops the build. konsol#255 row 7b — WHY THE RUNNING SUMS CARRY THE DIMENSIONS. Until 7b the two partitions below were (entity, account, partner) with no dimensions, which matched the model's own un-widened differencing. Once a file may split an account across declared dimension values (row 7a-1) and the differencing is keyed on the full key (row 7b), this test's row-level source_net_amount is ONE SLICE's figure while an un-widened running sum adds EVERY slice's movement — it compares 600 against 300 and calls a correct model wrong. Measured on 7a-2's fixture: the only movements that satisfy the un-widened cumulation there are the broken ones (slice A = its full figure, slice B = 0), i.e. the exact defect assert_tb_movements_difference_within_dimension exists to catch. So the partitions are widened with dim_partition_by over the dimensions var — never a literal column name. This makes the test STRICTER (it judges each slice on its own), and on a site that declares no dimensions it renders character-for-character what it rendered before. Tolerance 0.01, as for the other balance tests.
<sub>error · tests/assert_tb_movements_cumulate_to_source.sql · konsol#255 konsolidat#199</sub>
tb_movements_difference_within_dimension
A movement is differenced against the SAME dimension combination (konsol#255).
silver_tb_movements turns a 'Year-to-date movement' or 'Period-end balance' file into period movements by subtracting the previous period's figure for the key. Once a file carries declared dimension values, the key includes them: an account split across two cost centres is TWO series, and each period's figure belongs to one of them. KNOWN RED at konsol#255 row 7a-2. Both lagInFrame partitions in silver_tb_movements (previous_net_any_year, previous_net_same_year), its keys CTE and every join onto source are still keyed on (data_area_id, main_account, partner_data_area_id) with no dimensions — deliberately, see the grain note at the top of that model. So the two series are walked as one: a slice's figure is differenced against the OTHER slice's figure and every amount on the split account is wrong. Row 7b widens the partitions and this test turns green. Why the existing suite cannot see it. The differencing telescopes, so the error cancels within the (entity, account, partner) key: assert_tb_movements_cumulate_to_source runs its running sums on that same un-widened key and comes back exact, and a file whose slices net out across accounts still sums to zero per period, so assert_tb_movements_balance passes too. Both are measured to pass on this test's must_flag fixture. What is flagged. Per row, the previous figure the model used is exactly source_net_amount - movement_amount; the previous figure the FULL key implies is recomputed here with dim_partition_by over the declared dimensions. A row whose movement disagrees with the full-key figure by more than 0.01 is returned, with both previous figures and both movements side by side. predecessor_dimension_key is the un-widened window reconstructed over this model's output rather than its spine: it names the slice the row was differenced against, but two slices of one period are tied in that ordering, so treat it as an explanation and the two previous_net columns as the evidence. Quiet where it must be quiet. It is konsol's close-time suite that runs this (dbt test --select test_type:singular), on sites that declare no dimensions at all and on CI's fresh site: - no declared dimensions: the presence guard below returns the row-less branch, so nothing is computed and nothing can be flagged; - 'Period movement' files: not differenced at all, filtered out here; - an account that is not split: the full key and the un-widened key walk the same single series and agree. Out of scope, declared rather than silent: the synthesised year-end close. A 'year_end_close' row is computed on the un-widened key and carries BLANK dimensions at this commit, so it — and the first period differenced against it — would disagree with a full-key recomputation for a reason this test is not about. What a close per dimension value means is konsol#255 row 7b's decision; assert_year_end_close_declared / assert_year_end_close_carried judge the close itself. So exactly two things are left unjudged: the close rows, and the row whose predecessor IS a close row. They stay in both windows, so every other row's chain is the model's own. That exclusion is deliberately narrow because the alternative is not: measured on this warehouse's live silver_tb_movements, every one of its 36,665 activity rows is 'Period-end balance' and 41 of its 44 entities carry a close, so excluding a whole entity that has one would leave this test judging three entities and calling itself green. Tolerance 0.01, as for the other movement tests.
<sub>error · tests/assert_tb_movements_difference_within_dimension.sql · konsol#255</sub>
tb_submission_batches_balance
Every claimed trial-balance batch must balance: sum(debit) = sum(credit) within a small rounding tolerance.
konsol validates this before a submission can be submitted (on the SAME rounded-to-cents values that land here), so a failure means rows were landed or altered outside the doctype flow. Defense in depth for the one property that makes a trial balance a trial balance. Aliases are defined once and reused — the displayed difference is by construction the number the HAVING fired on.
<sub>error (default) · tests/assert_tb_submission_batches_balance.sql</sub>
tb_submission_has_basis
Every claimed trial-balance batch declares what its amounts ARE (konsolidat#199).
An ERP exports period movements, year-to-date movements or period-end balances, and the numbers alone cannot tell which. konsol writes the declared basis on the claim row (amount_basis); silver_tb_movements normalises each batch to period movements from it. A batch with no basis ('' — claimed before the column existed, or by another path) or with a value outside the three known strings cannot be normalised, and guessing would silently misstate every downstream balance. So this is an error: the build stops and names the batch until its basis is declared.
<sub>error · tests/assert_tb_submission_has_basis.sql · konsolidat#199</sub>
tb_submission_period_start_not_epoch
Guard against the join_use_nulls=0 default silently winning over the TBS coalesce fallback.
silver_gl_entries builds a synthetic GL row for every trial-balance submission (F8). Its accounting_date/document_date come from a LEFT JOIN from bronze_trial_balance_submissions to silver_fiscal_periods, coalesced to build_date_from_year_period() when the entity's fiscal calendar isn't loaded -- exactly the shape of a TB-only site, which has no ERP calendar at all (konsol#182). Under join_use_nulls=0 ClickHouse fills an unmatched LEFT JOIN with the joined column's type default, NOT NULL. Date's default is toDate(0) = 1970-01-01, so coalesce(sfp.period_start_date, ...) never falls through: every submission for an entity with no loaded calendar lands on 1970-01-01 instead of the first day of its own fiscal year/period. This test fails if any Trial Balance Submission row in silver_gl_entries carries the ClickHouse Date zero-value, which is never a legitimate posting date for a submitted batch.
<sub>error (default) · tests/assert_tb_submission_period_start_not_epoch.sql · konsol#182</sub>
tb_submission_rows_complete
Every claimed batch must hold exactly the row count its claim recorded.
The claim is written AFTER the rows land, carrying konsol's count — so a partial landing that somehow got claimed (or rows deleted/duplicated afterwards) shows up as a count mismatch here. This is the check the control table's row_count column exists to enable.
<sub>error (default) · tests/assert_tb_submission_rows_complete.sql</sub>
tb_submission_single_batch_per_period
At most ONE claimed batch per (entity, fiscal_year, fiscal_period).
Two claimed batches for the same entity-period flow ADDITIVELY into silver_gl_entries and gold sums them — each batch balancing individually, so no balance test can see the double-count. konsol refuses a second submission while one is submitted; this is the warehouse-side guarantee for rows that arrived any other way.
<sub>error (default) · tests/assert_tb_submission_single_batch_per_period.sql</sub>
topside_journal_balanced
PRD-5 Test: Each top-side journal must be balanced (debits = credits).
konsol#353 follow-up: the tolerance is one unit of the journal currency's minor unit (USD 0.01, BHD 0.001, JPY 1), not a flat 0.01. The materiality floor is currency-scaled (Deepak Pai, 18 Sep 2026, konsolidat#209; a flat default was rejected). The journal's currency is its group's reporting currency (the root row, data_area_id ''), and its minor unit is the currencies row konsol writes from ISO Currency. A journal whose group declares no reporting currency with a minor unit has nothing to be judged by, so it is reported (reason 'no currency'), never judged at a default. join_use_nulls=0 would read a missing minor unit as 0 (a tolerance of 1), so the two cases are a UNION ALL with an INNER JOIN and a NOT IN, never a LEFT JOIN.
<sub>error (default) · tests/assert_topside_journal_balanced.sql · konsol#353 konsolidat#209</sub>
trial_balance_balances
Sum of all debits should equal sum of all credits per entity/period D365 sandbox/demo data is often unbalanced, so warn rather than fail
n fail
<sub>warn · tests/assert_trial_balance_balances.sql</sub>
year_end_close_carried
The next year's file carries the result in the account the close posted it to (konsolidat#199, PR 200 re-review finding 2).
silver_tb_movements closes a period-end-balance year by moving the P&L balances into the chart's flagged retained-earnings account in the Closing period. The next year's first file must then list that account with the result in it. When it does not — the ERP keeps the result in another equity code, or the flag sits on the wrong account — the spine reads the flagged account as 0 in that first period and reverses the close as activity. The symptom: retained earnings shows minus the year's result at P1 while another equity code shows plus the result, and every statement still balances, so nothing else names it. One row per year-end close on the retained-earnings key whose entity's first claimed period after the close has no source row for that key (data_area_id, fiscal_year = the closed year, main_account). Warn severity: the figures are wrong for two equity lines, not for the build, and the fix is in konsol (flag the account the files really use) or in the upload, not in the warehouse.
<sub>warn · tests/assert_year_end_close_carried.sql · konsolidat#199</sub>
year_end_close_carries_no_cta
konsolidat#259 (option #259-1, decided by Deepak Pai, 6 Oct 2026): the year-end close moves amounts that are already translated, so it creates no exchange difference.
silver_tb_movements closes a period-end-balance year in the year's Closing period: every P&L key is reversed and the result moves into the retained-earnings account (posting_layer 'Year-end close' in silver_gl_entries). Translated naively, the reversal goes at the period's average rate and retained earnings at its own declared rate, so the close leaves -(the year's P&L) x (average - closing) in that period's CTA, which cancels the year's CTA and moves it into retained earnings every year. Under #259-1 retained earnings is credited with the year's TRANSLATED result, whatever the account's fx_method declares, and the P&L reversal returns each P&L key's translated year to exactly zero. So, for every (group, entity, Closing-type period) that carries a year-end close: | CTA of that period | <= 0.01 | the year's translated P&L, summed through that period | <= 0.01 It also names an ERP-POSTED close: a Closing period with no 'Year-end close' rows but P&L activity, whose CTA is not zero. The warehouse cannot tell such a close from ordinary activity, so it translates it as activity and does not guess; this test says where that happened. Warn severity (plan §3 R3): the consolidated statements still balance, the split between retained earnings and CTA is what is wrong. Kinds: year_end_close the synthesized close, checked on both conditions erp_posted_close P&L activity in a Closing period, checked on CTA
<sub>warn · tests/assert_year_end_close_carries_no_cta.sql · konsolidat#259</sub>
year_end_close_declared
Every period-end-balance year that must be closed can be closed (konsolidat#199, PR 200 finding 1;
re-review findings 1 and 3). A 'Period-end balance' file carries the year's P&L in its accounts until the year end; the next year's file starts them from zero, with the result moved into retained earnings — the ERP's year-end close, which the file never shows. silver_tb_movements re-creates that close as a synthetic post-close period in the fiscal year's Closing period (epm_staging.fiscal_periods, period_type = 'Closing'), posting the P&L balances to the chart's single retained-earnings account (silver_main_accounts.is_retained_earnings = 1). Without both it synthesizes nothing — and the next year's first period would then carry the reversal of the whole previous year's P&L as activity. So: one row per (entity, fiscal year) that NEEDS a close — its batches are period-end balances, a later fiscal year has data, and SOMETHING SITS IN A P&L ACCOUNT at the year's last claimed period (any P&L balance there is not 0 — not the net: silver_tb_movements closes every P&L key, so a year whose revenue and expenses cancel still needs its close; a balance-sheet-only entity, or a file that already zeroes its P&L, needs no close and is not held up by a missing Closing period or flag) — and LACKS a usable Closing period (none in the calendar for the year, or one that does not sort after the year's last claimed period: the close must post after the balances it closes) or a single retained-earnings account, with the reason. Error severity: the numbers downstream would be wrong for every P&L account of the next year.
<sub>error · tests/assert_year_end_close_declared.sql · konsolidat#199</sub>
year_end_close_invents_no_movement
The synthesised year-end close moves only what a close moves (konsol#255).
silver_tb_movements synthesises a post-close period for a 'Period-end balance' entity-year (PR 200 finding 1). By its own design — the grain note at the top of that model — the close period carries the last claimed period's balances with the P&L keys set to 0 and the year's result added to retained earnings. So exactly THREE kinds of movement may come out of it: - a P&L key, reversed (silver_main_accounts.is_pnl = 1) - the retained-earnings key, partner '' (is_retained_earnings = 1) - every other key: the SAME figure it already had, which differences to 0 and is dropped again This test judges the third kind. A 'year_end_close' row on a non-P&L, non-retained key that carries a movement is a balance the close INVENTED: no file ever claimed it, and it is added to the account's cumulative balance for every period that follows. RED at konsol#255 row 14, GREEN at row 17. Row 7b widened the differencing windows with the declared dimensions but left the close computed on the un-widened key and carrying BLANK dimension values, and the two halves contradicted on an account that a file splits across dimension values: close_source summed that account back to its WHOLE balance, while the widened lagInFrame differenced the blank-dimensioned close row against the blank SLICE's previous figure — zero, because a split account has no blank slice. The close emitted the whole balance as a movement out of nothing. Measured on assert_year_end_close_invents_no_movement.must_flag.sql (the dimensioned twin of silver_tb_movements.year_end_close.sql): account ZZ1000, split 60/40 across two declared dimension values and unchanged between FY2024 P12 and FY2025 P1, got a close row of source 100 / movement +100 and cumulated to 200 against a stated balance of 100. Row 17 put close_spine on the same widened key as every other row; the same fixture now emits no close row for ZZ1000 at all and it cumulates to 60 + 40 = 100. What a close does per dimension value is settled: the year's result moves into retained earnings as ONE undimensioned lump (decision of 23 September 2026, Deepak Pai, konsol#255 — the OFF default of Dimension.survives_close). This test does not rest on that answer: it only says that whatever the close does, it may not create a balance the source never stated, and it would hold just as well if the lump were dimensioned. Why the existing suite cannot see it. The invented rows come in pairs that net to zero whenever the split assets have split liabilities behind them (they are the same balances, differenced the same wrong way), so the entity-period still sums to zero and assert_tb_movements_balance passes. assert_tb_movements_cumulate_to_source runs its running sums on the FULL key, and the invented row is the only row of the blank slice, so its running sum equals its own source figure — exact, and green. assert_tb_movements_difference_within_dimension excludes 'year_end_close' rows and their successors, deliberately and in writing. All three were measured green on this test's fixture while it was red. NOT judged here, and the other symptom of the same contradiction: a P&L account that a file SPLITS across dimension values was never reversed at all (its blank close row was 0 against a blank predecessor of 0 and was dropped), so the next year's first period read last year's result as activity. That is an under-close, not an invention, and it is caught by assert_tb_movements_balance — the close period was short by the result and the next first period long by it. Its fixture is assert_tb_movements_balance.split_pnl_close.must_flag.sql, added at row 17. Quiet where it must be quiet, by construction rather than by a guard: - a site that declares no dimensions: every key has one series, so the close row and the balance it carries sit in the same window partition and difference to 0 — there is nothing to return. No dimensions guard and no dimension column is referenced, so this test renders identically whatever the var holds; - a 'Period movement' or 'Year-to-date movement' entity: no close is synthesised for it at all; - an entity whose accounts are not split: same single series as above. Tolerance 0.01, as for the other movement tests.
<sub>error · tests/assert_year_end_close_invents_no_movement.sql · konsol#255</sub>
Currency and translation
bs_translated_at_closing_rate
konsolidat#257: a balance-sheet balance is translated at the CLOSING rate of the reporting date (IAS 21.39(a)), not as the sum of each period's movement at that period's own closing rate.
gold_consolidated_trial_balance keeps the movement grain: one row per (group, entity, period, account, partner, dimensions) carrying that period's translated movement. Every reader sums those movements to get a balance. So for every key of a balance sheet account that is translated at the closing rate, the translated movements summed to period p must equal the local movements summed to p times p's closing rate: | sum(translated_amount to p) - sum(local_amount to p) x closing(p) | <= 0.01 Which keys: a balance sheet account (is_balance_sheet = 1) that is not equity (is_equity = 0; equity is never revalued, decided on #257 Q2, 6 Oct 2026) and whose chart declares fx_method = 'closing' or declares nothing (an undeclared account translates at the closing rate). An account declared 'average' or 'historical' is out of scope. The declaration comes from the chart (silver_main_accounts), not from the rate the row happens to carry. Which periods: EVERY period in which the entity has any row for the group (the entity's spine), from the key's first row on - not only the periods the key itself moved in. A balance that did not move in a period still has to be retranslated there; checking only the key's own rows would miss exactly that case. The closing rate of a spine period is read from the entity's rows in that period (one currency pair per entity and group, so one closing rate). Same-currency entities translate at 1.0 and are skipped.
<sub>error (default) · tests/assert_bs_translated_at_closing_rate.sql · konsolidat#257</sub>
conversion_factor_known
Every ConversionFactor value must be one the D365 adapter resolves.
The adapter's else-branch passes an unrecognised factor through unscaled — the exact silent-scaling failure class of #138, one enum value away. This test turns that into a build failure instead. Extend the adapter's multiIf AND this list together when D365 grows a new display factor.
<sub>error (default) · tests/assert_conversion_factor_known.sql · konsolidat#138</sub>
cta_not_zero_when_rates_differ
PRD-2 Test: CTA must be non-zero when an entity-period translated at more than one rate.
What CTA is: gold_fx_revaluation.cta_amount is the residual of currency translation, -sum(group_amount) per entity-period. Balance-sheet rows translate at the closing rate, P&L rows at the average rate and (with an approved Historical Equity Rate) equity rows at that historical rate. Because the local trial balance sums to zero, the translated one only fails to sum to zero when more than one rate was applied; that gap is the CTA. When CTA must be non-zero: an entity-period in which at least one row translated at a rate other than its closing_rate. A zero CTA there means gold_fx_revaluation lost the residual, and this test flags it. Why a rate difference alone is not enough: closing_rate != average_rate only says two rates were available. A balance-sheet-only entity (no P&L rows, no historical equity rate) translates every row at closing_rate, so its CTA is 0 by construction and must not be flagged (konsolidat#195). Since konsolidat#176 a missing historical equity rate is a warning, not an error, and such equity rows fall back to the closing rate, which makes balance-sheet-only entities with CTA 0 a normal case. Hence the extra countIf(translation_rate != closing_rate and group_amount != 0) > 0 condition below (a row that put nothing into the group translated nothing, whatever its rate). konsolidat#259 (option #259-1, 6 Oct 2026): an entity-period that carries the year-end close silver_tb_movements synthesizes is not checked. Its P&L reversal translates at the average rate, but retained earnings takes exactly the translated result, so its CTA is 0 by construction; assert_year_end_close_carries_no_cta requires that 0.
<sub>error (default) · tests/assert_cta_not_zero_when_rates_differ.sql · konsolidat#176 konsolidat#195 konsolidat#259</sub>
cta_recycled_on_disposal
CTA must be recycled to P&L on disposal (IAS 21.48).
(IAS 21.48). konsolidat#198 (row J6b): rewritten to read epm_staging.business_disposals instead of ownership_periods, and gold_business_disposal_journal instead of gold_disposal_adjustments. Why: since konsolidat#198 the disposal lives on the submitted Business Disposal document (submit = approval), and gold_business_disposal_journal recycles the disposed entity's accumulated CTA as its cta line (account_role 'cta', main_account 'CTA'); gold_disposal_adjustments, which posted the one-sided 'cta_recycling' row this test used to look for, is gone. The Ownership Period only carries the effective share and the consolidation window, so an is_disposal Ownership Period is no longer a deal the warehouse must account for (on the stack the deals are still Drafts: nothing submitted). Flags a submitted disposal of an entity whose accumulated CTA in the group, from gold_fx_revaluation up to and including the disposal period, is not zero, when the disposal journal has no cta line. The disposal period is the calendar period (epm_staging.fiscal_periods, start_date <= date <= end_date, Closing periods skipped) holding the disposal date, exactly as the journal maps it, and the CTA is summed by (fiscal_year, fiscal_period) tuple, never by date or month. A disposal with a retained interest posts no journal at all, so a non-zero CTA names it here as well as in assert_disposal_gain_loss_exists. A disposal date outside the declared calendar has no period and is not checked here (row J7's guard names it). A same-currency entity's CTA is 0 and is never owed.
<sub>error (default) · tests/assert_cta_recycled_on_disposal.sql · konsolidat#198</sub>
cta_zero_for_same_currency
PRD-2 Test: CTA must be zero when entity currency = reporting currency
<sub>error (default) · tests/assert_cta_zero_for_same_currency.sql</sub>
deal_rate_resolved
konsolidat#198 (row J9;
PR #203 review 3 + 4): a submitted deal that needs a governed Closing rate the group has not published for its period. gold_business_combination_journal and gold_business_disposal_journal INNER JOIN every rate they translate at, so such a deal posts NOTHING (never a 0: a LEFT JOIN miss read 0 under join_use_nulls = 0 and booked a false bargain gain, or goodwill = consideration, or a false disposal loss). Silence is not an answer either: this test stops the build and names the pair. One row per submitted deal and (from_currency, to_currency) it needs with no Closing rate for its period. Fixture: dbt_project/test_fixtures/assert_deal_rate_resolved.must_flag.sql. The currencies a deal needs, exactly the ones the journals translate: the entity's accounting currency (epm_staging.entities; '' when the entity is not in the registry, and that is reported as such): the acquired balances, the opening balances, the derecognised balances each consideration / acquisition-costs / proceeds line's own currency the header's consideration_currency / proceeds_currency, when the document has no consideration (proceeds) lines and the header amount is not zero (the journals fall back to the header figure then). Row J13 (PR #203 second review 1): the acquisition-costs lines do NOT count here — the journal's consideration_line_count reads only business_combination_consideration, so a combination with a header amount, no consideration line and one cost line falls back to the header and needs its rate; counting the cost row as "a line" left that header unchecked while the journal dropped the deal silently. Fixture: dbt_project/test_fixtures/assert_deal_rate_resolved.header.must_flag.sql. a combination's consideration_currency when it measures NCI at 'full' and share_acquired_pct < 100 (konsol#204, row M2b): the journal translates the declared NCI fair value at that currency's rate and drops the deal when it is missing, even when every consideration line is in another currency. Row M4 (PR #205 review): whatever nci_fair_value says, exactly the journal's condition. Fixtures: dbt_project/test_fixtures/assert_deal_rate_resolved.nci_fair_value.must_flag.sql, dbt_project/test_fixtures/assert_deal_rate_resolved.nci_fair_value_zero.must_flag.sql. into the group's reporting currency (the root row of epm_gold.consolidation_groups), for the deal's period: epm_staging.fiscal_periods by start_date <= date <= end_date (Closing periods skipped), then rate_period_map() (so a Closing period would ask for its year's last Regular period's rates, as every trial-balance translation does). A currency equal to the group currency translates at 1 and needs no rate. Scope follows the journals: every submitted Business Combination; a Business Disposal with retained_interest_pct = 0 (a disposal that keeps an interest posts nothing and is named by assert_disposal_gain_loss_exists). A deal whose group has no root row or whose date is outside the declared calendar has no period to look a rate up for; assert_acquisition_accounts_declared names those. Reported: deal, kind ('business_combination' | 'business_disposal'), from_currency, to_currency, and the deal's fiscal_year / fiscal_period. NOT IN rather than a LEFT JOIN null test (join_use_nulls = 0).
<sub>error (default) · tests/assert_deal_rate_resolved.sql · konsol#204 konsolidat#198 konsolidat#203 konsolidat#205</sub>
declared_historical_has_a_rate
<sub>warn · tests/assert_declared_historical_has_a_rate.sql · konsol#374 konsolidat#213 konsolidat#218 konsolidat#92</sub>
equity_historical_rate_is_asof
grynn-in/konsolidat#92 finding #2: the historical equity rate applied to a period must be the AS-OF rate (the latest tranche whose rate_date <= period_date), not the most-recent-ever rate.
The previous row_number()/rn=1 join ignored period_date, so an early period could get a future tranche's rate. The existing assert_equity_uses_historical_rate test only checks that a historical rate was used, not the correct-period one — this asserts the period correlation. konsol#374 (Deepak Pai, 7 Nov 2026, option b): a Historical Equity Rate converts INTO one presentation currency (to_currency). A sub-group that presents in EUR and its parent that presents in USD each need their own rate for the same entity and account, and the model matches a rate on the consolidating group's reporting_currency. The expected rate here is therefore resolved exactly as the model resolves it: on the entity's OWNING group (gold_entity_ownership.owner_group, where the rate is recorded once), the entity, the account, AND the row's reporting currency. Keyed on the consolidating group alone, a multi-level tree never matched a rate recorded under the sub-group; keyed without the currency, two tranches for two presentation currencies were one as-of series and the later one won at both levels. Fails (returns rows) when, for a row that applied a historical rate: * no tranche into the row's reporting currency qualifies as-of the period (rate borrowed from the future, or from another currency's series), or * the applied rate differs from the as-of expected rate.
<sub>error (default) · tests/assert_equity_historical_rate_is_asof.sql · konsol#374 konsolidat#92</sub>
equity_rate_coverage
<sub>warn · tests/assert_equity_rate_coverage.sql · konsolidat#104 konsolidat#120 konsolidat#176 konsolidat#232</sub>
equity_uses_historical_rate
PRD-10 Test: an account the chart DECLARES at the historical rate must be translated at that rate (not the closing rate).
konsolidat#213: the declaration is uses_historical_rate (fx_method = 'historical'), not is_equity — is_equity says what the account IS (account_type = 'Equity'), which is konsol's deal-layer meaning and decides nothing about translation. This test always meant the declaration.
<sub>error (default) · tests/assert_equity_uses_historical_rate.sql · konsolidat#213</sub>
every_translated_currency_has_a_governed_rate
<sub>warn · tests/assert_every_translated_currency_has_a_governed_rate.sql · konsol#103 konsolidat#93</sub>
exchange_rate_currencies_are_iso
grynn-in/konsolidat#91: every currency code used in FX must be a known ISO 4217 code present in the currencies seed.
from_currency / to_currency are otherwise unvalidated free strings — a typo or an unmapped code silently mis-translates (or drops to the 1.0 fallback) instead of failing the build. Uses NOT IN (not a left-join null check): ClickHouse left joins fill a miss with the column default ('') rather than NULL when join_use_nulls=0. konsol#182: no ERP quotes built (a trial-balance-only site, or a selection that does not build silver_exchange_rates) means nothing to check.
<sub>error (default) · tests/assert_exchange_rate_currencies_are_iso.sql · konsol#182 konsolidat#146 konsolidat#91</sub>
exchange_rate_positive
All exchange rates must be positive after silver cleaning
eaning
<sub>error (default) · tests/assert_exchange_rate_positive.sql</sub>
exchange_rate_sane_magnitude
<sub>warn · tests/assert_exchange_rate_sane_magnitude.sql · konsol#182 konsolidat#138 konsolidat#174 konsolidat#176 konsolidat#93</sub>
fx_magnitude_cases
The shared FX magnitude cases (konsolidat#176 / konsol #174).
The SAME case table runs through konsol's konsol.group_rates.magnitude_problem, so the two implementations of the rule cannot drift. Keep the VALUES below aligned with konsol's list, case for case. Rule (macros/fx_magnitude.sql): a currency has no reference when isNaN(usd_log10) OR (usd_log10 = 0 AND currency_code != 'USD'); a rate is plausible when abs(log10(rate) - (usd_log10(to) - usd_log10(from))) <= 1 (fx_is_implausible). The model's guard uses the same fx_is_implausible, so this test covers the rule that refuses builds too. expected: ok | implausible | no_reference | invalid. Reads no model or source, so it cannot skip anything; it runs wherever dbt test / dbt build runs (CI only parses the project).
<sub>error (default) · tests/assert_fx_magnitude_cases.sql · konsolidat#174 konsolidat#176</sub>
governed_rate_grain_unique
<sub>warn · tests/assert_governed_rate_grain_unique.sql · konsol#103 konsolidat#176</sub>
governed_rate_sane
<sub>warn · tests/assert_governed_rate_sane.sql · konsol#103 konsolidat#138 konsolidat#174</sub>
historical_is_equity_only
konsolidat#92, finding 4 — the half the warehouse owns.
konsol translates and does not remeasure. fx_method = 'historical' is therefore an Equity-only declaration: an Asset or Liability carried at the rate of the day it arrived would be remeasurement (IAS 21's non-monetary treatment), which this product does not do. konsol#239 refuses any such declaration at publish, so a chart governed today cannot carry one. A stack whose chart predates that guard still can, and that is what this test is for. The damage is not that the number is wrong in an obvious way: gold_consolidated_trial_balance applies a historical rate only where the chart declares one, so a Historical Equity Rate keyed to a non-equity account is simply never applied and the balance quietly falls back to the closing rate. Silent is the problem. This names the declaration instead. Error, not warn. assert_equity_rate_coverage warns because every row it returns is master data with a defined fallback (equity with no historical rate translates at closing, which is a decision, not a mistake). A historical declaration on a non-equity account has no such reading: it is a wrong declaration, and the fallback it lands on is not what the chart asked for. Nothing downstream can repair it, so the build should stop. GREEN requires every account declaring historical to be typed Equity — the konsolidat#213 invariant, uses_historical_rate = 1 implies is_equity = 1. is_equity is what the account IS (account_type = 'Equity'); uses_historical_rate is what the chart DECLARES (fx_method = 'historical'). Two kinds of offender, one row each, the assert_staging_not_stale shape: DECLARATION — the chart itself, an account typed non-equity that declares historical. One row per account. RATE — a Historical Equity Rate someone entered against an account that is not equity. The chart is where the damage is, but the rate is the row a user typed and expects to see honoured, and it can outlive the declaration that made it plausible (retype the account and the rate simply stops mattering, still sitting there). It is never applied either way, so name it too. One row per rate row, tranches included: each is a separately entered rate that does nothing.
<sub>error (default) · tests/assert_historical_is_equity_only.sql · konsol#239 konsolidat#213 konsolidat#92</sub>
nci_plus_group_equals_translated
PRD-4 Test: group_amount + nci_amount must equal translated_amount
<sub>error (default) · tests/assert_nci_plus_group_equals_translated.sql</sub>
translated_amount_formula
PRD-1 Test: translated_amount must equal local_amount × translation_rate + retranslation_amount.
konsolidat#257: a balance sheet key declared at closing also carries its retranslation, cum_local(prev) × (closing(p) − closing(prev)), on its own row; every other row carries 0.
<sub>error (default) · tests/assert_translated_amount_formula.sql · konsolidat#257</sub>
translation_follows_fx_method
<sub>warn · tests/assert_translation_follows_fx_method.sql · konsol#182</sub>
translation_rate_resolved
grynn-in/konsolidat#109, #194 — every consolidated row must carry a resolved FX rate.
Two failure modes, both of which silently misstate translated balances: 1. translation_rate = 0 — a LEFT-join miss defaulted the rate column to 0 (join_use_nulls=0) and the entity's translated/group/nci amounts collapse to $0. (The original #109.) 2. translation_rate IS NULL — defensive: a Nullable rate that escaped every rate branch would evade a bare = 0 check (NULL = 0 -> NULL). A cross-currency row translating at exactly 1.0 is NOT a failure (#194): near-parity pairs are quoted to 3 decimals, so 1.000 is a legitimate approved rate. The model has no parity fallback — a translated currency with no approved rate stops the build (throwIf in gold_consolidated_trial_balance) before this test runs — so 1.0 here can only be a real quote. A green result means every entity/period translated with a resolved rate.
<sub>error (default) · tests/assert_translation_rate_resolved.sql · konsolidat#109 konsolidat#194</sub>
Ownership and the consolidated result
all_layers_present
PRD-22: no consolidation layer the models computed is lost on its way into gold_fully_consolidated_tb, and none appears there without its source.
Decided by Deepak Pai, 6 Oct 2026: konsolidat#238 option #238-4, at error severity. It supersedes #238-1, which conditioned the layers on declarations (Published IC accounts, partner membership, more than one currency). A review of PR #261 measured that this did not match the models: an unmatched IC pair, with no ic_difference_account, is eliminated by nothing, and CTA does not depend on how many currencies the group has. Whether an elimination SHOULD exist stays with gold_ic_reconciliation and gold_ic_unmatched. Rejected: #238-1 as worded, and #238-2 (warn and keep asserting all four). A layer must appear for a group exactly when its source model has rows for that group. Each source is mapped to the adjustment_type gold_fully_consolidated_tb gives it: - entity: gold_consolidated_trial_balance (layer 1); - ic_elimination: gold_ic_eliminations, elimination_view 'group' (layer 2). The 'nci' kind lands as ic_elimination_nci. Every other kind, including unrealized_profit from ic_elimination_rules, lands as ic_elimination. NCI-view rows never enter the consolidated TB; - topside: gold_consolidation_adjustments, adjustment_type 'topside' (layer 4 passes adjustment_type through); - cta: gold_fx_revaluation (layer 3). Every model carries the group in consolidation_group. Two directions, one row per (group, layer): - missing_layer: the source has rows, the consolidated TB has none; - unexpected_layer: the consolidated TB has the layer, the source has no rows (a stale or misattributed layer). konsolidat#238 / #249: NOT IN, not a LEFT JOIN. adjustment_type is a String, and under join_use_nulls = 0 (the server default; a singular test carries no settings clause) an unmatched LEFT JOIN fills it with '' rather than NULL. The former where actual.layer is null therefore matched nothing, and the test could never fail.
<sub>error (default) · tests/assert_all_layers_present.sql · konsolidat#238 konsolidat#249 konsolidat#261</sub>
consolidated_cf_reconciles
Phase 6.1 Test (AC#5): at group grain, per consolidation_group / fiscal_year / fiscal_period, the sum of Operating + Investing + Financing cash flows must equal the net change in (translated) cash — the movement of is_cash = 1 accounts across all consolidation layers — within +/- 0.01.
This end-to-end tie holds ONLY when the fully consolidated trial balance balances for that group/period (Σ amount = 0). The cash-flow model is built as cash_flow_amount = −amount over every non-cash account, so by the double-entry identity total_activity = −Σ(non-cash) = Σ(cash) PRECISELY when Σ(all amount) = 0. When the consolidated TB does NOT balance, total_activity absorbs the imbalance and cannot tie to cash — but that is an upstream consolidation defect, not a cash-flow-model bug, and it is asserted separately by assert_end_to_end_bs_balances. We therefore gate this tie on a balanced TB: groups whose consolidated BS does not balance are excluded here (caught by that assertion + the FX/CTA bug it tracks) and re-enter this test automatically once the consolidated TB balances. The model's own correctness (no account dropped or mis-signed) is what keeps the residual exactly equal to the TB imbalance.
<sub>error (default) · tests/assert_consolidated_cf_reconciles.sql</sub>
consolidation_group_root_unique
konsolidat#198 (design §1, row J10;
PR #203 review 6): a consolidation group with more than one root row in epm_gold.consolidation_groups (data_area_id = ''). The root row is where konsol syncs the group's reporting currency, the deal policy and the deal accounts; the three deal journals (gold_business_combination_journal, gold_goodwill_amortisation_journal, gold_business_disposal_journal) read it through their group_policy CTE. Since row J10 that CTE aggregates the root row with any() per column, so a duplicate can no longer double every line of every journal (the failure this test was written against: 10 acquisition lines instead of 5, still summing to 0, so no balance test saw it), but any() picks one of the rows arbitrarily: if the two disagree, the policy the journals apply is undefined. Error severity: the build stops and names the group. Fixture: dbt_project/test_fixtures/assert_consolidation_group_root_unique.must_flag.sql.
<sub>error (default) · tests/assert_consolidation_group_root_unique.sql · konsolidat#198 konsolidat#203</sub>
draft_excluded_from_consolidated
PRD-16 Test: Draft adjustments must never appear in the consolidated adjustments
<sub>error (default) · tests/assert_draft_excluded_from_consolidated.sql</sub>
effective_ownership_in_range
PRD-8 / F2 / konsol#117: a resolved ownership share is a fraction between 0 and 1, and the direct links into an entity's node sum to at most 1.
Was "gold_consolidation_hierarchy.effective_ownership_pct is between 0 and 100" — a column that held the DIRECT percentage despite its name, and which F2 deleted along with the second grain it represented. Until konsol#117 this test also asserted effective <= direct: true for one chain, where every further link can only shrink the share, and false for a graph, where a second path adds to it (shape 1: direct links into D sum to 0.80, the effective share at P is 0.68, at A it is 0.60 — but P→A 80% and P→D 20% with A→D 100% would give effective 1.0 against a direct 1.0, and three paths can put effective above any single direct link). What holds for a graph: eff(G, E) <= 1 (konsol refuses issued shares past 100%, validate refusal 4), and direct_ownership_pct — the sum of the DISTINCT links into E's node — is at most 1 for the same reason.
<sub>error (default) · tests/assert_effective_ownership_in_range.sql · konsol#117</sub>
effective_ownership_is_path_sum
konsol#117: the effective share is the SUM over paths of the PRODUCT of each path's dated link percentages.
Replaces assert_effective_ownership_is_chain_product, which took one product over every link of a (group, entity) and so would have multiplied two paths into each other (shape 1: 0.8 x 0.6 x 0.2 = 0.096 instead of 0.48 + 0.20 = 0.68). Independent of the model's arithmetic: gold_entity_ownership uses arrayProduct over a groupArray per path and sum across paths; this recomputes each path as exp(sum(log(...))) keyed on path_id, straight from the ancestry closure and the periods, then sums, so a bug in either aggregation shows up as a disagreement rather than cancelling out. A link is matched on BOTH its nodes (owned and owner), as the model does: two owners of one node are two links. A (group, entity, period) with an unresolved link on any path is skipped (the has_complete_chain / window case is assert_ownership_chain_complete's), and so is one with a zero link (log(0) is undefined). Fixtures: assert_effective_ownership_is_path_sum.direct_plus_indirect.sql (+ .must_flag), .indirect_associate.sql, .single_chain.sql.
<sub>error (default) · tests/assert_effective_ownership_is_path_sum.sql · konsol#117</sub>
end_to_end_bs_balances
PRD-22 Test: the fully consolidated trial balance must balance end to end — total debits ≈ total credits across ALL layers (entity translation + IC elimination + CTA + topside + equity method + acquisition/disposal).
This sums every account, not just balance-sheet ones. gold_fully_consolidated_tb is a per-period MOVEMENT trial balance, so the balance-sheet movements alone do NOT net to zero — they net to the period's net income (which lives in the open P&L accounts, not yet closed to equity). The meaningful double-entry invariant is therefore that the WHOLE TB nets to zero: every asset/liability/equity movement has its counterpart somewhere in the same TB (the P&L that drives equity, plus the CTA that absorbs the FX translation difference). When this holds, the consolidated balance sheet and cash flow tie. The earlier BS-only form passed only because every group consolidated to zero (rate/ownership bugs); it never actually exercised this invariant.
<sub>error (default) · tests/assert_end_to_end_bs_balances.sql</sub>
entity_in_one_consolidation_node
F2: an entity must be a node of the consolidation tree exactly once.
Consolidation Group's autoname is CG-{consolidation_group}-{data_area_id}, so CG-GROUP_CORP-DEMF and CG-GROUP_EMEA-DEMF could coexist — and the live stack had exactly that shape after a stray dbt seed. Before F2 each node simply fed its own group. Now the ancestry closure emits a full chain per (ancestor, entity) pair for BOTH nodes, so any shared ancestor consolidates the entity twice, and gold_entity_ownership — which groups on (group, entity, period) — merges the two chains' links into a single meaningless product. konsol refuses this at save time (ConsolidationGroup._validate_entity_in_one_node); this catches data that predates the guard or arrived another way.
<sub>error (default) · tests/assert_entity_in_one_consolidation_node.sql</sub>
group_amount_formula
PRD-1 Test: group_amount must equal translated_amount × ownership_pct
<sub>error (default) · tests/assert_group_amount_formula.sql</sub>
hierarchy_rollup_ties
A group node's amount must equal the sum of its descendant leaves for the same slice: hierarchy, node, entity, period, account and every other dimension.
Compared per account, not per node total: a voucher that balances inside one dimension value nets a node's total to 0, and a totals-only check would pass on a wrong rollup. konsolidat#220: the tree is resolved per period. A leaf row of gold_tb_at_hierarchy_node counts towards a group only through the closure link whose window (valid_from .. valid_to) covers the period's end_date (declared calendar, epm_staging.fiscal_periods; a period the calendar does not list is judged at the last day of its month). So a moved leaf is counted once, under the parent it had then, and an ended group gets nothing later. Both sides are stacked and summed per key, so a group row with no leaves and leaves with no group row both show as a difference. Output aliases differ from the joined columns' names: ClickHouse strips the qualifier from the left table's columns in a join, so a same-named alias would shadow them.
<sub>error (default) · tests/assert_hierarchy_rollup_ties.sql · konsolidat#220</sub>
ic_difference_not_from_ownership
Decision 12 (13 Sep 2026): ownership never produces an intercompany difference.
Each pair's two sides are recomputed from gold_consolidated_trial_balance at 100% (translated_amount), never the ownership-weighted group_amount. Fails when: - difference: the pair's difference is not the sum of its two 100% sides; - ownership: the sides net to zero at 100% but the pair is not matched with difference 0. For example, 1000 at a 100%-owned entity against 1000 at an 80%-owned one is matched, although the group view holds 1000 and 800.
<sub>error (default) · tests/assert_ic_difference_not_from_ownership.sql</sub>
ic_nci_account_declared
<sub>warn · tests/assert_ic_nci_account_declared.sql · konsolidat#208</sub>
ic_nci_leg_entity
#175 third review L2: an NCI-line leg is attributed to the entity whose minority owners hold it.
- Group view, 'nci': one leg takes a pair side (its account and entity) down to the share the other side is held at; the other leg is on the NCI line, attributed to the OTHER side's entity, the partly owned one. - NCI view, 'matched': one leg eliminates a side's minority share; the other is on the NCI line, attributed to that same side's entity. Each entry has exactly one NCI leg, and its other leg is one of the pair's two sides.
<sub>error (default) · tests/assert_ic_nci_leg_entity.sql · konsolidat#175 konsolidat#208</sub>
ic_nci_line_nets_zero
#175 third review L2: the NCI line, summed over both views, is 0 per group and period.
Decision 12 moves the minority's share of an intragroup balance to the NCI line twice: the group view's 'nci' entries (the better-owned side's excess share) and the NCI view's 'matched' entries (each side's minority share). Across the two they cancel: in the full (100%) consolidation an intragroup balance leaves nothing on the NCI line. A leg sent anywhere else (the difference account, a wrong sign) leaves the line unbalanced.
<sub>error (default) · tests/assert_ic_nci_line_nets_zero.sql · konsolidat#175 konsolidat#208</sub>
ic_reconciliation_matched
PRD-15 Test: Matched IC balances must have net_balance ≈ 0
<sub>error (default) · tests/assert_ic_reconciliation_matched.sql</sub>
nci_movement_reconciles
PRD-13 Test: NCI movement — share of profit must be consistent with the NCI amount from consolidated TB P&L entries
<sub>error (default) · tests/assert_nci_movement_reconciles.sql</sub>
nci_zero_for_full_ownership
PRD-4 Test: NCI amount must be zero for fully-owned entities
<sub>error (default) · tests/assert_nci_zero_for_full_ownership.sql</sub>
ownership_chain_complete
F2: every entity that reaches a consolidated result must have an ownership percentage for EVERY link between it and that group, in that period.
Ownership Period is the only grain now, so a node with no period covering the date has no ownership at all — and a chain is only as resolvable as its weakest link. gold_entity_ownership reports such a chain as has_complete_chain = 0 and effective 0 rather than inventing a number (ownership_pct or 100 is exactly the falsy-zero bug F2 removes). This turns that flag into a failed build naming the entity, so the gap is fixed by adding a period rather than absorbed as a silent zero. outside_ownership_window is excluded on purpose: a node whose ownership history exists but does not reach this period is one we did not own then — before an acquisition, after a disposal (PRD-11/12, both first-class here). Consolidation excludes those rows either way, but only an UNRECORDED gap is worth failing a build over. Without the distinction an entity acquired in 2025 failed for every period back to the start of the warehouse.
<sub>error (default) · tests/assert_ownership_chain_complete.sql</sub>
ownership_paths_acyclic
konsol#117 (design section 3): a path from a group to an entity never visits a node twice.
konsol refuses a cycle at Ownership Period validate and build_rows raises on one; this is the warehouse backstop for a closure row that slipped past both (a patch, a hand-written row). One result per cyclic path, naming it. path (the tree path, kept for readers) is checked too, so a volume whose closure predates path_id is covered. Fixture: assert_ownership_paths_acyclic.must_flag.sql seeds ZZA/ZZB/ZZA (flags 1).
<sub>error (default) · tests/assert_ownership_paths_acyclic.sql · konsol#117</sub>
ownership_uses_effective_date
PRD-9 Test: When temporal ownership exists, the consolidated TB must use it Check that ownership_pct matches the temporal staging record for the period
<sub>error (default) · tests/assert_ownership_uses_effective_date.sql</sub>
waterfall_reconciles
PRD-22 Test: Waterfall final_amount must equal sum of all layers
<sub>error (default) · tests/assert_waterfall_reconciles.sql</sub>
Acquisitions and disposals
acquired_balances_complete
<sub>warn · tests/assert_acquired_balances_complete.sql · konsolidat#198 konsolidat#203</sub>
acquisition_accounts_declared
konsolidat#198 (design §1/§1a, row J7): a submitted Business Combination whose group has not declared something the acquisition journal needs.
gold_business_combination_journal never assumes an account code or a policy (design §1: "dbt never assumes a code"), so an undeclared field either drops the deal (no root row, no calendar period) or posts to main_account '' / reads the policy as its fallback. Both are silent; this test stops the build and names them: one row per deal and field, with the value found and why it is not acceptable. Fixture: dbt_project/test_fixtures/assert_acquisition_accounts_declared.must_flag.sql. What is required, and when (design §1 "Required when"; §1a "every setting is required once the group has a Business Combination; there are no defaults"): root_row the group's root row in epm_gold.consolidation_groups (data_area_id = ''), where konsol syncs the accounts and the policy; without it nothing else of the group is checked (one line says it all) acquisition_period a non-Closing epm_staging.fiscal_periods row spanning acquisition_date accounting_framework IFRS | US GAAP | Local nci_measurement partial | full, the DEAL's (konsol#205: its override or the group's value, resolved by konsol into business_combinations), when share_acquired_pct < 100 (at 100% the journal posts no NCI) nci_fair_value > 0 when the deal's nci_measurement = 'full' and share_acquired_pct < 100 (konsol#204: line (5) is this declared figure; undeclared it would post NCI 0) goodwill_treatment Impairment only | Amortise acquisition_costs_treatment Expense | Capitalise measurement_period Off | 12 months bargain_purchase Recognise gain | Refuse (a policy must be present AND one of its options: the journal reads any other value as 'partial' / 'Expense' / 'Recognise gain', the fallback this test stops) goodwill_amortisation_years > 0 and goodwill_amortisation_expense_account when goodwill_treatment = 'Amortise' goodwill_account, investment_account when total_consideration > 0 fair_value_adjustment_account when the header or an acquired-balance row carries a fair-value adjustment nci_account when share_acquired_pct < 100 bargain_purchase_gain_account when konsol's Result shows a bargain (goodwill < 0 or bargain_purchase_gain > 0) under 'Recognise gain' disposal_proceeds_account when the deal has acquisition costs (the account the group settles deal cash through; the journal's settlement side) acquisition_costs_account when it has costs and acquisition_costs_treatment = 'Expense' is_retained_earnings the chart flags a retained-earnings account (silver_main_accounts.is_retained_earnings) when the entity has trial-balance rows before the acquisition period: line (0)'s balancing line goes there A declared account must also be a Published posting leaf of the chart (silver_main_accounts): the journal would otherwise post to a code the chart does not know. Refused by name until konsolidat#204 is decided (row J12, PR #203 review 1): share_acquired_pct < 100 layer 1 of gold_fully_consolidated_tb carries a full-method subsidiary at the parent's share, while the IFRS 3 template posts 100% of the net assets plus an NCI line, so a partial-share deal would count the minority twice. One row per such deal, whatever the root row declares; the balance tests still prove the NCI arithmetic on business_combination_80pct.sql, selected without this guard (see that fixture's header). Not checked here: konsol's framework constraints (US GAAP -> full NCI, IFRS -> Impairment only, Local -> framework_note) are the document's validate() rules; the warehouse posts what is declared. The disposal journal's accounts are assert_disposal_accounts_declared's (row J10); a duplicated root row is assert_consolidation_group_root_unique's (the root CTE below reads any() per column, as the journals do).
<sub>error (default) · tests/assert_acquisition_accounts_declared.sql · konsol#204 konsol#205 konsolidat#198 konsolidat#203 konsolidat#204</sub>
acquisition_journal_balances
konsolidat#198 (design §6): every acquisition journal (ACQ-…) the warehouse posts from a submitted Business Combination sums to zero in its period.
The journal is balanced by construction (design §4: goodwill or the bargain gain is the counterpart of every other line), so a row here is a model bug, not a data problem: one-sided rows were exactly what made assert_end_to_end_bs_balances (PRD-22) fail on every acquisition period before this. One test per journal model (row J5cb), each ref-ing only its own model, so that +gold_business_combination_journal assert_acquisition_journal_balances is selectable on its own and a fixture that CREATEs only the acquisition tables builds it. Siblings: assert_goodwill_amortisation_journal_balances, assert_disposal_journal_balances. Fixtures: dbt_project/test_fixtures/business_combination_100pct.sql, business_combination_bargain.sql.
<sub>error (default) · tests/assert_acquisition_journal_balances.sql · konsolidat#198</sub>
acquisition_measured_in_period
<sub>warn · tests/assert_acquisition_measured_in_period.sql · konsolidat#198</sub>
bargain_purchase_refused
konsolidat#198 (design §1a, row J4): a submitted Business Combination whose group's policy is bargain_purchase = 'Refuse' and whose price is below the fair value acquired (negative goodwill).
gold_business_combination_journal posts NOTHING for such a deal (IFRS 3.36 asks for a reassessment of what was acquired and what was paid before any gain is booked), so the build must stop here and name it: the group either corrects the Business Combination in konsol or changes its policy to 'Recognise gain'. One row per refused deal: deal, group, entity, consideration, bargain amount. How it is found: a deal of a 'Refuse' group with no journal lines at all. The journal refuses a deal only for this reason; a deal it cannot measure (empty acquired-balances table and net_assets_acquired = 0) also posts nothing and is named by assert_goodwill_calculated, and lands here too under 'Refuse' (then bargain_purchase_gain is 0 and the row says so). The amount is the header's Result figure as konsol computed it (group currency); the journal's own figure does not exist for a deal it did not post. Fixture: dbt_project/test_fixtures/business_combination_bargain.refuse.sql.
<sub>error (default) · tests/assert_bargain_purchase_refused.sql · konsolidat#198</sub>
deal_goodwill_matches_header
konsolidat#213 (row D4): the goodwill the acquisition journal posts must equal the goodwill konsol computed on the submitted Business Combination.
Both are the same deal's figure in group currency (_staging__sources.yml: "the header carries the deal and konsol's Result figures in group currency"), and until this test nothing said so. Why it matters: konsol measures net assets from the account TYPE (business_combination.py: account_type == "Equity"), while gold_business_combination_journal measures them from silver_main_accounts.is_equity. While is_equity meant "translated at historical rate" the two could disagree on any account a chart declares historical without typing as Equity — and would have, silently, on the first submitted deal: the journal would have eliminated those balances as pre-acquisition equity while the header's goodwill came from the account type. is_equity is now the account type (row D1), so the two meanings are one; this test is what keeps them that way. The journal's figure is the deal's goodwill_raw = consideration + capitalised costs + NCI − (net assets + FVA): the goodwill line when it is positive, the bargain_gain line when it is negative (exactly one of the two posts, design §4 lines 3 and 3b). The header's is goodwill, or −bargain_purchase_gain when konsol booked the bargain in that column instead. Only deals the journal actually posted are compared (INNER JOIN on its lines): a deal it refuses (bargain under 'Refuse') or cannot measure (no acquired balance sheet) posts no line at all and is named by assert_bargain_purchase_refused / assert_goodwill_calculated, not here. One row per deal that disagrees, with both numbers. Fixtures: dbt_project/test_fixtures/business_combination_100pct.sql (PASS) and dbt_project/test_fixtures/assert_deal_goodwill_matches_header.must_flag.sql (the same rows with the header's goodwill moved 500 off the journal's; must FAIL with 1 result).
<sub>error (default) · tests/assert_deal_goodwill_matches_header.sql · konsolidat#213</sub>
disposal_accounts_declared
konsolidat#198 (design §1/§5, row J10;
PR #203 review 2): a submitted Business Disposal whose group has not declared an account the disposal journal posts to. gold_business_disposal_journal never assumes an account code (design §1: "dbt never assumes a code"), so an undeclared account either drops the disposal (no root row, no calendar period) or posts to main_account ''. Both are silent; this test stops the build and names them: one row per disposal and field, with the value found and why it is not acceptable. It mirrors assert_acquisition_accounts_declared for the acquisition journal. Fixture: dbt_project/test_fixtures/assert_disposal_accounts_declared.must_flag.sql. What is required, and when (design §1 "Required when"; §1a "there are no defaults"): root_row the group's root row in epm_gold.consolidation_groups (data_area_id = ''), where konsol syncs the accounts; without it nothing else of the group is checked (one line says it all) disposal_period a non-Closing epm_staging.fiscal_periods row spanning disposal_date disposal_gain_loss_account always: the balancing line of every disposal journal disposal_proceeds_account always: the proceeds debit (the account the group settles deal cash through) goodwill_account always: the goodwill the acquisition booked is derecognised here (a deal fair_value_adjustment_account with none posts a zero, but the account must still be known) nci_account when a minority exists: retained_interest_pct > 0 or share_disposed_pct < 100 A declared account must also be a Published posting leaf of the chart (silver_main_accounts): the journal would otherwise post to a code the chart does not know. Refused by name until konsolidat#204 is decided (row J12, PR #203 review 1): share_disposed_pct < 100 or retained_interest_pct > 0 layer 1 of gold_fully_consolidated_tb carries a full-method subsidiary at the parent's share, while the disposal template derecognises 100% of the balance sheet against an NCI line, so a partial disposal (or one leaving a retained interest) would count the minority twice. One row per such disposal, whatever the root row declares; the disposal journal posts nothing for it either (design §5/§7), which assert_disposal_gain_loss_exists also names. Not checked here: the acquisition journal's accounts and policies are assert_acquisition_accounts_declared's.
<sub>error (default) · tests/assert_disposal_accounts_declared.sql · konsolidat#198 konsolidat#203 konsolidat#204</sub>
disposal_gain_loss_exists
every submitted disposal must have produced a gain or loss.
gain or loss. konsolidat#198 (row J6b): rewritten to read epm_staging.business_disposals instead of ownership_periods, and gold_business_disposal_journal instead of gold_disposal_adjustments. Why: since konsolidat#198 the disposal lives on the submitted Business Disposal document (submit = approval), and gold_business_disposal_journal posts the balanced disposal journal from it; gold_disposal_adjustments, which posted the one-sided 'disposal_gain_loss' row this test used to look for, is gone. The Ownership Period only carries the effective share and the consolidation window, so an Ownership Period flagged is_disposal is no longer a deal the warehouse must account for (on the stack the deals are still Drafts: nothing submitted, nothing owed). Coupling this test to ownership_periods would flag every disposal window for no reason. Flags a submitted disposal whose journal has no gain_loss line. Two causes, both worth the accountant's eye: * a retained interest (retained_interest_pct > 0): the journal posts only full disposals; the remeasurement of the interest kept is out of scope (design §5, §7) and must be booked as a manual topside, so the disposal is NAMED here rather than posted wrong or silently skipped; * no posting at all: the group has no root row in consolidation_groups, or the disposal date is outside the declared calendar (row J7's guard names the missing declaration itself). A disposal whose proceeds equal the carrying amount to the cent has no gain_loss line either and is named here too; that coincidence is worth a look.
<sub>error (default) · tests/assert_disposal_gain_loss_exists.sql · konsolidat#198</sub>
disposal_has_balances
<sub>warn · tests/assert_disposal_has_balances.sql · konsolidat#198 konsolidat#203</sub>
disposal_journal_balances
konsolidat#198 (design §6): every disposal journal (DSP-…) the warehouse posts from a submitted Business Disposal sums to zero in its period.
The journal is balanced by construction (design §5: the gain/loss line is the counterpart of every other line), so a row here is a model bug, not a data problem. One test per journal model (row J5cb), each ref-ing only its own model, so that +gold_business_disposal_journal assert_disposal_journal_balances is selectable on its own. Siblings: assert_acquisition_journal_balances, assert_goodwill_amortisation_journal_balances. Fixture: dbt_project/test_fixtures/business_disposal.sql.
<sub>error (default) · tests/assert_disposal_journal_balances.sql · konsolidat#198</sub>
goodwill_amortisation_journal_balances
konsolidat#198 (design §6): every goodwill amortisation journal (GWA-…) sums to zero in each of its periods: the expense debit and the goodwill credit of one instalment are each other's counterpart (design §1, goodwill_treatment = 'Amortise').
A row here is a model bug, not a data problem. One test per journal model (row J5cb), each ref-ing only its own model, so that +gold_goodwill_amortisation_journal assert_goodwill_amortisation_journal_balances is selectable on its own. Siblings: assert_acquisition_journal_balances, assert_disposal_journal_balances. Fixtures: dbt_project/test_fixtures/goodwill_amortisation.sql, goodwill_amortisation.disposal.sql.
<sub>error (default) · tests/assert_goodwill_amortisation_journal_balances.sql · konsolidat#198</sub>
goodwill_calculated
every submitted acquisition with a price must have had its goodwill calculated.
l calculated. konsolidat#198 (row J2b): rewritten to read epm_staging.business_combinations instead of ownership_periods, and gold_business_combination_journal instead of gold_acquisition_adjustments. Why: since konsolidat#198 the deal lives on the submitted Business Combination document (submit = approval), and gold_business_combination_journal posts the balanced acquisition journal from it; gold_acquisition_adjustments no longer posts goodwill rows. The Ownership Period only carries the effective share and the consolidation window, so a priced Ownership Period is no longer a deal the warehouse must account for (the stack's deals are still Drafts there: nothing submitted, nothing owed). Coupling this test to ownership_periods would fail every acquisition period for no reason. Flags a submitted deal with total_consideration > 0 whose journal has neither a goodwill nor a bargain_gain line (from row J4 a bargain purchase books the gain instead of goodwill). The usual cause: no measurement basis (empty acquired-balances table and net_assets_acquired = 0), so the journal posted nothing for the deal. A deal whose consideration equals fair-value net assets to the cent has neither line either and is named here too; that coincidence is worth a look.
<sub>error (default) · tests/assert_goodwill_calculated.sql · konsolidat#198</sub>
post_disposal_excluded
PRD-12 Test: Post-disposal periods must have zero ownership (entity excluded) When temporal ownership records a disposal, no consolidated TB rows should exist for that entity in periods after the disposal
<sub>error (default) · tests/assert_post_disposal_excluded.sql</sub>
proration_pre_acquisition_excluded
PRD-11 Test: Pre-acquisition P&L amounts must be excluded (adjustment_amount < 0)
<sub>error (default) · tests/assert_proration_pre_acquisition_excluded.sql</sub>
Intercompany
equity_method_no_ic_elim
PRD-14: an equity-method entity must never appear in an IC elimination.
Keyed on the ENTITY, not just the group. The previous cut joined on (consolidation_group, fiscal_year, fiscal_period) alone, because gold_ic_eliminations threw its entities away — so a correct elimination between two fully-consolidated entities failed the build as soon as ANY node in that group was equity-method in that period. Harmless while every seeded row said 'full'; a live false positive now that the method is real data and F2 propagates 'equity' to every descendant of an equity-held sub-group. One exception (#175 third review M1): the period a balance-sheet pair leaves the group because a side moved to equity, the pair's 'left' row reverses everything eliminated while that side was fully consolidated. Those entries touch the equity-method entity in its first equity period, and only undo earlier ones: the row's values are 0, so nothing new is eliminated. assert_ic_pair_left_is_reversed checks they are complete.
<sub>error (default) · tests/assert_equity_method_no_ic_elim.sql · konsolidat#175</sub>
ic_account_in_one_pair
konsol#159: each intercompany account belongs to one pair.
An account paired with two counterparts would have one side matched twice, which is the over-elimination konsolidat#148 removed. konsol refuses such a row; this catches one that reached the warehouse anyway (ic_account_map() then keeps just one counterpart).
<sub>error (default) · tests/assert_ic_account_in_one_pair.sql · konsol#159 konsolidat#148</sub>
ic_difference_account_in_chart
<sub>warn · tests/assert_ic_difference_account_in_chart.sql · konsol#159 konsolidat#175 konsolidat#208</sub>
ic_difference_cause
Decision 13 (13 Sep 2026): each intercompany difference is labelled by its cause, and only a booking difference counts against the tolerance.
- currency: each side's currency is its entity's functional currency (silver_entity_currencies), the input the rule reads. 2. cause: difference_cause follows the rule (see gold_ic_reconciliation): none below materiality_floor(); fx across currencies; booking in one currency when the local amounts do not net to zero; fx in one currency when they do (translation only). The local amounts are recomputed from gold_consolidated_trial_balance (ic_expected_pair_values), not taken from the model's own columns (#175 re-review L4). 3. status: a booking difference is within_tolerance or over_tolerance against the group's tolerance. An fx difference on a balance-sheet pair across currencies is judged the same way, since both sides are at the closing rate (konsol#305-W3-5). Any other fx difference (a movement pair across currencies, or translation only in one currency) is 'fx_difference' and does not count against the tolerance. 4. label: each 'difference' elimination row carries its pair's cause, so splitting the difference account in two later needs no data change.
<sub>error (default) · tests/assert_ic_difference_cause.sql · konsol#305 konsolidat#175</sub>
ic_elimination_nets_zero
Intercompany elimination nets to zero, three ways (konsolidat#148).
Every elimination row carries both legs, so "debit + credit = 0" per row is true by construction and proves little on its own. The checks that can fail: 1. entry: each row's two legs net to zero (kept: it is what the layer relies on); 2. layer: the ic_elimination layer of gold_fully_consolidated_tb nets to zero per group and period, so both legs of every entry (the NCI line's included, decision 12) reached it; 3. pair: on the pair's basis (decision 14: to date for a balance-sheet pair, the period for a P&L pair), what the GROUP VIEW holds of the two sides plus its eliminations nets to zero (the 100% view is assert_ic_full_view_nets_zero) when the group has an intercompany-difference account, and to exactly the group share of the residuals when it has none (only the matched amount is eliminated then).
<sub>error (default) · tests/assert_ic_elimination_nets_zero.sql · konsolidat#148</sub>
ic_elimination_within_balance
konsolidat#148 / konsol#159 (decision 1, 13 Sep 2026): elimination never exceeds the balance it cancels.
The engine this replaced joined every ordered entity pair and eliminated 2.61M against a 2.56M intercompany revenue balance, and 31.5M against a 14.5M payables balance. This is the invariant that would have caught both. Balance eliminations only (unrealized profit is a margin on inventory, not a balance being cancelled), in the group view, on each pair's basis (decision 14): a balance-sheet account to date, from inception, as the group view carries it; a P&L account in the period. 1. account: per (group, period, account), total elimination does not exceed the account's consolidated balance. The balance is taken gross, as the sum of |balance| per (entity, partner): a partnerless row or an entity with the opposite sign stays on the account after elimination, and a net figure would flag a correct elimination of the rest. The difference account's and the NCI line's legs are destinations, not eliminations of their balances, so they are left out. 2. side: per pair, each side is eliminated by no more than the group view holds of it (group_balance_*), in the direction that reduces it. An elimination whose pair key matches no pair is flagged (side_without_pair).
<sub>error (default) · tests/assert_ic_elimination_within_balance.sql · konsol#159 konsolidat#148 konsolidat#208</sub>
ic_full_view_nets_zero
#175 re-review H1: the full (100%) view nets each pair to zero.
The consolidation report's Consolidated column is the group view (gold_fully_consolidated_tb) plus the NCI view (nci_amount per account, plus the NCI view's eliminations). With A 100% and B 80% on 1000/-1000, the group view eliminated -1000 and +800 and put +200 on the NCI line, but nothing eliminated B's minority share (-200) of the payable, so the payable showed -200 at 100%. Per pair and row, on the pair's basis (decision 14): what both sides hold at 100% (balance_a + balance_b = group_amount + nci_amount) plus every elimination on the pair's own sides, group and NCI view, nets to zero when the group has an intercompany-difference account, and to the 100% residuals when it has none. The NCI line and the difference account are destinations, not the pair's sides. The group view on its own is assert_ic_elimination_nets_zero.
<sub>error (default) · tests/assert_ic_full_view_nets_zero.sql · konsolidat#175</sub>
ic_match_status_cases
konsol#305-W3-5 (Deepak Pai, 3 Oct 2026, option C): a balance-sheet pair compares both sides translated at the closing rate, so a cross-currency balance difference is judged against the group's tolerance: over it 'over_tolerance', within it 'within_tolerance'.
Its difference_cause stays 'fx'. A P&L (movement) pair compares the period at average rates and stays 'fx_difference'. A same-currency booking difference is judged as before. On the fixture test_fixtures/assert_ic_match_status_cases.sql (group ZZIC, tolerance 10, FY2026 P1): - ZZE ZZ2100 <-> ZZP ZZ1100: EUR/USD, balance, difference 40 -> over_tolerance, cause fx; - ZZF ZZ2100 <-> ZZS ZZ1100: EUR/USD, balance, difference 4 -> within_tolerance, cause fx; - ZZE ZZ5100 <-> ZZP ZZ4100: EUR/USD, movement, difference -80 -> fx_difference, cause fx; - ZZP ZZ1100 <-> ZZS ZZ2100: USD/USD, balance, difference 50 -> over_tolerance, cause booking. One row per expectation not met; an expected pair that is missing is a row too. Without group ZZIC (a site that did not load the fixture) the test has nothing to check and returns no rows.
<sub>error (default) · tests/assert_ic_match_status_cases.sql · konsol#305</sub>
ic_pair_basis
Decision 14 (13 Sep 2026): a balance-sheet intercompany pair matches on its balance to date (from inception, as gold_balance_sheet carries it).
A P&L pair matches on the period's movement. 1. basis: a pair on a balance-sheet account is on the 'balance' basis, one on a P&L account on 'movement' (is_balance_sheet of account_a in gold_consolidated_trial_balance). 2. value: each side equals its 100% amount recomputed from gold_consolidated_trial_balance on that basis (ic_expected_pair_values). A balance-sheet pair booked in different periods is compared on what has been booked to date, so it matches once both sides are in.
<sub>error (default) · tests/assert_ic_pair_basis.sql</sub>
ic_pair_left_is_reversed
#175 third review M1: while a balance-sheet pair is not live in a group, nothing of it is eliminated there.
Every elimination posted while both sides were in the group has been reversed. Membership is resolved here from the ownership data itself, not from gold_entity_ownership or the model's spine: an entity line-consolidates into a group at a date when EVERY link of its chain to that group (consolidation_ancestry) has an ownership period covering the date with method full or proportional. So a partner that was disposed of, a sub-group sold while its own entity's ownership stays open, and a stake moved to equity all count as having left, per group. For every balance-sheet pair, and every period the warehouse holds from the pair's first reconciliation row to the group's latest period, in which either side is not a member: the pair's eliminations to date, per view, account and entity, are 0. That covers the periods before a pair joins (nothing posted yet) and every period after it left (all reversed).
<sub>error (default) · tests/assert_ic_pair_left_is_reversed.sql · konsolidat#175</sub>
unrealized_profit_elimination
PRD-15 Test: Unrealized profit elimination = ending_inventory × margin_pct
<sub>error (default) · tests/assert_unrealized_profit_elimination.sql</sub>
Equity method
equity_associate_has_average_rate
konsolidat#279 / PRD-14: every equity-method associate with a non-zero result in a period, whose accounting currency differs from its group's reporting currency, has exactly one usable governed Average rate for that period into the group currency (epm_staging.group_exchange_rates, konsolidat#93), keyed through rate_period_map() exactly as gold_equity_method_associates keys it (a Closing-type period reads its year's last Regular period, konsolidat#199 row D9).
Why a sibling test and not the model's own stop. gold_equity_method_associates refuses to build when an associate's Average rate is missing, duplicated or invalid (throwIf in its translated CTE), but ClickHouse's throwIf takes a constant message, so the stop names no key, and the line-consolidation guards do not cover an associate at all: governed_translated_keys() (the pre_hook guard, assert_every_translated_currency_has_a_governed_rate, deploy.sh's fx_precheck) excludes consolidation_method = 'equity' on purpose. Without this test an operator got "some associate, some period". This lists every key, in the shape a person fixes it: approve the Average rate in konsol Group Exchange Rate (or cancel the extra one). reason is one of: missing (no approved Average rate for the rate key); duplicate (more than one approved Average rate: the model's anyIf would pick one); invalid (an Average rate that is zero, negative or not finite); no_reporting_currency (the group has no root row in epm_gold.consolidation_groups, data_area_id = '', or its reporting_currency is blank, so there is no currency to translate INTO: not a rate problem, fix the Consolidation Group in konsol. The model stops on this first, with its own message, and the row is labelled so it is never read as a missing rate). Built from the model's own inputs (never from the model: a refused build must still let this run and name the key). A zero result needs no rate (0 x anything is 0), and the model does not stop on one either, so a zero-result period is not listed. join_use_nulls=0: a rate miss fills n_average = 0 on the LEFT JOIN, so the count is the signal, never a NULL test across the join; a group-root miss fills to_currency = ''. severity warn, on purpose, as assert_every_translated_currency_has_a_governed_rate: this test sits on the model's INPUTS, and at error severity a flag made dbt build SKIP gold_equity_method_associates and everything below it before the model ran, so its throwIf never decided and the fixture gate saw SKIPPED where it expected REFUSED (CI run 42393401046 on 34eaddf). The model decides: its throwIf stops the build; this test, in the same run, names the keys. A WARN here is never "fine": it is the list of what the refused build needs. Fixtures: dbt_project/test_fixtures/assert_equity_associate_has_average_rate.must_flag.sql (SEK associate in a EUR group with a Closing rate but no Average rate: 2 rows, FY2026 P12 and the Closing period P13 that reads P12), ...no_reporting_currency.must_flag.sql (no root row: 2 rows), and assert_equity_method_journal_balances.sql (the balanced case: passes).
<sub>warn · tests/assert_equity_associate_has_average_rate.sql · konsolidat#199 konsolidat#279 konsolidat#93</sub>
equity_income_formula
PRD-14 Test: Equity income = net_income × ownership_pct × the period's governed Average rate from the associate's accounting currency into the group's reporting currency (1.0 when they are the same).
The EQ_INCOME entry should match the formula. 7 Nov 2026: the oracle translates, as the model does since the same day. It compared the entry with net_income × ownership_pct in the associate's OWN currency, so it passed on a SEK associate in a EUR group whose figure had never been translated (the defect it should have caught). A Closing-type period reads its year's last Regular period's rate (rate_period_map(), konsolidat#199 row D9), the same rule the model applies. join_use_nulls=0: an entry whose rate key has no Average rate reads 0 here, so its expected value is 0 and the entry (never 0 itself, the model drops |amount| <= 0.01) is flagged rather than excused. Fixture: dbt_project/test_fixtures/assert_equity_method_journal_balances.sql.
<sub>error (default) · tests/assert_equity_income_formula.sql · konsolidat#199</sub>
equity_method_journal_balances
PRD-14: every equity-method journal (EQ_<group><entity><year>_P<period>) the warehouse posts sums to zero in its period: the EQ_INCOME line and the EQ_INVEST line are the two sides of one entry (Cr share of profit, Dr investment), so a row here is a model bug, not a data problem.
Found 7 Nov 2026 building the aquila-bike example: gold_equity_method_associates put the SAME signed figure on both lines, so a profit of X posted -X twice (net -2X) into layer 5 of gold_fully_consolidated_tb, and assert_end_to_end_bs_balances (PRD-22) failed for any group with an associate in every period the associate had a result. Same pattern as the deal-journal tests (assert_acquisition_journal_balances and siblings): one test, ref-ing only its own model, so gold_equity_method_associates assert_equity_method_journal_balances is selectable on its own. Fixture: dbt_project/test_fixtures/assert_equity_method_journal_balances.sql (SEK associate at 30% in a EUR group; a 1,000 SEK profit at a 0.09 Average rate is EQ_INCOME -27.00 / EQ_INVEST +27.00).
<sub>error · tests/assert_equity_method_journal_balances.sql</sub>
equity_method_single_line
PRD-14 Test: Equity method entities must appear as single-line entries (not full line-by-line consolidation).
The two accounts allowed are the two sides of the one journal gold_equity_method_associates posts per associate per period: EQ_INCOME (the translated share of the result) and its negation on EQ_INVEST (assert_equity_method_journal_balances).
<sub>error (default) · tests/assert_equity_method_single_line.sql</sub>
Cash flow
cf_categories_equal_net_change
Phase 6.1 Test (AC#4): per data_area_id / fiscal_year / fiscal_period, the sum of Operating + Investing + Financing cash flows must equal the net change in cash (the signed movement of is_cash = 1 accounts), within +/- 0.01.
This holds by construction: gold_cash_flow_indirect sums −(period_debit − period_credit) over every non-cash account, and the full trial balance is balanced double-entry, so Σ(cash) = −Σ(non-cash). A failure would mean a non-cash account was dropped or the books are not balanced for that period (a data issue surfaced by the Phase 6.10 assertion suite, not a model bug).
<sub>error (default) · tests/assert_cf_categories_equal_net_change.sql</sub>
cf_net_income_equals_group_pnl
#175 third review L1: the cash flow's net income is the group view's consolidated P&L, every layer included.
The group view's P&L is gold_fully_consolidated_tb's P&L accounts (silver is_pnl = 1), per group and period. The statement reports them on its "Net Income (Consolidated)" line, except an account the cash-flow mapping gives a line of its own (a Published row with a line item), which is reported there. So those accounts are left out of both sides. It fails when the statement drops a P&L entry. The case it was written for: the minority's part of a P&L pair's elimination (decision 12, the group view's 'nci' entries, ic_elimination_nci) is in the P&L, and the statement once left it out with the balance-sheet pairs' ones.
<sub>error (default) · tests/assert_cf_net_income_equals_group_pnl.sql · konsolidat#175</sub>
scoped_cash_flow_ytd_confined
A3 / grynn-in/konsolidat: confine the FRESHLY-WRITTEN slice of a scoped close.
A1 (#119) asserted that under an orchestrator scope close every row in the WHOLE persisted gold_cash_flow_indirect / gold_ytd_trial_balance table was confined to the scoped entities. A2 (#116) then made both models incremental (rewriting only the close slice; since #154 a pre_hook deletes it and the SELECT appends it), so a scoped close rewrites ONLY the in-scope entity's keys and PRESERVES every other entity's prior rows BY DESIGN. The whole-table invariant therefore became false and the A1 test false-failed (122 retained rows). REAL invariant checked here: the FRESHLY-WRITTEN slice — the rows the close actually (re)derives and writes — must be confined to the resolved scope. That slice IS each model's SOURCE projection: gold_trial_balance filtered by the SAME period_filter + scope_filter predicates the model applies (cash-flow: single-period; YTD: include_period=false, year-bounded). We check that pre-persist projection (the handoff's "check the SELECT pre-persist" reconciliation), which is robust to A2's incremental preservation of out-of-scope sibling slices and needs NO write-time marker — so the gold contract tables stay byte-for-byte unchanged. NON-VACUOUS via an INDEPENDENT oracle. The genuine weakness of the first A3 cut (commit 9ad34db) was NOT the source-projection — it was the oracle: it resolved scoped_entities from gold_consolidation_hierarchy with the SAME LIKE/path patterns scope_filter uses, so the projection was a subset of the oracle BY CONSTRUCTION and an offender could never appear (a tautology). Here the oracle is resolved INDEPENDENTLY from the flat consolidation_groups seed with EXACT equality only (no LIKE, no path, no hierarchy), so if scope_filter ever OVER-SELECTS (e.g. an unescaped _/% LIKE metacharacter, a lost slash boundary, a widened predicate) it pulls an entity into the projection that the exact-equality oracle does not contain, and that entity surfaces below as an offender. RED reachable: broadening scope_filter (e.g. adding an extra or data_area_id = ...) under a resolvable scope makes the over-selected entity an offender; GREEN once the macro selects exactly the scope. The oracle resolves an ENTITY scope (matches itself) or ANY consolidation group, top-level or intermediate, to every entity that rolls into it — the ancestry closure carries one row per (ancestor group, entity), so a sub-group needs no special case. An unresolvable scope yields an empty oracle and the check is suppressed rather than false-failing; a genuinely bogus/zero-entity scope is already guarded by assert_scope_resolves_to_entities. F2 removed the previous ASSUMPTION (konsolidat#124) that the flat seed and the hierarchy agree on top-level group membership. They did not — the seed put DEMF and GBMF under GROUP_CORP, the doctype under GROUP_EMEA (#130) — and the seed is gone. Oracle and macro now read the same tree by two different mechanisms: a parent-link closure here, a path-string LIKE there. Tradeoff (vs. the rejected write-time marker): this guards against the scope_filter MACRO over-selecting, not against a model dropping the scope_filter call entirely. The latter would need a persisted load marker on the gold tables, which violates the no-var byte-for-byte invariant; all three consolidation models share the same chokepoint filter pattern and that is covered by review. (Do NOT call period_filter()/scope_filter() inside a -- comment: Jinja renders the macro and its multi-line output breaks out of the comment line.) OPT-IN: with no entity_scope var this returns no rows (full build byte-for-byte unchanged).
<sub>error (default) · tests/assert_scoped_cash_flow_ytd_confined.sql · konsolidat#116 konsolidat#119 konsolidat#124 konsolidat#130 konsolidat#154</sub>
Reporting hierarchies
hierarchy_all_entities_resolved
PRD-8 / F2: every entity node in the consolidation structure must be reachable by the tree walk.
Was "every entity in the consolidation_groups SEED appears in the hierarchy". The seed is gone — it was the same ClickHouse relation konsol writes, so the test compared a table with itself whenever a governed build had re-seeded it. The structure table is the left side now, and the right side is the ancestry closure, which is what consolidation actually traverses: an entity missing from it reaches no group at all.
<sub>error (default) · tests/assert_hierarchy_all_entities_resolved.sql</sub>
hierarchy_closure_windows
konsolidat#220: every closure link holds only within a window (valid_from ..
valid_to), the intersection of the member tranches along the path, and carries the ancestor tranche's label for that window. On the fixture hierarchy_dated.sql (ZZ_DIV): - ZZ_EX -> ZZ_E holds only within 2017-01-01 .. 2024-12-31; - ZZ_EX -> ZZ_B holds only from 2025-01-01; - ZZ_GX -> ZZ_G holds only within 2013-04-01 .. 2020-06-03; - ZZ_AX -> ZZ_A is labelled "Alpha" before 2025 and "Alpha New" from 2025; - no closure row has valid_from > valid_to. One row per broken expectation. A closure without the window columns is read as "every link holds always" (1900-01-01 .. 2299-12-31), so the checks fail on their merits rather than with a missing-column error. Without hierarchy ZZ_DIV (a site that did not load hierarchy_dated.sql) the test has nothing to check and returns no rows.
<sub>error (default) · tests/assert_hierarchy_closure_windows.sql · konsolidat#220</sub>
hierarchy_no_circular_ref
PRD-8 Test: No circular references — parent_group must not equal own consolidation_group when parent_group is populated and data_area_id is empty (group node)
<sub>error (default) · tests/assert_hierarchy_no_circular_ref.sql</sub>
hierarchy_node_as_of
konsolidat#220: the trial balance rolls up the tree AS IT WAS in each period, with that period's labels.
On the fixture hierarchy_dated.sql (hierarchy ZZ_DIV over dim_business_unit, entity ZZE1, cash ZZ1000): - FY2018 P6: ZZ_EX rolls to ZZ_E and ZZ_ROOT, not ZZ_B; ZZ_GX rolls to ZZ_G; - FY2024 P6: ZZ_AX rolls to ZZ_A labelled "Alpha"; - FY2025 P6: ZZ_EX rolls to ZZ_B, not ZZ_E; ZZ_AX rolls to ZZ_A labelled "Alpha New"; no row carries ZZ_E or ZZ_G (both ended before 2025); - every node carries each amount once (a leaf with two tranches is not counted twice). Budgets (row H4) the same way, on hierarchy ZZ_DIV_CC over dim_cost_center (a budget has no business unit), scenario ZZ_PLAN_H, revenue ZZ4000: FY2018 P6 ZZ_EX rolls to ZZ_E and ZZ_ROOT, not ZZ_B; FY2025 P6 ZZ_EX rolls to ZZ_B and ZZ_ROOT, not ZZ_E. Variance (row H5) the same way, on the same cost-centre tree (business unit never reaches variance): the budget_amount of budget_scenario_id ZZ_PLAN_H on ZZ4000 is -70 at FY2018 P6 on ZZ_EX, ZZ_E and ZZ_ROOT (not ZZ_B), and -600 at FY2025 P6 on ZZ_EX, ZZ_B and ZZ_ROOT (not ZZ_E). The node rows must be exactly the expected ones: one row per missing or wrong node, one per unexpected node. Without hierarchies ZZ_DIV / ZZ_DIV_CC (a site that did not load hierarchy_dated.sql) the test has nothing to check and returns no rows: the close runs every singular test on every site, so it must not flag the fixture's nodes as missing there.
<sub>error (default) · tests/assert_hierarchy_node_as_of.sql · konsolidat#220</sub>
hierarchy_node_columns
konsolidat#206: the hierarchy node models name their dimension column hierarchy_dimension.
Each selects it from the leaf closure (lc) in a join whose other side (the long form of the TB / variance / budget) has a hierarchy_dimension column too; unaliased, ClickHouse keeps the qualifier and the column comes out as lc.hierarchy_dimension, which no reader can select by its plain name. One row per model with no column named hierarchy_dimension.
<sub>error (default) · tests/assert_hierarchy_node_columns.sql · konsolidat#206</sub>
tree_node_reached_by_links
konsol#117 (design section 1): the Consolidation Group tree stays the reporting structure, the links say what is owned.
The one rule tying them together: every non-root tree node is reached from its tree parent by at least one link path. Paths compose, so this local rule covers every ancestor. What "reached" reads as here: - an ENTITY node: epm_staging.consolidation_ancestry has a (tree parent group, entity) row — konsol's path enumeration writes one per path from each group node to each entity it reaches, so no row means no path; - a pure GROUP node (no entity): at least one Ownership Period names it as the owned node. The closure carries no rows for group nodes (a group is a destination, never a contributor), so which owner holds it is not checked here; konsol's validate refuses an owner outside the same root. A node with no path gives its tree ancestors nothing: its numbers never reach the consolidated result, silently. This fails the build naming it. Fixtures: assert_tree_node_reached_by_links.sql (pass), .must_flag.sql (flags 2: one unreached entity node, one unlinked group node).
<sub>error (default) · tests/assert_tree_node_reached_by_links.sql · konsol#117</sub>
unassigned_as_of
konsolidat#220: a dimension value is unassigned in a period only when no leaf tranche of the default hierarchy covers that period.
On the fixture hierarchy_dated.sql (ZZ_DIV over dim_business_unit, entity ZZE1): - ZZ_ZX is a leaf only from 2025-01-01, so it is unassigned in FY2024 P6 and not in FY2025 P6; - ZZ_EX is a leaf in every period it has actuals (under ZZ_E to 2024, under ZZ_B from 2025): never unassigned. Guards: the fixture must reach gold_trial_balance with ZZ_ZX in FY2025 and ZZ_EX, or the "not unassigned" checks pass vacuously. One row per broken expectation. A model without fiscal_year / fiscal_period is read as "unassigned in every period" (fy = 0), so the checks fail on their merits rather than with a missing-column error. Without hierarchy ZZ_DIV (a site that did not load hierarchy_dated.sql) the test has nothing to check and returns no rows. konsolidat#220 — SCOPE. This test is scoped to a fixture tree over a BUSINESS-UNIT dimension: hierarchy_dated.sql builds ZZ_DIV over dim_business_unit, and the tb CTE below reads gold_trial_balance.dim_business_unit by name, aliases that one dimension to code, and filters it to that tree's member codes. The column exists only where the site declares that dimension — gold_trial_balance renders its dimension columns from var('dimensions') — so a site that does not declare it, including a site with no dimensions at all (the starting state of every site since konsol#230), has nothing here to check. The guard below then renders a query that asserts nothing and returns no rows, instead of failing on a missing column. Why the guard tests the declared dimension list and not the built relation's columns: both answer the same question, but the declared list is decided by configuration, so the same vars always render the same SQL, and a site that DOES declare dim_business_unit can never have this assertion silently skipped by a warehouse that is merely not built yet. It is the same compile-time membership test as the has_period guard below, taken against the var that creates the column. A dimension list rendered through dim_select() would not do: that emits EVERY declared dimension as its own column, which fits neither the as code alias nor the member-code assertion.
<sub>error (default) · tests/assert_unassigned_as_of.sql · konsol#230 konsolidat#220</sub>
variance_node_single_budget
konsolidat#206: gold_variance_at_hierarchy_node keeps each budget scenario apart.
gold_variance_analysis has one set of rows per active budget-type scenario (budget_scenario_id), the actuals repeated against each. Summed over the leaf rows (hierarchy_is_group = 0) of one hierarchy and dimension, the node model's actual_amount for a (budget_scenario_id, entity, year, period, account) must equal gold_variance_analysis' actual_amount over the rows whose dimension value is a leaf of that hierarchy. So must its budget_amount (PR #211 review 4): a node that adds two budget scenarios together, or shows one scenario's budget under another, fails. The budget is compared NULL-safely: two missing budgets (null) agree, and a null against a number differs. A node model that does not carry budget_scenario_id is compared on the rest of the key, so each budget scenario's actuals meet the node's sum across scenarios: with two budget scenarios the actuals are counted twice and the test fails rather than erroring. One row per mismatched key. Output aliases differ from the joined columns' names: ClickHouse strips the qualifier from the left table's columns in a join, so a same-named alias would shadow them.
<sub>error (default) · tests/assert_variance_node_single_budget.sql · konsolidat#206 konsolidat#211 konsolidat#220</sub>
Budget, forecast and variance
budget_fact_grain_unique
grynn-in/konsolidat#94: the canonical budget fact must hold exactly one row per (scenario, entity, year, period, account, budget dims).
The two entry methods (annual×profile spread and manual monthly identity-spread) are UNIONed, with manual overriding annual-spread on the same grain — this asserts the precedence actually dedups and nothing double-counts.
<sub>error (default) · tests/assert_budget_fact_grain_unique.sql · konsolidat#94</sub>
favorable_expense
PRD-7 Test: Expense accounts where actual < budget should be marked favorable
<sub>error (default) · tests/assert_favorable_expense.sql · konsol#182</sub>
favorable_revenue
PRD-7 Test: Revenue accounts where actual > budget should be marked favorable
<sub>error (default) · tests/assert_favorable_revenue.sql · konsol#182</sub>
scenario_rows_declared
PR #211 review 2 (konsolidat#206): the scenarios of gold_scenario_trial_balance are declared.
This test checks declaration, activeness and branch type: every scenario_id with rows is an ACTIVE scenario in epm_gold.scenario_definitions whose scenario_type suits its branch, and the site declares at most one active actual scenario (the GL branch is stamped with it; with several it keeps the fallback 'ACTUAL'). Branch (data_source) -> accepted scenario_type: gl -> actual budget, d365_budget -> budget or forecast Forecasts are legitimate rows of the scenario trial balance, so the budget branches accept them here. The variance models read only 'budget'-type scenarios, so forecast rows never reach variance; that is by design, not a problem this test names. Problems: undeclared - one row per (scenario_id, data_source) with rows: no scenario_definitions row for the id; inactive - declared, but no row with is_active = 1; wrong_type - active, but no active row has the branch's type; several_actual - one row whenever more than one active 'actual' scenario is declared, whatever the rows say: scenario_id lists the active actual ids (sorted, comma-separated), data_source ''.
<sub>error (default) · tests/assert_scenario_rows_declared.sql · konsolidat#206 konsolidat#211</sub>
spread_has_12_periods
each ANNUAL-spread budget line spreads into exactly 12 periods.
riods. Excludes manual (identity-spread) budgets (#94): a manually-entered budget can legitimately be partial-year, so it carries no structural 12-period guarantee.
<sub>error (default) · tests/assert_spread_has_12_periods.sql · konsolidat#94</sub>
spread_sums_to_annual
PRD-6 Test: Sum of 12 spread period amounts must equal annual_amount
<sub>error (default) · tests/assert_spread_sums_to_annual.sql</sub>
variance_abs_formula
PRD-7 Test: variance_abs must equal actual_amount - budget_amount
<sub>error (default) · tests/assert_variance_abs_formula.sql</sub>
variance_budget_matches_year
konsolidat#206 (PR #211 review 3): an actual is compared only with the budget scenarios that budget its entity and fiscal year.
A variance row that pairs a budget scenario with a (data_area_id, fiscal_year) where that scenario has no budget line would show the whole actual as variance against a budget that does not exist. An actual grain no budget scenario covers comes out once, under budget_scenario_id ''. PR #211 review 2, point 1: the '' (uncovered) rows are checked too. They never sit in an entity-year some active budget scenario budgets, and every actual grain of an uncovered entity-year has its '' row with the grain's actual amount (the running total to date in gold_variance_ytd). Each model groups by budget_scenario_id, so a grain cannot have two '' rows. Checked on each variance model (its period column in brackets): gold_variance_analysis (fiscal_period), gold_variance_quarterly (fiscal_quarter, through gold_period_hierarchy as the model maps it), gold_variance_ytd (fiscal_period). One row per problem: unbudgeted_year - a (budget_scenario_id, data_area_id, fiscal_year) in the model where the scenario has no budget line; blank_beside_scenario - a '' (data_area_id, fiscal_year) that some active budget scenario has budget lines for; uncovered_missing - an actual grain of an entity-year no active budget scenario covers with no '' row, or whose '' row carries another actual amount.
<sub>error (default) · tests/assert_variance_budget_matches_year.sql · konsolidat#206 konsolidat#211</sub>
variance_covers_budget_scenarios
konsolidat#206: every active budget-type scenario (its scenario_type declared in epm_gold.scenario_definitions) that has rows in gold_scenario_trial_balance has variance rows of its own (budget_scenario_id) in each variance model.
A model that does not yet carry budget_scenario_id covers no scenario, so the test fails on it rather than erroring. PR #211 review 4: and each budget scenario carries every actual grain of the (data_area_id, fiscal_year)s it budgets exactly once, with the actual amount of that grain (the running total to date in gold_variance_ytd): a model that repeats or sums the actuals across budget scenarios, or drops them, fails. The grain is the model's own: entity, fiscal year, period (fiscal_quarter in gold_variance_quarterly, through gold_period_hierarchy as the model maps it), main account and the budget dimensions. One row per problem: uncovered_scenario - a (model, budget scenario) with no variance rows; actual_not_once - a (model, budget scenario, actual grain) with no row or more than one; actual_amount - the grain's row carries another actual amount.
<sub>error (default) · tests/assert_variance_covers_budget_scenarios.sql · konsolidat#206 konsolidat#211</sub>
The chart of accounts
bs_only_bs_accounts
Balance sheet view should only contain BS accounts (is_balance_sheet = 1) The gold_balance_sheet model filters WHERE is_balance_sheet = 1, so no non-BS rows should appear
appear
<sub>error (default) · tests/assert_bs_only_bs_accounts.sql</sub>
every_account_is_pnl_or_balance_sheet
<sub>warn · tests/assert_every_account_is_pnl_or_balance_sheet.sql · konsol#182</sub>
governed_chart_declarations_usable
<sub>warn · tests/assert_governed_chart_declarations_usable.sql · konsol#182</sub>
governed_chart_grain_unique
<sub>warn · tests/assert_governed_chart_grain_unique.sql · konsol#182</sub>
is_equity_is_account_type_equity
konsolidat#213: is_equity says what the account IS — the chart types it as Equity — which is the meaning konsol's deal layer uses (business_combination.py: account_type == "Equity").
What the chart DECLARES about translation is a separate fact with its own column, uses_historical_rate. Deriving is_equity from fx_method conflated the two, so an asset declared at the historical rate read as equity and would have been eliminated as pre-acquisition equity by the acquisition journal. One row per account whose flags disagree with its declaration.
<sub>error (default) · tests/assert_is_equity_is_account_type_equity.sql · konsolidat#213</sub>
pnl_only_pnl_accounts
P&L view should only contain P&L accounts (is_pnl = 1 on each row) The gold_pnl_by_period model filters WHERE is_pnl = 1, so no non-PnL rows should appear
appear
<sub>error (default) · tests/assert_pnl_only_pnl_accounts.sql</sub>
undeclared_accounts_in_trial_balance
<sub>warn · tests/assert_undeclared_accounts_in_trial_balance.sql · konsol#182</sub>
Calendar and periods
auto_reversal_period_declared
konsol#305-D2-11: every auto_reversal lands on a declared Regular period strictly after its journal's own period.
konsol checks this when the journal is approved; this catches a calendar changed afterwards.
<sub>error (default) · tests/assert_auto_reversal_period_declared.sql · konsol#305</sub>
fiscal_calendar_is_loaded
#77 — Guard against the silent fiscal-calendar fallback (FY0/P0 regression).
silver_gl_entries joins each GL row to a fiscal calendar; when the join misses, ClickHouse fills fp.* with 0 and the model falls back to deriving the period from the posting date (see #65). That fallback is correct for calendar fiscal years but silently wrong for offset ones — and a missed join is exactly what put every row in FY0/P0 before #65/#76. This test fails if any entity that actually has GL activity points (via entity_fiscal_calendars) at a fiscal calendar that ISN'T loaded in silver_fiscal_periods. That is the precise condition under which the join silently misses, turning a future re-break (e.g. a seed pointing an active entity back at a non-existent calendar, or a calendar dropping out of the raw load) into a failing test instead of quietly-wrong numbers.
<sub>error (default) · tests/assert_fiscal_calendar_is_loaded.sql · konsolidat#65 konsolidat#76 konsolidat#77</sub>
period_net_equals_debit_minus_credit
period_net_amount must equal period_debit - period_credit per trial balance row.
e row. Fails on pre-fix gold until a full refresh rebuilds gold_trial_balance with the new measure.
<sub>error (default) · tests/assert_period_net_equals_debit_minus_credit.sql</sub>
ytd_at_last_regular_period_equals_annual
<sub>warn · tests/assert_ytd_at_last_regular_period_equals_annual.sql · konsol#230 konsolidat#199 konsolidat#220</sub>
Platform and data integrity
adjustment_type_populated
PRD-5 Test: Every row in fully consolidated TB must have an adjustment_type
<sub>error (default) · tests/assert_adjustment_type_populated.sql</sub>
auto_reversal_generated
konsol#305-D2-11: every line of an Approved journal that names a reversal period has an auto_reversal row in exactly that period, and no auto_reversal row exists without one.
NOT IN, never LEFT JOIN ... is null: under join_use_nulls=0 a miss reads '' and the old guard could never fail.
<sub>error (default) · tests/assert_auto_reversal_generated.sql · konsol#305</sub>
auto_reversal_negates_original
konsol#305-D2-2 / D2-11 (batch review 27 Sep finding 1): an auto_reversal row must net to exactly minus its original line, not merely exist in the right period (assert_auto_reversal_generated only checks presence).
Key a line by (consolidation_group, journal_id, data_area_id, main_account); sum net_amount per key, split between the auto_reversal rows and the rest. Only journals that have a reversal are compared (inner join): a journal with no reversal has no row in reversals and is silently skipped, never a LEFT JOIN ... IS NULL (konsolidat#249).
<sub>error (default) · tests/assert_auto_reversal_negates_original.sql · konsol#305 konsolidat#249</sub>
cast_to_decimal128_is_exact
depends_on: {{ ref('bronze_trial_balance_submissions') }} konsolidat#191: cast_to_decimal128(expr, scale) must recover the exact decimal value that was submitted, not truncate it.
toDecimal128(Float64, scale) truncates toward zero on the binary double, which is usually a hair below the decimal the value was entered as (e.g. 0.29 becomes 0.28). Summed over a trial-balance batch, balanced raw batches arrive unbalanced in bronze (konsolidat#191). A float sum (e.g. two submitted amounts added together, as gold_scenario_trial_balance.sql does) has the same problem even after the text-route fix, because the shortest text form of the sum itself can sit a hair below the cent (0.7 + 0.1 = 0.7999999999999999) — the macro now rounds to the target scale before the text step so this casts exactly too. Cases: an ordinary two-decimal amount, a large amount from the reported batch (177,485,814.95), a negative amount, a Nullable(Float64) input (assumeNotNull must still work through toString), a float sum whose binary result is a hair short of the cent, and a very small value at scale 12 (the exchange-rate caller's scale). Depends on bronze_trial_balance_submissions (not read otherwise) purely so CI's indirect test selection picks this test up whenever that model is selected — see dbt_project/tests/assert_ic_difference_account_in_chart.sql for the same pattern. bronze_trial_balance_submissions feeds silver_gl_entries -> gold_trial_balance_by_partner -> gold_consolidated_trial_balance, which is in tb_only_first_build.py's MUST_CREATE, so dbt build --select @silver_main_accounts (the tb-only-first-build CI job) now selects this test too.
<sub>error (default) · tests/assert_cast_to_decimal128_is_exact.sql · konsolidat#191</sub>
d365_gl_vouchers_balance
konsolidat#155 — every D365 voucher nets to zero at staging.
Silver derives debit/credit from the SIGN of the amount (konsolidat#112), so the amount has to arrive signed. The demo generator shipped magnitudes with the sign only in IsCredit; every credit was booked as a debit, every trial balance went one-sided, and nothing failed until assert_silver_gl_debit_credit_balance, three layers down, by entity-year, where it was mistaken for "demo-data tension". This fails at the source, per voucher, whatever the feed. It deliberately does not re-derive the sign from IsCredit: on real D365 that flag can disagree with the sign on storno lines (#112/#118, assert_is_credit_retired). A correctly signed voucher nets to zero either way. Grouped by voucher alone, entity-less headers included: a voucher must balance whatever entity it is attributed to.
<sub>error (default) · tests/assert_d365_gl_vouchers_balance.sql · konsolidat#112 konsolidat#118 konsolidat#155</sub>
incremental_slice_preserved
A2 / grynn-in/konsolidat#116 Test: incremental-by-period materialization.
A scoped orchestrator close (entity_scope / fiscal_year / fiscal_period vars) must update ONLY its own slice and leave every OTHER slice intact. Before A2 the four consolidation models were table-materialized, so a scoped run OVERWROTE the whole table — zeroing every entity/year outside the close. A2 made them incremental, rewriting only the close slice on each run, so a scoped run replaces only the in-scope slice and preserves the rest. Since #154, three of them do it with a pre_hook that deletes the slice before the SELECT appends it; gold_fully_consolidated_tb, which has no filters of its own, is a table again, rebuilt from the already-scoped upstream. This guard makes the old data-loss fail loudly. OPT-IN via a DEDICATED var assert_preserved_entity — deliberately distinct from the orchestrator's entity_scope so this guard never collides with the A1 confinement guard (assert_scoped_cash_flow_ytd_confined). With no var it returns no rows, so a normal full build always passes (byte-for-byte opt-in). Usage (after a full build, then a scoped close on a DIFFERENT entity): dbt run --select <4 incremental models> --vars '{entity_scope: DEMF, fiscal_year: 2024}' dbt test --select assert_incremental_slice_preserved --vars '{assert_preserved_entity: USMF}' RED (table mat — the scoped run wiped the table): USMF gone -> rows -> FAIL. GREEN (incremental — USMF slice preserved): USMF kept -> 0 rows -> PASS. NOTE: gold_fully_consolidated_tb carries the kept entity in its UNSCOPED acquisition/equity/topside layers too, so its entity-balance layer is isolated with adjustment_type = 'entity' (the layer fed by the scoped chokepoint).
<sub>error (default) · tests/assert_incremental_slice_preserved.sql · konsolidat#116 konsolidat#154</sub>
is_credit_retired
konsolidat#118 — the legacy is_credit flag is retired.
Since konsolidat#112 silver derives debit/credit purely from the SIGN of the (already-signed) accounting_currency_amount; is_credit no longer drives the split and must not be carried through the GL staging/bronze output. This guard fails the build if is_credit reappears as a column on the canonical staging model or the bronze GL fact, so the dead flag cannot silently creep back. Always-on (not opt-in): it asserts a permanent schema contract, returns 0 rows once is_credit is gone, and never touches model SQL — full builds are unchanged. RED before C1 (is_credit carried through staging→bronze); GREEN after.
<sub>error (default) · tests/assert_is_credit_retired.sql · konsolidat#112 konsolidat#118 konsolidat#124</sub>
journal_grain_unique
konsolidat#198 row J11 (PR #203 review 7) + row J13 (second review 2): layer 6 of gold_fully_consolidated_tb must carry the deal journals at the grain gold_consolidated_ytd windows over — exactly one row per period within the YTD window's PARTITION BY (consolidation_group, data_area_id, fiscal_year, main_account, adjustment_type, the dimension columns) for adjustment_type 'acquisition', 'goodwill_amortisation' and 'disposal'.
konsol#305 V03 (P6): layer 4 (topside adjustments) carries the same defect — it passed gold_consolidation_adjustments lines through unsummed, so two topside lines on one account, entity and period (or an auto_reversal line next to its original, konsol#305-D2-11) gave two running totals instead of one. Layer 4 now SUMs to this grain like layer 6, so this check also covers 'topside', 'reclassification' and 'auto_reversal'. Fixture: dbt_project/test_fixtures/assert_journal_grain_unique.topside.sql. The journals themselves post several lines to one account in one period when the roles differ: the acquisition journal's line (0) opening_balance and its equity_eliminated line on the same equity account (history fixture ZZ3100: -687.5 and +687.5), the disposal journal's derecognised and proceeds lines on the same cash account. gold_consolidated_ytd runs a rows between unbounded preceding and current row window ordered by fiscal_period, so two rows in one period give two running totals (-687.5, then 0) instead of one (0). Layer 6 SUMs each journal branch to this grain, like the proration branch and layer 1 already do; a row here means a branch passes journal lines through unsummed. Row J13: journal_id is NOT part of the key. The YTD window does not partition by it, so two journals of one entity posting to one account in one period (a second deal, or an amortisation instalment next to a disposal in the same period) would again be two rows under one running total; layer 6 therefore groups without journal_id (emitting any(journal_id)) and this test keys on exactly the window's partition columns plus fiscal_period. The journals seen so far are reported as journal_ids for the reader. Fixtures: dbt_project/test_fixtures/business_combination_history.sql and business_disposal.sql (+gold_fully_consolidated_tb assert_journal_grain_unique assert_acquisition_journal_balances).
<sub>error (default) · tests/assert_journal_grain_unique.sql · konsol#305 konsolidat#198 konsolidat#203</sub>
partner_grain_not_fanned_out
konsol#159 / #175 review (B1, B2): the partner column must not fan out any per-account figure.
With several partners on one account, a join or a running sum keyed without the partner multiplies it: 300 instead of 150 year on year, 250 instead of 150 YTD. 1. tb_grain: one gold_trial_balance row per (entity, year, period, account, dimensions). 2. consolidated_ytd: the entity layer of gold_consolidated_ytd is the true cumulative group amount of gold_consolidated_trial_balance summed to the account grain. Every model here rebuilds in the consolidation build scope (+tag:domain:consolidation), which picks this test whenever a trial balance is submitted (#175 re-review F1). gold_ytd_trial_balance and gold_prior_year_comparison do not rebuild there, so their grain is checked by single-model tests (assert_ytd_trial_balance_grain, assert_prior_year_comparison_grain), picked only when their model is.
<sub>error (default) · tests/assert_partner_grain_not_fanned_out.sql · konsol#159 konsolidat#175</sub>
prior_year_comparison_grain
konsol#159 / #175 review B1, re-review F1: gold_prior_year_comparison keeps one row per (entity, year, period, account, dimensions).
With a row per intercompany partner, each current row joined every prior-year partner row (300 instead of 150). Refs this model only, so a build picks the test exactly when it builds the model (see assert_ytd_trial_balance_grain).
<sub>error (default) · tests/assert_prior_year_comparison_grain.sql · konsol#159 konsolidat#175</sub>
reversal_nets_to_zero
PRD-16 Test: Original + reversal entries must net to zero per journal_id group
<sub>error (default) · tests/assert_reversal_nets_to_zero.sql</sub>
scope_resolves_to_entities
A1 / grynn-in/konsolidat#119 guard: an orchestrator scope close must resolve to at least one entity.
A misconfigured/unknown entity_scope code would match nothing in gold_consolidation_hierarchy, so scope_filter would silently narrow every consolidation model to ZERO rows and the close would "succeed" empty. This guard makes that fail the (test-gated) governed build loudly instead. OPT-IN: no entity_scope var => no rows (full build passes). With entity_scope set it returns one row (=> failure) only when the code resolves to 0 entities.
<sub>error (default) · tests/assert_scope_resolves_to_entities.sql · konsolidat#119</sub>
staging_not_stale
Fails when a write-through table's contents no longer match what its last successful sync says about it.
Background: D11 wanted ClickHouse to read Frappe's MariaDB directly so metadata could never go stale. F4 reversed that — write-through avoids making every dbt run a live dependency on the Frappe database. The cost of reversing it is losing D11's one real benefit, "never stale". This is how that comes back without the coupling. konsol's clickhouse.sync_table() stamps epm_staging.sync_watermark on every successful sync, and reconcile_all() re-stamps every table after migrate. Two things can then be detected: EMPTIED — the watermark promises rows the table no longer has. A wiped ClickHouse, a restore in the wrong order, a half-finished migration. LAGGING — a table missing from the latest reconcile run. reconcile_all() stamps every watermark it writes with one run id; a write-through stamps none (''). Every table with a watermark row and no row from the latest run is one that run could not reach, including a table no reconcile has ever stamped: one that has failed in every reconcile since the upgrade keeps only its old '' stamp, and is exactly the case below. (Retired tables lose their rows in konsol's _retired_watermark_cleanup; on 11 Oct 2026 every live table was in the 7 Oct reconcile, none is write-through only.) This is the case that matters most: epm_staging.ownership_periods held three rows dated 2026-06-19 for records Frappe no longer had, and AMDE at 75% from that ghost row drove every consolidated statement while Frappe's own Consolidation Group said 100%. konsolidat#246, option #246-1 (Deepak Pai, 11 Oct 2026). LAGGING used to mean "more than lag_hours older than the newest watermark of any table". One write-through edit then made every untouched table look stale: publishing one Reporting Hierarchy gave 26 LAGGING rows for tables whose rows were current. A write-through neither joins nor leaves a run, so it can no longer do that. Rejected: #246-2 (drop LAGGING) and #246-3 (raise the lag hours). The latest run is the settled run that started last (its earliest stamp). A run is settled once its newest stamp is at least watermark_run_settle_seconds (default 60) old: a reconcile still running when dbt tests (a fresh install's queued reconcile_warehouse can overlap one) has stamped only the tables it has reached so far, and judging it would report the rest LAGGING for the second or so it takes to finish. Until it settles, the run before it is judged. A run that failed or was killed partway is the latest run once settled, so every table it did not reach is LAGGING, even one a write-through has refreshed since: the rule asks whether the reconcile reached the table, not whether the table is recent. NO_RECONCILE_RUN — no reconcile has stamped a run id yet. An upgrading site is in this state from the moment the watermark gains its reconcile_run_id column (konsol's ensure_reference_tables(), or sync_watermark_upgrade() in on-run-start) until the first reconcile after it, which konsol's migrate runs. That window must not go red, and must not pass for ever either: the test allows lag_hours from the column's arrival, read from system.tables.metadata_modification_time, then fails. Both writers issue that ALTER only when the column is missing, because an ALTER that changes nothing still moves that time. Deliberately NOT dbt's built-in source freshness. That keys on the data's own updated_at, so a table nobody edited reads as stale and an empty table reads as stale — on this project it marks most of epm_staging red, which is why nobody runs it. The watermark records when the sync ran, not when the data changed, so "unchanged" and "not syncing" stop looking alike. Tune the grace with --vars '{"watermark_lag_hours": N}'. It now bounds only NO_RECONCILE_RUN; LAGGING has no time threshold. Returns one row per problem — dbt fails the run when any row comes back.
<sub>error (default) · tests/assert_staging_not_stale.sql · konsolidat#246</sub>
ytd_trial_balance_grain
konsol#159 / #175 review B2, re-review F1: gold_ytd_trial_balance keeps one row per (entity, year, period, account, dimensions).
With a row per intercompany partner, each got a partial running total (250 instead of 150). Refs this model only, so a build picks the test exactly when it builds the model: the consolidation scope does not rebuild it, and a test comparing it with a model that scope does rebuild failed every trial balance submission's build against a stale table.
<sub>error (default) · tests/assert_ytd_trial_balance_grain.sql · konsol#159 konsolidat#175</sub>
Other
consolidation_journal_names_every_journal
konsol#305 V05 (batch review finding 2): gold_consolidation_journal is the audit trail the 8.2 drill reads (E10), and it must name every journal it reports on.
Before the fix, layer 4 of gold_fully_consolidated_tb sums topside/reclassification/auto_reversal lines to the account grain and reports any(journal_id) for the group — one journal name survives when two journals post to the same account in the same period (batch review 27 Sep finding 2: ZZJ-00001 and ZZJ-00002 on one key became one row labelled with only one of them). This test returns every journal_id present in gold_consolidation_adjustments (the topside/reclassification/ auto_reversal rows, none of them 'entity') that is absent from gold_consolidation_journal. Fixture: dbt_project/test_fixtures/assert_journal_grain_unique.topside.sql (reused from V03, not copied): ZZJ-00001 and ZZJ-00002, both Dr ZZ1100 / Cr ZZ2100, ZZG/ZZS FY2026 P3.
<sub>error (default) · tests/assert_consolidation_journal_names_every_journal.sql · konsol#305</sub>
equity_never_revalued
konsolidat#257 Q2 (decided by Deepak Pai, 6 Oct 2026): equity is never revalued.
An equity account's translated movement is its local movement at the rate the row declares (historical, else the closing rate of the period it was posted in), whatever its fx_method. A balance sheet balance is retranslated at each closing rate (#257), but an equity balance is not: retranslating it would bury the exchange difference in equity lines and leave no separate component to recycle on disposal (IAS 21.39(c), .48). So on every equity row (is_equity = 1, from the chart): | translated_amount - local_amount x translation_rate | <= 0.01 A revaluation shows up as exactly that difference: a filler row with local_amount = 0 and a translated amount, or a retranslation_amount on a row that moved. The one declared exception is the year-end close leg of the retained-earnings account (konsolidat#259-1, decided 6 Oct 2026): in a Closing-type period, retained earnings is credited with the year's translated result, not its local result at a rate. That leg is governed by assert_year_end_close_carries_no_cta, so this test leaves the retained-earnings account's rows in Closing periods to it. Nothing else is exempt: another equity account in a Closing period is still checked.
<sub>error (default) · tests/assert_equity_never_revalued.sql · konsolidat#257 konsolidat#259</sub>
method_declared_for_multi_path
konsol#117 (design section 2): when a group reaches an entity along several paths and the links do not settle the method — their weakest-link methods disagree, or no path is all-full and the paths sum past DECLARATION_TRIGGER_PCT (50%, the IFRS 10.B35 presumption of control) — the group must DECLARE the method (Consolidation Method Declaration on the group node, synced to epm_staging.consolidation_method_declarations).
The macro resolves such a row as method_source = 'undeclared' and consolidation_method 'none', so nothing consolidates for (group, entity); this test fails the build naming the group, the entity, the period, the sum and the paths. The percentage decides nothing here: 60% held as two 30% equity stakes may be joint control (IFRS 11) or control (IFRS 10); only the group can say. Fixtures: assert_method_declared_for_multi_path.undeclared.must_flag.sql (flags 1), .declared_full.sql and .declared_equity.sql (pass).
<sub>error (default) · tests/assert_method_declared_for_multi_path.sql · konsol#117</sub>