Sum aggregration not counting all rows

I am having trouble with a sum aggregation. I am performing a sum on a table called orderitems, on a field called linetotal, which is worked out via quantity * price, a fairly basic thing to do. The problem is that if I add to orderitems via a formindialog, the aggregate function doesn’t seem fire, so I can add items to an order without the total being updated. The aggregation is used in a stored calculation on an orders table, to work out the current total for an order:

var totaldiscounts = discount + preorders_to_credits_total.orderCreditsTotal;
var totalcharges = deliverycharge + surcharge + vat;
return (preorders_to_preorderitems.agg_sum_orderItemsLineTotals + totalcharges) - totaldiscounts;

When I add most items to an order, the total updates. However I have to add pizza toppings via a formindialog to ensure that they are associated with a pizza item and it’s these items that are not counted in the total when they’re added to an order. HOWEVER! If I add say three toppings ($0.50) to a pizza ($1.00) for a total of $2.50, then delete one topping, the total updates showing the new correct total for pizza + two toppings ($2.00).

I am at a loss as to why this is happening, and it is rather a large problem. Any ideas?

Whoops – forgot version information

Servoy 2.2 final running on linux (ubuntu) using java 1.5.0_04

Any suggestions?

Just tried the latest beta (2.2.1 rc2 is what the announcement says, but 2.2.2 build 328 is what shows up in the Help > About dialog) and this problem is still present.

I have same issue here…

I have a stored calc that returns an amount of minutes:

var vMinutes = null

if(hours_estamated || minutes_estamated) {
	vMinutes = minutes_estamated + hours_estamated * 60
}

return vMinutes

When I sum this calculation, the sum doesn’t contain all records…

Servoy Developer
Version 3.1.6-build 410
Java version 1.5.0_07-87 (Mac OS X)

if(hours_estamated || minutes_estamated) { 
   vMinutes = minutes_estamated + hours_estamated * 60 
}

I would do this, and that might be the cause as well (unless you prefill with 0):

var hEstimated = hours_estimated != null ? hours_estimated : 0;
var mEstimated = minutes_estimated != null ? minutes_estimated : 0;

vMinutes = mEstimated + (hEstimated * 60);

BTW Karel, did you know Riccardo already uses that Avatar?

IT2Be:
BTW Karel, did you know Riccardo already uses that Avatar?

Hei: it’s not an Avatar. It’s a portrait! ;)

hmmm a portrait. Well in that case you are a cute boy :lol:

be carefull with stored calculations and aggregates.
first you have to had every record in view (on the form), before, the calc is really calculated. (saved to the DB) Only THAN the aggregate will work.

if you want to be 100% sure, you have to do: databasemanager.recalculate(foundset) first!
(but that can be a real time consuming thing if you have thousands of records in your foundset.)

Riccardino:

IT2Be:
BTW Karel, did you know Riccardo already uses that Avatar?

Hei: it’s not an Avatar. It’s a portrait! ;)

Ai! Sorry… no… haven’t noticed..
Gonna get myself some other funny avatar soon!