My shop is set up to use a 20% sales tax and it stores tax exclusive prices. The tax is then added at the checkout stage and using the normal basket it seems to work OK.
When using POS if I add a product that has a price of £100 ex tax the line item unit price is shown as £120 and the line total is £144.
If I click the cursor into the POS line item unit price field and then without changing anything click back out again the price drops to £100 and the line total changes to £120 which is what is should have been in the first place.
At all times the total summary shows figures that match the line totals.
Clicking back into the unit price field the price changes from the £100 to £120 and then when I click back out again the price reverts to £100
Displaying tax exclusive prices but entering tax inclusive prices in the unit price field when editing is odd behaviour so I'm guessing this isn't normal. Can someone confirm whether the unit price should include or exclude tax?
If I refresh the page or click the Sale link again, then click into and out of the line item unit price field the problem occurs again and the price drops by another 20% and this process can be repeated a number of times.
Has anyone come across anything similar?
I'm guessing this behaviour will be something to do with my install but it doesn't have anything specifically odd about it's tax configuration.
I've not yet tried it on a fresh stock install but will probably do this next if I can't work out the issue.
| Comment | File | Size | Author |
|---|---|---|---|
| #19 | commerce_pos_inclusive_taxes_final.patch | 5.58 KB | Anonymous (not verified) |
| #16 | commerce_pos_taxes.patch | 5.25 KB | Anonymous (not verified) |
| #9 | Screenshot from 2017-02-21 15-58-32.png | 9.27 KB | thejacer87 |
Comments
Comment #2
mirko@le-dot.com commentedwe are experiencing the same issue.
i thought it might be something regarding jQuery version or theme based (we are using Adminimal), but it's not - i trie several versions and and the issues still appears.
Comment #3
ollie222 commentedWell I've just installed an up to date version of commerce kickstart with a basic similar setup of tax and modules including POS and the problem isn't occurring on this install.
The line item unit price and the line item total always shows prices excluding tax and the totals show the correct figures.
Clicking in and out of the field shows the same price. Incidentally looking at the code there are two unit prices, one is a label showing the formatted amount and the other is the input field with the raw value and clicking in and out shows and hides one of the values.
I've set it up with jQuery update 1.7 so I don't think Jquery is an issue.
With my fully configured shop if I create an order via the normal order admin section the prices are shown without any tax. After I click the 'Apply pricing rules' button then the unit price includes tax. It doesn't change when I click in and out of it like in POS however on the fresh kickstart site it continues to always show the tax exclusive price.
I do have a few modules to manipulate the price formatting when displaying and there are also some changes to correct the total taxes charged when discounts are applied.
Presumably something else is modifying the price when it shouldn't be doing so and this is the issue seen in POS but as it also happens in the standard order admin it's likely this may not be a POS issue.
I'll post up if I find any more info and I'd appreciate it if you'd do likewise.
Comment #4
ollie222 commentedIf it helps I've tracked it down to an issue with tax inclusive prices.
If you untick 'Display taxes of this type inclusive in product prices.' in the tax type definition then the POS works ok. This was a issue even though the product prices are stored without tax with the 'Include tax in this price' dropdown next to the price set to 'none'.
If memory serves me correctly changing having this ticked solved a few other issues with taxes, discounts and rounding so I need to do some further testing.
Comment #5
mirko@le-dot.com commentedthank you for tracking this down. i was digging trough the POS module, and looking for the reason there.
we have the same configuration (taxes are included, checkbox in tax configuration is active). but i need to make a fresh copy of the live site first to properly test it and give you feedback about it.
as you say there are some more issues when the product price includes taxes, so in general, would it make sense to store the netto price, then add tax and configure the rounding?
this just seems much more math then the other way around, and that can always cause issues, as we see.
Comment #6
ollie222 commentedDue to the tax, discount and rounding errors I've found with commerce when storing prices with VAT I've always set them up as a sales tax, stores the prices excluding tax and then used formatters to display the with and without tax values.
What in isolation is a simple problem to solve when you try and make it work for all possibilities around the world it becomes far more complex to solve.
The site I'm currently working on is predominately B2B so it's ok to display VAT exclusive prices and the 'Display taxes of this type inclusive in product prices.' shouldn't have been ticked.
I've got another project that is B2C to finish in the next few weeks so I'll probably take a deeper look at it then but I the issue could well POS itself that is not handling figures correctly when they're tax inclusive.
Also as for storing prices without tax remember that doing this means you can't set certain tax inclusive product prices. eg with the UK 20% rate if you store VAT exclusive prices you can't set a product to have a VAT inclusive price of 9.99
ex VAT -> inc VAT
8.29 -> 9.95
8.30 -> 9.96
8.31 -> 9.97
8.32 -> 9.98
8.33 -> 10
Personally I'd like to see all product prices stored without tax but to 3 decimal places. The user could still be allowed to enter the price inc tax when editing but it would just be converted before being saved.
Then when prices are displayed they could just be formatted to include the elements that you want.
I would have thought this would make pricing calculations much simpler and it would solve a lot of the issues but it wouldn't be an easy change as Commerce stores prices in pennies/cents and then divides by 100 to get the actual price but a number of modules have this figure of 100 hard coded into them. I know others have looked at doing this in the past with different degrees of success.
Comment #7
smccabe commentedHey Ollie222,
My understand if this issue is that it is related to commerce in general and its general wonky tax logic, not anything specific to POS. Marking as "Works as Designed" but feel free to continue discussion in this issue if you want.
Cheers,
Comment #8
mirko@le-dot.com commentedI tested the behavior in pos and trough the checkout when the VAT is not included in the product price.
When I was searching for the product trough the SKU-search-box in POS, i got the result displayed with price including the VAT. When I added the product to the list it used the price displayed (including VAT) and the result was exactly the same as before (too much VAT).
I reindexed the search index a couple of times, and flushed caches as well. The behavior remained the same.
It seems to me, that POS pre-calculate the price indexed, and then adds the VAT trough the GUI again..?
When ordering the same product trough the store and order process everything works like expected. The price is displayed processed, including VAT.
The POS is installed on a clean Drupal commerce setup, not on kickstarter, so could that be an issue?
Comment #9
thejacer87 commentedJust ran some investigations. Tracked it down to the call to `$base_price = commerce_price_component_load($line_item_wrapper->commerce_unit_price->value(), 'base_price');` on line 242 of commerce_pos.transaction.inc.
The first time you add the item to the list, it loads the line item's "base price". But for whatever reason, the base price is the expected base price + inc vat, AS WELL as a vat price component. But then, like @mirko8003 @Ollie222 mentioned, if you click in the text field then back out, the line item comes in with the expected price components.
But the POS still displays some weirdness (pic). It again grabs the total, but really should just get the base price. I wasn't able to track it any further back to see if it's a commerce issue or POS though.
Comment #10
yurg commentedI'd like to add to @thejacer87 notes, that it's something related to line 255 of beta8 (and prev.) in CommercePosTransactionBaseActions.php
which is somehow related to line 10 of commerce_pos.transaction.js
Hope someone smarter can shed some light on it; I've made a pull request https://github.com/AcroMedia/commerce_pos/pull/14 which seems to fix the issue, yet it looks more complex than that.
Comment #11
eem88 commentedI'm having the same problem. When I don't check "Display taxes of this type inclusive in product prices." in de Tax settings, then the correct price is calculated in the POS. But then customers see the prices with the tax not included, so this workaround is not an option for me.
As a workaround, I made the following change in the CommercePosTransactionBaseActions.php file:
below line 178, I added a line to recalculate the amount to the price without VAT:
$amount = $line_item_wrapper->commerce_unit_price->amount->raw();
$amount = $amount/1.21; // substracts the VAT from the amount
Comment #12
yurg commented@eem88 This may be the way to go; what if we replace hard-coded VAT (1.21 in your case) by VAT value picked from, say, one of the Tax module hooks?
Comment #13
Anonymous (not verified) commentedI took a swing at this here: https://github.com/AcroMedia/commerce_pos/pull/22
Adds a check to see if the tax is inclusive before recalculating it.
This is a similar approach to how https://github.com/AcroMedia/commerce_pos/pull/14 does it, but it doesn't break when not using Tax Inclusive prices.
Like the other approach, this has a known issue where the Components section with the Subtotal no longer shows the tax breakdown.
I'm still looking into a better solution that will fix it AND show the components properly, but this fix at least lets people get past the issue and is safe enough to merge because it doesn't break when not using tax inclusive prices.
Comment #14
smccabe commented@wildkatana what are your thoughts on a full fix? I'd rather do that then a temp one, but if the full fix is a big effort, we should probably commit this temp one.
Comment #15
smccabe commentedSetting this back to "needs work" to get a fix that shows the components properly as well.
Comment #16
Anonymous (not verified) commentedI think I may have finally cracked the issue. It was quite complex to debug. In the end I ended up taking out some code which from what I can tell wasn't doing anything good and was actually actively causing issues.
I also had to add an adjustment to include taxes in the base price when editing. The end result is that it all works as it should with both inclusive and exclusive taxes.
https://github.com/AcroMedia/commerce_pos/pull/22
Comment #17
smccabe commentedComment #18
smccabe commentedPatch looks good from a manual code review, but it has conflicts preventing it from applying, mind rerolling/rebasing and I should be good to merge in.
Comment #19
Anonymous (not verified) commentedThat was a bit tricky to merge and test without introducing regressions. This patch seems to handle both cases (inclusive taxes and returns for different amount than the product price) correctly.
Comment #20
Anonymous (not verified) commentedComment #21
smccabe commentedmerged
Comment #23
smccabe commented