PHP · Track 7 · Tutorial 1 of 5

Ask for the overnight consolidation

Ask BrizoConsol to consolidate tonight, once, after the last thing you send today.

You will needA month sent in track 3.
By the endA consolidation request waiting for tonight's run, and its ID to check tomorrow.

1Why ask

The months you send are recalculated by the overnight run. Asking for a consolidation tells that run to consolidate the company, whether or not you sent anything new - after a correction made on screen, for example. Ask once, after your last write of the day.

2Ask for tonight's consolidation

Create consolidate.php:

consolidate.php

<?php
// consolidate.php - asks for tonight's consolidation.
require __DIR__ . '/brizo.php';

$answer = written(call('POST', "/organisations/$companyId/consolidation-requests"));
$request = $answer['data'];

echo "Consolidation request {$request['id']}: {$request['status']}";
echo $answer['meta']['deduplicated'] ? " (one was already waiting)\n" : "\n";
php consolidate.php

Check

Consolidation request 12: pending
From the request to the figures
A consolidation request waits until the overnight run takes it.

3Ask twice, get one

A company has at most one request waiting. Run the script again while it waits, and you get the same request back, marked deduplicated:

php consolidate.php

Check

Consolidation request 12: pending (one was already waiting)
Asking twice is harmless
Ask again while one is waiting, and you get the same request back.

4What to keep

Keep the request's ID: the next tutorial reads what became of it. Each request is also written to the group's System Audit Trail, naming the credential that asked.

5Good to know

  • It runs overnight only, at 01:40. Nothing is consolidated while your code waits.
  • It's asked for a company, or for the group when the group is ticked on the credential.
  • It needs the Consolidation (trigger overnight run) box on the credential.

Want more detail? See the documentation