How "Order" field is updated when a "OrderProduct" detail record is changed ?

Hi Team,



In the "Order" section there is a multicurrency field 'Total' and the values get auto-calculated/updated when a detail (OrderProduct) record is added/modified/deleted.



As this is a two different tables & modules, a sandbox should be used for the communication. Could you please assist us with the below queries?

1. EventHandler/Method name where the actual calculation is executed?

2. Where is the Sandbox mechanism used in OrderPageV2 & OrderProductDetailV2?

3. Which package has these client modules where the OOTB logic is written?

 

Attached the image reference,

 

 

Any insight on this would be appreciated.

 

 

BR,

Bhoobalan Palanivelu.

Like 0

Like

3 comments

Team,



Any insight on this?





Regards,

Bhoobalan Palanivelu.

One approach you can take is to add a subscriber to the detail. It is a function you can add to the detail definition to receive add/edit/delete updates from the detail. I believe that is possibly how it is working now out of the box. 

Locate the detail and add a subscriber like this: 

details: {
    ProductInProductsTab: {
        schemaName: "OrderProductDetailV2",
        entitySchemaName: "OrderProduct",
        filter: {
            masterColumn: "Id",
            detailColumn: "Order"
        },
        subscriber: { methodName: "refreshAmount" }
    }
}

Then add the function:

methods: {
  refreshAmount: function() {
    // refresh or do something since the detail has had something added/edited/deleted
  }
}

Ryan

Hi, 

This logic may be quite difficult to follow, and due to that I recommend you add breakpoints in the network to see it for yourself, but if you want a small step-by-step explanation then here it is:

When you are changing the product values the system triggers the method onBaseQuantityOrUnitChange in the schema BaseProductDetailPageV2? after it calcDiscountAmount, calcTaxAmount, and calcTotalAmount also start in this schema. Then the method saveRowChanges from the schema OrderProductDetailV2 and following the chain of methods we get to refreshAmount from BaseOrderPage and updateAmount/updateAmountFromDB from ProductEntryPageUtils. After that, triggers a modifyAmountESQ/updateAmountColumnValues from BaseOrderPage and in the end calls updateAmountColumnValues from ProductEntryPageUtils which is setting the "Amount" column.

I know I missed quite a lot of steps but it's really better to inspect this logic for yourself using breakpoints.

Show all comments