Naokai
18 Aug 2009, 3:09 AM
Hi im trying to calculate some values for a statistic.. now i have the problem if i call this part of the code:
i get on first call: zero.
and if i call this part a second time i get the right values..
can somebody help me out i didnt find the problem here..
Here is my Code
var positivValue = 0;
var negativValue = 0;
var turnoverValue = 0;
storeTurnover.load({
params: {
select: 'turnover',
date: date,
markt: markt
}
});
storeTurnover.data.each(function(item, index, totalItems){
if (item.get('Umsatz') > 0) {
positivValue = (parseFloat(positivValue) + parseFloat(item.get('Umsatz')));
} else {
negativValue = (parseFloat(negativValue) + parseFloat(item.get('Umsatz')));
}
});
positivValue = format_amount(Math.abs(0.85 * (positivValue)));
negativValue = format_amount(Math.abs(0.85 * (negativValue)));
turnoverValue = format_amount(positivValue - negativValue);
Lars
i get on first call: zero.
and if i call this part a second time i get the right values..
can somebody help me out i didnt find the problem here..
Here is my Code
var positivValue = 0;
var negativValue = 0;
var turnoverValue = 0;
storeTurnover.load({
params: {
select: 'turnover',
date: date,
markt: markt
}
});
storeTurnover.data.each(function(item, index, totalItems){
if (item.get('Umsatz') > 0) {
positivValue = (parseFloat(positivValue) + parseFloat(item.get('Umsatz')));
} else {
negativValue = (parseFloat(negativValue) + parseFloat(item.get('Umsatz')));
}
});
positivValue = format_amount(Math.abs(0.85 * (positivValue)));
negativValue = format_amount(Math.abs(0.85 * (negativValue)));
turnoverValue = format_amount(positivValue - negativValue);
Lars