I was very happy to see VAT-inclusive pricing included in the recent DC beta. However, I run into a strange behavior that seems wrong to me. Perhaps it's me doing something wrong or not understanding how this is supposed to work.

We have different VAT rates here in Sweden (6, 12 and 25 percent, depending on product type). Hence, I defined three rates as shown in the "Tax Rates" illustration. Each of the VAT rates are defined as in the "Tax Def" illustration.

A typical product is defined as shown in the "Prod def" illustration, with a price of 100 SEK, including 25% VAT (i.e., the ex VAT price is 80 SEK). So far so good.

The weirdness starts when viewing the product in the store, as shown in the "Shop" illustration. Note that the price shown is 118,72 SEK, not 100 as expected.

Adding this product to the shopping cart shows the same odd total in the shopping cart. Going to the Checkout page gives a hint as to why, as shown in the "Checkout" illustration. This shows the "subtotal" as the ex-VAT price (which is correct). It also shows SEK 20 as the 25% VAT applied to this product. However, it also shows items for 6% VAT and 12% VAT, which is incorrect, as there's only a single product in the cart, which has the standard VAT of 25% applied. Hence, the 6% and 12% VAT items should not be shown in this case. Indeed, they ought to be shown only when there are products with those corresponding VAT rates in the shopping cart.

Any thoughts on what's going on here. Is this a bug, or am I perhaps missing something?

-JM

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

rszrama’s picture

Status: Active » Needs review

By default, taxes are going to be added to the base product price at the point of display. However, if you edit or add new products after defining your tax rates, you can opt to input product prices as price including tax and select the proper rate. I believe that will solve the behavior you're experiencing.

TheWizz’s picture

FileSize
31.29 KB

Just tried adding another even newer product, also set to a 100 SEK price, including 25% VAT. It shows exactly the same behavior (see enclosed picture). Surely, this must be incorrect – it shouldn't be adding three kinds of VAT for one product - only the VAT type assigned to that product. Please let me know if you think I'm doing something wrong here, of if this appears to be a bug (in which case I assume it will bite anyone who has more than one VAT percentage to deal with).

checker’s picture

Version: 7.x-1.0-beta2 » 7.x-1.x-dev

I have exactly the same problem.
I created more than one vat tax and at checkout it shows always a calculation of all vat taxes.
Could there be problems because of wrong rules? I have not changed anything else.

pcambra’s picture

Status: Needs review » Postponed (maintainer needs more info)

I think that this is working as desired.

What's happening here is that you've created 3 different tax rates for the tax type VAT with different % rates but you haven't configured the conditions that are going to rule that tax rates and then are applied sitewide to all products.

You should go to the tax rates in admin/commerce/config/taxes/rates and then configure each tax rate so it is applied only to the products you want to, maybe category based or some other characteristic that is common to the products of each tax rate.
Then you can select in a product basis which tax rate is inclusive to the products because by default when you add a tax it is added to the base price you already have.

So, in the product edit form what you are selecting is not what tax rate to apply to the product but which tax rate is inclusive to that product.

TheWizz’s picture

FileSize
14.54 KB
11.95 KB

Thanks for your reply and clarification. However, what you say doesn't feel very intuitive to me. Also, it seems somewhat contradictory. When viewing the product in the "Products" list, its price is indicated as SEK 100, including VAT (see illustration 1). However, once added to the cart, the same product now indicates a price of SEK 118.72 (se ill 2).

Anyway, assuming this is what I must do, how can I make the rule conditional on, say, a taxonomy term associated with the product? I couldn't find the product's taxonomy terms anywhere in the rule selectors. Using this method (assuming I can figure out how to select the taxonomy term as a rule condition), I could duplicate the "included VAT" selector in a taxonomy term, which is then used to control the rule. However, it seems a bit unnecessary having to specify the desired VAT rate *twice* for every product. What's the rationale of *not* using the "included VAT" selector to specify what VAT should be applied? Are there really cases where you want all available VAT rates to be applied to all products by default? This doesn't seem to make sense to me.

rszrama’s picture

Ahh, yes, the problem here is that you appear to have inputted a product price including a VAT. That tax won't be recalculated later, as it's already been included in the price... but you can only at present input prices with one tax. The other VAT is appearing later because it still needs to be calculated. As Pedro mentioned, you'll need to use Rules to determine which tax should apply... and obviously you don't need both happening at one point in time.

Regarding the data selectors, we need to get a bigger tutorial out, but for now you need to use the "Entity has field" condition to ensure the field you're looking for is on the entity (product). Once you ensure it exists, you can use it in additional conditions' data selectors.

checker’s picture

