Skip to content

Read bank transaction

Reads one bank transaction: the header, the total line on the bank account, the detail and VAT lines, and what each line is matched with.

Twinfield documentation: Bank transactions.

get($dayBook, $number) returns a BankTransaction, or throws a TransactionNotFoundException when the transaction (or the day book) does not exist. Use find() to get null instead.

  • $transaction->header: company, day book, number, status (Provisional or Final), period, date, currency, user and dates.
  • $transaction->startValue and closeValue: the balance of the statement, as Amount.
  • $transaction->total: the line on the bank account, with the total including VAT. Its debitCredit is debit when more money came in than went out.
  • $transaction->details: what the money is for. dim2 is the customer, supplier or cost centre, with the name Twinfield adds; matchStatus and matches say whether the invoice is paid.
  • $transaction->vat: the VAT per VAT code.

Amounts are Amount objects: exact numeric strings such as 121.00, which you can echo directly.

$twinfield = Example::twinfield();
if (!isset($argv[1], $argv[2])) {
echo 'Pass a bank book and transaction number, e.g. BNK 202600045.', PHP_EOL;
exit(0);
}
try {
$transaction = $twinfield->bankTransactions()->get($argv[1], (int) $argv[2]);
} catch (TransactionNotFoundException $exception) {
echo 'Not found: ', $exception->reason, PHP_EOL;
exit(1);
}
$header = $transaction->header;
echo 'Transaction: ', $header->dayBook, ' ', $header->number, ' (', $header->status->name, ')', PHP_EOL;
echo 'Date: ', $header->date->format('Y-m-d'), ', period ', $header->period, PHP_EOL;
echo 'Statement: ', $transaction->statementNumber ?? '-', PHP_EOL;
echo 'Balance: ', $transaction->startValue, ' → ', $transaction->closeValue, ' ', $header->currency, PHP_EOL;
echo 'Total: ', $transaction->total->debitCredit->value, ' ', $transaction->total->value,
' on ', $transaction->total->dim1->code, PHP_EOL;
foreach ($transaction->details as $line) {
echo sprintf(
' %-6s %-6s %-8s %10s %-12s %s',
$line->debitCredit->value,
$line->dim1->code,
$line->dim2->code ?? '',
$line->value,
$line->matchStatus->value,
$line->dim2->name ?? $line->description ?? '',
), PHP_EOL;
foreach ($line->matches as $set) {
foreach ($set->lines as $match) {
echo ' matched with ', $match->dayBook, ' ', $match->number, ' line ', $match->line,
': ', $match->matchValue, PHP_EOL;
}
}
}
foreach ($transaction->vat as $line) {
echo sprintf(
' %-6s %-6s VAT %-4s %10s',
$line->debitCredit->value,
$line->dim1->code,
$line->vatCode,
$line->value,
), PHP_EOL;
}
Terminal window
php examples/bank-transactions/read-bank-transaction/example.php BNK 202600045
Transaction: BNK 202600045 (Provisional)
Date: 2026-11-03, period 2026/11
Statement: 245
Balance: 974.01 → 1397.46 EUR
Total: debit 423.45 on 1010
credit 1300 1000 435.55 matched Example customer
matched with VRK 202600012 line 1: 435.55
debit 4500 KPL01 10.00 notmatchable Algemeen
debit 1520 VAT IH 2.10

What the SDK sends to Twinfield and what Twinfield sends back, for a call like the one in this example. The responses come from the tests, with example data.

Twinfield documentation: Bank transactions: Read.

$twinfield->bankTransactions()->get('BNK', 202600045);

The SDK sends this XML as xmlRequest of ProcessXmlString to processxml.asmx:

<read>
<type>transaction</type>
<office>1000</office>
<code>BNK</code>
<number>202600045</number>
</read>

Twinfield answers with this XML in ProcessXmlStringResult:

