Invoice Line Items and logic hook

I am trying to fire a couple of after save logic hooks on save of an invoice.

The first one has to deal with a single field calculation at the Invoice level and it seems to be working just fine.

The second one has to do with the Line Items of the invoice (AOS_Products_Quotes) objects (aos_products_quotes relationship).

I am editing the Invoice and hitting save. After the save, it fires the after_save trigger, BUT I am getting OLD values in the after_save trigger.

I did notice that if I edit the Invoice the second time, the after save trigger has the new values.

What’s going on here? Post the first after_save trigger, I should have got the new values from the AOS_Products_Quotes table. Why is there a delay here or am I missing something basic?

Vishal. :unsure:

Looks like the logic hook for the AOS_Invoice is firing up first followed by the logic hook for AOS_Products_Quotes.

Should this not be backwards? Don’t we want the child items to be saved and then the AOS_Invoice data (commit both in one transaction) and then call the logic hooks?



No, quote get’s saved first to get the ID and then the rest of logic get’s executed, that’s why you have quote LH firing before LH for line items.

If I am editing an invoice, then the flow is similar; I get the Invoice LH firing before the line item LH.

Hate to bring up an old thread, I was wondering if anyone knows of a way around this issue. We have after_save logic hooks we would like to execute on invoices but because of the order of operations the logic is inconsistent in execution.