[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

SF.net SVN: ledger-smb: [338] trunk/LedgerSMB/Form.pm



Revision: 338
          http://svn.sourceforge.net/ledger-smb/?rev=338&view=rev
Author:   einhverfr
Date:     2006-10-27 11:43:43 -0700 (Fri, 27 Oct 2006)

Log Message:
-----------
Fixed number parsing for (n), n DR and n CR formats

Modified Paths:
--------------
    trunk/LedgerSMB/Form.pm

Modified: trunk/LedgerSMB/Form.pm
===================================================================
--- trunk/LedgerSMB/Form.pm	2006-10-27 17:56:09 UTC (rev 337)
+++ trunk/LedgerSMB/Form.pm	2006-10-27 18:43:43 UTC (rev 338)
@@ -391,9 +391,10 @@
 	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 @@
 
 
 	$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);
 }


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.