diff --git a/lib/OfxParser/Ofx.php b/lib/OfxParser/Ofx.php index c3d0b6e..872aedb 100644 --- a/lib/OfxParser/Ofx.php +++ b/lib/OfxParser/Ofx.php @@ -310,7 +310,7 @@ private function createDateTimeFromStr($dateString, $ignoreErrors = false) private function createAmountFromStr($amountString) { // Decimal mark style (UK/US): 000.00 or 0,000.00 - if (preg_match('/^-?([\d,]+)(\.?)([\d]{2})$/', $amountString) === 1) { + if (preg_match('/^-?([\d,]+)(\.)([\d]{2})$/', $amountString) === 1) { return (float)preg_replace( ['/([,]+)/', '/\.?([\d]{2})$/'], ['', '.$1'], @@ -319,7 +319,7 @@ private function createAmountFromStr($amountString) } // European style: 000,00 or 0.000,00 - if (preg_match('/^-?([\d\.]+,?[\d]{2})$/', $amountString) === 1) { + if (preg_match('/^-?([\d\.]+,[\d]{2})$/', $amountString) === 1) { return (float)preg_replace( ['/([\.]+)/', '/,?([\d]{2})$/'], ['', '.$1'], diff --git a/tests/OfxParser/OfxTest.php b/tests/OfxParser/OfxTest.php index 486f287..1d3d02c 100644 --- a/tests/OfxParser/OfxTest.php +++ b/tests/OfxParser/OfxTest.php @@ -37,7 +37,12 @@ public function amountConversionProvider() '-1.000,00' => ['-1.000,00', -1000.0], '1' => ['1', 1.0], '10' => ['10', 10.0], - '100' => ['100', 1.0], // @todo this is weird behaviour, should not really expect this + '100' => ['100', 100.0], + '1000' => ['1000', 1000.0], + '10000' => ['10000', 10000.0], + '-100' => ['-100', -100.0], + '-1000' => ['-1000', -1000.0], + '-10000' => ['-10000', -10000.0] ]; }