After some days thinking about that i would also say it is not user friendly. The vat field should contain "price is incl. vat" and "price is excl. vat" and not all possible vat taxes.
Is there a use case where you type in a price for example incl. vat 20% and building a rule that this product let calculate with vat 15%?

EndEd’s picture

Hi, I'm having half of the same problem and I dont see how to apply the solution presented in #6 by rszrama about the data selectors and rules. In my product entity I made a field:

Label = Tax
Name = field_product_tax
Field = Term reference
Widget = Select List

This is referenced to a Vocabulary named Tax and Its terms (4, 8, 18) that represent the tax rate.

Also i´ve created 3 tax rates 4%, 8%, 18% VAT Type.

When i click configure component on the 18% VAT tax rate I see rules. I suppose to use conditions to for example make a comparison like this:

If entity:product:field_product_tax = 16 then Apply a tax rate to a line item

If I use as suggested in #6 the Entity has field, what kind of selector should I choose? Because I didn´t find nothing near entity (product) as suggested. I'm only have as options, line-items or site data-selectors that could check with the field "field_product_tax". Also no matter what permutation i choose of data selectors when i tried a second condition as suggested in #6 that allow me to do the data comparison I dont see how to do it as I dont find any new data close to "field_product_tax".

I hope someone that knows what im doing wrong could help.

pcambra’s picture

Status: Postponed (maintainer needs more info) » Active

Ok, reproduced problem in #8, when adding a new field to the product entity, it seems not to be available for rules even if the entity is loaded using entity has field condition.

googletorp’s picture

I didn't test this out, but from ready #6, #8 and #9, this looks like a rules bug that can be fixed using hook_entity_property_info_alter, see #1053850: Fix metadata-assertions for referenced entities.

EndEd’s picture

Subscribing

SteffenR’s picture

FileSize
69.85 KB

I just tried the latest version and getting the same errors - the tax rules could not be applied cause there's no field or entity to check for. In this case all taxes are applied in the cart display.

Subscribing ...

EndEd’s picture

Hi, i´ll try to explain the workaround that works for me while we wait this to be fixed.

In my case I create a custom product entity field that represent the product tax. I named it as 'field_product_tax'. So this field could have '4', '8' or '18' as a tax.

Then I created 3 tax rates (store->configuration->taxes->tax rates). One for a 4%, 8% and finally 18% tax rate. Be sure you have checked 'Define a default Rules component for determining this tax rate's applicability to a product' when you create them.

When you have them created, you click in configure component (store->configuration->taxes->tax rates) for the 18% tax rate you just created so you get into rules for that tax.

In the conditions click add condition, select 'Entity has field', select 'line-item' as the entity data selector and 'commerce_product' as the field to check for. Normally you could keep using 'Entity has field' to go deeper and access the field you custom created but as rules has a bug, you leave it that way for the moment and click save.

Go to Rules Components (admin/config/workflow/rules/components) and click add new component. Select the 'Condition set (AND)'. In my case I named it as 'Check if the Product has 18% VAT'. Select 'Entity->Product' as the data type. Also type 'Product' as label and 'product' as the machine name. Select Continue.

Then in conditions, click 'add condition'. Select 'product' as the data selector and the field you want to expose... remember that in my case was 'field_product_tax'. Then I add another condition but this time I chose 'data comparison'. Then I can select 'product:field-product-tax', 'Equals' as the operator and '18' as Data Value. Click Save.

So with this method we finally find a way to access via rules the custom field we created in the product entity. Now the final piece of the puzzle is to use this component you created inside the component that drupal commerce creates when you create a tax rate. So go here (store->configuration->taxes->tax rates) and click again in configure component for the 18% tax rate. This open rules and you will see the condition (entity has field) you created before.

Create a new condition and you will see 'Components' as an option and inside you will see the custom component we created to access our product entity custom field. In my case I named 'Check if the Product has 18% VAT'. Select 'line-item:commerce-product' as the data selector and thats it.

So when I add a product to the cart I'm checking with rules if that product has a value 18 in the product entity field_product_tax (our custom field) and if its true then it use the tax rate.

Thats the way for the moment to access custom fields inside the entity product via rules.

Maybe there are other ways but this one works for me. Hope this helps anyone.

pcambra’s picture

Thanks for the how-to EndEd, just two things:

Then in conditions, click 'add condition'. Select 'product' as the data selector and the field you want to expose... remember that in my case was 'field_product_tax'. Then I add another condition but this time I chose 'data comparison'. Then I can select 'product:field-product-tax', 'Equals' as the operator and '18' as Data Value. Click Save.

Just before this, you need to invoke "Entity has field" with field_product_tax for your component.
Also, you'd probably want to add a new condition "Data value is empty" (Negated) that checks if the field has a value to avoid notices when the field has no data

EndEd’s picture

Thanks for the tips pcambra. :)

