magento / magento2

Prior to making any Submission(s), you must sign an Adobe Contributor License Agreement, available here at: https://opensource.adobe.com/cla.html. All Submissions you make to Adobe Inc. and its affiliates, assigns and subsidiaries (collectively “Adobe”) are subject to the terms of the Adobe Contributor License Agreement.
http://www.magento.com
Open Software License 3.0
11.56k stars 9.32k forks source link

Rounding problem on prices when adding tax to display prices #18025

Open mlindholm opened 6 years ago

mlindholm commented 6 years ago

Preconditions

  1. Magento 2.2.x, 2.3.x & 2.4-develop
  2. PHP 7.1.9 & 7.2
  3. MySql 5.6.37

Steps to reproduce

  1. Set Configuration > Tax > Calculation Settings to following: tax_calculation_settings
  2. Set Configuration > Tax > Price Display Settings to Including Tax

Expected result

  1. Tax should be added to price set in product data when getting amount from classes extending Magento\Framework\Pricing\Price\AbstractPrice. Example Affirm Water Bottle with price of 7.00 with tax of 25 percent should result final value of 8.75

Actual result

  1. Magento\Framework\Pricing\Price\AbstractPrice returns value of 8.750001. This is visible example data-price-amount se to price wrapper element. See screenshot. image

Own findings

Problem seems to stem from Magento\Tax\Model\Calculation\AbstractCalculator. Calculator is adding delta of 0.000001 in deltaRound to prices, even if the $round is set to false and no rounding is happening.

    /**
     * Round price based on previous rounding operation delta
     *
     * @param float $price
     * @param string $rate
     * @param bool $direction
     * @param string $type
     * @param bool $round
     * @return float
     */
    protected function deltaRound($price, $rate, $direction, $type = self::KEY_REGULAR_DELTA_ROUNDING, $round = true)
    {
        if ($price) {
            $rate = (string)$rate;
            $type = $type . $direction;
            // initialize the delta to a small number to avoid non-deterministic behavior with rounding of 0.5
            $delta = isset($this->roundingDeltas[$type][$rate]) ?
                $this->roundingDeltas[$type][$rate] :
                0.000001;
            $price += $delta;
            $roundPrice = $price;
            if ($round) {
                $roundPrice = $this->calculationTool->round($roundPrice);
            }
            $this->roundingDeltas[$type][$rate] = $price - $roundPrice;
            $price = $roundPrice;
        }
        return $price;
    }
magento-engcom-team commented 6 years ago

Hi @Tuuhea. Thank you for your report. To help us process this issue please make sure that you provided the following information:

Please make sure that the issue is reproducible on the vanilla Magento instance following Steps to reproduce. To deploy vanilla Magento instance on our environment, please, add a comment to the issue:

@magento-engcom-team give me {$VERSION} instance

where {$VERSION} is version tags (starting from 2.2.0+) or develop branches (2.2-develop +). For more details, please, review the Magento Contributor Assistant documentation.

@Tuuhea do you confirm that you was able to reproduce the issue on vanilla Magento instance following steps to reproduce?

ghost commented 6 years ago

Hi @Tuuhea, thank you for your report. We've acknowledged the issue and added to our backlog.

m2-assistant[bot] commented 4 years ago

Hi @engcom-Charlie. Thank you for working on this issue. Looks like this issue is already verified and confirmed. But if you want to validate it one more time, please, go though the following instruction:


magento-engcom-team commented 4 years ago

:white_check_mark: Confirmed by @engcom-Charlie Thank you for verifying the issue. Based on the provided information internal tickets MC-30105 were created

Issue Available: @engcom-Charlie, You will be automatically unassigned. Contributors/Maintainers can claim this issue to continue. To reclaim and continue work, reassign the ticket to yourself.

stale[bot] commented 3 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed after 14 days if no further activity occurs. Thank you for your contributions.

t-heuser commented 3 years ago

Hold up, just because no one works on it it'll get closed? It's an bug which needs to be fixed!

DJB95 commented 3 years ago

Does anyone have an update on this? Is this maybe fixed in M2.4.x?

t-heuser commented 3 years ago

I can confirm that the error still exists in 2.4.1, so not yet fixed.

DJB95 commented 3 years ago

@oneserv-heuser alright, thanks Timon! hopefully this will be fixed soon

