[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
SF.net SVN: ledger-smb: [242] trunk/LedgerSMB/Form.pm
- Subject: SF.net SVN: ledger-smb: [242] trunk/LedgerSMB/Form.pm
- From: ..hidden..
- Date: Fri, 20 Oct 2006 08:54:01 -0700
Revision: 242
http://svn.sourceforge.net/ledger-smb/?rev=242&view=rev
Author: einhverfr
Date: 2006-10-20 08:53:54 -0700 (Fri, 20 Oct 2006)
Log Message:
-----------
Moved ->parse_amount() to use Math::BigFloats to avoid issues of double-parsing
Modified Paths:
--------------
trunk/LedgerSMB/Form.pm
Modified: trunk/LedgerSMB/Form.pm
===================================================================
--- trunk/LedgerSMB/Form.pm 2006-10-20 04:55:08 UTC (rev 241)
+++ trunk/LedgerSMB/Form.pm 2006-10-20 15:53:54 UTC (rev 242)
@@ -388,13 +388,18 @@
my ($self, $myconfig, $amount, $places, $dash) = @_;
+ my $negative = ($amount < 0);
+ if ($amount){
+ $amount =~ s/-//;
+ $amount = $self->parse_amount($myconfig, $amount);
+ }
+
if ($places =~ /\d+/) {
#$places = 4 if $places == 2;
$amount = $self->round_amount($amount, $places);
}
# is the amount negative
- my $negative = ($amount < 0);
# Parse $myconfig->{numberformat}
@@ -406,8 +411,6 @@
if ($myconfig->{numberformat}) {
- $amount =~ s/-//;
- $amount = $self->parse_amount($amount, $myconfig);
my ($whole, $dec) = split /\./, "$amount";
$amount = join '', reverse split //, $whole;
@@ -486,8 +489,12 @@
my ($self, $myconfig, $amount) = @_;
+ eval $amount->isa('Math::BigFloat'); # Amount may not be an object
+ if (!$@ and $amount->isa('Math::BigFloat')){
+ return $amount;
+ }
my $numberformat = $myconfig->{numberformat};
- my $decimal_regex = /\.\d{2}/;
+ my $decimal_regex = /\.\d+$/;
if (($numberformat !~ $decimal_regex) and ($amount =~ $decimal_regex)){
# We have already parsed this number
$numberformat = "1000.00";
@@ -508,6 +515,7 @@
}
$amount =~ s/,//g;
+ $amount = new Math::BigFloat($amount);
return ($amount * 1);
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.