Bronze Models
16 models in the epm_bronze schema. Bronze casts the canonical staging views to ClickHouse types and gives them a sorting key. No business logic.
Two kinds of source:
- ERP data (15 models) read the staging views in
epm_staging(see Staging). Six read a canonicalstg_*model and so work for every ERP invar('erp_sources'). Nine read a D365 F&O adapter model directly; withd365_fonot inerp_sourceseach compiles to an empty relation with its normal columns (empty_relation(),macros/erp_sources.sql), so downstream models keep building. - Trial-balance upload (1 model,
bronze_trial_balance_submissions) reads the tables konsol's Trial Balance Submission doctype lands inepm_raw.
Column types below are the cast the model applies (db_adapter.sql macros). Every ERP model also carries _airbyte_extracted_at (DateTime) and _airbyte_raw_id (String).
General Ledger
bronze_general_journal_account_entries
GL lines from stg_gl_entries (all ERPs). Incremental (delete+insert on recid), ReplacingMergeTree(_airbyte_extracted_at), partitioned by toYear(accounting_date), cluster-aware. Joins stg_d365_fo__gl_entries for the two D365-only columns only when d365_fo is listed; otherwise they are 0. Each incremental run re-reads rows extracted at or after the last loaded batch.
| Column | Type | Description |
|---|---|---|
recid | Int64 | Source record id (D365 RecId; ERPNext a hash of name) |
data_area_id | String | Legal entity |
accounting_date | Date | Posting date |
main_account | String | Account code |
accounting_currency_amount | Decimal(38,2) | Signed amount: positive debit, negative credit. Silver derives debit/credit from the sign |
reporting_currency_amount | Decimal(38,2) | D365 reporting-currency amount; 0 for other ERPs |
transaction_currency_amount | Decimal(38,2) | Amount in transaction currency |
transaction_currency_code | String | Transaction currency |
posting_type | String | Posting type |
general_journal_entry_recid | Int64 | Journal header RecId (D365 only; 0 otherwise) |
ledger_account | String | Full ledger account string |
description | String | Posting text |
partner_data_area_id | String | Intercompany partner entity, '' when none (konsol#159). NULL in every adapter today |
dim_* | String | One column per declared dimension (dim_select_from_source) |
bronze_general_journal_entries
Journal headers from stg_d365_fo__gl_journal_entries (D365 only). Incremental like the lines.
Columns: recid, data_area_id, accounting_date, journal_number, journal_category, document_number, document_date, description, posting_layer, fiscal_calendar_period, fiscal_calendar_year_recid.
Chart of Accounts
bronze_main_accounts
ERP chart from stg_accounts (all ERPs). Note: since konsol#182 silver_main_accounts reads the governed chart in epm_staging.main_accounts, not this table; this table is kept for the ERP view of the chart.
Columns: main_account_id, account_name, account_type, main_account_category, debit_credit_default, chart_of_accounts, is_suspended (Int8).
bronze_main_account_categories
From stg_d365_fo__main_account_categories (D365 only). Columns: recid (hash of RecId), account_category, description, account_type, is_closed.
Organization
bronze_legal_entities
From stg_legal_entities (all ERPs). Columns: data_area, entity_name, accounting_currency, reporting_currency, party_number, country_region. Since konsolidat#255 the consolidation models take an entity's currency from konsol's Entity master (silver_entity_currencies), not from here.
Fiscal Calendar
bronze_fiscal_calendars
From stg_d365_fo__fiscal_calendars (D365 only). Columns: calendar_id, calendar_name, start_date, end_date, recid.
bronze_fiscal_calendar_years
From stg_d365_fo__fiscal_calendar_years (D365 only). Columns: fiscal_calendar, year_name, start_date, end_date, recid. silver_fiscal_periods generates monthly periods from these year ranges.
Financial Dimensions
bronze_financial_dimensions
From stg_d365_fo__financial_dimensions (D365 only). Columns: dimension_name, description, backing_entity_type, is_active (Int8), recid.
bronze_financial_dimension_values
From stg_d365_fo__financial_dimension_values (D365 only). Columns: dimension_name, dimension_value, description, is_suspended (Int8), active_from, active_to, recid.
Exchange Rates
bronze_exchange_rate_currency_pairs
From stg_exchange_rates (all ERPs). Partitioned by toYear(valid_from).
| Column | Type | Description |
|---|---|---|
from_currency | String | Source currency |
to_currency | String | Target currency |
valid_from | Date | Effective start |
valid_to | Date | Effective end (2099-12-31 when open) |
exchange_rate | Decimal(38,12) | TRUE rate. The D365 adapter divides out ConversionFactor (Hundred, Thousand, ...) once in staging (#138); no later layer scales a rate. Scale 12 keeps per-10000 quotes from rounding to 0 |
exchange_rate_type | String | Rate type |
recid | UInt64 | rowNumberInAllBlocks() (positional) |
These are the ERP quotes. Consolidation translates only from the governed rates in epm_staging.group_exchange_rates; the ERP quotes pre-fill drafts in konsol.
bronze_exchange_rate_types
From stg_d365_fo__exchange_rate_types (D365 only). Columns: exchange_rate_type, type_name, description, recid.
Budget
bronze_budget_register_entries
Register headers from stg_d365_fo__budget_register_entries (D365 only). Columns: recid, data_area_id, budget_model_id, budget_transaction_code, reason_comment, budget_status, document_date.
bronze_budget_transaction_lines
Budget lines from stg_budget_entries (all ERPs), partitioned by toYYYYMM(transaction_date). Joins stg_d365_fo__budget_entries for budget_register_entry_recid and include_in_cash_flow when d365_fo is listed; otherwise 0. A full table, not incremental: the staging record_id is positional.
Columns: recid, budget_register_entry_recid, transaction_date, main_account, accounting_currency_amount, transaction_currency_amount, transaction_currency, the budget dimensions (get_budget_dimensions()), include_in_cash_flow (Int8).
Consolidation
bronze_consolidation_account_groups
D365 consolidation account groups from stg_d365_fo__consolidation_groups (D365 only). Columns: consolidation_account_group, group_name, description, recid. Not read by any silver or gold model; konsol's Consolidation Group doctype defines the group structure.
Trial Balance
bronze_trial_balance_snapshot
Fiscal-year trial-balance snapshots from stg_trial_balance (all ERPs; D365 TrialBalanceFiscalYearSnapshots, ERPNext aggregated from GL Entry). Partitioned by fiscal_year.
Columns: data_area_id, main_account, main_account_name, fiscal_year, opening_balance, debit_amount, credit_amount, closing_balance (all Decimal(38,2)), currency_code, account_type.
bronze_trial_balance_submissions
The trial balances konsol's Trial Balance Submission doctype lands in epm_raw.trial_balance_submissions, restricted to claimed batches: raw rows INNER JOIN the control table epm_raw.trial_balance_submission_control (one row per claimed batch_id, grouped first so a duplicated claim cannot fan rows out). An unclaimed batch (a crash mid-submit, a cancelled submission) is invisible here without any delete; resubmission is a new batch_id. Cluster-aware.
Columns that konsol adds to the raw tables later than the model (partner_data_area_id, the declared dim_* columns, amount_basis) are read only when present, so the two repos deploy in either order.
| Column | Type | Description |
|---|---|---|
batch_id | String | The claimed batch |
data_area_id | String | Legal entity |
fiscal_year | UInt16 | Fiscal year |
fiscal_period | UInt8 | Fiscal period |
main_account | String | Account code |
debit_amount, credit_amount | Decimal(38,2) | As submitted (cast_to_decimal128(..., 2): rounded, never truncated, konsolidat#191) |
description | String | Row description |
partner_data_area_id | String | Intercompany partner, '' when none (konsol#159) |
dim_* | String | The submitted file's declared dimension values (konsol#255) |
submission_name | String | Trial Balance Submission document name |
submitted_at | DateTime | When the rows were landed |
claimed_at | DateTime | Latest claim time |
claimed_row_count | UInt32 | Row count the claim recorded |
amount_basis | String | Period movement, Year-to-date movement or Period-end balance; '' = undeclared, which assert_tb_submission_has_basis refuses (konsolidat#199) |
Read by silver_tb_movements. Tests: assert_tb_submission_batches_balance, assert_tb_submission_has_basis, assert_tb_submission_rows_complete, assert_tb_submission_single_batch_per_period, assert_tb_submission_period_start_not_epoch.