Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

$total is not correct #9413

Closed
BroCart opened this issue Mar 7, 2021 · 13 comments
Closed

$total is not correct #9413

BroCart opened this issue Mar 7, 2021 · 13 comments
Assignees
Labels
3.0.x.x Affects the 3.0.x.x maintenance version Assigned to Daniel Task assigned to Daniel for final say

Comments

@BroCart
Copy link

BroCart commented Mar 7, 2021

>2.x

Not correct TOTAL in cart and checkout
one of places where bug is: https://github.com/opencart/opencart/blob/master/upload/catalog/controller/checkout/cart.php#L114

To Reproduce
Steps to reproduce the behavior:

  1. Go to admin --> System-->Localisation-->Currency and set USD value 1.00000000, then add new currency (ex.: UAH [Ukrainian Hryvnia] and add value 28.55 (as conversion rate) AND add Decimal Places "0" (and select as default front currency)
  2. Add some product with price 5$
  3. Go to front and add to cart 1 q-ty of this product (5$ * 28.55) = 142.75 (with Decimal Places "0" will be 143)
  4. go to basket and write to input area 10 of quantity this product: (5 * 10) * 28.55 = 1427.5 (with Decimal Places "0" will be 1428), it's NOT correct, must be 1430
    logic of total = round(((unit_price * quantity) * conversion_rate), decimal_place)

Expected behavior
(5[price of unit] * 28.55[conversion rate]) tnen rounded, by decimal place AND then * quantity

correct logic of total = round((unit_price * conversion_rate), decimal_place) * quantity

Screenshots / Screen recordings
http://joxi.ru/EA40JKptp67wqA.png

Additional context
correct logic into controller cart:
$price_temp = $this->currency->format($unit_price, $this->session->data['currency'], false, false);
$total = $this->currency->format($product['quantity'], $this->session->data['currency'], $price_temp);

detailed discussion (ukrainian): https://forum.brocart.net/threads/okruglennja-cin.237/

@WebkulOpencart WebkulOpencart added the 3.0.x.x Affects the 3.0.x.x maintenance version label Mar 8, 2021
@WebkulOpencart
Copy link
Contributor

@BroCart this is not correct, in this case, the admin gets the 2 UAH extra which is not feasible. So, I am closing this issue.

@BroCart
Copy link
Author

BroCart commented Mar 8, 2021

4.x version is have this bug too:
https://github.com/opencart/opencart/blob/master/upload/catalog/controller/checkout/cart.php#L114, why you close this issue and not solve the problem ?! in the world economy it is unacceptable to provide incorrect information when calculating the client for the purchase of goods

@WebkulOpencart WebkulOpencart reopened this Mar 9, 2021
@WebkulOpencart
Copy link
Contributor

@BroCart Please let me know for my above comment
#9413 (comment)

@seo-bro
Copy link

seo-bro commented Mar 9, 2021

In the previous option, the admin will benefit.
And if so:
http://icecream.me/uploads/4b03fe921516ad17d7c4202d028e231d.png
Here the buyer is already forced to overpay, is the mathematical logic broken 13 x 10 = 135?

@WebkulOpencart
Copy link
Contributor

Mathematically this is correct. so, closing this issue.

@seo-bro
Copy link

seo-bro commented Mar 9, 2021

Please do not close the question and listen to my arguments.
In most countries of the world, the buyer has the right to purchase a product or service at the price indicated on the price tag. And also there is responsibility for false information.
Why should a customer buy 1 item at $ 10 and 100 pieces at $ 10.5?
Why 2 x 2 ≠ 4?
The rights of the buyer are violated and lawsuits are possible against stores in countries where the coins were withdrawn from circulation.

@chulcha
Copy link

chulcha commented Mar 9, 2021

round(sum(totals)) ≠ sum(round(total))

@BroCart
Copy link
Author

BroCart commented Mar 9, 2021

Mathematically this is correct. so, closing this issue.

not quite so, for example:
opencart.com is multicurrency and sells goods for Euro:
base price (1.0000000) in admin in $, and selling by € (conversion rate: 1,19)
price of modul: 45$
settings currency Euro is: Decimal Places "0"
expected logic: round(53,55) = 54€
now, go to front and add 10 modules (quantity license per domens), what price will be displayed for customer 540 or 536 € ?

@WebkulOpencart
Copy link
Contributor

price of modul: 45$
settings currency Euro is: Decimal Places "0"
expected logic: round(53,55) = 54€
now, go to front and add 10 modules (quantity license per domens), what price will be displayed for customer 540 or 536 € ?

As per the Default, OpenCart working 536 € will be displayed. As single unit price is 53.55.

I need @danielkerr confirmation to make the changes as per your request.

@ADDCreative
Copy link
Contributor

This issue has been mentioned many times before both here (see #5657, #1990 and #779 for just some of the examples) on the forums.

It is obviously going to be very noticeable if converting to a high value currency without decimals.

To fix it you would have to do all the checkout total and tax calculations after the currency conversion and rounding. This gets rather complicated when you throw in tax calculation and displaying with and without taxes.
See copona/copona@8f05001#commitcomment-25190143 and copona/copona@8f05001#commitcomment-27435401 for more details on what's involved.

@WebkulOpencart WebkulOpencart reopened this Mar 9, 2021
@BroCart
Copy link
Author

BroCart commented Mar 9, 2021

@danielkerr in my opinion the parameter $quantity should be added to public function format( as a property of an object
poc:
0. system/library/cart/currency.php --> https://image.prntscr.com/image/vgD9LCyhTKqGgAsr6VhVQQ.png

  1. catalog/controller/checkout/cart.php --> https://image.prntscr.com/image/MkCpo_s8QC6vzhLLQGT8Eg.png

p.s. pandorra's box: system/library/cart/cart.php

@WebkulOpencart WebkulOpencart added the Assigned to Daniel Task assigned to Daniel for final say label Mar 12, 2021
@WebkulOpencart
Copy link
Contributor

@danielkerr As I checked you closed the old issues for the same so we need your confirmation for the same so that we can solve and close this ASAP.

@rsuchovsky
Copy link

Has the rounding issue been resolved? But did the problem just end here?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3.0.x.x Affects the 3.0.x.x maintenance version Assigned to Daniel Task assigned to Daniel for final say
Projects
None yet
Development

No branches or pull requests

7 participants