Skip to content

List electronic bank statements

Shows the bank statements of the last 7 days with their balances, whether they are posted, and per line the amount, the other party and how Twinfield allocated it.

Twinfield documentation: Electronic bank statements.

Statements come from the BankStatementService, a Command & Query web service, so the client needs a company (company('1000')); Example::twinfield() uses your default company. You get every statement of the company: the ones you imported with create() and the ones Twinfield downloaded from the bank itself.

  • electronicBankStatements()->list($from, $to): statements dated from $from to $to, both days included. Only the date counts. Posted statements are included; pass includePosted: false for only the ones still to be processed.
  • listByCreationDate(from: …): statements imported since a moment, e.g. to pick up new statements since the last run.
  • Each BankStatement has bankBook, number, date, openingBalance, closingBalance, transactionNumber (null while not posted) and lines. A line has a signed amount (negative for money paid), the other party (contraIban, contraAccountName), description, recognition (how Twinfield recognised it, e.g. ContraIban or AllocationRule) and allocations.
  • An allocation has a type (GeneralLedger, Customer, Supplier, Suspense, …), dimensions and matchings (the invoice it paid). signedAmount() gives it the sign of the line, so the allocations of a line add up to its amount.

Twinfield has no paging: ask for a month or less at a time, as a long period with many statements can time out.

$twinfield = Example::twinfield();
$days = (int) ($argv[1] ?? 7);
$from = new DateTimeImmutable(sprintf('-%d days', $days));
$to = new DateTimeImmutable('today');
$statements = $twinfield->electronicBankStatements()->list($from, $to);
echo 'Company ', $twinfield->companyCode(), PHP_EOL;
echo count($statements), ' statement(s) dated ', $from->format('Y-m-d'), ' to ', $to->format('Y-m-d'), PHP_EOL;
foreach ($statements as $index => $statement) {
echo sprintf(
'[%d/%d] %s %d of %s: %s to %s, %d line(s), %s',
$index + 1,
count($statements),
$statement->bankBook,
$statement->number,
$statement->date->format('Y-m-d'),
$statement->openingBalance,
$statement->closingBalance,
count($statement->lines),
$statement->isPosted() ? 'posted as ' . $statement->transactionNumber : 'not posted',
), PHP_EOL;
foreach ($statement->lines as $line) {
$allocations = array_map(
static fn (BankStatementAllocation $allocation): string => sprintf(
'%s %s %s',
$allocation->type->value,
implode('/', $allocation->dimensions),
$allocation->signedAmount(),
),
$line->allocations,
);
echo sprintf(
' %3d %10s %-30.30s %s%s',
$line->lineId,
$line->amount,
$line->contraAccountName ?? $line->description ?? '',
implode(', ', $allocations),
$line->recognition === null ? '' : ' (' . $line->recognition->value . ')',
), PHP_EOL;
}
}
Terminal window
php examples/electronic-bank-statements/list-electronic-bank-statements/example.php # last 7 days
php examples/electronic-bank-statements/list-electronic-bank-statements/example.php 31 # last month

Add TWINFIELD_DEBUG=1 to see the SOAP request and response.

Output in the format of a real company, with made-up values:

Company 1000
2 statement(s) dated 2026-11-02 to 2026-11-09
[1/2] BNK 1686 of 2026-11-07: 6191.73 to 7366.31, 4 line(s), posted as 202600314
1 1262.87 Payment provider GeneralLedger 1010 1262.87
2 -85.95 Example Supplies B.V. Supplier 1600/2001 -85.95 (ContraIban)
3 -22.34 Telecom Provider Supplier 1600/2002 -22.34 (AllocationRule)
4 20.00 Example Customer Customer 1300/1001 20.00
[2/2] BNK 1687 of 2026-11-08: 7366.31 to 8556.08, 1 line(s), posted as 202600313
1 1189.77 Payment provider GeneralLedger 1010 1189.77

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: Electronic bank statements: GetBankStatements.