TheWizz’s picture

Just checked out latest dev version (from https://github.com/rszrama/commercedev.git), to see if there were any news in this area. But I still have the same problem. Surely, there must be a more elegant solution than the complex work-around suggested in #13? I have a hard time seeing how it would ever be useful to apply ALL possible VAT rates to a product, rather than the VAT rate that has been set as "included in price". This surely seems like a bug to me. If this is by design, a straightforward way to avoid it is needed for all countries where diversified VAT applies (and where VAT is typically included in the displayed price, as is the case in most european countries).

From the discussion above, I get the impression that part of the work-around is to add another VAT field to each product, essentially stating the same thing as the "VAT included in price" selector, but in a way that can be used by rules. Having the same data in two places for each product, to be maintained manually, seems very error prone to me, and not particularly user friendly. But perhaps I've misunderstood something.

rszrama’s picture

Status: Active » Closed (works as designed)

Again, the default behavior of taxes is for every tax rate you define to apply to every product in the cart. You specify conditions to restrict which products on an order your tax rates apply to. When you enter a price including VAT, you're effectively bypassing the condition process so that the product always includes that tax in the price, but your other tax rates are still applying later in the calculation process.

You have two options here:

  1. Add conditions to the default rules components defined for your tax rates to restrict taxes by product type or something.
  2. Simply disable the default product pricing rules that perform the calculation of taxes. Then no additional taxes will be applied to your products other than what you include when you enter the price.

It's important to remember that many places in the world have multiple taxes and even cumulative taxes (tax on tax). That's why the system works the way it does. For places where you have various set tax rates and only one is going to apply to each of your products (and you know it needs to be included on display), you may as well just take option 2 above.

It might be helpful to have a condition that can check to see if any tax has already been applied to the line item, too.

TheWizz’s picture

Thanks for the clarification, and your patience, Ryan! I'll take a look to see if I can figure this out. It sounds like it shouldn't be that complicated, and in my case shouldn't require any additional "VAT category" added to each product. Just a slight tweak of the VAT rules being applied, as per your option #2 above.

I'll post back here once I get it working, hoping that it may help someone else (assuming I'm not the only one that struggles with this).

-JM

rszrama’s picture

Excellent. And yeah, it'll be worth documenting that even though we implement a generic setup here that assumes all taxes apply unless otherwise configured (as opposed to none apply unless specifically indicated), it's very simple to reverse this assumption by adjusting the default Rules.

TheWizz’s picture

FileSize
47.31 KB
108.27 KB

OK, so I went ahead and disabled the "Calculate Taxes: VAT" rule (see first attached illustration), and now the price calculation behaves as I want it to (as shown in the second attached screenshot). Here I have a couple of products with 25% VAT and one with 6% VAT (all with VAT inclusive pricing). The total and the indicated VAT amounts are all correct.

The only (in my mind) confusing aspect here is having to disable "Calculate Taxes: VAT", even though VAT is still calculated properly (since it's already included in the price, as specified for each product). Perhaps the wording of this rule could be made clearer, since disabling it now may give the impression that all VAT calculation will go away, which isn't really the case for VAT already included in the price, where it is still factored in and listed as desired.

Hopefully, this discussion and conclusion is of some help to others in a similar situation.

-JM

rszrama’s picture

Issue tags: +dcsprint6

Mmm, yeah, this definitely deserves some review. Oh, poo, and I meant to have a call with Bojhan today about the sprint in June. I'll have to catch him tomorrow if I can.

malbrecht’s picture

Status: Closed (works as designed) » Active

Hi,

after having puzzled around this problem for about two days (trying to adjust rules, which don't seem to work as expected) I have given up for the moment. On my site I need the ability to show prices NET (without VAT) to one user group and BRUT (including VAT) to another. So disabling the calculation of the taxes globally somehow seems like the wrong aproach.
All I would need is a switch "apply VAT only once" (which is one of the basic rules for VAT in oposite to taxes, which can be added one on each other).
Since I also need to change the VAT type (and rate) according to the contents of the cart it seems to me that the systematics of the TAX-system need to be defined more granulary and less "hardcoded logic" :-) At least solution #2 does not seem to apply to this problem as well.

So, to sum it up: Is there any progress in this matter or do I have to stick with a completely different shopping cart system? :-)

bojanz’s picture

Status: Active » Closed (works as designed)

You need to input prices without VAT, and then limit the VAT calculation rule as you wish.
Basically, making it behave like sales tax.

See the discussion #1240216: Allow display inclusive taxes to be removed via Rules for details (and feel free to provide your own opinion there).

Carlitus’s picture

I've made this using a term instead a field with the help of Commerce Extra Rules Conditions module. It's easier than #13

http://drupal.org/project/commerce_conditions