{"action":"opened","issue":{"url":"https://api.github.com/repos/magento/magento2/issues/18025","repository_url":"https://api.github.com/repos/magento/magento2","labels_url":"https://api.github.com/repos/magento/magento2/issues/18025/labels{/name}","comments_url":"https://api.github.com/repos/magento/magento2/issues/18025/comments","events_url":"https://api.github.com/repos/magento/magento2/issues/18025/events","html_url":"https://github.com/magento/magento2/issues/18025","id":359339070,"node_id":"MDU6SXNzdWUzNTkzMzkwNzA=","number":18025,"title":"Rounding problem on prices when adding tax to display prices","user":{"login":"Tuuhea","id":5977769,"node_id":"MDQ6VXNlcjU5Nzc3Njk=","avatar_url":"https://avatars1.githubusercontent.com/u/5977769?v=4","gravatar_id":"","url":"https://api.github.com/users/Tuuhea","html_url":"https://github.com/Tuuhea","followers_url":"https://api.github.com/users/Tuuhea/followers","following_url":"https://api.github.com/users/Tuuhea/following{/other_user}","gists_url":"https://api.github.com/users/Tuuhea/gists{/gist_id}","starred_url":"https://api.github.com/users/Tuuhea/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Tuuhea/subscriptions","organizations_url":"https://api.github.com/users/Tuuhea/orgs","repos_url":"https://api.github.com/users/Tuuhea/repos","events_url":"https://api.github.com/users/Tuuhea/events{/privacy}","received_events_url":"https://api.github.com/users/Tuuhea/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2018-09-12T06:53:19Z","updated_at":"2018-09-12T06:53:19Z","closed_at":null,"author_association":"NONE","body":"### Preconditions\r\n<!---\r\n    Please provide as detailed information about your environment as possible.\r\n    For example Magento version, tag, HEAD, PHP & MySQL version, etc..\r\n-->\r\n1. Magento 2.2.5\r\n2. PHP 7.1.9\r\n3. MySql 5.6.37\r\n\r\n### Steps to reproduce\r\n1.  Set _Configuration > Tax > Calculation Settings_ to following:\r\n![tax_calculation_settings](https://user-images.githubusercontent.com/5977769/45406384-682dde00-b677-11e8-85ec-e1400d2bc6ec.png)\r\n2. Set  _Configuration > Tax > Price Display Settings_ to _Including Tax_\r\n\r\n### Expected result\r\n<!--- Tell us what should happen -->\r\n1. 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\r\n\r\n\r\n### Actual result\r\n<!--- Tell us what happens instead -->\r\n1. Magento\\Framework\\Pricing\\Price\\AbstractPrice returns value of 8.750001. This is visible example data-price-amount se to price wrapper element. See screenshot.\r\n![image](https://user-images.githubusercontent.com/5977769/45406745-80522d00-b678-11e8-842b-123a9c1e1484.png)\r\n\r\n\r\n### Own findings\r\n\r\nProblem 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. \r\n\r\n```\r\n    /**\r\n     * Round price based on previous rounding operation delta\r\n     *\r\n     * @param float $price\r\n     * @param string $rate\r\n     * @param bool $direction\r\n     * @param string $type\r\n     * @param bool $round\r\n     * @return float\r\n     */\r\n    protected function deltaRound($price, $rate, $direction, $type = self::KEY_REGULAR_DELTA_ROUNDING, $round = true)\r\n    {\r\n        if ($price) {\r\n            $rate = (string)$rate;\r\n            $type = $type . $direction;\r\n            // initialize the delta to a small number to avoid non-deterministic behavior with rounding of 0.5\r\n            $delta = isset($this->roundingDeltas[$type][$rate]) ?\r\n                $this->roundingDeltas[$type][$rate] :\r\n                0.000001;\r\n            $price += $delta;\r\n            $roundPrice = $price;\r\n            if ($round) {\r\n                $roundPrice = $this->calculationTool->round($roundPrice);\r\n            }\r\n            $this->roundingDeltas[$type][$rate] = $price - $roundPrice;\r\n            $price = $roundPrice;\r\n        }\r\n        return $price;\r\n    }\r\n```"}}
{"actor":{"display_login":"Tuuhea"}}