berstein Posted January 9, 2023 Share Posted January 9, 2023 Dear all, I would like to know how to detect (or some kind of flag) whether the invoice is created through new order, recurring, or manually created. For new order, I can search for the order that have the same invoice ID as the invoice. For recurring, temporary, I get all the relid of the invoice items and loop them in tblinvoiceitems. If any of the relid return more than 1, then the invoice is recurring. Is there any better way to achieve this? Thank you 0 Quote Link to comment Share on other sites More sharing options...
berstein Posted January 9, 2023 Author Share Posted January 9, 2023 Dear all, For update, I change the logic where if all invoice item's relid is 0 and the type is "", then it counted as manual invoice. Then, if the invoice is not counted as new order or manual invoice, it counted as recurring invoice. Still, if you have better way to achieve this, please inform me. Thank you 0 Quote Link to comment Share on other sites More sharing options...
Kian Posted January 9, 2023 Share Posted January 9, 2023 Use InvoiceCreation hook point. More in particular source parameter. Quote Indicates where the invoice creation action originated, can be one of adminarea, api or autogen 0 Quote Link to comment Share on other sites More sharing options...
berstein Posted January 10, 2023 Author Share Posted January 10, 2023 15 hours ago, Kian said: Use InvoiceCreation hook point. More in particular source parameter. Dear @Kian, thank you for your reply, Unfortunately, the data I'm collecting is pulled via SQL query, so I think hooks is out of the options. But, after some thought, we can use the hook to create flag of the invoice in the database by using custom table. The only downside is this will only works on invoice created after this hooks' activation. I have used this hook in the past, but if I'm not mistaken, the autogen source can't differentiate between recurring invoice and invoice created through new order. Please correct me if I'm wrong. Thank you 0 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.