Update Billed Amount In The Sales Order, when Invoice Paid through REST

Hello. I’m working on a integration between ERPNext and a eCommerce platform through REST API. Today i’ve encountered a issue with Sales Invoice which is related to the change of Sales Order status.

The Sales Invoice is firstly created as a draft and as the payment have been detected in the eCommerce platform it makes another REST request to submit the draft document with paid amount etc… and with the (update_billed_amount_in_sales_order = 1) value which should update the billed amount to the Sales Order. The Sales Invoice will be successfully marked as Paid, but the information about the payment won’t reach the Sales Order and the status of the Sales Order will remain “To Deliver and Bill” as it should change to “To Deliver” when the invoice is paid.

This works tho, if you go through the process manually. Make Sales Order, submit it, Make Invoice submit it with paid amount.