while adding a product to an invoice, iam trying to override the given quantity value by an external value.
My problem is: iam not sure where i have to do this.
My attempt was to do it in the “LINEBILL_INSERT” trigger event, but when i try to override $object->qty the change will be ignored.
Checking facture.class.php it turns out, that the returned result from the trigger is just a statuscode.
Hope someone can give me a hint, maybe i totally overlooked something.
Thanks alot in advance!
I was able to solve my problem, but of course there is a new one.
After changing the qty of a product inside a bill i would like to recalculate the total prices - is there a way to trigger it without calculating these values on my own?
Hi LuHe,
Nope, it should be done automatically if your trigger is working. The update_price() is run on the parent invoice after the line->insert().
Check in the addline function of the Facture class what’s the outcome of the line->insert() with and without your trigger activated.
Regards,
Marc
Thanks alot for your response! Iam glad that there is a way to do it like this.
Unfortunetly your code results for me in a blank page.
Where do i get $main_object from?
I changed the trigger to “BILLREC_MODIFY” cause my changes should trigger after editing a custom field for a invoice template, but i guess that shouldnt change any behavior, right?
Is there a place where i can find something like that in the documentation? In my oppinion handling something like this is quite important.
Thank you very very much!