C# · Track 2 · Tutorial 4 of 4

Read your chart back

Read the chart BrizoConsol holds for the company - every account, its type and whether it's in use - so your code can check codes before sending figures.

You will needA chart sent in the earlier tutorials of this track.
By the endA script that lists the company's accounts, and filters for the ones you need.

1Why read the chart back

Reading the chart tells you what BrizoConsol holds now - including accounts someone added on screen, and accounts you retired. It's the list to check codes against before you send a month.

2Read it

Create ReadChart.cs:

ReadChart.cs

// ReadChart.cs - reads the company's chart of accounts back.
public static class ReadChart
{
    public static async Task Run(string[] args)
    {
        var answer = await Brizo.Call("GET", $"/organisations/{Brizo.CompanyId}/accounts");
        foreach (var account in answer.Body!["data"]!.AsArray())
        {
            Console.WriteLine($"{account!["code"],-6}{account["name"],-22}{account["type"],-22}{account["status"]}");
        }
    }
}
What you can ask for, and what comes back
Reading the chart: optional filters in, every account's details out.

3Run it

dotnet run -- ReadChart

Check

1000  Operating bank        BANK                  Active
1200  Trade receivables     ACCOUNTS RECEIVABLE   Active
2000  Trade payables        ACCOUNTS PAYABLE      Active
4000  Sales - products      REVENUE               Active
5000  Cost of sales         DIRECT COSTS          Active
6000  Rent                  EXPENSE               Active
6900  Sundry expenses       EXPENSE               Inactive

4000 shows its new name and 6900 is Inactive, from the previous tutorial.

Types come back in BrizoConsol's own spelling
Types read back in BrizoConsol's own spelling - in capitals - together with their class.

4Narrow it down

Add ?status=Active for the accounts in use, ?type=Revenue for one type, or ?code=4000 for one account. A code the company doesn't hold answers 404.

Want more detail? See the documentation