genkgo / camt

PHP Parser for CAMT messages
MIT License
81 stars 67 forks source link

Cannot parse "00000000000XXXX.XX" to Money #122

Closed nssnl closed 2 years ago

nssnl commented 2 years ago

Recently upgraded to 2.3 (coming from 0.6.0). I tested with CAMT.053.001.02 files of NL ING and NL ABN - both files give no issues with 0.6.0. For NL ING also no issues with 2.3, but with NL ABN, getting the following error:

Cannot parse "000000000005202.96" to Money

The Amt entries in the XML all having leading zero's. The first entry is: <Amt Ccy="EUR">000000000005202.96</Amt>

When, for testing purposes, I remove the leading zero's of all Amt entries, there are no issues. Anybody else has experienced this issue?

nssnl commented 2 years ago

Fixed this, by removing the leading zero's of the amount in /src/Util/MoneyFactory.php

Added below line 27 ($amount = (string) $xmlAmount;): $amount = ltrim($amount, "0");

Works with the example, but also tested with a few other amounts like 000.10 for example, resulting in .10 after ltrim, but working as it should.

PowerKiKi commented 2 years ago

Will be fixed via https://github.com/moneyphp/money/pull/702