OpenCart - how to calculate VAT correctly? - e-commerce

Here's an example of the issue at hand:
A product costs 81.25 (that is price including 20% VAT, in other words, 81.25 is equal to 67.71+13.54). I've set the price calculations to the best of my belief (from Extensions->Order Totals) and within Shopping Cart, we'd see the following break-down:
A table of the product with thumbnail, description, quantity, price: and last cell says 81.25. Below that:
Sub-total: 67.71 (that is price without VAT)
+20% VAT: 13.54 (that is the VAT, achieved through Taxes)
-10% Discount: -8.13 (all products over $50 receive 10% discount, that is, 10% off of 81.25)
TOTAL: 73.12
Unfortunately, our customers are very sensitive to VAT, so the calculation should break-down to:
-10% discount: 8.12 (that is 10% off the full price of 81.25)
Sub-total: 60.94 (that would be the full price,81.25, minus the 10% discount or 8.12 first and excluding the 20% VAT second)
+20% VAT: 12.19
TOTAL: 73.12
As you can see, the Total is the same, but the VAT is different. I've tried a different Total Order from the OpenCart admin, but if I start with Discount, it does not have a previous value to discount in the first place and returns 0.
A possible theoretical solution in my mind, perhaps if Total could be duplicated somehow, renamed and inserted hidden in the very first position (so that it would equal 81.25 at the beginning, then discount etc.) that might work. I would really appreciate your ideas.

I see what's Your point. But If I buy something from Your store for the end-price of 73.125 (that is 81.25 - 10% discount) while there is 20% VAT, the price without VAT is 60.9375 and the VAT is indeed 12.1875. This is simply because the discount is applied to the sub-total price (end-price of the product including VAT) and not to the price without VAT.
If You would like to do it Your way, thus subtracting 10% discount from the netto price of the product (excluding VAT), You would have to apply 10% discount on the VAT as well:
price excl. VAT -10% discount: 81.25/1.2 * 0.9 = 67.708333 * 0.9 = 60.9375
VAT = 13.541666 (BUT SEE point 3)
VAT - 10% discount = 13.541666 * 0.9 = 12.1875
Your counting is incorrect simply because if we count Your results (that were very wrongly rounded), we would end up with the final price of 60.9375 (price excl. VAT - 10% discount) + 13.541666 (VAT w/o 10% discount) = 74.4791666 ~ 74.48
AND
74.48 !== 73.12
BUT counting the discounted price + discounted VAT
60.9375 + 12.1875 = 73.125 which is correct result!
I hope now is it clear that OC counts the result correctly while Your idea is wrong...

It should really go
Subtotal (67.71)
Discount (-6.77)
VAT (13.54)
Total (73.12)
The subtotal is actually the "total" you mentioned you wanted to have and rename. It's not possible to have the total show before the taxes etc are applied for the simple fact that the order total is calculated in order of those totals

Uncle Fester, I think you are right.
We have to have in mind two groups of buyers, retail and wholesale.
If you tell a guy in retail that he has 10% discount, it should mean that if the final price (w/ VAT) was, lets say USD 100, he would expect that the discounted price should be USD 90.
On the other hand, for a wholesale customer, it is a bit different. Wholesale customers are interested in prices w/o VAT only, so, a price for him is USD 90 + VAT and when you tell him he has 10% discount, he counts on USD 81 w/o VAT.
Back to the VAT calculation, lets look at the same price of a product in amount of USD 90 w/o VAT and USD 100 w/ VAT. Lets say we are giving 10% discount to both customer groups.
Retail customer is counting on a price of USD 90 (USD 75 + VAT), while
Wholesale customer counts on a price of USD 97.2 (USD 81 + VAT).
So, that is the initial approach to the issue.
Next, something that I do not understand is the following:
basically, any tax is to be paid in a certain percentage of the final sum, dont you agree?
So, if the final price of the product (w/o VAT) is USD 100, then the VAT is USD 20 (if rate is 20%), and final amount is USD 120. If however, one receives 10% discount, his bill is now USD 90 + VAT, or USD 99 is the final sum. In other words, VAT amount in Invoice should always be the exact percentage of the goods that is precised in the law.
If it stays written that it is USD 13,54 - it is NOT 20% of the net, but the gross amount of the goods. In this case, VAT grows to 22,2%!?! And all of you are saying that is how it should be???
I really do not understand this...

There are 2 ways of calculating VAT-
Method 1) Applying VAT on each item
Method 2) Applying VAT on the subtotal
For my country in Malaysia, the VAT has to be calculated using Method 1. Consequently, the accounting (XERO) and billing (TradeGecko) software I use also uses Method 1. Unfortunately, OpenCart uses Method 2, and I am still searching for the solution for OpenCart that allows me to use Method 1.
Method 1 and Method 2 will give you different VAT amount, simply because of where the rounding of the VAT amount is taking place. For Method 1, the rounding of VAT takes place at the item level, while in Method 2, the rounding takes place at the sub-total level.
If only OpenCart has a simple radio button that allows us to choose either one, that should please almost 99% of the users.

Related

Shopify Math liquid rounding not returning the same value when using automatic discount

I am using the following code:
{{ product.price | times: 0.90 | money_with_currency}}
I also have a 10% automatic discount enable. The price returned using the code above is not the same as the price returned using automatic discount:
Product cost |$35.49 |$34.41 |$46.59 |$52.99
price using code: |$31.94 |$30.97 |$41.93 |$47.69
10% discount in cart |$31.95 |$30.97 |$41.94 |$47.70
I would like to display the same amount using the code as the prices shown in cart
pic attached

