diff options
-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); } |