$twinfield->electronicBankStatements()->list(
from: new DateTimeImmutable('2026-11-05'),
to: new DateTimeImmutable('2026-11-05'),
);

The SDK sends this in the SOAP body to BankStatementService.svc, with SOAPAction http://www.twinfield.com/BankStatementService/Query; the access token goes in the SOAP header:

<Query xmlns="http://www.twinfield.com/" xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns:a="http://schemas.datacontract.org/2004/07/Twinfield.WebServices.BankStatementService" i:type="a:GetBankStatements">
<a:IncludePostedStatements>true</a:IncludePostedStatements>
<a:StatementDateFrom>2026-11-05T00:00:00</a:StatementDateFrom>
<a:StatementDateTo>2026-11-05T00:00:00</a:StatementDateTo>
</Query>

Twinfield answers with this SOAP body:

<Result xmlns="http://www.twinfield.com/" xmlns:a="http://schemas.datacontract.org/2004/07/Twinfield.WebServices" xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns:b="http://schemas.datacontract.org/2004/07/Twinfield.WebServices.BankStatementService" i:type="b:GetBankStatementsResult">
<b:BankStatements>
<b:BankStatement>
<b:AccountNumber>127160099</b:AccountNumber>
<b:ClosingBalance>12278.6000</b:ClosingBalance>
<b:Code>GWPO</b:Code>
<b:Currency>EUR</b:Currency>
<b:Iban>TS04ODEF6943262301</b:Iban>
<b:Lines>
<b:BankStatementLine>
<b:AllocationMethods/>
<b:AllocationRuleStorageLevel>NotStored</b:AllocationRuleStorageLevel>
<b:Allocations>
<b:BankStatementAllocation>
<b:Amount>713.8400</b:Amount>
<b:BaseAmount>713.8400</b:BaseAmount>
<b:ChequeNumber i:nil="true"/>
<b:DescriptionFormat i:nil="true"/>
<b:Dimension1>63821</b:Dimension1>
<b:Dimension2>7039</b:Dimension2>
<b:Dimension3/>
<b:Dimension4/>
<b:Dimension5/>
<b:Dimension6/>
<b:Matchings>
<b:BankStatementMatching>
<b:BaseValue>-025.1800</b:BaseValue>
<b:Code>RLU</b:Code>
<b:LineId>1</b:LineId>
<b:Number>823698474</b:Number>
</b:BankStatementMatching>
</b:Matchings>
<b:PayingInSlipNumber i:nil="true"/>
<b:SaveDescriptionFormatToAllocationRule>false</b:SaveDescriptionFormatToAllocationRule>
<b:Sense>Debit</b:Sense>
<b:Type>Supplier</b:Type>
<b:VatLines/>
</b:BankStatementAllocation>
</b:Allocations>
<b:Amount>-025.1800</b:Amount>
<b:BaseAmount>-025.1800</b:BaseAmount>
<b:ContraAccountName>Ioykcnakp Shujp Z.D.</b:ContraAccountName>
<b:ContraAccountNumber/>
<b:ContraIban>CE15WDEA0005422626</b:ContraIban>
<b:Description>QNB 19732535</b:Description>
<b:EndToEndId>5312341SU613356</b:EndToEndId>
<b:LineId>1</b:LineId>
<b:PaymentReference/>
<b:Recognition>ContraIban</b:Recognition>
<b:Reference>5312341SU613356</b:Reference>
<b:ReturnReason/>
<b:TransactionTypeId>S279</b:TransactionTypeId>
</b:BankStatementLine>
<!-- 13 more b:BankStatementLine elements -->
</b:Lines>
<b:Number>4914</b:Number>
<b:OpeningBalance>32179.3000</b:OpeningBalance>
<b:StatementDate>2025-10-04T00:00:00</b:StatementDate>
<b:SubId>1</b:SubId>
<b:TransactionNumber>838025747</b:TransactionNumber>
</b:BankStatement>
</b:BankStatements>
</Result>

View examples/electronic-bank-statements/list-electronic-bank-statements/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.