Skip to main content

Gold Models

Business-ready models in the epm_gold schema, consumed by the Frappe API and Excel reports.

Trial Balance & GL

gold_trial_balance

Period-level trial balance aggregated from GL entries. Primary model for the actuals scenario.

ColumnTypeDescriptionTest
data_area_idStringLegal entity identifiernot_null
fiscal_yearUInt16Fiscal yearnot_null
fiscal_periodUInt8Fiscal period (1–12)not_null
main_accountStringMain account ID from chart of accountsnot_null
dim_cost_centerStringCost center dimension
dim_departmentStringDepartment dimension
dim_business_unitStringBusiness unit dimension
period_debitDecimalsum(debit_amount)
period_creditDecimalsum(credit_amount)
period_net_amountDecimalsum(accounting_currency_amount)
transaction_countUInt64count(*)

API mapping: scenario=actuals → queries this table.

gold_ytd_trial_balance

Year-to-date running totals over gold_trial_balance.

ColumnTypeDescriptionTest
data_area_idStringLegal entity identifiernot_null
fiscal_yearUInt16Fiscal year
fiscal_periodUInt8Fiscal period
main_accountStringMain account ID
dim_cost_centerStringCost center
dim_departmentStringDepartment
dim_business_unitStringBusiness unit
ytd_debitDecimalCumulative debit through period
ytd_creditDecimalCumulative credit through period
ytd_net_amountDecimalCumulative net amount through periodnot_null desc

Test: assert_ytd_p12_equals_annual — YTD at period 12 must equal sum of all 12 periods.

P&L Models

gold_pnl_by_period

P&L view — revenue and expense accounts only.

ColumnTypeDescriptionTest
data_area_idStringLegal entitynot_null
fiscal_yearUInt16Fiscal year
fiscal_periodUInt8Fiscal period
main_accountStringAccount (revenue/expense only)not_null
account_typeStringRevenue or Expense
period_net_amountDecimalNet amount for period

Test: assert_pnl_only_pnl_accounts — only P&L account types present.

gold_pnl_quarterly

Quarterly P&L aggregation for P&L accounts.

ColumnTypeDescriptionTest
data_area_idStringLegal entity
fiscal_yearUInt16Fiscal year
fiscal_quarterStringQuarter label (Q1–Q4)not_null
main_accountStringAccount
quarter_net_amountDecimalSum of period_net_amount for the quarter

gold_pnl_half_yearly

Half-yearly P&L aggregation for P&L accounts.

ColumnTypeDescriptionTest
data_area_idStringLegal entity
fiscal_yearUInt16Fiscal year
fiscal_halfStringHalf label (H1, H2)not_null
main_accountStringAccount
half_net_amountDecimalSum of period_net_amount for the half

Balance Sheet Models

gold_balance_sheet

Balance sheet view — cumulative balances for BS accounts.

ColumnTypeDescriptionTest
data_area_idStringLegal entitynot_null
fiscal_yearUInt16Fiscal year
fiscal_periodUInt8Fiscal period
main_accountStringAccount (asset/liability/equity only)not_null
account_typeStringAsset, Liability, or Equity
cumulative_balanceDecimalRunning sum of period_net_amount within the year

Test: assert_bs_only_bs_accounts — only BS account types present.

gold_bs_movement

Balance sheet movement schedule: opening, movement, closing.

ColumnTypeDescriptionTest
data_area_idStringLegal entity
fiscal_yearUInt16Fiscal year
fiscal_periodUInt8Fiscal period
main_accountStringAccountnot_null
opening_balanceDecimalCumulative balance at prior period
period_movementDecimalNet amount for the period
closing_balanceDecimalCumulative balance at current period

Consolidation Models

gold_consolidated_trial_balance

Multi-company consolidated trial balance with currency translation.

ColumnTypeDescriptionTest
consolidation_groupStringGroup identifiernot_null
data_area_idStringLegal entitynot_null
fiscal_yearUInt16Fiscal year
fiscal_periodUInt8Fiscal period
main_accountStringAccount
local_amountDecimalAmount in entity's local currency
accounting_currencyStringEntity's local currency code
reporting_currencyStringGroup reporting currency
translation_rateDecimalFX rate applied
closing_rateDecimalPeriod-end FX rate
average_rateDecimalPeriod average FX rate
translated_amountDecimallocal_amount × translation_rate
ownership_pctDecimalParent's ownership percentage
group_amountDecimaltranslated_amount × ownership_pct
nci_amountDecimaltranslated_amount × (1 − ownership_pct)

