Tatra banka b-mail
Tatra banka sends a b-mail notification for every movement on an account that has notifications turned on. TatraBankaMailParser reads it. This recipe parses three of them: an incoming payment, an outgoing payment in another currency, and a payment whose variable symbol only exists as a structured creditor reference.
Source: examples/tatra-banka
The mails
An incoming payment. The header line (… bol zostatok Vasho uctu … zvyseny o …) is what supports() looks for:
text
Vazeny klient,
16.1.2015 12:51 bol zostatok Vasho uctu SK9812353347235 zvyseny o 12,31 EUR.
uctovny zostatok: 142,11 EUR
aktualny zostatok: 142,11 EUR
disponibilny zostatok: 142,11 EUR
Popis transakcie: CCINT 1100/000000-261426464
Referencia platitela: /VS1234056789/SS/KS
Informacia pre prijemcu: test-sprava
S pozdravom
TATRA BANKA, a.s.
http://www.tatrabanka.sk
Poznamka: Vase pripomienky alebo otazky tykajuce sa tejto spravy alebo inej nasej sluzby nam poslite, prosim, pouzitim kontaktneho formulara na nasej Web stranke.
Odporucame Vam mazat si po precitani prichadzajuce bmail notifikacie. Historiu uctu najdete v ucelenom tvare v pohyboch cez internet banking a nemusite ju pracne skladat zo starych bmailov.The other two mails
An outgoing payment in USD with all three symbols:
text
Vazeny klient,
16.1.2015 12:11 bol zostatok Vasho uctu SK9812353347235 znizeny o 1 243,29 USD.
uctovny zostatok: 100,00 EUR
aktualny zostatok: 100,00 EUR
disponibilny zostatok: 100,00 EUR
Popis transakcie: CCINT 1100/000000-261426464
Referencia platitela: /VS1234056789/SS9087654321/KS5428175648
S pozdravom
TATRA BANKA, a.s.
http://www.tatrabanka.sk
Poznamka: Vase pripomienky alebo otazky tykajuce sa tejto spravy alebo inej nasej sluzby nam poslite, prosim, pouzitim kontaktneho formulara na nasej Web stranke.
Odporucame Vam mazat si po precitani prichadzajuce bmail notifikacie. Historiu uctu najdete v ucelenom tvare v pohyboch cez internet banking a nemusite ju pracne skladat zo starych bmailov.A payment where Referencia platitela is a name and the variable symbol is the (Ref) of a structured creditor reference in Informacia pre prijemcu:
text
Vazeny klient,
12.1.2015 12:11 bol zostatok Vasho uctu SK9812369347235 znizeny o 2,20 EUR.
uctovny zostatok: 32,52 EUR
aktualny zostatok: 32,52 EUR
disponibilny zostatok: 32,52 EUR
Popis transakcie: CCINT 1100/000000-261426464
Referencia platitela: Firstname Surname
Informacia pre prijemcu: (CdtrRefInf)(Tp)(CdOrPrtry)(Cd)SCOR(/Cd)(/CdOrPrtry)(/Tp)(Ref)1234056789(/Ref)(/CdtrRefInf)
S pozdravom
TATRA BANKA, a.s.
http://www.tatrabanka.sk
Poznamka: Vase pripomienky alebo otazky tykajuce sa tejto spravy alebo inej nasej sluzby nam poslite, prosim, pouzitim kontaktneho formulara na nasej Web stranke.
Odporucame Vam mazat si po precitani prichadzajuce bmail notifikacie. Historiu uctu najdete v ucelenom tvare v pohyboch cez internet banking a nemusite ju pracne skladat zo starych bmailov.The code
php
<?php
declare(strict_types=1);
// Parse Tatra banka b-mail notifications ("bol zostatok Vasho uctu ... zvyseny/znizeny o ...").
require __DIR__ . '/vendor/autoload.php';
use Tomaj\BankMailsParser\MailContent;
use Tomaj\BankMailsParser\Parser\TatraBanka\TatraBankaMailParser;
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 TatraBankaMailParser();
foreach (['incoming.txt', 'outgoing.txt', 'structured-reference.txt'] as $file) {
$body = (string) file_get_contents(__DIR__ . '/mails/' . $file);
echo $file, ' supported: ', $parser->supports($body) ? 'yes' : 'no', "\n";
$mail = $parser->parse($body);
show($mail);
// Money is an integer number of minor units, never a float
$direction = $mail->money?->isNegative() ? 'outgoing' : 'incoming';
echo " => {$direction} payment of {$mail->money?->amount} minor units\n\n";
}The output
text
incoming.txt supported: yes
money 12.31 EUR
transactionDate 2015-01-16 12:51:00 +01:00
accountNumber SK9812353347235
sourceAccountNumber 1100/000000-261426464
vs 1234056789
receiverMessage test-sprava
description CCINT 1100/000000-261426464
=> incoming payment of 1231 minor units
outgoing.txt supported: yes
money -1243.29 USD
transactionDate 2015-01-16 12:11:00 +01:00
accountNumber SK9812353347235
sourceAccountNumber 1100/000000-261426464
vs 1234056789
ss 9087654321
ks 5428175648
description CCINT 1100/000000-261426464
=> outgoing payment of -124329 minor units
structured-reference.txt supported: yes
money -2.20 EUR
transactionDate 2015-01-12 12:11:00 +01:00
accountNumber SK9812369347235
sourceAccountNumber 1100/000000-261426464
vs 1234056789
receiverMessage (CdtrRefInf)(Tp)(CdOrPrtry)(Cd)SCOR(/Cd)(/CdOrPrtry)(/Tp)(Ref)1234056789(/Ref)(/CdtrRefInf)
description CCINT 1100/000000-261426464
=> outgoing payment of -220 minor unitsWhat to notice
- The amount is
Money, not a float.money->amountis an integer in minor units (1231for 12.31 EUR) andmoney->format()prints it with the currency. The direction is the sign:znizeny o(decreased by) gives a negative amount. There is no separate "incoming/outgoing" field. - The date is in
Europe/Bratislava, the bank's wall clock, whateverdate.timezoneyour server uses. accountNumberis your account (the one whose balance changed).sourceAccountNumberis the counterparty fromPopis transakcie, anddescriptionkeeps the whole line.- Symbols come from
Referencia platitela: /VS…/SS…/KS…. An empty/SSstaysnull. Without that shape the parser looks for aVStoken, then for the last number ofInformacia pre prijemcu(in the third mail the(Ref)of a structured creditor reference), then for the last number ofReferencia platitela, the same order as 4.1.0. The payer writes that message, so match a payment by its amount too, not only by the symbol. See the Tatra banka guide for the full order. receiverMessageis the payer's message as written, including the structured reference markup.
Next: CardPay and ComfortPay results come from Tatra banka too, in a different format.