20
Views
7
Comments
Solved
How to auto-calculate the total price from two diferent aggregates in a web screen

Hi,


I'm trying to "auto" calculate the total of a order. 

Example:

Barbecue Pizza = 10€

Coca-Cola = 5€


What I have to do so this auto-calculate the Total of the order?


Ps: I have 2 diferent aggregates for Pizzas and Drinks, in which, both of them has diferent prices for the diferent "objects".


Thanks.

Rank: #487
Solution

Hi Guilherme,

On your aggregate, you can click on the arrow on the top right corner of your attribute and get the sum off all the records for that attribute.


If you have two aggregates, you would have to do this for both and then sum those values, like this:


Let me know if this helps,

Pedro

Rank: #487

You can also create new attributes where you can add your own logic. In this case, I'm calculating the Price * Quantity to get the Total Price of an order.


Let me know if this helps.

Rank: #287

Hi,

You can't auto-calculate the value across different aggerate. You have to do that manually by adding some code.

Can you consider combining two aggregates into one? I think it's not difficult.

Kind Regards


Rank: #245

I think you are right. If its the same order, why not use 1 aggregate and if you want to display them in separate tables, then use the listfilter.

As for the sum, i think this is easy: if the aggregate gives few records then just loop throught them to get the total. If there are many records, perhaps its best tu create another aggregate with a group by and use the sum.


Rank: #18996

@Pedro Marques  Thank you! Worked just fine!

Rank: #487

Glad it worked!