summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoreinhverfr <einhverfr@4979c152-3d1c-0410-bac9-87ea11338e46>2006-10-18 22:19:23 +0000
committereinhverfr <einhverfr@4979c152-3d1c-0410-bac9-87ea11338e46>2006-10-18 22:19:23 +0000
commit52467aa22c2b458e599fbf3e5d2a2662342364b6 (patch)
tree1ea4183de51ec33eb4c4d89f4364c402d3672d56
parenta3726d5e16cead6694c5e349c1a7d2055cb7aa61 (diff)
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
-rwxr-xr-xLedgerSMB/Form.pm16
1 files 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;
}