<transaction result="1" location="temporary">
<header>
<office name="Example Holding B.V." shortname="Holding">1000</office>
<code name="Bank" shortname="Bank">BNK</code>
<currency name="Euro" shortname="Euro">EUR</currency>
<date>20261103</date>
<statementnumber>245</statementnumber>
<startvalue>974.01</startvalue>
<closevalue>1397.46</closevalue>
<origin>import</origin>
<user name="Example user" shortname="User">EXAMPLE</user>
<inputdate>20261103101530</inputdate>
<modificationdate>20261104091200</modificationdate>
<period>2026/11</period>
<number>202600045</number>
<freetext1>Statement 245</freetext1>
</header>
<lines>
<line type="total" id="1">
<dim1 name="Bank" shortname="" type="BAS" inuse="true" vatcode="" vatobligatory="false">1010</dim1>
<debitcredit>debit</debitcredit>
<value>423.45</value>
<description>Statement 245</description>
<rate>1</rate>
<basevalue>423.45</basevalue>
<reprate>1.500000000</reprate>
<repvalue>635.18</repvalue>
<matchstatus>notmatchable</matchstatus>
</line>
<line type="detail" id="2">
<dim1 name="Debiteuren" shortname="Debiteuren" type="BAS" inuse="true" vatcode="" vatobligatory="false">1300</dim1>
<dim2 name="Example customer" shortname="" type="DEB" inuse="true" vatcode="" vatobligatory="false">1000</dim2>
<debitcredit>credit</debitcredit>
<value>435.55</value>
<invoicenumber>2026-0042</invoicenumber>
<description>Invoice 2026-0042</description>
<duedate>20261108</duedate>
<rate>1</rate>
<basevalue>435.55</basevalue>
<reprate>1.500000000</reprate>
<repvalue>653.33</repvalue>
<currencydate/>
<matchlevel>2</matchlevel>
<customersupplier>2</customersupplier>
<openvalue>0.00</openvalue>
<openbasevalue>0.00</openbasevalue>
<openrepvalue>0.00</openrepvalue>
<matchstatus>matched</matchstatus>
<matches>
<set status="final">
<matchdate>20261103</matchdate>
<lines>
<line>
<code>VRK</code>
<number>202600012</number>
<line>1</line>
<method>payment</method>
<matchvalue>435.55</matchvalue>
</line>
</lines>
<matchvalue>435.55</matchvalue>
</set>
</matches>
</line>
<line type="detail" id="3">
<dim1 name="Bankkosten" shortname="" type="PNL" inuse="true" vatcode="IH" vatobligatory="false">4500</dim1>
<dim2 name="Algemeen" shortname="" type="KPL" inuse="true" vatcode="" vatobligatory="false">KPL01</dim2>
<debitcredit>debit</debitcredit>
<value>10.00</value>
<description>Bank costs</description>
<vatcode name="BTW 21%" shortname="Hoog" type="purchase">IH</vatcode>
<vatvalue>2.10</vatvalue>
<vatbasevalue>2.10</vatbasevalue>
<vatrepvalue>3.15</vatrepvalue>
<rate>1</rate>
<basevalue>10.00</basevalue>
<reprate>1.500000000</reprate>
<repvalue>15.00</repvalue>
<comment>Monthly fee</comment>
<matchstatus>notmatchable</matchstatus>
</line>
<line type="vat" id="4">
<dim1 name="Te vorderen BTW" shortname="" type="BAS" inuse="true" vatcode="" vatobligatory="false">1520</dim1>
<debitcredit>debit</debitcredit>
<value>2.10</value>
<rate>1</rate>
<basevalue>2.10</basevalue>
<reprate>1.500000000</reprate>
<repvalue>3.15</repvalue>
<vatturnover>10.00</vatturnover>
<vatbaseturnover>10.00</vatbaseturnover>
<vatrepturnover>15.00</vatrepturnover>
<vatcode name="BTW 21%" shortname="Hoog" type="purchase">IH</vatcode>
<vatbasevalue>2.10</vatbasevalue>
<vatvalue>2.10</vatvalue>
<baseline>3</baseline>
<matchstatus>notmatchable</matchstatus>
</line>
</lines>
</transaction>

View examples/bank-transactions/read-bank-transaction/example.php on GitHub.

Made by SolveBeam

Twinfield and Wolters Kluwer are trademarks of Wolters Kluwer. Their names and logos are used only to refer to their products.