ERPNext.com Frappe Cloud Support Partners Foundation Frappe School

API issue creating Sale Order

Hi, I’m using the Frappe Client API to send sales orders to ERPNext, which works - apart from the taxes & shipping rule. This is what is submitted (amongst doctype, etc):-

{‘taxes_and_charges’:‘Vat - 20%’, ‘shipping_rule’:‘Next Day Courier’}

This appears in the taxes and shipping rule box on the order but it just seems like text - not activated, if you get my meaning. The rules do not work unless you use the drop down and choose them.

Any ideas on how to fix this??

So the issue is that the method that fills in the taxes and charges from the Tax and Shipping Rule templates is a client side Javascript function, which doesn’t get run when you send it over the API (which only processes server side functions).

Unfortunately, it doesn’t look like the apply_shipping_charges python function is whitelisted, so I don’t think there’s a way to call it through the API, but you can try:

GET http://yoursite.com:8000/api/method/erpnext/erpnext/controllers/selling_controller.apply_shipping_rule

If that doesn’t work, you likely will need to whitelist it or create a separate function that calls it. Alternatively, you can create a server side script that uses the before_save hook to call the apply_shipping_rule function.

I can’t figure out how the taxes and charges template is applied, so I can’t tell you how to implement that one. Hopefully someone else can give a clue.

Thanks Ben,

Javascript makes sense!

No luck though :frowning:

I’m using the hosted version of ERPNext so haven’t got access to create server side scripts. Would i be able to whitelist it client side or alternative?

I’m not aware of any way of doing that.

I would raise a GitHub issue. The developers might decide to whitelist that method, or they can have add a validation that checks to see if any rules have been added if there are shipping/tax templates listed.

Hi #foxman, any luck with this issues at all?

No, had to close my erpNext site in the end as it is mission critical…