VAT configuration guide

11 лет назад
This is a rough and ready tutorial on how to set up NopCommerce VAT support for shops in the EU.

I'm starting with a fresh install of NopCommerce 1.8. Unless stated the following tasks are mandatory/critical.

1. Log into the Administration area

2. Go to Configuration, Tax, Tax Settings.
2a. Check/tick EU VAT enabled. This will ensure that tax is charged only for shipments in the EU.
2b. Select the country your shop is in.
2c. Optional: If applicable, check Allow VAT exemption. This will ensure that your VAT registered customers who are shipping within the EU but outside the shop country will not be charged VAT.
2d. Optional: If you checked "Allow VAT exemption" then you might want to check the "web service" and "notify admin" boxes too. This will check VAT numbers submitted by your customers against the EU database. Note: This process works but the communication of the statuses to the admin is a bit poor (and can't be seen in admin area). I hope to improve this some time.
2e. Set Tax Based On to "Shipping Address".
2f. Hit save.

3. Go to Configuration, Location, Countries. Check that all the countries which are in the scope of the VAT have "Subject to VAT" set to true. Note that as far as I know Jersey, Guernsey and the other Channel Islands are not part of the UK and are not within the scope of VAT. If you sell to those places you may need to change that.

4. Go to Configuration, Tax, Tax Classes. Set up a tax class for each VAT rate in force in your country. For example, "Standard Rate", "Zero rate", "Discounted rate". Delete any classes already there.

5. Go to Configuration, Tax, Tax Providers. Make the Fixed Rate Provider the default and save.

6. Now we need to edit the tax rates which will be charged by the fixed rate provider, so hit Edit. You'll see your VAT rate categories there if you go to the Configuration tab. Now just enter the percentage rates e.g. 17.5, 0%, 5%, and save.

7. That's the VAT support set up. Now you need to make sure that all products have a tax category assigned to them. In most cases this will be the Standard Rate of course.

Hope that helps someone. Corrections and suggestions for improvement welcome.

I intended to post this on a new NopCommerce/tech blog but I haven't got round to setting it up yet. Will do so some time!

11 лет назад

11 лет назад

first of all, I would like to thank you all for the excellent job, the VAT extension is wonderful.

I have a little problem that I'm investigating right now: it seems to me that a customer that is eligible for VAT exemption sees all the prices plus the taxes until he selects for the first time a billing or shipping address (this depends on the setting in the tas settings page), then on the subsequent visits the prices are shown without taxes.

So for example my store is "located" in Italy, and I set up a new user with default, billing and shipping addresses in UK. This user has a valid VAT number (either checked against the EU database or marked manually as valid).
This example user is eligible for VAT exemption, but when he browses the store for the first time, he sees all the prices plus the taxes. If he puts an article in the cart, also the cart shows at the bottom the amount of the tax, until he selects an address (either a billing or shipping address, this depends on the settings of the system). After this step, the cart shows correctly the tax amount (in this case, no tax), and everywhere in the site all the prices now are correctly shown without taxes.

My store is configured as follows:
Prices include tax: NO
Tax display type: INCLUDING TAX
Display tax suffix: YES
Display all applied tax rates: YES
Hide zero tax: NO
Hide tax in order summary: NO
Tax based on: BILLING ADDRESS (also with SHIPPING ADDRESS is the same)
Default Country: ITALY
Shipping is taxable: NO
Payment method additional fee is taxable: NO
EU VAT enabled: YES
Your shop country: ITALY
Allow VAT exemption: YES
Use web service: NO
Notify admin when a new VAT number is submitted: YES

Could you please check if this is an issue of the system or is caused by some errors in my configuration?

Thank you very much.

Best regards

Luca Pandolfini
11 лет назад
Hi Luca,

As an aside, I think you need to calculate tax based on shipping address. You should check the VAT rules in Italy but I believe that VAT is chargeable on the shipping location. I'm not an expert and if you can prove me wrong on this please do!! I'm thinking that it would be good if the installer asked if the shop needs VAT support and then set this and the tax categories up?

I still had the blank store I used to create the tutorial so I changed it to reflect your settings. I then created a user in the UK and marked their VAT number as valid.

When I visit a product as this new user I see it as $100 including tax. The user has billing and shipping addresses visible in the admin area but has NEVER been through checkout.

When I view the same product as an anon I see a price of $115 including tax. (I set up a 15% rate to test with).

Does your new customer have any address under Customer Billing Addresses and Customer Shipping Addresses in Edit customer details? If no, the software won't know which country they're in so will default to charging them tax until a billing/shipping address is chosen in checkout.

In CreateCalculateTaxRequest():

var basedOn = TaxManager.TaxBasedOn;

            if (basedOn == TaxBasedOnEnum.BillingAddress)
                if (customer == null || customer.BillingAddress == null)
                    basedOn = TaxBasedOnEnum.DefaultAddress;
            if (basedOn == TaxBasedOnEnum.ShippingAddress)
                if (customer == null || customer.ShippingAddress == null)
                    basedOn = TaxBasedOnEnum.DefaultAddress;

If there's no address available it falls back to the default tax address. You configured your default tax address to be in Italy and also you configured your shop's VAT location to be Italy. VAT is always charged if shipping to the same country, so I suspect that's what happening.

If you're comfortable with Visual Studio I would suggest putting a breakpoint at line 481 of TaxManager.cs in the business logic project (var calculateTaxRequest = CreateCalculateTaxRequest(productVariant, taxClassId, customer);) and stepping through from there.


11 лет назад
Thank you for your reply.

I checked with VisualStudio putting a breakpoint as you suggested, and these are my results.

I'm browsing the store with a new user that has a default address in the UK, and shipping and billing addresses also in the UK, but has never been through checkout. By the way, I changed the setting as you suggested for the base address for VAT calculation, now my store is using the shipping address (I will check with an accountant as soon as I can).

The problem seems to be at line 166 of TaxManager.cs:
if (customer == null || customer.ShippingAddress == null)

because this is evaluated as true!
The customer object isn't null, but the shipping address is null even if I entered a shipping address in the admin area before logging in.
Stepping into the method, I went through line 282 of Customer.cs
_shippingAddressCache = CustomerManager.GetAddressById(this.ShippingAddressId);

where "this" represents the current user (I checked the properties and they have, almost, the correct values). The problem here is that the property ShippingAddressId is 0. If I browse through all the properties of the object, I can see that ShippingAddress is null, but ShippingAddresses contains the right address.

If I select an article and I go through the checkout process leaving the breakpoints in place, after I select the shipping address at some point I see that the property ShippingAddressId is populated with the right value, and in the following page I see that the tax is not applied (this is the expected behavior).

What I don't understand is why you are experiencing with a different situation even if the settings are the same. Am I forgetting something? You surely know the system better than me, so if you think that something can be different feel free to tell me!

In the meantime, I would like to thank you again for your help.

Best regards

Luca Pandolfini
11 лет назад
Just a little follow-up to my previous post. I checked with a business consultant here in Italy and he confirmed me that the VAT must be applied depending on the shipping address, not the billing one.
I'm sorry I doubted you, I just wanted to be sure because this is really not my field.


Best regards
Luca Pandolfini
11 лет назад
Thanks Luca for the information from the business consultant about the VAT address.

I can't explain why we're seeing a discrepancy in behaviours. Maybe Andrei will help? I'll send him a private message.

How did you get the code you pasted in to be colour formatted?
11 лет назад
Just using the first button on the right, above the textarea.
It will insert [ code ] and [ / code ] and you have to place your code inside!
11 лет назад
Luca ,

Very strange. Try the following steps:
1. Open \Modules\CustomerRegister.ascx.cs
2. Set breakpoint on the line 376 ("customer = CustomerManager.SetDefaultShippingAddress(customer.CustomerId, shippingAddress.AddressId);")
3. Try to register as a new customer and let me know whether this method is invoked and default shipping address is set
11 лет назад
Hi Andrei,

thank you for your help. I did what you suggested and the default address is set correctly.
The problem is that the user I used before to check this procedure was created from scratch in the admin area, and not from the public registration page.
Maybe there is a little difference in how the user is created, it seems to me that the administration page to create the user does not set the default address as the public registration page. Could this be the cause of my problem?

Best regards
Luca Pandolfini