hi there

i use a fresh commerce kickstart 7.x-2.0 installation
with commerce tax ui 7.x-1.4
and commerce price table 7.x-1.1

my problem is now that the price table did not work
in combination with tax rates!

for my needs (german law), the prices are always inclusive tax.
but the tax need to be displayed in the checkout separately (in the commerce order total)

i added 2 vat tax rates (7% and 19%)
and a price table to the variation type / line-item ( e.g. drinks)
admin/commerce/config/product-variation-types/drinks/fields
the Number of values is set to unlimted.

then i created a product
with 19% vat and a price from 10 euro

in the product i filled some prices in the price table
1 to 2 = 10euro
3 to-1 = 5euro

everything fine to this point.
the price table is visible on
the productdisplay.
and in the checkout/ cart
the price is depending on the quantitiy
thats super!

but in the
checkout -> commerce order total
the tax rate is missing for this product!

if i deactivate the price table
or if there is a product without a price table depending price
the tax rates is visible!

so i tried to change the weight of the rules
in hope this will count the vat after the price table replaced the price:

commerce_price_table_override_price from -10 to 10
and the
commerce_tax_type_vat from 0 to -10
so the commerce_tax_type_vat (which calculating the sell price of a product and taxes for a line item)
is executes AFTER the commerce_price_table_override_price

but this is not working too..

is there a possibility to connect commerce_price_table with the tax calculation ?

very grateful for any help
hofer

Comments

malbrecht’s picture

