Adding Shipping Charge to Purchase Order in ERPNext

I hope this message finds you well. I am currently working on a customization task for ERPNext, and I’m seeking guidance on how to add a new field for Shipping Charge in the Purchase Order document.

Specifically, I aim to:

  1. Introduce a new field named “Shipping Charge” in the Purchase Order form.
  2. Include the Shipping Charge in the calculation of both the “Total” and “Grand Total” of the Purchase Order.
  3. Distribute the Shipping Charge among the items in the Purchase Order based on their quantity, adjusting the net rate and net amount accordingly.

I’ve reviewed the existing documentation and codebase, but I’m seeking advice on the best practices for implementing this customization.

Any assistance, code snippets, or pointers to relevant resources would be greatly appreciate.

I didn’t understand which function update the total’s and in which file.

Are you looking to change the actual price of each item? Usually, a purchase order shows the prices of the items you’re purchasing based on your vendor’s quote, and you wouldn’t typically want to change the rate of each item to also include the shipping, as it might confuse the vendor since they’ll likely track shipping as a separate line item on their end. Unless you have an arrangement with the vendor?

Or maybe I misunderstand, and you only want your internal costs (not the item price) to reflect a pro-rated portion of the shipping amount? If so, you might want to look at the ‘landed cost’ feature of ERPnext, which could be what you’re trying to accomplish:
https://docs.erpnext.com/docs/user/manual/en/stock-transactions-landed-cost-voucher

I want distribute shipping charge in item’s net rate and net amount not in rate and amount.
And also add in total.

And I can’t understand in which file and in which function where i can modify.

The inbuilt shipping charges are very inflexible

Ended up using an Item called Carriage for the shipping charges, and just added it there.