Tests: assert_translated_amount_formula, assert_group_amount_formula, assert_nci_plus_group_equals_translated, assert_nci_zero_for_full_ownership, assert_bs_uses_closing_rate, assert_pnl_uses_average_rate.

gold_ic_eliminations

Intercompany elimination entries.

ColumnTypeDescriptionTest
consolidation_groupStringGroup identifier
fiscal_yearUInt16Fiscal year
fiscal_periodUInt8Fiscal period
rule_idStringIC elimination rule IDnot_null
debit_eliminationDecimalDebit-side elimination amount
credit_eliminationDecimalCredit-side elimination amount
elimination_amountDecimalLesser of debit/credit IC balances

Test: assert_ic_elimination_nets_zero — eliminations net to zero per group/year/period.

gold_fx_revaluation

Currency translation adjustment (CTA) entries.

ColumnTypeDescriptionTest
consolidation_groupStringGroup identifiernot_null
data_area_idStringEntity
fiscal_yearUInt16Fiscal year
fiscal_periodUInt8Fiscal period
cta_amountDecimalsum(local × (closing − average) × ownership)

Tests: assert_cta_not_zero_when_rates_differ, assert_cta_zero_for_same_currency.

gold_consolidation_adjustments

Top-side journal adjustments for consolidation.

ColumnTypeDescriptionTest
consolidation_groupStringGroup identifiernot_null
journal_idStringJournal entry IDnot_null
adjustment_typeStringType of adjustment
data_area_idStringEntity
fiscal_yearUInt16Fiscal year
fiscal_periodUInt8Fiscal period
main_accountStringAccount
debit_amountDecimalDebit
credit_amountDecimalCredit
net_amountDecimaldebit_amount − credit_amount

Test: assert_topside_journal_balanced — each journal must balance (debits = credits).

gold_fully_consolidated_tb

Unified consolidated TB: entity balances + IC eliminations + CTA + topside adjustments.

ColumnTypeDescriptionTest
consolidation_groupStringGroup identifiernot_null
adjustment_typeStringLayer: entity, ic_elimination, cta, or topside typenot_null
data_area_idStringEntity (or blank for non-entity layers)
fiscal_yearUInt16Fiscal year
fiscal_periodUInt8Fiscal period
main_accountStringAccount
amountDecimalAmount for this layer

Test: assert_fctb_entity_layer_ties — entity layer ties to gold_consolidated_trial_balance.group_amount.

gold_consolidated_ytd

Year-to-date running totals on fully consolidated trial balance.

ColumnTypeDescriptionTest
consolidation_groupStringGroup identifiernot_null
adjustment_typeStringLayer type
fiscal_yearUInt16Fiscal year
fiscal_periodUInt8Fiscal period
main_accountStringAccount
ytd_amountDecimalCumulative sum of amount through period

Advanced Consolidation Models

These models implement IFRS consolidation mechanics on top of gold_consolidated_trial_balance. See the PRD-* comment at the top of each .sql for the requirement reference.

gold_consolidation_hierarchy

Multi-level consolidation group hierarchy with effective ownership (PRD-8). Reads from the epm_staging.consolidation_hierarchy source when populated; otherwise falls back to a flat, single-level hierarchy derived from the consolidation_groups seed. Grain: one row per consolidation_group × data_area_id.

ColumnTypeDescriptionTest
consolidation_groupStringGroup identifiernot_null
data_area_idStringLegal entity
parent_groupStringParent group in the hierarchy (blank at top level)
hierarchy_levelUInt8Depth in the hierarchy (1 = top in fallback)
effective_ownership_pctDecimalEffective ownership through the hierarchy chain
pathStringMaterialized path, e.g. group/entity

See gold_consolidation_hierarchy.sql.

gold_equity_method_associates

Equity-method entries for associates with 20–50% ownership (PRD-14), generated for entities where consolidation_groups.consolidation_method = 'equity'. For each entity/period it computes equity_income = net_income × ownership_pct (P&L accounts from gold_trial_balance, P&L filtered via silver_main_accounts.is_pnl) and emits two single-line entries per period using reserved accounts EQ_INCOME and EQ_INVEST. Grain: two rows per consolidation_group × data_area_id × fiscal_year × fiscal_period (income recognition + investment movement).

