Java · 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.
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 TakeOver.java. It's the month send with one more declaration, switch_source:
TakeOver.java
// TakeOver.java - takes September over from the source that holds it.
import java.util.List;
import java.util.Map;
public class TakeOver {
public static void main(String[] args) throws Exception {
var request = Brizo.written(Brizo.call("POST", "/organisations/" + Brizo.COMPANY_ID + "/trial-balances", Map.of(
"declarations", Map.of(
"source_reference", "my-ledger",
"period", "2026-09",
"value_basis", "company_base",
"rate_direction", "document_to_base",
"base_currency", "SGD",
"switch_source", true),
"records", List.of(
Map.of("account_code", "1000", "debit", 20000.00, "credit", 0),
Map.of("account_code", "1200", "debit", 5000.00, "credit", 0),
Map.of("account_code", "2000", "debit", 0, "credit", 5000.00),
Map.of("account_code", "4000", "debit", 0, "credit", 30000.00),
Map.of("account_code", "5000", "debit", 8000.00, "credit", 0),
Map.of("account_code", "6000", "debit", 2000.00, "credit", 0))),
Map.of("Idempotency-Key", Brizo.COMPANY_ID + "-2026-09-takeover-v1")));
Brizo.show("Trial balance", request);
if (request.path("result").has("switched_from")) {
System.out.println("Taken over from " + request.path("result").path("switched_from").asText()
+ " (" + request.path("result").path("rows_removed").asText() + " rows removed)");
}
}
}gradle -q run -Pmain=TakeOverCheck
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.
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.
Want more detail? See the documentation