Bigcommerce - Update Price of Products in Cart Based on Price List & Custom Fields

With Bigcommerce Price Lists, we obviously have the ability to give discounts based on bulk buys/qty.
We want to be able to combine the quantities of items in the cart if the products have a common custom field (or similar) and give the bulk price list discounts based on the combined qty.
For example:
Product A has a bulk purchase discount - buy 5+ and get 10% discount
Product B has a bulk purchase discount - buy 10+ and get 15% discount
Both these products would have a custom field/meta field at the variant level that = "Allow Combined Discount A"
So that means if Product A has a cart qty of 4, and product B has a cart qty of 6, the combined qty = 10
Product A should receive 10% discount (as combined qty >=5)
Product B should receive 15% discount (as combined qty >=10)
How can we achieve this? Ideally, the price updates/discounts would apply immediately when the cart quantities reach the correct levels. There could also be other products in the cart with different combining custom field/meta field values, which would need to calculate their own total - e.g. "Allow Combined Discount B"
Promotions on categories will not work as there are can be varients on products a and b where the bulk discounts do not apply, or the qty of some variants should not count towards a combined total to apply price list bulk buy discounts.

Best way to store differing tax rates for countries in SQL (then how to use it in a basket situation)

I have raw data that I'm trying to sort; I have the tables (I think) decided on with a basket including a basket_id, customer_id, basket_date, total_price, tax and payment_type.
Tax is a set portion of the total price, so if the total price were 512.99 and the seller came from the UK (which would denote a tax percentage of 10%, different for each country and a total of 6 countries) then the tax would be 51.299. I need to store that tax figure, NOT the percentage, in this basket table by somehow referencing the tax percentage in another tax table so that SQL can automatically calculate the figure from the percentage*total_price. Is this possible?
I don't need anything unnecessary in examples, JUST what I need to do, no need to overcomplicate it!

TSQL - How to find out if a Users Currency rate is correct based on another currency rate for the same user

We currently have an issue where some rates for users have not been entered correctly and I have been tasked to find out which entries are incorrect, but unfortunately I am bit stuck.
The requirements are as follows;
If user only has a GBP charge out rate, then do nothing
If user has Charge out rate in GBP + USD then;
GBP must = USD / 1.55 otherwise FALSE
The following is how I started it:
We have a table called TIMERATE where a users charge out rate is entered, with a new line added every time the rate changes. It is possible for the user to have a charge out rate in more than one currency.
Here is a cut of the data in the table for a single user;
tkinit tkeffdate tkrt01 tkrtcur
LAU 01/02/2014 170 GBP
LAU 01/08/2014 260 GBP
LAU 01/12/2014 130 GBP
LAU 01/08/2014 260 USD
LAU 01/12/2014 210 USD
LAU 01/02/2015 260 USD
To find out the latest rate for each currency:
SELECT
TKINIT as Timekeeper,
MAX (tkeffdate) as MaxEffectiveDate,
tkrtcur as Currency,
Cast (NULL as decimal (16,2)) as Rate
INTO
#LatestRate
FROM
TIMERATE
GROUP BY
TKINIT, tkrtcur
ORDER BY
TKINIT
Then I updated the Rate in the temp table
update
#LatestRate
Set
Rate = tkrt01
from
#LatestRate
JOIN
Timerate on TKINIT = Timekeeper
and tkrtcur = Currency
and tkeffdate = MaxEffectiveDate
So i now have the latest rate for each currency for each user, but I do not know how to manipulate the data to fit the requirements
Does anyone have any ideas? Have I gone about this the wrong way?
Rabbit's answer is the easiest way to compare if the conversion was done correctly.
Going off of your initial steps, you can run this query on the #LatestRate table to give you the results. Pls ensure the comparison in the case statement is working correctly. I have not tested this code.
SELECT
GBP.Timekeeper as Timekeeper,
GBP.MaxEffectiveDate as EffectiveDate,
GBP.Currency as GBP,
GBP.Rate as GBPRate,
USD.Currency as USD,
USD.Rate as USDRate,
case
when USD.Rate is null then 'GBP Only'
when round(USD.Rate/1.55,2)=round(GBP.Rate,2) then 'Correct Conversion'
else 'FALSE'
end as IsConversion
FROM #LatestRate GBP
INNER JOIN #LatestRate USD
ON GBP.Timekeeper=USD.Timekeeper
and GBP.MaxEffectiveDate=USD.MaxEffectiveDate
and GBP.Currency='GBP' and USD.Currency='USD'
Join the table to itself on the tkinit and date where one side has the gbp and the other side has usd. This will give you both on one row so you can check to see if the rate is correct.

How to set taxes following in OpenERP?

How to set taxes following in OpenERP?
PRIVATE LIMITED FORMULA FOR INVOICE.
PRODUCT NAME QUANTITY RATE AMOUNT.
Sugar 22000KG 21.00 4,62,000/-
________
(Gross Price including
With Profit margin) 4,62,000/-
BASIC EXCISE #12% (462000*12%) 55,440/-
EDU.CESS#2% (55440*2%) 1,109/-
SEC.HIGHER EDU CESS#1% 5,54/-
(55,440*1%)
________
5,19,103/-
VAT #4% (519103*4%) 20764/-
ADD VAT#1% (519103*1%) 5191/-
_________
5,45,058/-
If you look at the Tax from View you have child Tax , just set your child tax over their in sequence you want to add their but yes do into expect the sum total after some tax applied then grand total after other total applied.
Thank You