ColumnTypeDescriptionTest
consolidation_groupStringGroup identifiernot_null
data_area_idStringAssociate entity
fiscal_yearUInt16Fiscal year
fiscal_periodUInt8Fiscal period
main_accountStringEQ_INCOME or EQ_INVEST
account_nameStringEquity method - share of profit / Equity method - investment
reporting_currencyStringGroup reporting currency
amountDecimalnet_income × ownership_pct
adjustment_typeStringConstant equity_method
journal_idStringEQ_{entity}_{year}_P{period}

See gold_equity_method_associates.sql.

gold_acquisition_adjustments

Step-acquisition adjustments — P&L proration, goodwill, and fair value adjustments (PRD-11), driven by epm_staging.ownership_periods rows with an acquisition_date. P&L for the acquisition year is prorated to post-acquisition months only (via the prorate_period_amount macro), and goodwill = acquisition_price − (net_assets × ownership_pct / 100). Grain: one row per generated adjustment entry.

ColumnTypeDescriptionTest
consolidation_groupStringGroup identifiernot_null
data_area_idStringAcquired entity
fiscal_yearUInt16Fiscal year
fiscal_periodUInt8Fiscal period
main_accountStringSource account, 1800 (goodwill), or 1900 (FVA)
account_nameStringAccount / entry description
adjustment_typeStringpnl_proration, goodwill, or fair_value_adjustment
adjustment_amountFloat64Amount of the acquisition adjustment
acquisition_dateDateAcquisition date driving the proration

See gold_acquisition_adjustments.sql.

gold_disposal_adjustments

Disposal gain/loss and CTA recycling at deconsolidation (PRD-12), driven by epm_staging.ownership_periods rows where is_disposal = 1. Computes gain_loss = disposal_price − (net_assets × ownership_pct / 100) − remaining_goodwill (remaining goodwill sourced from gold_acquisition_adjustments), plus reclassification of accumulated CTA from gold_fx_revaluation to P&L at the disposal date (IAS 21.48). Grain: one row per generated disposal entry.

ColumnTypeDescriptionTest
consolidation_groupStringGroup identifiernot_null
data_area_idStringDisposed entity
fiscal_yearUInt16Year derived from disposal_date
fiscal_periodUInt8Period derived from disposal_date
disposal_priceFloat64Disposal proceeds (0 on CTA recycling rows)
net_assetsFloat64Net assets at disposal (0 on CTA recycling rows)
ownership_pctFloat64Ownership percentage disposed
remaining_goodwillFloat64Unamortized goodwill at disposal
gain_loss_amountFloat64Disposal gain/loss or recycled CTA amount
adjustment_typeStringdisposal_gain_loss or cta_recycling
disposal_dateDateDisposal date

See gold_disposal_adjustments.sql.

gold_nci_movement_schedule

Non-controlling interest movement schedule (PRD-13), built for fully consolidated entities where consolidation_groups.ownership_pct < 100 and consolidation_method = 'full'. NCI share of profit comes from gold_consolidated_trial_balance.nci_amount over P&L accounts; the NCI closing balance from the same column over balance-sheet accounts. Grain: one row per consolidation_group × data_area_id × fiscal_year × fiscal_period.

ColumnTypeDescriptionTest
consolidation_groupStringGroup identifiernot_null
data_area_idStringSubsidiary entitynot_null
entity_nameStringSubsidiary name
fiscal_yearUInt16Fiscal year
fiscal_periodUInt8Fiscal period
nci_pctDecimalNCI percentage (1 − ownership_pct)
nci_closing_balanceDecimalNCI balance from BS nci_amount
share_of_profitDecimalNCI share of profit for the period
consolidation_methodStringfull

See gold_nci_movement_schedule.sql.

gold_ic_reconciliation

Intercompany reconciliation — matched vs unmatched balances per entity pair (PRD-15). Joins gold_consolidated_trial_balance.group_amount for both sides of each ic_elimination_rules debit/credit account pair within a group/period, restricted to entity_a < entity_b to avoid duplicate pairs. Grain: one row per group × period × entity pair × matched account pair.

ColumnTypeDescriptionTest
consolidation_groupStringGroup identifier
entity_aStringFirst entity in the pairnot_null
entity_bStringSecond entity in the pair
fiscal_yearUInt16Fiscal year
fiscal_periodUInt8Fiscal period
account_aStringIC account on entity A (rule debit account)
account_bStringIC account on entity B (rule credit account)
balance_aDecimalEntity A group balance
balance_bDecimalEntity B group balance
net_balanceDecimalbalance_a + balance_b
match_statusStringmatched when abs(net_balance) < 0.01, else unmatched

