Skip to content

VÚB ​

VÚB banka mails one payment as Label: value lines. VubMailParser reads it.

Source: examples/vub

The mail ​

text
Dátum:   11.12.2019
Na účet: SK9999999999999999999999
Suma:    13,37
Z účtu:  SK1111111111111111111111
VS:      9999999999
ŠS:      910
KS:      0308
Stav:    zrealizovaný
SIGN:    5CB8A45E42ABC48539E672B9F8E1B3F8E62F97FABDBCF880D0913B5A0C8431CE

The code ​

php
<?php

declare(strict_types=1);

// VÚB mails one payment as "Label: value" lines.

require __DIR__ . '/vendor/autoload.php';

use Tomaj\BankMailsParser\MailContent;
use Tomaj\BankMailsParser\Parser\Vub\VubMailParser;
use Tomaj\BankMailsParser\ValueObject\Money;

function show(MailContent $mail): void
{
    foreach (get_object_vars($mail) as $field => $value) {
        $value = match (true) {
            $value instanceof DateTimeInterface => $value->format('Y-m-d H:i:s P'),
            $value instanceof Money => $value->format(),
            default => $value,
        };
        if ($value !== null) {
            printf("  %-20s %s\n", $field, $value);
        }
    }
}

$parser = new VubMailParser();
$mail = $parser->parse((string) file_get_contents(__DIR__ . '/mails/payment.txt'));

echo "payment.txt\n";
show($mail);

// accountNumber is the payer ("Z účtu"), ownAccountNumber is your account ("Na účet").
echo "  => {$mail->money?->format()} from {$mail->accountNumber} to {$mail->ownAccountNumber}\n";

The output ​

text
payment.txt
  money                13.37 EUR
  transactionDate      2019-12-11 00:00:00 +01:00
  accountNumber        SK1111111111111111111111
  ownAccountNumber     SK9999999999999999999999
  vs                   9999999999
  ss                   910
  ks                   0308
  sign                 5CB8A45E42ABC48539E672B9F8E1B3F8E62F97FABDBCF880D0913B5A0C8431CE
  => 13.37 EUR from SK1111111111111111111111 to SK9999999999999999999999

What to notice ​

  • Two accounts. accountNumber is the payer (Z účtu, "from account"), as in 4.x. ownAccountNumber is your account (Na účet, "to account").
  • Currency. Suma: 13,37 names no currency, so it is EUR. A line such as Suma: 13,37 CZK keeps CZK. The decimal mark is a comma; 13.37 on this line is not an amount and leaves money null.
  • Symbols. VS, KS and the specific symbol from ŠS:, SS: or S:.
  • sign is the SIGN line, stored and not verified.
  • Detection is strict. supports() needs Dátum, Z účtu, Na účet, Suma, VS and Stav or SIGN, each at the start of a line, so an ordinary invoice with Suma and VS is not taken for a VÚB payment.

See the VÚB guide for every field and pattern.

Released under the MIT License.