Merge pull request #534 from victorsl/BUG-7070

BUG 7070 "Sum function not calculating properly" SOLVED
This commit is contained in:
julceslauhub
2012-09-07 07:26:59 -07:00
2 changed files with 36 additions and 20 deletions

View File

@@ -2215,21 +2215,32 @@ function G()
};
//Gets number without mask
this.getValue = function(masked_num){
var __DECIMAL_SEP = '.';
var xNum = masked_num.split('');
_num = '';
for (u=0; u < xNum.length; u++){
switch(xNum[u]){
case '0': case '1': case '2': case '3': case '4':
case '5': case '6': case '7': case '8': case '9': case __DECIMAL_SEP:
_num += xNum[u];
break;
}
}
return _num;
};
this.getValue = function (elem) {
var arrayNum = elem.value().split("");
var num = "";
for (var i = 0; i <= arrayNum.length - 1; i++) {
switch (arrayNum[i]) {
case "0":
case "1":
case "2":
case "3":
case "4":
case "5":
case "6":
case "7":
case "8":
case "9":
num = num + arrayNum[i];
break;
case elem.comma_separator:
num = num + ".";
break;
}
}
return num;
};
//DEPRECATED
this.toMask2 = function (num, mask, cursor)

View File

@@ -932,10 +932,12 @@ var G_Grid = function(oForm, sGridName){
if (aAux[2] == nnName[2] && j <= (this.oGrid.rows.length-2)){
oAux=this.getElementByName(j, nnName[2]);
var oAux2 = oAux.value().replace(/[$|a-zA-Z\s]/g,'');
if ( (oAux != null) && (oAux.value().trim() != '') && (oAux2)) {
fTotal += parseFloat(G.getValue(oAux.value()));
if ((oAux != null) && (oAux.value().trim() != "") && (oAux2)) {
fTotal = fTotal + parseFloat(G.getValue(oAux));
}
j++;
j = j + 1;
}
}
/*
@@ -964,13 +966,16 @@ var G_Grid = function(oForm, sGridName){
i = 1;
fTotal = 0;
aAux[2] = aAux[2].replace(']', '');
while ((oAux = this.getElementByName(i, aAux[2]))) {
if ( oAux.value() != "" ) {
fTotal += parseFloat(G.getValue(oAux.value().trim() ));
if (oAux.value().trim() != "") {
fTotal = fTotal + parseFloat(G.getValue(oAux));
}
sMask = oAux.mask;
i++;
i = i + 1;
}
i--;
if (fTotal > 0) {
fTotal = (fTotal / i).toFixed(2);