Purchase Invoice rounding through API

Disabling and enabling rounding is working properly when i do it from erpnext frontend.

When i do the same using API, it sets the field value properly but it doesn’t impact rounding.

In the above case, the disable rounding was unchecked using API, rounding should have happened. now if i change any other field value so that the update button shows up and i click on update button, then the rounding happens

Can anyone help me on this please?

Seems it works when i use the RPC, put api/resource way has the issue