See gold_ic_reconciliation.sql.

gold_consolidation_journal

Unified audit trail of all consolidation journal entries (PRD-22). One row per non-entity journal entry from gold_fully_consolidated_tb (i.e. all rows where adjustment_type != 'entity'), split into debit/credit by sign. Grain: one row per source journal entry.

ColumnTypeDescriptionTest
consolidation_groupStringGroup identifier
data_area_idStringEntity (or blank for non-entity layers)
fiscal_yearUInt16Fiscal year
fiscal_periodUInt8Fiscal period
main_accountStringAccount
account_nameStringAccount / entry description
adjustment_typeStringSource layer typenot_null
journal_idStringJournal identifier linking to source adjustment
reporting_currencyStringGroup reporting currency
debit_amountDecimalamount when amount >= 0, else 0
credit_amountDecimal-amount when amount < 0, else 0
net_amountDecimalSigned amount
entry_sourceStringCopy of adjustment_type

See gold_consolidation_journal.sql.

gold_consolidation_waterfall

Single-row consolidation build-up per group per period (PRD-22). Pivots the layers of gold_fully_consolidated_tb into cumulative checkpoints: entity → IC elimination → CTA → topside → equity method → acquisition/disposal → final. Grain: one row per consolidation_group × fiscal_year × fiscal_period.

ColumnTypeDescriptionTest
consolidation_groupStringGroup identifiernot_null
fiscal_yearUInt16Fiscal year
fiscal_periodUInt8Fiscal period
entity_amountDecimalEntity-layer total
after_ic_elimDecimalentity + ic_elimination
after_ctaDecimalafter_ic_elim + cta
after_topsideDecimalafter_cta + topside (incl. reclassification, auto_reversal)
after_equity_methodDecimalafter_topside + equity_method
final_amountDecimalSum of all layers
ic_elimination_amountDecimalIC elimination layer
cta_amountDecimalCTA layer
topside_amountDecimalTopside layer
equity_method_amountDecimalEquity-method layer
acq_disposal_amountDecimalAcquisition/disposal layer (proration, goodwill, FVA, disposal gain/loss, CTA recycling)

See gold_consolidation_waterfall.sql.

Allocation Model

gold_allocation_results

Results of driver-based cost allocations (multi-step cascade).

ColumnTypeDescriptionTest
allocation_rule_idStringRule identifiernot_null
step_orderUInt8Step number in cascade (1, 2, 3)
data_area_idStringEntity
fiscal_yearUInt16Fiscal year
fiscal_periodUInt8Fiscal period
source_accountStringAccount being allocated from
source_cost_centerStringCost center being allocated from
target_cost_centerStringCost center receiving allocation
target_accountStringAccount receiving allocation
driver_typeStringDriver used (headcount, sqm, revenue)
pool_amountDecimalTotal amount in the allocation pool
driver_weightDecimalRecipient's share (0–1)
allocated_amountDecimalAmount allocated to this target

Tests: assert_each_step_sums_to_pool, assert_no_self_allocation.

gold_allocation_audit_trail

Audit trail of all allocation runs — active and reversed — for traceability (PRD-21). Joins epm_staging.allocation_runs to gold_allocation_results on fiscal_year / fiscal_period; for runs with status = 'Reversed' the allocated amount is negated. Grain: one row per run × allocation result line.

ColumnTypeDescriptionTest
allocation_run_idStringRun identifier for traceability
run_statusStringActive or Reversed
run_byStringUser who ran the allocation
run_atDateTimeRun timestamp
reversal_ofStringRun ID this run reverses (if a reversal)
allocation_rule_idStringAllocation rule
step_orderUInt8Step number in the cascade
data_area_idStringEntity
fiscal_yearUInt16Fiscal year
fiscal_periodUInt8Fiscal period
source_accountStringAccount allocated from
source_cost_centerStringCost center allocated from
target_cost_centerStringCost center receiving allocation
target_accountStringAccount receiving allocation
driver_typeStringAllocation driver
pool_amountDecimalTotal pool amount
driver_weightDecimalRecipient's share (0–1)
allocated_amountDecimalAllocated amount (negated when run is reversed)

