PHP · Track 3 · Tutorial 5 of 6

Take a month over from another source

When a month is already held by another source, hand it to yours deliberately - and see what's removed and recorded when you do.

You will needThe month script from Send a month's trial balance.
By the endA month taken over from another source, and the judgement of when that's the right thing to do.

1Why a month can be refused

Each month of a company's figures has one owner. If September already came from somewhere else - a spreadsheet upload, or a connected accounting system - your send is refused with month_held_by_another_source, so two sources never add their figures together.

2Decide before you take over

Usually the other source is the company's accounting system, and the right fix is to stop one of the two. Take a month over only when your system is meant to replace that source for it.

3Take September over

Create take-over.php. It's the month send with one more declaration, switch_source:

take-over.php

<?php
// take-over.php - takes September over from the source that holds it.
require __DIR__ . '/brizo.php';

$request = written(call('POST', "/organisations/$companyId/trial-balances", [
    'declarations' => [
        'source_reference' => 'my-ledger',
        'period' => '2026-09',
        'value_basis' => 'company_base',
        'rate_direction' => 'document_to_base',
        'base_currency' => 'SGD',
        'switch_source' => true,
    ],
    'records' => [
        ['account_code' => '1000', 'debit' => 20000.00, 'credit' => 0],
        ['account_code' => '1200', 'debit' => 5000.00, 'credit' => 0],
        ['account_code' => '2000', 'debit' => 0, 'credit' => 5000.00],
        ['account_code' => '4000', 'debit' => 0, 'credit' => 30000.00],
        ['account_code' => '5000', 'debit' => 8000.00, 'credit' => 0],
        ['account_code' => '6000', 'debit' => 2000.00, 'credit' => 0],
    ],
], ["Idempotency-Key: $companyId-2026-09-takeover-v1"]));

show('Trial balance', $request);
if (isset($request['result']['switched_from'])) {
    echo "Taken over from {$request['result']['switched_from']} ({$request['result']['rows_removed']} rows removed)\n";
}
php take-over.php

Check

Trial balance: request 91 - 6 created, 0 updated, 0 unchanged, 0 refused
Taken over from xero (6 rows removed)

The answer names the source that held the month and how many of its rows were removed. A month no one else holds is simply written.

A month has one owner
A month has one owner. Stating switch_source hands it to your send, and says so in the answer.

4It's recorded

Each take-over is written to the group's System Audit Trail, so anyone can see later where the month's figures came from.

Every take-over is recorded
A take-over is never silent: the System Audit Trail records which source lost the month.

Want more detail? See the documentation