Trade Control documentation

Synthetic Dataset - Technical

Purpose

This page describes how Trade Control’s synthetic dataset is constructed for proof and reconciliation work.

It is intentionally technical: it documents the dataset generator as a controlled, repeatable test fixture used to validate accounting derivations (Cash Statement, Balance Sheet snapshots, and annual reconciliation views).

The generator is implemented as discrete stored procedures prefixed App.proc_DatasetSyntheticMIS_*, orchestrated by App.proc_DatasetSyntheticMIS.

Entry point procedures

Scenario runner (how proofs exercise the generator)

EXEC_DatasetSyntheticMIS.sql executes four scenarios designed to exercise the reconciliation across profit/loss and VAT modes:

  • VAT off + profit (@PriceRatio = 3.0)
  • VAT on + profit (@PriceRatio = 3.0)
  • VAT off + loss (@PriceRatio = 0.5)
  • VAT on + loss (@PriceRatio = 0.5)

Each scenario calls App.proc_DatasetSyntheticMIS with:

  • @IsCompany = 1
  • @IsVatRegistered from the scenario
  • @EnableOpeningBalance = 1
  • all major modules enabled (projects, invoices, payments, payables, wages, expenses, assets, tax, transfers)

The scenario runner then records results from Cash.vwEquityReconciliationByYear for comparison.

Orchestration overview (module call order)

App.proc_DatasetSyntheticMIS runs the following steps in order.

0) Template selection and VAT inference

  • Chooses template name based on @IsCompany:
    • company: Minimal Micro Company Accounts 2026
    • non-company: Sole Trader Accounts 2026
  • If @IsVatRegistered is not provided, it is inferred from App.tbTemplate.IsVatRegistered.

1) Shared lookup table: #DatasetCodes

A temp table #DatasetCodes is created once per run and used by all nested procedures to share generated codes (Subjects, Projects, etc.) deterministically.

2) Bootstrap (mandatory)

Responsibilities (high level):

  • Reverse-engineer required node configuration from existing node options and current user context.
  • Preserve Identity rows for the current user (so reseeding the node does not break logins).
  • Reset the node to a known baseline with App.proc_NodeDataInit.
  • Recreate the node and install the selected template via App.proc_NodeBusinessInit and App.proc_BasicSetup.
  • Optionally enable/seed opening balance behavior when @EnableOpeningBalance = 1.

This step is what makes runs repeatable: every scenario begins from the same baseline.

3) Project-side trading lifecycle (conditional)

Executed when @EnableProjects = 1:

These procedures create the trading activity that drives profit/loss and therefore the annual reconciliation.

4) Payables side (conditional)

Executed when @EnablePayables = 1:

These procedures generate operating cash movements and costs required for non-trivial Cash Statement coverage.

5) Company assets (conditional)

Executed when @IsCompany = 1 and @EnableAssets = 1:

This provides asset-state behavior for balance sheet snapshotting and capital-related flows.

6) VAT (conditional)

Executed when @IsVatRegistered = 1 and @EnableTax = 1:

This enables VAT-on scenarios and is part of proving VAT does not break the annual bridge (penny-level rounding only).

7) Transfers / current-to-reserve sweep (conditional)

Executed when @EnableTransfers = 1:

This introduces non-trade cash movements (sweeps) so bank/cash behavior is not trivial.

8) Corporation tax on profit (conditional)

Executed when @IsCompany = 1 and @EnableTax = 1:

This provides corp tax behavior required to prove:

  • corp tax is treated as P&L expense in profit years, and
  • loss carry mechanics do not create spurious “tax credits” in loss years.

9) Final rebuild (mandatory)

This ensures downstream reporting surfaces (views/materializations that depend on rebuild logic) are coherent for the scenario outputs and proof script.

Relationship to the proof paper

The proof paper references:

This synthetic dataset exists specifically to provide controlled coverage of the reconciliation under:

  • profit vs loss regimes,
  • VAT enabled/disabled,
  • non-trivial payables/expenses/wages,
  • assets,
  • transfers,
  • opening balance positioning.

The dataset can then be used as a reliable foundation for tutorials and guides.