Total order amount per customer

0
In my domain model the entity Customer is associated to Order (1 to many). The requirement is to show the sum of the order amount of open orders per customer. My idea was to add a data view with a microflow as data source to determine the total order value per customer. Then I wanted to show this total order value per customer combined with some customer attributes (1 row per customer) in a nested data grid. However, I cannot get the app working. What would be the best way to achieve this? Your input is highly appreciated.
asked
3 answers
0

Hi Arjan,

Have you considered this:

- Create a calculated attribute under Customer called TotalOpenOrderAmount. Calculate the value (in a microflow) by retrieving all open orders and take the sum of the Prices. You can show this value on your Customer_Overview (datagrid) and Customer_NewEdit (dataView) page.

Hope this helps.

Kind regards,

Tim Vredevoort

 

answered
2

Hi Arjan, one approach can be as follows,
1. Create an attribute OrderTotal in Customer entity.

2. Create a MF that takes Order and Customer as input parameters and update the OrderTotal of Customer with the OrderValue of Order $Customer/OrderTotal+$Order/OrderValue

3. Call this MF as sub MF in the MF where you are setting the Customer-Order assc.

 

PS: Other approaches can involve event handlers or may be setting the OrderTotal as a calculated attribute with a MF that retrieves the assc Orders list and iterates over summing the order values and returning the number.

 

Hope this gives you an idea on how to proceed. Good Luck!

 

answered
0

Thanks for the input! Works now, using a calculated attribute.

answered