mschindler83/fints-hbci-php

Transaction date is not retrieved correctly

Closed this issue · 4 comments

Hello everybody!

My code so far:

<?php

require 'vendor/autoload.php';

use Fhp\FinTs;
use Fhp\Model\StatementOfAccount\Statement;
use Fhp\Model\StatementOfAccount\Transaction;

$fints = new FinTs(
    URL,
    PORT,
    CODE,
    USERNAME,
    PIN
);

$accounts = $fints->getSEPAAccounts();

$oneAccount = $accounts[0];

$from = new \DateTime('2016-01-01');
$to   = new \DateTime();

$soa = $fints->getStatementOfAccount($oneAccount, $from, $to);

foreach ($soa->getStatements() as $statement) {
    echo $statement->getDate()->format('Y-m-d') . ': Start Saldo: ' . ($statement->getCreditDebit() == Statement::CD_DEBIT ? '-' : '') . $statement->getStartBalance() . PHP_EOL;
    echo 'Transactions:' . PHP_EOL;
    echo '=======================================' . PHP_EOL;
    foreach ($statement->getTransactions() as $transaction) {
        echo 'Date        : ' . $transaction->getDate()->format('Y-m-d') . PHP_EOL;
        echo 'Amount      : ' . ($transaction->getCreditDebit() == Statement::CD_DEBIT ? '-' : '') . $transaction->getAmount() . PHP_EOL;
        echo 'Booking text: ' . $transaction->getBookingText() . PHP_EOL;
        echo 'Name        : ' . $transaction->getName() . PHP_EOL;
        echo 'Description : ' . $transaction->getDescription1() . PHP_EOL;
        echo '=======================================' . PHP_EOL . PHP_EOL;
    }
}
echo "Found " . count($soa->getStatements()) . ' statements.' . PHP_EOL;

Output:

2016-01-01: Start Saldo: 0
Transactions:
=======================================
Date        : 2016-01-01
Amount      : 43.56
Booking text: Gutschrift
Name        : Name
Description : Description
=======================================

Date        : 2016-01-01
Amount      : -43.56
Booking text: Überweisung
Name        : Name
Description : Description
=======================================

Date        : 2016-01-01
Amount      : 150
Booking text: Gutschrift
Name        : Name
Description : Description
=======================================

Found 1 statements.

The problem:
The date value of the transaction always equals the supplied $from date.

I'm not sure if this is a problem with my code or the library. I tried it with the german bank ING-Diba.

How can I get the "real" transaction date?

Thank you for reading this far!

Hi @MrCrankHank

Thanks for reporting!
And sorry for the late response.

At the moment the transaction date is always the booking date of the transaction and not the valuta date.
This means that the transaction date is always the date of the statement of account.

2016-01-01: Start Saldo: 0

Date : 2016-01-01

Did you expect something else?
Then let me know. Maybe we can improve here something :)

Best,
Markus

H markus!

No worries :)

Actually i expected it would output the valuta date of the specific transaction.

Is there a way to get it?

In my application the user imports the data from the bank and is then able to map it to invoices. The first import is usually over a long range (like from 2016-01-01 to today). It's difficult to find the right transaction for the right invoice, if the date isn't specific.

Appreciate your help!

Thanks.

Alex

This is the data i would expect (according to the web interface of the ING-Diba)

Output:

2016-01-01: Start Saldo: 0
Transactions:
=======================================
Date        : 2016-02-25
Amount      : 43.56
Booking text: Gutschrift
Name        : Name
Description : Description
=======================================

Date        : 2016-02-26
Amount      : -43.56
Booking text: Überweisung
Name        : Name
Description : Description
=======================================

Date        : 2016-07-21
Amount      : 150
Booking text: Gutschrift
Name        : Name
Description : Description
=======================================

Found 1 statements.

It just testet it with my other account (Deutsche Kredit Bank, DKB). The dates are closer to the data in the webinterface, but for some odd reason not identical. I can provide further information in a few hours, when I get home.

I think this should solve it:
#5