BigBooks Docs
Onboarding a Company

Data Migration Wizard

As an admin, you will stand up a brand-new tenant by running one tracked migration batch that imports the chart of accounts, the opening trial balance, and the fixed-asset register, then commits them together so the company goes live with a balanced, auditable ledger.

What you'll accomplish

As an Admin, you will stand up a brand-new tenant by running one tracked migration batch that imports the chart of accounts, the opening trial balance, and the fixed-asset register, then commits them together so the company goes live with a balanced, auditable ledger.

Before you start

The data migration tooling lives on two admin-only surfaces — neither is the master-detail record view used elsewhere in BigBooks.

  • /[lang]/admin/data-migration is the wizard's home: a plain page header with a Start new migration button and a history table of past batches (created date, adapter, fiscal year, status, OB-line and asset counts, plus View / Rollback / Delete actions). It is gated to role === "admin" and is also behind the dataMigrationWizard.enabled feature flag — when the flag is off, the page shows a "not available for this company" notice.
  • /[lang]/settings/migrations is the admin settings entry that surfaces the same wizard as a Data Migration card above a table of registered system migrations (developer/maintenance scripts run via migrations/run.ts). Non-admins are redirected to the dashboard.

Each batch moves through fixed statuses — draftcoa_donevalidatedcommitted (with rolled_back / failed as terminal states) — so an interrupted run resumes from its last checkpoint instead of re-importing. All amounts are stored as integer satang (1 LAK = 100 satang).

Compliance Note

The opening trial balance must net to zero before it can commit, and committing writes a balanced, posted opening-balance journal entry — so a migrated tenant starts MoF 2020-compliant. Do not bypass the wizard with direct opening-balance or bulk-import calls; that skips these validation and reconciliation guards.

Steps

Open the migration history Go to /[lang]/admin/data-migration (or open the Data Migration card under /[lang]/settings/migrations). Review any past batches in the history table; an empty company prompts you to start the first migration.

Data migration home: Start new migration button and the batch history table with status badges.
Data migration home: Start new migration button and the batch history table with status badges.

Start a new migration and import the chart of accounts Click Start new migration to open the staged wizard. The first stage imports and pre-flights the chart of accounts for the new tenant; once accepted, the batch advances to coa_done.

Wizard stage 1: chart-of-accounts import with the pre-flight result.
Wizard stage 1: chart-of-accounts import with the pre-flight result.

Validate the opening trial balance and assets Provide the opening trial balance and the fixed-asset register. The wizard validates that the trial balance nets to zero and that asset rows are well-formed; passing both moves the batch to validated. Running debit/credit totals show whether the trial balance is in balance.

Wizard validation: opening trial balance with debit/credit totals and the fixed-asset register preview.
Wizard validation: opening trial balance with debit/credit totals and the fixed-asset register preview.

Commit the batch Review the reconciliation summary and Commit. The wizard atomically creates the COA codes, posts the opening-balance journal entry, and creates the fixed assets, then marks the batch committed. A committed batch can be rolled back from the history table if needed.

Commit stage with the reconciliation summary and the resulting batch marked committed.
Commit stage with the reconciliation summary and the resulting batch marked committed.

What happens behind the scenes

The wizard records every stage on a migrationBatches document. createBatch opens the batch; runCoaPreflight imports/validates the chart of accounts; validateTB and validateAssets check the opening trial balance and asset register; and commit (in migrationBatches/mutations.ts) performs the atomic go-live — it creates the COA codes (createdCoaCodes), drives the opening balances through openingBalanceBatches/mutations.ts so a posted, balanced opening-balance journal entry is written, and inserts the fixed assets (createdAssetIds). The batch's reconciliation block (e.g. tbDebitTotal) is what the history table reports. migrationBatches/queries.ts (listForCompany, getById, getReconciliationReport) reads batches and lets a resumed run continue from its checkpoint; rollback reverses a committed batch; deleteBatch removes a non-committed record and deactivates any zero-activity COA codes it created. The registered-migrations table on the settings page is a separate developer surface served by migrations/run.ts (listRegistered, getRecentRuns, run) and is not part of tenant onboarding.

AccountDebitCredit
Asset / expense opening balances (per line)Debit total-
Liability / equity opening balances (per line)-Credit total

Common problems

  • Feature disabled: When dataMigrationWizard.enabled is off for the company, /[lang]/admin/data-migration shows a "not available" notice — the wizard cannot be run.
  • Not an admin: Both surfaces are admin-only; non-admins are redirected or denied.
  • Unbalanced trial balance: An opening trial balance that does not net to zero fails validation and cannot commit.
  • GL 331/339 conflict: Posting opening balances that mix retained-earnings accounts is blocked (a year-end-close guard carried into the opening-balance post).
  • Interrupted run: A batch left in draft/coa_done/validated is resumed from its last checkpoint — start a fresh batch only if you mean to.
  • Bypassing the wizard: Direct opening-balance or bulk-import calls skip the reconciliation guards and must not be used for go-live.

On this page