Skip to main content

Multi-ERP Consolidation: From Many Sources to One Set of Numbers

How data from several ERPs — D365 F&O, ERPNext, and in future SAP and others — converges into a single silver and gold layer, producing one trial balance and one consolidation regardless of how many source systems feed it.

This document tells the end-to-end story. For the precise column contract every source adapter must satisfy, see Canonical Staging Schema & Adapter Interface.

Status as of 2026-11-05

The architecture below is built: 7 canonical models under models/staging/canonical/, a d365_fo adapter (16 models) and an erpnext adapter (7 models), bronze reading canonical only, and the erp_sources switch (konsolidat#207). There is no SAP adapter (stg_sap__* below is illustrative); the Connector doctype accepts erp_type values d365_fo, d365_bc, sap_s4, sap_ecc, sap_b1, erpnext, but only the first and last have dbt models. The default is erp_sources: [] (dbt_project.yml:70): a fresh stack builds no ERP adapter and the trial-balance upload is its source. The dimension_mappings crosswalk is the konsol-owned table epm_staging.dimension_mappings, written by the Dimension Mapping doctype; the dbt seed of that name was deleted (konsolidat 85dff3b). Verified against dbt_project/models/staging/, dbt_project/dbt_project.yml, konsol/pipeline/doctype/connector/connector.py and konsol/dbt_config.py.


The core principle​

A real group rarely runs on one ERP. After acquisitions you inherit SAP in one subsidiary, D365 in another, ERPNext in a third. The warehouse is built so that this heterogeneity is absorbed at the edges and never leaks upward:

Fan out at the bottom, converge in the middle, stay source-agnostic at the top.

  • Raw + staging adapters are per source — they grow each time you add an ERP.
  • Canonical staging is the convergence point — every source becomes one shape here.
  • Silver and gold are source-agnostic — they consume the canonical models and neither know nor care how many ERPs exist upstream.

The only trace of origin that survives upward is a single lineage column, erp_source, carried on every row for audit and drill-down.

The shape, end to end​

Source systems (N ERPs) epm_raw (one table-set epm_staging adapters canonical
per source, fans WIDE) (one per source)
┌──────────────────┐ ┌────────────────────────┐ ┌────────────────────────┐
│ D365 F&O │ ───────▶ │ d365: general_journal_ │──▶│ stg_d365_fo__gl_entries│──┐
│ OData entities │ │ account_entry_bi_… │ └────────────────────────┘ │
└──────────────────┘ └────────────────────────┘ │
┌──────────────────┐ ┌────────────────────────┐ ┌────────────────────────┐ │ ┌─────────────────────────────┐
│ SAP S/4HANA │ ───────▶ │ sap: bseg, bkpf, ska1 │──▶│ stg_sap__gl_entries │──┼──▶│ canonical.stg_gl_entries │
│ BSEG/BKPF/SKA1 │ (future) │ (future) │ │ (not built) │ │ │ UNION ALL + dimension │
└──────────────────┘ └────────────────────────┘ └────────────────────────┘ │ │ harmonization; every row │
┌──────────────────┐ ┌────────────────────────┐ ┌────────────────────────┐ │ │ tagged erp_source │
│ ERPNext │ ───────▶ │ erpnext: tab_gl_entry │──▶│ stg_erpnext__gl_entries│──┘ └──────────────┬──────────────┘
│ tabGL Entry │ └────────────────────────┘ └────────────────────────┘ │
└──────────────────┘ ▼
epm_bronze (type-cast, materialized)
▼
epm_silver: silver_gl_entries (the conformed fact)
▼
epm_gold: trial balance · consolidation · reports

Layer by layer​

epm_raw — landing (per source, native shape)​

Each connector lands its source system's native schema, untouched. These look nothing alike: D365 exposes OData entities like GeneralJournalAccountEntryBiEntities; SAP exposes line-item table BSEG joined to header BKPF; ERPNext exposes tabGL Entry. Tables are namespaced per source so they never collide (d365_raw, erpnext_raw sources in dbt).

epm_staging adapters — translate native → canonical (per source)​

This is where the real per-source work happens. Each source gets an adapter model per canonical entity, e.g. stg_d365_fo__gl_entries, stg_erpnext__gl_entries (and, when one is written, stg_sap__gl_entries). Every adapter for a given entity must emit the identical column set — the canonical contract. The adapter's job is purely mechanical reshaping: rename fields, fix debit/credit sign conventions, flatten composite accounts, normalise dates.

The adapter contract is the whole game

The header of canonical/stg_gl_entries.sql says it plainly: "Every ERP adapter must produce the same column set." Get the adapter right and everything above it works unchanged. The exact columns are specified in Canonical Staging Schema and in dbt_project/models/staging/README.md, which also states the sign rule: amounts are signed at the boundary (debit positive, credit negative), split once in silver, and never inferred again.

canonical.stg_gl_entries — the convergence point​

One model per business entity (stg_gl_entries, stg_trial_balance, stg_accounts, stg_legal_entities, stg_exchange_rates, stg_budget_entries, stg_fiscal_periods) UNION ALLs every active source adapter, driven by a single dbt variable:

{% set erp_sources = var('erp_sources', []) %}

with unioned as (
{% for erp in erp_sources %}
select erp_source, record_id, entity_id, posting_date,
main_account, amount, dim_cost_center, /* … canonical columns … */
from {{ ref('stg_' ~ erp ~ '__gl_entries') }}
{% if not loop.last %}union all{% endif %}
{% endfor %}
)

With no ERP listed, each canonical model compiles to empty_relation(...) (macros/erp_sources.sql): no rows, the same column names and types, so the models downstream keep building.

Two things happen here that make multi-ERP actually work:

  1. Tagging. Every row gains erp_source (d365_fo, erpnext, …), the lineage stamp that follows it all the way to gold (test_erp_source_valid in tests/staging/ checks it).
  2. Dimension harmonization. Master-data codes are translated to group standards via the crosswalk (next section), so downstream layers see one coherent vocabulary.

epm_bronze → epm_silver → epm_gold — source-agnostic​

From bronze up, nothing is ERP-specific. Bronze type-casts and materializes the canonical output. silver_gl_entries is the single conformed GL fact. Gold builds the trial balance, balance sheet, P&L, and the full consolidation (gold_consolidated_trial_balance, gold_ic_eliminations, gold_nci_movement_schedule, FX/CTA, …) on top of silver. These models are byte-identical whether one ERP or five feed them — adding a source never edits a silver or gold model.

The three hard parts​

Adding a source is not just "plug in a connector." The genuine effort lives in three places, all of them at or below the canonical layer.

1. The adapter contract​

Each source's native model must be reshaped to the exact canonical column set — identical names, types, and semantics. SAP's document-level postings, sign conventions, and multi-segment accounts all have to be massaged to match what D365's adapter already produces. This is mechanical but meticulous, and it is the bulk of onboarding a new ERP.

2. Dimension & account harmonization (the crosswalk)​

The genuinely hard problem. The same cost center is CC-100 in D365 and 0001000 in SAP. The same expense rolls up to different local account numbers. If you don't reconcile these, your consolidated numbers are nonsense.

The epm_staging.dimension_mappings crosswalk — keyed on (dimension, erp_source, entity, source value) and written by the Dimension Mapping doctype on Publish — maps each system's native codes to group-standard codes, applied centrally in canonical via the dim_harmonize_select / dim_harmonize_joins macros (macros/dimension_helpers.sql; two joins per dimension, entity-specific then ERP-wide default). Unmapped values pass through unchanged and surface in gold_unmapped_dimension_values so gaps are visible, not silent.

D365: dim_cost_center = CC-100 ──┐
├──▶ epm_staging.dimension_mappings ──▶ group code: 1000 — Sales
SAP: dim_cost_center = 0001000 ──┘ (crosswalk, keyed on erp_source)

The same idea applies to the chart of accounts: every source's local accounts must map to the one group chart (the Main Account doctype, konsol#182) before a meaningful trial balance can be summed across entities.

3. Entity identity & cross-source intercompany​

  • Entity identity. Each entity_id must resolve to exactly one legal entity in the consolidation hierarchy (the Entity doctype; data_area_id at the bronze boundary), even if two systems hold overlapping company codes.
  • Intercompany across sources. Once entities span ERPs, an intercompany pair can be a D365 entity selling to an ERPNext entity. The IC matching and elimination (gold_ic_eliminations, gold_ic_reconciliation) pair rows by the flagged Intercompany Account and partner_data_area_id across source systems, not just within one. The erp_source tag plus harmonized partner codes are what make that join possible.

Worked example: two GL lines, one trial balance​

A revenue posting in D365 and the equivalent in SAP arrive in completely different shapes and converge into one number. (SAP side illustrative: no SAP adapter exists.)

StageD365 rowSAP row
RawGeneralJournalAccountEntryBiEntities: LedgerAccount=4000-CC100, AccountingCurrencyAmount=-1000, IsCredit=1BSEG: HKONT=800000, KOSTL=0001000, DMBTR=1000, SHKZG=H
Adapterstg_d365_fo__gl_entries: main_account=4000, amount=-1000, dim_cost_center=CC-100stg_sap__gl_entries: main_account=800000, amount=-1000, dim_cost_center=0001000
Canonicalerp_source=d365_fo, main_account → 4000 (group), dim_cost_center → 1000erp_source=sap_s4, main_account → 4000 (group), dim_cost_center → 1000
GoldBoth land on group account 4000 / cost center 1000 and sum into one trial-balance line← same line

The trial balance shows one revenue figure for group account 4000; drilling down splits it back out by erp_source for audit.

The control plane​

Multi-ERP is configuration plus one committed line, not code-forking:

  • konsol Connector doctype — each source is one connector with its own erp_type (d365_fo, d365_bc, sap_s4, sap_ecc, sap_b1, erpnext), credentials, legal entities, dimension column maps, and Airbyte source + connection. The Dimension Mapping rows for that source carry its crosswalk.
  • erp_sources dbt var — the list of active sources the canonical models union. dbt_project.yml sets it to [] by default. konsol does not regenerate it: dbt_config.py manages only dimensions, base_measures and the fiscal mappings, and says why — "a connector being enabled says nothing about its data having ever landed, so which ERPs the build trusts stays a deliberate, committed engineering decision" (konsolidat#139). The Connector controller's docstring still claims otherwise; the dbt_config.py behaviour is what runs.
  • Connector registry & per-ERP specs — see the Connector Registry PRD and the per-ERP PRDs (SAP S/4HANA, SAP ECC, SAP B1, D365 BC, ERPNext) in the konsolidat repository for the roadmap.

Adding a new ERP — the checklist​

1. Build the connector → source-<erp>/ (Airbyte source), register + provision
2. Land raw data → epm_raw.<erp>_* (native schema)
3. Write the staging adapters → models/staging/<erp>/stg_<erp>__*.sql
(must emit the canonical column set; see staging/README.md)
4. Add crosswalk rows → Dimension Mapping doctype, keyed on erp_source
(cost centers, departments, accounts → group codes)
5. Map the chart of accounts → local CoA → the group chart (Main Account)
6. Resolve entities & IC → Entity doctype; partner codes for cross-source IC
7. Flip the switch → add '<erp>' to erp_sources in dbt_project.yml (by hand, committed)
8. dbt build → canonical auto-unions the new source;
silver & gold rebuild unchanged

Steps 1–6 are real work, concentrated at the edges. Steps 7–8 are a one-line change and a rebuild — because everything from canonical up was designed to be source-agnostic from day one.

Summary​

  • Per-source at the edges (epm_raw, staging adapters), one canonical model in the middle, fully source-agnostic analytics above (epm_silver, epm_gold).
  • The hard work is the adapter contract and dimension/account harmonization, not the consolidation logic — which never changes.
  • erp_source is the lineage thread: harmonized away for the numbers, preserved for the drill-down.

See also​