Ugly bug in javascript number entry formatting code.
authorJanusz Dobrowolski <janusz@frontaccounting.eu>
Tue, 7 Sep 2010 06:33:48 +0000 (06:33 +0000)
committerJanusz Dobrowolski <janusz@frontaccounting.eu>
Tue, 7 Sep 2010 06:33:48 +0000 (06:33 +0000)
CHANGELOG.txt
js/utils.js

index 4909b54f7cb20397f6e8d71d3b53aa989ea67166..880dddc35945fb7777a7407bc288fb5966ea6ac2 100644 (file)
@@ -19,11 +19,15 @@ Legend:
 ! -> Note
 $ -> Affected files
 
+07-Sep-2010 Janusz Dobrowolski
+# Ugly bug in formating numbers
+$ /js/utils.js
+
 07-Sep-2010 Joe Hunt/Chaitanya
 ! Removed all decimal roundings in cost price calculations
 $ /purchasing/includes/db/grn_db.inc
   /manufacturing/includes/db/work_orders_db.inc
-  
+
 06-Sep-2010 Janusz Dobrowolski
 # Fixed error on new contact add.
 $ /includes/ui/contacts_view.inc
index 9b1b1ac479202cbb08e91cf391aa09298c97a2c9..0474ae2361b21f8c28cc71d3dd75883e6ec2ac87 100644 (file)
@@ -219,12 +219,11 @@ function price_format(post, num, dec, label, color) {
        num = Math.floor(num*decsize+0.50000000001);
        cents = num%decsize;
        num = Math.floor(num/decsize).toString();
+       for( i=cents.toString().length; i<dec; i++){
+               cents = "0"+cents;
+       }
        if (max) // strip trailing 0
                cents = cents.toString().replace(/0+$/,'');
-       else
-               for( i=cents.toString().length; i<dec; i++){
-                       cents = cents + "0";
-               }
        for (var i = 0; i < Math.floor((num.length-(1+i))/3); i++)
                num = num.substring(0,num.length-(4*i+3))+user.ts+
                        num.substring(num.length-(4*i+3));