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

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



Revision: 226
          http://svn.sourceforge.net/ledger-smb/?rev=226&view=rev
Author:   einhverfr
Date:     2006-10-18 15:19:23 -0700 (Wed, 18 Oct 2006)

Log Message:
-----------
Fixed issues with parsing numbers in "1 000.00" format and in double parsing them.

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

Modified: trunk/LedgerSMB/Form.pm
===================================================================
--- trunk/LedgerSMB/Form.pm	2006-10-18 21:28:12 UTC (rev 225)
+++ trunk/LedgerSMB/Form.pm	2006-10-18 22:19:23 UTC (rev 226)
@@ -478,14 +478,24 @@
 
 	my ($self, $myconfig, $amount) = @_;
 
-	if (($myconfig->{numberformat} eq '1.000,00') ||
-		($myconfig->{numberformat} eq '1000,00')) {
+	my $numberformat = $myconfig->{numberformat};
+	my $decimal_regex = /\.\d{2}/;
+	if (($numberformat !~ $decimal_regex) and ($amount =~ $decimal_regex)){
+		# We have already parsed this number
+		$numberformat = "1000.00";
+	}
 
+	if (($numberformat eq '1.000,00') ||
+		($numberformat eq '1000,00')) {
+
 		$amount =~ s/\.//g;
 		$amount =~ s/,/\./;
 	}
+	if ($numberformat eq '1 000.00'){
+		$amount =~ s/\s//g;
+	}
 
-	if ($myconfig->{numberformat} eq "1'000.00") {
+	if ($numberformat eq "1'000.00") {
 		$amount =~ s/'//g;
 	}
 


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