{"action":"closed","issue":{"url":"https://api.github.com/repos/magento/magento2/issues/19209","repository_url":"https://api.github.com/repos/magento/magento2","labels_url":"https://api.github.com/repos/magento/magento2/issues/19209/labels{/name}","comments_url":"https://api.github.com/repos/magento/magento2/issues/19209/comments","events_url":"https://api.github.com/repos/magento/magento2/issues/19209/events","html_url":"https://github.com/magento/magento2/issues/19209","id":380684781,"node_id":"MDU6SXNzdWUzODA2ODQ3ODE=","number":19209,"title":"Validation on Product quantity in case of decimals","user":{"login":"manolismax","id":3092976,"node_id":"MDQ6VXNlcjMwOTI5NzY=","avatar_url":"https://avatars3.githubusercontent.com/u/3092976?v=4","gravatar_id":"","url":"https://api.github.com/users/manolismax","html_url":"https://github.com/manolismax","followers_url":"https://api.github.com/users/manolismax/followers","following_url":"https://api.github.com/users/manolismax/following{/other_user}","gists_url":"https://api.github.com/users/manolismax/gists{/gist_id}","starred_url":"https://api.github.com/users/manolismax/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/manolismax/subscriptions","organizations_url":"https://api.github.com/users/manolismax/orgs","repos_url":"https://api.github.com/users/manolismax/repos","events_url":"https://api.github.com/users/manolismax/events{/privacy}","received_events_url":"https://api.github.com/users/manolismax/received_events","type":"User","site_admin":false},"labels":[{"id":686420665,"node_id":"MDU6TGFiZWw2ODY0MjA2NjU=","url":"https://api.github.com/repos/magento/magento2/labels/Issue:%20Clear%20Description","name":"Issue: Clear Description","color":"0e8a16","default":false},{"id":688811200,"node_id":"MDU6TGFiZWw2ODg4MTEyMDA=","url":"https://api.github.com/repos/magento/magento2/labels/Issue:%20Format%20is%20valid","name":"Issue: Format is valid","color":"0e8a16","default":false}],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":4,"created_at":"2018-11-14T12:53:46Z","updated_at":"2018-11-19T09:00:09Z","closed_at":"2018-11-19T09:00:08Z","author_association":"NONE","body":"Hello, \r\nI have faced a validation issue, on product quantity when i work with decimals. I get a quantity validation error if i set decimal value to Increments\r\n\r\n### Preconditions \r\nMagento 2.2.6\r\nsample data\r\n\r\n### Steps to reproduce\r\n\r\n#### On admin->productPage -> Advanced Inventory \r\nSet :\r\n\r\n- Minimum Qty Allowed in Shopping Cart = 0.5\r\n- Qty Increments = 0.1\r\n\r\n#### Frontend Product page\r\n Set:  quantity =1\r\n\r\n### Expected result \r\n quantity =1 is  a multiple of 0.5  , so the product has to be added on cart\r\n### Actual result \r\nA validation error throws  always  **You can buy this product only in quantities of 0.1 at a time.**\r\n\r\n### Explanation\r\nAs i tried to debug this error, I ended up on [this line](https://github.com/magento/magento2/blob/22539f972e32128aeeec0f65aebb1f29879f8231/lib/web/mage/validation.js#L1578) on [validation.js](https://github.com/magento/magento2/blob/22539f972e32128aeeec0f65aebb1f29879f8231/lib/web/mage/validation.js)\r\n\r\nThe bug is on `  qty % $.mage.parseNumber(params.qtyIncrements) === 0;` , cause the javascript modulo operator doesn't work correctly on floats. As you can see on the following links, unfortunately is a known js issue.\r\n[link1](https://stackoverflow.com/questions/3966484/why-does-modulus-operator-return-fractional-number-in-javascript) [link2](http://adripofjavascript.com/blog/drips/avoiding-problems-with-decimal-math-in-javascript.html)\r\n\r\nYou can simply replicate it on console \r\n\r\n```\r\nconsole.log(5%1)\r\n0\r\n\r\nconsole.log(.5%.1)\r\n0.09999999999999998\r\n```\r\n\r\n\r\nAs a quick solution, the only i can propose is to multiple both before validation with a big number Example: ` (10000 *qty) %( $.mage.parseNumber(params.qtyIncrements) * 10000) === 0;`\r\n"}}
{"actor":{"display_login":"orlangur"}}