PHP · Track 2 · Tutorial 3 of 4

Keep the chart in step

Your chart changes over time. Send those changes so BrizoConsol keeps step: new accounts, new names, and accounts you no longer use.

You will needThe chart from Send your chart of accounts.
By the endA chart send that adds, renames and retires accounts, without losing any account's history.

1Decide how your chart is sent

Most systems send their whole chart each time. Tell BrizoConsol which kind of send it is with mode:

merge keeps what you leave out; replace_all retires it
Two ways to send a chart: merge keeps what you leave out, replace_all retires it.

2Send the whole chart, with changes

Create sync-chart.php. It renames account 4000 and leaves out 6900, which the first chart had:

sync-chart.php

<?php
// sync-chart.php - sends the whole chart, so accounts it leaves out are retired.
require __DIR__ . '/brizo.php';

$accounts = [
    ['code' => '1000', 'name' => 'Operating bank', 'type' => 'Bank'],
    ['code' => '1200', 'name' => 'Trade receivables', 'type' => 'Accounts Receivable'],
    ['code' => '2000', 'name' => 'Trade payables', 'type' => 'Accounts Payable'],
    ['code' => '4000', 'name' => 'Sales - products', 'type' => 'Revenue'], // renamed
    ['code' => '5000', 'name' => 'Cost of sales', 'type' => 'Direct Costs'],
    ['code' => '6000', 'name' => 'Rent', 'type' => 'Expense'],
    // 6900 Sundry expenses is left out: replace_all marks it Inactive
];

$request = written(call('POST', "/organisations/$companyId/accounts", [
    'declarations' => ['source_reference' => 'my-ledger', 'mode' => 'replace_all'],
    'records' => $accounts,
]));

show('Chart', $request);
echo 'Retired: ' . ($request['result']['retired'] ?? 0) . "\n";

3Run it

php sync-chart.php

Check

Chart: request 91 - 0 created, 1 updated, 5 unchanged, 0 refused
Retired: 1

4000 is updated with its new name, five accounts are unchanged, and 6900 is retired - marked Inactive.

4Rename, retire, never re-code

  • To rename an account, send its code with the new name.
  • To retire one, leave it out of a replace_all send, or send it with "status": "Inactive".
  • Never change a code to rename. A new code is a new account; the old one stays, with its history.
Rename by name, never by code
Rename an account by changing its name. Changing its code makes a second account.

Want more detail? See the documentation