Unfortunately this is the way the price table seems to be designed (see my fruitles discussion here: http://drupal.org/node/1420512 ). It seems to be a problem with how the designers understand the difference between "product price" and "tax".

I was having exactly the problem described here (and in many more postings around drupal) and there does not seem to be a solution that works through drupal itself (by the means of rules, that is). I solved my issue last year by severely hacking the code of "price table", breaking compability but putting a wide grin on the customer's face. Unfortunately I cannot post the code because that customer gave up on drupal commere for good just before Christmas season in order to secure the "xmas online business", deleting my "hack solution" in the process :-(

What I basically did was setting a flag for commerce orders that included "price tabled content", grabbing that flag inside the code that renders the "invoice-like" checkout display AND the content for the variables used for email information, replacing all "total" values with "hand-calculated" values (using some really absurd str_replace lines).
I would be glad if this could be of any help for you finding a solution for your actual implementation, although it is dirty and not-transferable. I would prefer a "real" solution that used the drupal-way (rules etc), but my impression so far is that this is unwanted (both MY help and a fix to the tax-problem in price_table).

frederickjh’s picture

Hi!

The normal Commerce price when using a VAT type of tax allows you to say that the VAT is already included in the price given. Commerce price table does not.

VAT is a tax like US sales tax but the presentation of it is different. In most European countries the VAT is included in the price presented to the consumer. However on the final bill/receipt the amount of the VAT must be shown separately. Most people in countries where VAT is used are use to seeing round prices (ie. 10.00, 3.50, 6.80, etc.).

Some examples to explain. These examples use the VAT rate of 8%, that is one of the currently used VAT rates in Switzerland.

First we set the product price with no vat included in the price.

Commerce_product_price-inculde_tax_setting-none.png

The resulting shopping cart:
Commerce_product_price-inculde_tax_setting-none-shopping_cart.png
As you can see the price comes up to 10.80 not 10.00 as we had wanted so we can change the setting on the product price to include 8% VAT
Commerce_product_price-inculde_tax_setting-VAT_8_percent.png

and the resulting shopping cart:
Commerce_product_price-inculde_tax_setting-VAT_8_percent-shopping_cart.png

As you can see we now get the price we wanted of 10.00. If we take a look at the check out we can see the VAT amount being broken out.
Commerce_product_price-inculde_tax_setting-VAT_8_percent-checkout_showing_VAT_amount.png

Ok, now an example with Price Chart. First the price chart settings:
Commerce_product_price_chart_setting.png

Notice that we have no selector to allow us to say that the VAT is included in the price given and that the selector from the normal Commerce price has no effect on price chart.

Shopping cart with 1 item:
Commerce_product_price_chart-shopping_cart-qty-1.png
We can see that we are back to the 10.80 price when we really want a price of 10.00.

Shopping cart with 9 items:
Commerce_product_price_chart-shopping_cart-qty-9.png

Resulting shopping cart with 10 items:
Commerce_product_price_chart-shopping_cart-qty-10.png

OK, So I said to my self I think I can still use the price chart I just need to calculate the prices without VAT and enter them in the price table.

The calculation is easy to do. To calculate the price without Swiss VAT at 8% you can multiple the price with 8% VAT by 0.92592592592592592593 To find the rate for other VAT percentages you can use the formula: 100 / (percentage of tax + 100) = conversion rate. In the example above 100/108=0.92592592592592592593

This gave me the following results:

Prices
Qty Price w/VAT Price w/o VAT Price that Price Chart adjust given values to
1-9 10.00 9.2592592592592592593 9.25
10-19 9.00 8.33333333333333333337 8.35
20-49 8.00 7.40740740740740740744 7.4
etc.

I was able to enter the calculated prices without VAT but later figured out that after saving all values were rounded to two places after the decimal point. OK, you say but what were the results? First the price chart from the product before we adjusted the prices to prices without VAT:
Commerce_product_price_chart-before_price_adjustment.png

Now the price chart with the values price chart rounded the enter values to from the chart above:
Commerce_product_price_chart-after_price_adjustment.png

Not bad now lets add the product to our cart and see how that looks.

Shopping cart with 1 of the product:
Commerce_product_price_chart-price_without_VAT-shopping_cart-qty-1.png

Looks good and it also looks good with 2 but with 3 it looks like this:
Commerce_product_price_chart-price_without_VAT-shopping_cart-qty-3.png

We have lost 0.05, not good. With 8 of the product in our cart it looks like this:
Commerce_product_price_chart-price_without_VAT-shopping_cart-qty-8.png

Now we have lost 0.10 OK, lets see what happens when we hit our next level on the price chart of 10 items:
Commerce_product_price_chart-price_without_VAT-shopping_cart-qty-10.png

Now, we have 0.20 too much. This is definitely not going to work.

Currently I am working on this for a small site with one product and a donation. So, I am hoping I can make some rules to change the price based on quantity to make this work.

I hope that this helps to make this issue clearer and that a fix can be found.

For more info on this same issue see the closed issue number 1420512 starting at comment 2. The issue name is miss leading as it makes a turn in a different direction starting at comment 2.

Possible solutions:

  • Code product price chart to use the normal Commerce price's Include tax in this price widget
  • Code product price chart with its own Include tax in this price widget

If you need help on this issue or understanding VAT I am sure that rszrama can help you with it.

Thanks for your work on this module and God bless!

Frederick

frederickjh’s picture

Title:Commerce Price Table does handle VAT included in price like the normal commerce price does» Commerce Price Table does NOT handle VAT included in price like the normal commerce price does

Updated the issue title to reflect the true nature of the problem.

giuvax’s picture

subscribe

pcambra’s picture

Title:Commerce Price Table does NOT handle VAT included in price like the normal commerce price does» Add VAT inclusive support for price table field
Version:7.x-1.1» 7.x-1.x-dev
Category:bug» feature

Let's add a little sanity around here.

Price table doesn't support inclusive VAT at product level, we need to add the little widget for the VAT included that the normal price has.
Now the question is, what's the level of VAT configuration that is actually needed.
Adding a dropdown per field value it's probably too much and adding one per field level I don't know if it's even possible with field API (multiple field values and one global setting that is not repeated).
One solution would be to use the VAT included for the regular price that is going to be there anyways but it feels really wrong to do so.

giuvax’s picture

StatusFileSize
new29.3 KB

VAT is simply the same for every different quantity of products.
For me the best way to add it is adding the dropdown widget on the single row, and apply to the overridden price as usual. (see screenshot)

giuvax’s picture

If you're not going to fix this yet maybe someone can help me think of a rule to manage this? It's the last thing I have to do on my website and I have to solve it.

pcambra’s picture

If you're not going to fix this yet

I just didn't have time to find a way to do this properly. I'm not sure if you can add a "solo" widget to a multiple valued field.
Related #1968616: Use commerce_price_field_widget_form for commerce_price_table_field_widget_form

And of course, patches are welcome.

giuvax’s picture

A first way to solve this, I guess, is adding a display mode to pricetable field.
See if it's applicable: can you let me choose the display mode in the Manage display tab, adding other displays to Price table other than Price chart?
Maybe this can solve a first bunch of troubles. People like me who disabled the Calculate tax Rule (since they have many VAT rates not to be cumulated) deal with VAT simply choosing the 'formatted amount with components' in Manage display tab. If you can add this, on the order / cart page, it would just show the components available on the product price, no matter if the price has been substituted by the one on price table.
Or am I wrong?
Can this help just a bit?

giuvax’s picture

I added some actions to default price table rule, the one that substitutes base price with price table price.

   "DO" : [
      { "commerce_price_table_set_price" : {
          "commerce_line_item" : [ "commerce-line-item" ],
          "quantity" : [ "commerce-line-item:quantity" ]
        }
      },
      { "data_calc" : {
          "USING" : {
            "input_1" : [ "commerce-line-item:commerce-unit-price:amount-decimal" ],
            "op" : "*",
            "input_2" : ".21"
          },
          "PROVIDE" : { "result" : { "pricetable_vat" : "VAT on price table product" } }
        }
      },
      { "data_calc" : {
          "USING" : { "input_1" : [ "pricetable_vat" ], "op" : "*", "input_2" : "100" },
          "PROVIDE" : { "result" : { "pricetable_vat_single_decimal" : "VAT on single product price table (decimal)" } }
        }
      },
      { "commerce_line_item_unit_price_subtract" : {
          "commerce_line_item" : [ "commerce_line_item" ],
          "amount" : [ "pricetable_vat_single_decimal" ],
          "component_name" : "base_price",
          "round_mode" : "1"
        }
      },
      { "data_calc" : {
          "USING" : {
            "input_1" : [ "pricetable_vat_single_decimal" ],
            "op" : "*",
            "input_2" : [ "commerce-line-item:quantity" ]
          },
          "PROVIDE" : { "result" : { "totale_vat" : "Total VAT" } }
        }
      },
      { "commerce_line_item_unit_price_add" : {
          "commerce_line_item" : [ "commerce_line_item" ],
          "amount" : [ "pricetable_vat_single_decimal" ],
          "component_name" : "tax|iva",
          "round_mode" : "2"
        }
      }
    ]
  }
}

