PHP · Track 4 · Tutorial 4 of 4

Read invoices and bills back

Read back what BrizoConsol holds: the month's invoices and bills, with what's still owed on each.

You will needInvoices and bills sent in the earlier tutorials of this track.
By the endA script that reads any month's documents, and finds the ones you need.

1Read September's documents

Create read-documents.php:

read-documents.php

<?php
// read-documents.php - reads September's invoices and bills back.
require __DIR__ . '/brizo.php';

foreach (['invoices', 'bills'] as $kind) {
    $answer = call('GET', "/organisations/$companyId/$kind?period=2026-09");
    echo ucfirst($kind) . ":\n";
    foreach ($answer['body']['data'] as $document) {
        echo "  {$document['number']}  {$document['party']['name']}  {$document['currency']} "
            . number_format($document['total'], 2) . "  due " . number_format($document['amount_due'], 2)
            . "  {$document['status']}\n";
    }
}
What you can ask for, and what comes back
Reading documents back: a month, optionally narrowed, with every document's details and lines.

2Run it

php read-documents.php

Check

Invoices:
  INV-1001  Harbour Trading Pte Ltd  SGD 10,000.00  due 5,000.00  OVERDUE
  INV-1002  Pacific Desk Co  USD 1,000.00  due 1,000.00  OVERDUE
Bills:
  BILL-501  Northwind Furniture Supply  SGD 8,000.00  due 5,000.00  OVERDUE

Each document as you sent it, with its status. Sent after their October due dates, with money still owed, all three read OVERDUE.

Status reflects the day they were sent
The status was worked out when each document was sent: money still owed, due date passed.

3Narrow it down

  • status=OVERDUE - only documents in that state.
  • account_code=4000 - documents with a line on that account.
  • external_id=INV-1001 - one document. An identity the company doesn't hold answers 404.

Want more detail? See the documentation