Skip to content
This repository was archived by the owner on Sep 8, 2020. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions lib/OfxParser/Ofx.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'],
Expand All @@ -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'],
Expand Down
7 changes: 6 additions & 1 deletion tests/OfxParser/OfxTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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],
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Whether right or not, this is a BC break, so targeting this for next major.

'1000' => ['1000', 1000.0],
'10000' => ['10000', 10000.0],
'-100' => ['-100', -100.0],
'-1000' => ['-1000', -1000.0],
'-10000' => ['-10000', -10000.0]
];
}

Expand Down