PHP code example of webwingscz / bank-statements

1. Go to this page and download the library: Download webwingscz/bank-statements library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

webwingscz / bank-statements example snippets


use Webwings\BankStatements\Abo\AboDialect;
use Webwings\BankStatements\Abo\AboParser;

$parser = new AboParser(AboDialect::fio());

foreach ($parser->parseFile('statement.gpc') as $statement) {
    echo $statement->accountNumber?->toString(), "\n";   // 8310192897/2010
    echo $statement->closingBalance->toDecimalString(), "\n";

    foreach ($statement as $transaction) {
        printf(
            "%s  %10s  %-20s  VS %s\n",
            $transaction->date()?->format('Y-m-d'),
            $transaction->amount->toDecimalString(),   // "-24.20"
            $transaction->payerOrPayeeName() ?? '',
            $transaction->variableSymbol ?? '-',
        );
    }
}

$statements = $parser->parseString(file_get_contents('statement.gpc'));

new AboParser(AboDialect::forBankCode('0800'));   // Česká spořitelna
new AboParser(AboDialect::fio());                 // 2010
new AboParser(AboDialect::csob());                // 0300
new AboParser(AboDialect::standard());            // anything without a known deviation

AboDialect::custom(
    ['1' => PostingCode::Debit, '2' => PostingCode::Credit],
    hasCurrencyInTransaction: true,
    bankCode: '6210',
);

new AboParser(AboDialect::fio(), strict: true);

use Webwings\BankStatements\AccountNumber;
use Webwings\BankStatements\Wise\WiseParser;

$parser = new WiseParser(
    accountNumber: AccountNumber::fromParts('', '8310192897', '2010'),
    clientName: 'Webwings s.r.o.',
);

$statement = $parser->parseFile('statement_3807780_EUR_2026-06-01_2026-06-30.csv')->first();

echo $statement->currency;                            // EUR
echo $statement->closingBalance->toDecimalString();    // 1177.41

foreach ($statement as $transaction) {
    printf(
        "%s  %10s  %s\n",
        $transaction->date()?->format('Y-m-d'),
        $transaction->amount->toDecimalString(),       // "-1083.35"
        $transaction->payerOrPayeeName() ?? '',        // "Ovhcloud Dublin"
    );
}

use Webwings\BankStatements\Wise\WiseFileName;

$name = WiseFileName::tryParse($path);   // balanceId "3807780", currency "EUR", from, to
$parser = new WiseParser(accountNumber: $accountsByBalanceId[$name->balanceId] ?? null);

use Webwings\BankStatements\Wise\WiseDetailsType;
use Webwings\BankStatements\Wise\WiseTransactionDetail;

if ($transaction->detail instanceof WiseTransactionDetail) {
    $transaction->detail->exchangeRate;                              // "20.96460", a string on purpose
    $transaction->detail->exchangeToAmount?->toDecimalString();      // "150000.00"
    $transaction->detail->bookedAt?->format('Y-m-d H:i:s.v');        // the time of day, too
    $transaction->detail->runningBalance?->toDecimalString();
    $transaction->detail->cardLastFourDigits;
    $transaction->detail->detailsType === WiseDetailsType::Conversion;
}

$transaction->detail->isFee();      // true for the FEE- item
$transaction->detail->feeOf();      // "TRANSFER-2185636734"
$transaction->detail->fees;         // on the charged item: the 22.16 it reports

new WiseParser(accountNumber: $account, strict: true);

use Webwings\BankStatements\Camt\Camt053Parser;

$parser = new Camt053Parser();

foreach ($parser->parseFile('statement.xml') as $statement) {
    echo $statement->accountNumber?->toString(), "\n";   // 2600123456/0300
    echo $statement->identification, "\n";               // Stmt/Id
    echo $statement->closingBalance->toDecimalString(), "\n";

    foreach ($statement as $transaction) {
        printf(
            "%s  %10s  %-20s  VS %s\n",
            $transaction->date()?->format('Y-m-d'),
            $transaction->amount->toDecimalString(),
            $transaction->counterPartyName ?? '',
            $transaction->variableSymbol ?? '-',
        );
    }
}

use Webwings\BankStatements\Camt\CamtTransactionDetail;

if ($transaction->detail instanceof CamtTransactionDetail && $transaction->detail->isBatch()) {
    echo $transaction->detail->transactionDetailsCount;      // 3
    echo $transaction->detail->batchPaymentInformationId;    // PAYROLL-2026-07
}

$booked = array_filter(
    $statement->transactions,
    static fn (Transaction $t): bool => ! $t->detail instanceof CamtTransactionDetail
        || $t->detail->isBooked(),
);

new Camt053Parser(strict: true);

use Webwings\BankStatements\Mt940\Mt940Parser;

$parser = new Mt940Parser(bankCode: '0800', clientName: 'Vzor s.r.o.');

foreach ($parser->parseFile('AUSZUG.TXT') as $statement) {
    echo $statement->identification, "\n";               // field :20:
    echo $statement->accountNumber?->toString(), "\n";   // 2600123456/0800
    echo $statement->closingBalance->toDecimalString(), "\n";
}

new Mt940Parser(strict: true);

// Force a specific mechanism, e.g. to reproduce a production environment
new AboParser(AboDialect::fio(), decoder: new TextDecoder(converter: TextConverter::BuiltIn));