List general ledger accounts
Lists profit and loss accounts (pnl, default) or balance sheet accounts (bas), optionally only the codes matching a pattern such as "8*". It shows the number of accounts and the first 10, hidden ones included.
The two types are two resources: $twinfield->balanceSheetAccounts() (BAS) and $twinfield->profitAndLossAccounts() (PNL). search() returns a CodeNameSearch: all() fetches page by page while you iterate, get() gives one page and count() the number of matches. By default the pattern matches code and name; narrow it with inCode() or inName(). includeHidden() adds hidden accounts, with $summary->hidden:
$twinfield->profitAndLossAccounts()->search('8*')->inCode()->all();$twinfield->balanceSheetAccounts()->search()->group('LIQUID*')->all();$twinfield->profitAndLossAccounts()->search()->modifiedSince(new DateTimeImmutable('-1 week'))->all();$twinfield = Example::twinfield();
// "bas" or "pnl" from the command line (default pnl), and an optional pattern, e.g. "8*".$accounts = ($argv[1] ?? 'pnl') === 'bas' ? $twinfield->balanceSheetAccounts() : $twinfield->profitAndLossAccounts();
$search = $accounts->search($argv[2] ?? '*')->inCode()->includeHidden();
echo ucfirst($accounts->type()->label()), 's: ', $search->count(), PHP_EOL;
foreach ($search->limit(10)->get() as $account) { echo $account->code, ' ', $account->name, $account->hidden ? ' (hidden)' : '', PHP_EOL;}php examples/general-ledger-accounts/list-general-ledger-accounts/example.php pnlProfit and loss accounts: 102540000 Brutolonen en salarissen40005 Provisies en tantièmes40010 Vakantietoeslag40015 Vakantiebonnen40020 Brutolonen en salarissen 540025 Belaste vergoedingen40030 Bijzondere beloningen40035 Dotatie reserve vakantietoeslag40036 Dotatie reserve vakantiedagen40040 Brutolonen en salarissen 8php examples/general-ledger-accounts/list-general-ledger-accounts/example.php bas "01*"Balance sheet accounts: 530100 Oprichtingskosten (hidden)01000 Aanschaffingswaarde kosten van oprichting en uitgifte van aandelen01001 Cum. afschr. kst. van oprichting en uitgifte van aandelen…Source
Section titled “Source”View examples/general-ledger-accounts/list-general-ledger-accounts/example.php on GitHub.
Twinfield and Wolters Kluwer are trademarks of Wolters Kluwer. Their names and logos are used only to refer to their products.