Closed (fixed)
Project:
Commerce Point of Sale (POS)
Version:
8.x-2.x-dev
Component:
Code
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
10 Mar 2018 at 11:39 UTC
Updated:
13 Sep 2018 at 22:04 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #2
subhojit777Looking into it.
I was able to replicate the problem. IMO the check should be made based on whether the product has fraction quantity allowed or not. I will check how Commerce core does it OR what it has.
Comment #3
subhojit777Some work came up.
Comment #4
subhojit777In a vanialla Commerce installation you can find the decimal setting for quantity here
admin/commerce/config/order-item-types/default/edit/form-display/add_to_cart. Change the quantity widget toQuantityand you will see the decimal setting.I believe we can do something similar in the POS.
Comment #5
smccabe commentedAgree, we should match the what Commerce does for the cart.
Comment #6
shabana.navas commentedPatch attached. This matches what Commerce core is doing.
Comment #8
jnrfred commented#6 patch sets the quantity field by default to accept integer values but does not work when you check the option to allow decimal values i.e decimal values are rounded up.
Comment #9
shabana.navas commentedThanks Fred, I'll look into that, also need to fix the failing tests.
Comment #10
smccabe commentedComment #11
gmem commentedRerolled the patch and updated the schema, also updated the tests to remove the decimals from the quantities.
Comment #13
gmem commentedFixed missing schema, turns out bool != boolean. Test passes locally now.
Comment #14
gmem commentedComment #15
smccabe commentedFew todos:
Comment #16
gmem commentedThis patch just adds a test for the decimal setting and fixes a small typo, decimals don't seem to be returned properly in the form however and has to be investigated - might have something to do with how it's being rounded in src/Plugin/Field/FieldWidget/PosOrderItemWidget.php L270-276 (or so).
Comment #17
gmem commentedPassing locally, although Firefox seems to round the x.00 decimals to x, despite both the value and step, which is a bit weird UX wise (Chrome renders this fine).
Comment #18
gmem commentedFail related to #2986424: Refactor Tests
Comment #19
gmem commentedComment #20
smccabe commentedrerolled now that #2986424: Refactor Tests has landed
Comment #21
smccabe commentedWhen I disabled decimals, I was still able to input decimal quantities. Also, I would update your tests to use something like 1.50 and 1.5453 to test the right number of decimals and confirm that things are working, as 1 and 1.00 are the same and won't show a flaw well
Comment #22
gmem commentedUpdated the test to insert and test decimal values in the quantity field. I'm not sure if there's a way to completely restrict an HTML number input from having decimals input, but at the very least we can reject it properly.
Comment #23
gmem commentedRemoved round() when decimals are enabled and reverted to previous method.
Comment #24
smccabe commentedThis still isn't working right for me, although I didn't see anything obviously wrong in the code
If i try and set to 3 digits, it can get stuck not letting me user the up/down arrows of the number field, if i input a number manually, it rounds it to 2 decimal places even though I asked for 3. The step is set right, but the validation seems broken.
Also, and this is possibly not even worth fixing, but if I have decimals disable and set it to like .2 it will remove my product, because it rounds down to 0. This is pretty edge case, but it is also unexpected behaviour to the user.
Comment #25
gmem commentedSo because Commerce rounds the order item quantity itself we can't really be as flexible as we'd like (e.g precise weight), instead for the quantity field we match what Commerce does for the cart page (which actually doesn't seem to be working for me). If we wanted to enable things like precise weight we'd probably need to implement another field to order_item. Also updated test to check that step is set correctly.
Comment #26
gmem commentedReally need to remember to remove debugging screenshots... fixed.
Comment #28
smccabe commented