See gold_allocation_audit_trail.sql.

Budget & Variance Models

gold_spread_budget

Annual budget spread across 12 periods using profile weights. Primary model for the budget scenario.

ColumnTypeDescriptionTest
scenario_idStringBudget scenario IDnot_null
data_area_idStringEntity
fiscal_yearUInt16Fiscal year
fiscal_periodUInt8Fiscal period (1–12)
main_accountStringAccount
dim_cost_centerStringCost center
dim_departmentStringDepartment
annual_amountDecimalTotal annual budget
spread_profile_idStringSpread profile used
period_weightDecimalWeight for this period
period_amountDecimalannual_amount × period_weight

API mapping: scenario=budget → queries this table. Tests: assert_spread_sums_to_annual, assert_spread_has_12_periods.

gold_variance_analysis

Actual vs budget variance with favorable/unfavorable logic. Primary model for the variance scenario.

ColumnTypeDescriptionTest
data_area_idStringEntity
fiscal_yearUInt16Fiscal year
fiscal_periodUInt8Fiscal period
main_accountStringAccountnot_null
account_typeStringRevenue or Expense
actual_amountDecimalFrom trial balance
budget_amountDecimalFrom spread budget
variance_absDecimalactual_amount − budget_amount
variance_pctDecimalVariance as % of budget
variance_favorableUInt81 if favorable, 0 if unfavorable

API mapping: scenario=variance → queries this table. Tests: assert_variance_abs_formula, assert_favorable_revenue, assert_favorable_expense.

gold_variance_ytd

YTD variance: actual vs budget with running totals.

ColumnTypeDescriptionTest
data_area_idStringEntity
fiscal_yearUInt16Fiscal year
fiscal_periodUInt8Fiscal period
main_accountStringAccountnot_null
ytd_actualDecimalYear-to-date actual amount
ytd_budgetDecimalYear-to-date budget amount

gold_variance_quarterly

Quarterly variance: actual vs budget aggregated by quarter.

ColumnTypeDescriptionTest
data_area_idStringEntity
fiscal_yearUInt16Fiscal year
fiscal_quarterStringQuarter (Q1–Q4)not_null
main_accountStringAccount

gold_prior_year_comparison

Current vs prior year comparison with YoY variance.

ColumnTypeDescriptionTest
data_area_idStringEntity
fiscal_yearUInt16Current fiscal year
fiscal_periodUInt8Fiscal period
main_accountStringAccountnot_null
current_amountDecimalCurrent year period amount
prior_year_amountDecimalSame period prior year amount
yoy_variance_absDecimalcurrent_amount − prior_year_amount

Scenario & Period Models

gold_scenario_versions

Scenario version metadata from seed and API.

ColumnTypeDescriptionTest
scenario_idStringScenario identifiernot_null
scenario_nameStringDisplay name
scenario_typeStringactual, budget, forecast, whatif
is_activeUInt81 = active

gold_scenario_trial_balance

Union of actual + budget + forecast across all scenarios.

ColumnTypeDescriptionTest
scenario_idStringScenario identifiernot_null
data_area_idStringEntitynot_null
fiscal_yearUInt16Fiscal year
fiscal_periodUInt8Fiscal period
main_accountStringAccount
amountDecimalPeriod amount for the scenario

gold_period_hierarchy

Period dimension mapping fiscal_period to quarter and half labels.

ColumnTypeDescriptionTest
fiscal_periodUInt8Period number (1–12)not_null, unique
fiscal_quarterStringQuarter label (Q1–Q4)
fiscal_halfStringHalf-year label (H1, H2)

Data Quality Models

gold_unmapped_dimension_values

The "needs harmonization" review queue. Surfaces distinct (erp_source, dimension, source_value) triples present in stg_gl_entries (across dim_cost_center, dim_department, dim_business_unit) that have no published row in dimension_mappings — matched against both canonical_value and source_value of Published mappings via a left anti join. Because dim_harmonize() passes unmapped values through verbatim, an unmapped value appears in stg_gl_entries as its raw source value. Drives the Dimension Mapping review report. Grain: one row per distinct unmapped (erp_source, dimension, source_value).

ColumnTypeDescriptionTest
erp_sourceStringSource ERP system
dimensionStringdim_cost_center, dim_department, or dim_business_unit
source_valueStringRaw, unmapped dimension value

See gold_unmapped_dimension_values.sql.