Changeset 361
- Timestamp:
- 11/09/07 15:00:09
- Files:
-
- trunk/phpbms/common/javascript/common.js (modified) (1 diff)
- trunk/phpbms/modules/bms/javascript/invoice.js (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/phpbms/common/javascript/common.js
r349 r361 673 673 674 674 function numberToCurrency(number){ 675 675 676 var currency=""; 677 676 678 if(isNaN(parseFloat(number))) number=0; 677 679 678 680 if(number<0) 679 681 currency+="-"; 680 number=Math.abs(number); 681 currency+=CURRENCY_SYM; 682 683 number = Math.abs(number); 684 685 currency += CURRENCY_SYM; 686 682 687 if(number>0 && number <0) 683 688 currency+="0"; 684 689 685 var withThousands=parseInt(number).toString(); 690 var lessthanone = Math.round( (number-parseInt(number)) * (Math.pow(10,CURRENCY_ACCURACY)) ); 691 692 if(lessthanone >= Math.pow(10,CURRENCY_ACCURACY)){ 693 694 number++; 695 696 lessthanone -= Math.pow(10,CURRENCY_ACCURACY); 697 698 }//end if 699 700 lessthanone = lessthanone.toString() 701 702 while(lessthanone.length<CURRENCY_ACCURACY) 703 lessthanone = "0" + lessthanone; 704 705 var withThousands = parseInt(number).toString(); 686 706 var objRegExp = new RegExp('(-?[0-9]+)([0-9]{3})'); 707 687 708 while(objRegExp.test(withThousands)) 688 709 withThousands = withThousands.replace(objRegExp, '$1'+THOUSANDS_SEPARATOR+'$2'); 689 690 var lessthanone=Math.round((number-parseInt(number))*(Math.pow(10,CURRENCY_ACCURACY))).toString(); 691 while(lessthanone.length<CURRENCY_ACCURACY) 692 lessthanone="0"+lessthanone; 710 693 711 currency+=withThousands; 712 694 713 if(CURRENCY_ACCURACY!=0) 695 714 currency+=DECIMAL_SYMBOL+lessthanone; 715 696 716 return currency; 717 697 718 } 698 719 trunk/phpbms/modules/bms/javascript/invoice.js
r360 r361 1078 1078 1079 1079 //calculate and reformat discount 1080 var numDiscount ,discountValue;1080 var numDiscount; 1081 1081 if(discountFromID.value=="" || discountFromID.value=="0" || discountFromID.value=="0%"){ 1082 1082 numDiscount=currencyToNumber(thediscount.value); … … 1089 1089 } 1090 1090 } 1091 discountValue=numberToCurrency(numDiscount); 1092 thediscount.value= discountValue;1091 1092 thediscount.value= numberToCurrency(numDiscount); 1093 1093 1094 1094 //calculate totaltaxable