diff options
author | einhverfr <einhverfr@4979c152-3d1c-0410-bac9-87ea11338e46> | 2006-10-27 18:43:43 +0000 |
---|---|---|
committer | einhverfr <einhverfr@4979c152-3d1c-0410-bac9-87ea11338e46> | 2006-10-27 18:43:43 +0000 |
commit | 1fba00ada382828b310130b25ef349a4347643c8 (patch) | |
tree | c97a2195f7e3cf4abb76a930dd8982f5253788a4 | |
parent | c9c437c6edd8e257418e80400e63b3c97683029c (diff) |
Fixed number parsing for (n), n DR and n CR formats
git-svn-id: https://ledger-smb.svn.sourceforge.net/svnroot/ledger-smb/trunk@338 4979c152-3d1c-0410-bac9-87ea11338e46
-rwxr-xr-x | LedgerSMB/Form.pm | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/LedgerSMB/Form.pm b/LedgerSMB/Form.pm index dc8d16e9..d3ed1ff4 100755 --- a/LedgerSMB/Form.pm +++ b/LedgerSMB/Form.pm @@ -391,9 +391,10 @@ sub format_amount { my ($self, $myconfig, $amount, $places, $dash) = @_; - my $negative = ($amount < 0); + my $negative ; if ($amount){ $amount = $self->parse_amount($myconfig, $amount); + $negative = ($amount < 0); $amount =~ s/-//; } @@ -518,9 +519,13 @@ sub parse_amount { $amount =~ s/,//g; - if ($amount =~ s/\((\d+.?\d*)\)/$1/){ + if ($amount =~ s/\((\d*\.?\d*)\)/$1/){ $amount *= -1; } + if ($amount =~ s/(\d*\.?\d*) DR/$1/){ + $amount *= -1; + } + $amount =~ s/ CR//; $amount = new Math::BigFloat($amount); return ($amount * 1); } |