Add TAX to shipping costs

Think I must be going mad. Just realised that tax is not added to our shipping charges.

We have tax (VAT) set up at 20%, it is added to the products but not the shipping charges.

I assume I am missing a setting somewhere. Any ideas?

How are you adding the shipping the shipping charge in the first place?

As a shipping rule

On the sales order no TAX rate

Still have not been able to solve this. Any ideas how to add our VAT tax to the shipping cost?

Hi ! I’ve got the same issue, has anyone found a workaround ?
I understand you can add a new row with tax on prrevious row, but it seems risky because one can forget it very easily

Thanks !

I never worked it out so I set up an item called “shipping” and used that instead

We have also found this occurs, and per Pay VAT tax on shipping charges - #15 by rtimagine @umair states to place the shipping prior to the tax in the charges table and ensuring the tax is set to apply on the previous row total…

Now although that can work, it is problematic given the default tax templates always place the tax first and you add shipping after, so you need to move the items around and also change the tax to apply on the previous row - which is too error prone for end users. We elected to go the single item route for shipping too, however when doing packing slips you need to remember to remove the item as it is a non-stock item and so the packing slip cannot be saved…

I went that route too, made an item for shipping and made a tax rule for it under its item page.

Hi !

Found a little workaround for this.
We created a button called “Add Shipping and Taxes”, and then a Custom Script to enter what we wanted in a pop-up box and have it saved in the correct order.

In customize form:

In the form:

The custom script:

Thanks for your contribution ecollot,

Please could you copy and paste your code here, so others can use it but not have to key it in or contact you.

thank you


Sure, here it is:

Sales Invoice Script

What this does:

  • Handles click on “Add shipping and taxes” button:
    • Empties taxes table
    • Replaces by two items: first item shipping, second item VAT (applies to previous total)

frappe.ui.form.on(“Sales Invoice”, {

refresh: function (frm) {

    frm.add_shipping = function (cost, shipAccount, costCenter, vat) {

        var shipping = frm.add_child("taxes");
        frappe.model.set_value(shipping.doctype,, "charge_type", "Actual");
        frappe.model.set_value(shipping.doctype,, "account_head", shipAccount);
        frappe.model.set_value(shipping.doctype,, "cost_center", costCenter);
        frappe.model.set_value(shipping.doctype,, "description", "Shipping");
        frappe.model.set_value(shipping.doctype,, "tax_amount", cost);

        var taxes = frm.add_child("taxes");
        frappe.model.set_value(taxes.doctype,, "charge_type", "On Previous Row Total");
        frappe.model.set_value(taxes.doctype,, "row_id", "1");
        frappe.model.set_value(taxes.doctype,, "cost_center", costCenter);
        // frappe.model.set_value(taxes.doctype,, "description", "Shipping");
        frappe.model.set_value(taxes.doctype,, "account_head", vat);

add_shipping_and_taxes: function (frm) {
            'fieldname': 'cost',
            'fieldtype': 'Currency',
            'label': 'Shipping Cost',
            'reqd': 1,
            'default': 0,
        }, {
            'fieldname': 'costCenter',
            'fieldtype': 'Select',
	'options': 'General - AMF\n' +
		'Automation - AMF\n' +
		'Patch - AMF',
            'label': 'Cost Center',
            'reqd': 1,
            'default': 0,
            'fieldname': 'shipAccount',
            'fieldtype': 'Select',
		'3410 - Frais de transport et commissions (ex Paypal) - AMF',
            'label': 'Shipping Account',
            'reqd': 1,
            'fieldname': 'vat',
            'fieldtype': 'Select',
		'VAT 7.7% - AMF\n' + 
		'VAT 0% - AMF\n' + 
		'VAT 2.5% - AMF',
            'label': 'VAT',
            'reqd': 1,
        function (values) {
            frm.add_shipping(values.cost, values.shipAccount, values.costCenter, values.vat);
        'Shipping Cost Entry',
        'Add shipping',