From 6368d71c71eabcb28dd895f9311750ac1eef737a Mon Sep 17 00:00:00 2001 From: einhverfr Date: Sat, 21 Oct 2006 04:13:36 +0000 Subject: Corrected a number of amount parsing problems git-svn-id: https://ledger-smb.svn.sourceforge.net/svnroot/ledger-smb/trunk@247 4979c152-3d1c-0410-bac9-87ea11338e46 --- LedgerSMB/Form.pm | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/LedgerSMB/Form.pm b/LedgerSMB/Form.pm index 8c9cc51a..b42f7584 100755 --- a/LedgerSMB/Form.pm +++ b/LedgerSMB/Form.pm @@ -388,16 +388,20 @@ sub format_amount { my ($self, $myconfig, $amount, $places, $dash) = @_; + my $negative = ($amount < 0); + print STDERR "$amount\n"; if ($amount){ $amount =~ s/-//; $amount = $self->parse_amount($myconfig, $amount); } + print STDERR "$amount\n"; if ($places =~ /\d+/) { #$places = 4 if $places == 2; $amount = $self->round_amount($amount, $places); } + print STDERR "$amount\n"; # is the amount negative @@ -489,7 +493,7 @@ sub parse_amount { my ($self, $myconfig, $amount) = @_; - if (!UNIVERSAL::isa($amount, 'Math::BigFloat')){ # Amount may not be an object + if (UNIVERSAL::isa($amount, 'Math::BigFloat')){ # Amount may not be an object return $amount; } my $numberformat = $myconfig->{numberformat}; @@ -503,7 +507,7 @@ sub parse_amount { ($numberformat eq '1000,00')) { $amount =~ s/\.//g; - $amount =~ s/,/\./; + $amount =~ s/,/./; } if ($numberformat eq '1 000.00'){ $amount =~ s/\s//g; -- cgit v1.2.3