rb-ec commented 3 years ago

Any update on this yet? Please, Magento devs, please provide us with a hack until thsi is resolved properly!

stale[bot] commented 3 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed after 14 days if no further activity occurs. Is this issue still relevant? If so, what is blocking it? Is there anything you can do to help move it forward? Thank you for your contributions!

t-heuser commented 3 years ago

Still an issue which needs to be fixed.

rb-ec commented 3 years ago

definitely still an issue that needs fixing. @engcom-Charlie @magento-engcom-team

stale[bot] commented 3 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed after 28 days if no further activity occurs. Is this issue still relevant? If so, what is blocking it? Is there anything you can do to help move it forward? Thank you for your contributions!

t-heuser commented 3 years ago

And again, still an issue which needs to be fixed.

rb-ec commented 3 years ago

Yes, still an issue.

vivekp-dev commented 2 years ago

I am facing the same issue in Magento

mcspronko commented 2 years ago

Any chance to fix the issue that was reported back in 2018?

holzkern commented 1 year ago

Still an issue in 2023

othuress commented 1 year ago

Still an issue especially when TAX reported for OSS https://vat-one-stop-shop.ec.europa.eu/one-stop-shop_en creates deviations in reporting and what needs to actually needs to be paid. This issue needs attention and solution ASAP. reported in 2018 embarrassing this has not yet been fixed.

Seppo-Konttinen-Solteq commented 1 year ago

Yeap still an issue.

othuress commented 1 year ago

Hi @magento-engcom-team can you please pick up in this issue, it has been neglected for too long.

s0ko7likaj commented 1 year ago

🤣

m2-assistant[bot] commented 7 months ago

Hi @engcom-Bravo. Thank you for working on this issue. Looks like this issue is already verified and confirmed. But if you want to validate it one more time, please, go though the following instruction:


engcom-Bravo commented 7 months ago

@magento give me 2.4-develop instance

magento-deployment-service[bot] commented 7 months ago

Hi @engcom-Bravo. Thank you for your request. I'm working on Magento instance for you.

magento-deployment-service[bot] commented 7 months ago

Hi @engcom-Bravo, here is your Magento Instance: https://bb6da8a588409a21dd0ef2475d3765f5.instances-prod.magento-community.engineering Admin access: https://bb6da8a588409a21dd0ef2475d3765f5.instances-prod.magento-community.engineering/admin_2c20 Login: a70d9257 Password: efc6dbf39fda

engcom-Bravo commented 7 months ago

Hi @Tuuhea,

Thank you for reporting and collaboration.

Verified the issue on Magento 2.4-develop instance and the issue is reproducible.Kindly refer the screenshots.

Screenshot 2024-04-02 at 15 22 48

Magento\Framework\Pricing\Price\AbstractPrice returns value of 8.750001.

Hence Confirming the issue.

Thanks.

github-jira-sync-bot commented 7 months ago

Unfortunately, not enough information was provided to create a Jira ticket. Please make sure you added the following label(s): Reproduced on 2.4.x, ^Area:.*

Once all required labels are present, please add Issue: Confirmed label again.

github-jira-sync-bot commented 7 months ago

Unfortunately, not enough information was provided to create a Jira ticket. Please make sure you added the following label(s): Reproduced on 2.4.x, ^Area:.*

Once all required labels are present, please add Issue: Confirmed label again.

github-jira-sync-bot commented 7 months ago

Unfortunately, not enough information was provided to create a Jira ticket. Please make sure you added the following label(s): Reproduced on 2.4.x, ^Area:.*

Once all required labels are present, please add Issue: Confirmed label again.

github-jira-sync-bot commented 7 months ago

:white_check_mark: Jira issue https://jira.corp.adobe.com/browse/AC-11725 is successfully created for this GitHub issue.

m2-assistant[bot] commented 7 months ago

:white_check_mark: Confirmed by @engcom-Bravo. Thank you for verifying the issue.
Issue Available: @engcom-Bravo, You will be automatically unassigned. Contributors/Maintainers can claim this issue to continue. To reclaim and continue work, reassign the ticket to yourself.

github-jira-sync-bot commented 7 months ago

:x: Cannot export the issue. This GitHub issue is already linked to Jira issue(s): https://jira.corp.adobe.com/browse/AC-11725