From 52467aa22c2b458e599fbf3e5d2a2662342364b6 Mon Sep 17 00:00:00 2001 From: einhverfr Date: Wed, 18 Oct 2006 22:19:23 +0000 Subject: Fixed issues with parsing numbers in "1 000.00" format and in double parsing them. git-svn-id: https://ledger-smb.svn.sourceforge.net/svnroot/ledger-smb/trunk@226 4979c152-3d1c-0410-bac9-87ea11338e46 --- LedgerSMB/Form.pm | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/LedgerSMB/Form.pm b/LedgerSMB/Form.pm index 4b6fbad2..e952d1c3 100755 --- a/LedgerSMB/Form.pm +++ b/LedgerSMB/Form.pm @@ -478,14 +478,24 @@ sub parse_amount { my ($self, $myconfig, $amount) = @_; - if (($myconfig->{numberformat} eq '1.000,00') || - ($myconfig->{numberformat} eq '1000,00')) { + my $numberformat = $myconfig->{numberformat}; + my $decimal_regex = /\.\d{2}/; + if (($numberformat !~ $decimal_regex) and ($amount =~ $decimal_regex)){ + # We have already parsed this number + $numberformat = "1000.00"; + } + + if (($numberformat eq '1.000,00') || + ($numberformat eq '1000,00')) { $amount =~ s/\.//g; $amount =~ s/,/\./; } + if ($numberformat eq '1 000.00'){ + $amount =~ s/\s//g; + } - if ($myconfig->{numberformat} eq "1'000.00") { + if ($numberformat eq "1'000.00") { $amount =~ s/'//g; } -- cgit v1.2.3