From 1fba00ada382828b310130b25ef349a4347643c8 Mon Sep 17 00:00:00 2001 From: einhverfr Date: Fri, 27 Oct 2006 18:43:43 +0000 Subject: 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 --- LedgerSMB/Form.pm | 9 +++++++-- 1 file 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); } -- cgit v1.2.3