Of course I still have the problem that I can't manually insert a vat rate (since now I'm applying price table just to products with 21% vat)
Any help appreciated to extract the VAT rate value from commerce-line-item:price:data, since I need php and I ain't able to do it by myself.

So, with those actions, I'm calculating 21% VAT on single product (multiplying it by 100 to get decimal) then I subtract it from unit price.
Then, adding it to unit price as a tax type amount I get it displayed apart from unit price, just as usual, as a normal tax rate, as I needed.

giuvax’s picture

Not solved.
This rule is working just in case I have a single product in cart, or just products with price table applied.
Otherwise it doesn't work.

The only way to solve this is a workaround: I have to save in price table prices without vat, then I have to add an action to default price table rule, to calculate vat of a predetermined rate.

Grrrr.

MrPaulDriver’s picture

@pcambra Ref: #5 Your Comment: "One solution would be to use the VAT included for the regular price that is going to be there anyways but it feels really wrong to do so."

Isn't this the obvious thing to do? It doesn't sound wrong to me.

In other words - the price table should inherit the chosen tax treatment for any given product.

a.ross’s picture

Agree with #12. It doesn't feel coherent (half-using 1 field for the benefit of another), but it seems like the best way to solve it quickly.

sinn’s picture

subscribe

sinn’s picture

Issue summary:View changes
Status:Active» Needs review
StatusFileSize
new4 KB
new5.26 KB

There are few issues with Tax support:
1. Tax doesn't support any other fields types except "commerce_price".
2. "commerce_price_table" field doesn't support components.

I've taken patch for commerce_price_table widget from https://drupal.org/node/1968616 and added module custom_commerce_price_table for tax support.

Yes, i know that pcambra doesn't want store price config in each price table item but I think it is most consistent way in this module.

nwpullman2’s picture

Thanks sinn, we have tried your patch on top of 7.x-1.x-dev and it seems at a first glance to work well.

I understand different methods to solve the problem can be discussed, but this actually allowed us to go into production with our new Drupal-based store with a working solution.

Thanks a lot for your help!

Best

Nwpullman

Summit’s picture

Hi, @ nwpullman2 can you post your current module you are working with.
Did you also use https://drupal.org/node/1968616 ?
greetings, Martijn

Summit’s picture

Hi, thanks to nwpullman, this worked:
---
1. Replace the stable module code with the dev code from 7.x-1.x-dev (available from the download page)
2. Modify the dev code (you need to be able to read "diff" instructions):
https://drupal.org/files/issues/commerce_price_table_1886080_15_2_compon...
3. Create a new module called custom_commerce_price_table, all code is available here (you need to be able to read "diff" instructions):
https://drupal.org/files/issues/commerce_price_table_1886080_15_1_tax_su...
---
Greetings, Martijn