Read bank book
Reads one bank book: the code from the command line, or else the first bank book.
get() returns a BankBook, or throws a BankBookNotFoundException when the code does not exist. Use find() to get null instead. Cash books are not bank books: get('KAS') throws as well.
generalLedgerAccount: the balance sheet account of the bank;nullwhen not set, as on the default bank bookBNKof a new company.bankAccount: aBankAccountwithname,number,iban,bic,nbic,countryandreferenceNumber. Every field isnullwhen not set.automaticBankProcessing: whether statements, payments and direct debits go through the bank automatically, and thesignUpState(Inactive,Pending,Active). Read-only.
$twinfield = Example::twinfield();
// The code from the command line, or else the first bank book.$code = $argv[1] ?? $twinfield->bankBooks()->search()->limit(1)->get()->items[0]->code ?? exit('The company has no bank books.' . PHP_EOL);
try { $bankBook = $twinfield->bankBooks()->get($code);} catch (BankBookNotFoundException $exception) { echo 'Not found: ', $exception->reason, PHP_EOL;
exit(1);}
$account = $bankBook->bankAccount;$processing = $bankBook->automaticBankProcessing;
echo 'Code: ', $bankBook->code, PHP_EOL;echo 'Name: ', $bankBook->name, PHP_EOL;echo 'Short name: ', $bankBook->shortName ?? '-', PHP_EOL;echo 'Ledger account: ', $bankBook->generalLedgerAccount ?? '-', PHP_EOL;echo 'Account holder: ', $account->name ?? '-', PHP_EOL;echo 'Account number: ', $account->number ?? '-', PHP_EOL;echo 'IBAN: ', $account->iban ?? '-', PHP_EOL;echo 'BIC: ', $account->bic ?? '-', PHP_EOL;echo 'Country: ', $account->country ?? '-', PHP_EOL;echo 'Automatic: ', $processing->signUpState->value, PHP_EOL;echo ' statements: ', $processing->processStatements ? 'yes' : 'no', PHP_EOL;echo ' payments: ', $processing->processPayments ? 'yes' : 'no', PHP_EOL;echo ' direct debits: ', $processing->processDirectDebits ? 'yes' : 'no', PHP_EOL;php examples/bank-books/read-bank-book/example.php INGCode: INGName: ING 3255112Short name: -Ledger account: 1100Account holder: Example B.V.Account number: 3255112IBAN: NL45INGB0003255112BIC: -Country: NLAutomatic: Inactive statements: no payments: no direct debits: noSource
Section titled “Source”View examples/bank-books/read-bank-book/example.php on GitHub.