C# · Track 3 · Tutorial 3 of 6
Deal with refused records
Find out which lines of a month BrizoConsol refused and why - and send the month again so nothing is missing.
1Two kinds of refusal
A whole request can be refused - the wrong currency, a locked month - and then nothing is written and the answer is 422. Or single records can be refused while the rest are stored, and then the answer is still 202, with counts.rejected above zero. This tutorial is about the second kind, which is easy to miss.
2Send a month with a mistake
Create Refused.cs. Its last line names account 6100, which the chart doesn't hold:
Refused.cs
// Refused.cs - sends a month with an account code the chart does not hold.
public static class Refused
{
public static async Task Run(string[] args)
{
var request = Brizo.Written(await Brizo.Call("POST", $"/organisations/{Brizo.CompanyId}/trial-balances", new
{
declarations = new
{
source_reference = "my-ledger",
period = "2026-09",
value_basis = "company_base",
rate_direction = "document_to_base",
base_currency = "SGD",
},
records = new[]
{
new { account_code = "1000", debit = 20000.00, credit = 0.00 },
new { account_code = "1200", debit = 5000.00, credit = 0.00 },
new { account_code = "2000", debit = 0.00, credit = 5000.00 },
new { account_code = "4000", debit = 0.00, credit = 30000.00 },
new { account_code = "5000", debit = 8000.00, credit = 0.00 },
new { account_code = "6100", debit = 2000.00, credit = 0.00 }, // not in the chart
},
}, new() { ["Idempotency-Key"] = $"{Brizo.CompanyId}-2026-09-v2" }));
await Brizo.Show("Trial balance", request);
}
}
3Run it
dotnet run -- RefusedCheck
Trial balance: request 93 - 0 created, 0 updated, 5 unchanged, 1 refused
Refused record 5 (6100): account_not_found - The code 6100 is not in this organisation's chart; send it through the accounts kind first.Brizo.Show() sees counts.rejected is 1 and asks …/requests/{id}/results for each record's outcome, so you get the reason.
4Fix it and send again
Because a month is sent whole, September is now stored without the refused line. Correct the code - or add the account to the chart first - and send the whole month again with a new key. Sent with a key that was already used, nothing would be written.
# in Month.cs: var version = "v3";
dotnet run -- MonthCheck
Trial balance: request 94 - 1 created, 0 updated, 5 unchanged, 0 refused
Recalculation: pending6000 is created, because the refused send had left September without it.
5What each refusal means
| account_not_found | The code isn't in the company's chart. Send the chart first, or correct the code. |
|---|---|
| invalid_value | A figure isn't allowed - a negative debit or credit, for example. Both are positive figures on their own side. |
| duplicate_record_identity | The same account appears twice in one month. Add the lines together. |
| required_field_missing | A record has no account_code. |
Want more detail? See the documentation