Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bookingDate is off by one year in some cases #101

Open
i124q2n8 opened this issue Mar 13, 2018 · 0 comments
Open

bookingDate is off by one year in some cases #101

i124q2n8 opened this issue Mar 13, 2018 · 0 comments

Comments

@i124q2n8
Copy link

The bookingDate can be off by one year if the valuta date (month part) is earlier than the booking date.

The error is located in MT940.php:126

$year = substr($transaction, 0, 2);
$valutaDate = $this->getDate($year . substr($transaction, 2, 4));

$bookingDate = substr($transaction, 6, 4);
if (preg_match('/^\d{4}$/', $bookingDate)) {
	// if valuta date is earlier than booking date, then it must be in the new year.
	$year = substr($transaction, 2, 2) < substr($transaction, 6, 2) ? --$year : $year;
	$bookingDate = $this->getDate($year . $bookingDate);
}

The relevant input data to reproduce the error looks like this.

:61:1604300502DR100,00N032NONREF
:86:106?00AUSZAHLUNG?109200?20SVWZ+2016-04-30T06.07.39 Ka?21rte1 

The assumption that the valuta date cant be earlier than the booking date is wrong. (See comment above)
An easy way would be to calculate both dates (same year and previous year) and take the date with the least difference to the valuta date.

I don't know whether this solution has some other drawbacks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant