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 //Gets number without mask
this.getValue = function(masked_num){ this.getValue = function (elem) {
var __DECIMAL_SEP = '.'; var arrayNum = elem.value().split("");
var xNum = masked_num.split(''); var num = "";
_num = '';
for (u=0; u < xNum.length; u++){ for (var i = 0; i <= arrayNum.length - 1; i++) {
switch(xNum[u]){ switch (arrayNum[i]) {
case '0': case '1': case '2': case '3': case '4': case "0":
case '5': case '6': case '7': case '8': case '9': case __DECIMAL_SEP: case "1":
_num += xNum[u]; 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; break;
} }
} }
return _num;
};
return num;
};
//DEPRECATED //DEPRECATED
this.toMask2 = function (num, mask, cursor) 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)){ if (aAux[2] == nnName[2] && j <= (this.oGrid.rows.length-2)){
oAux=this.getElementByName(j, nnName[2]); oAux=this.getElementByName(j, nnName[2]);
var oAux2 = oAux.value().replace(/[$|a-zA-Z\s]/g,''); 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; i = 1;
fTotal = 0; fTotal = 0;
aAux[2] = aAux[2].replace(']', ''); aAux[2] = aAux[2].replace(']', '');
while ((oAux = this.getElementByName(i, aAux[2]))) { while ((oAux = this.getElementByName(i, aAux[2]))) {
if ( oAux.value() != "" ) { if (oAux.value().trim() != "") {
fTotal += parseFloat(G.getValue(oAux.value().trim() )); fTotal = fTotal + parseFloat(G.getValue(oAux));
} }
sMask = oAux.mask; sMask = oAux.mask;
i++; i = i + 1;
} }
i--; i--;
if (fTotal > 0) { if (fTotal > 0) {
fTotal = (fTotal / i).toFixed(2); fTotal = (fTotal / i).toFixed(2);