Bug 27801

Summary: Entering multiple lines of an item in Point of Sale can make the Collect Payment field off
Product: Koha Reporter: Kelly McElligott <kelly>
Component: Fines and feesAssignee: Martin Renvoize (ashimema) <martin.renvoize>
Status: CLOSED FIXED QA Contact: Tomás Cohen Arazi (tcohen) <tomascohen>
Severity: major    
Priority: P5 - low CC: andrew, caroline.cyr-la-rose, david, esther.melander, nick, sally.healey, tomascohen, victor
Version: Main   
Hardware: All   
OS: All   
Change sponsored?: --- Patch complexity: ---
Documentation contact: Documentation submission:
Text to go in the release notes:
This fixes the POS transactions page so that the total for the sale and the amount to collect are the same. Before this a POS transaction with multiple items in the Sale box, say for example 9 x .10 items, the total in the Sale box appears correct, but the amount to Collect from Patron is off by a cent.
Version(s) released in:
22.05.00,21.11.01,21.05.08,20.11.13
Circulation function:
Bug Depends on:    
Bug Blocks: 13985, 30139    
Attachments: Calculation error
Bug 27801: Fix javascript price calculations
Bug 27801: Fix javascript price calculations
Bug 27801: Fix javascript price calculations
Bug 27801: Fix javascript price calculations
Bug 27801: Fix javascript price calculations

Description Kelly McElligott 2021-02-25 22:28:09 UTC
When a POS transaction occurs and multiple items are being added to the Sale box, say for example 9 x .10 items.  The total in the This Sale box appears correct, but down below the amount to Collect from Patron is off by a cent. 

To Recreate:

1. Have an item to sell for .10 in the POS module
2. Add this item to the "Sale" 9 times- do not use the Quantity option- manually click add item 9x.
3. Under the This Sale, it totals up to .90
4. Under the Collect Payment box, the total is .89
Comment 1 Andrew Fuerste-Henry 2021-03-05 12:46:58 UTC
On further testing, this error also occurs when using the quantity field rather than clicking "Add" multiple times.
Comment 2 Andrew Fuerste-Henry 2021-03-05 12:55:10 UTC
Apologies for my indecisiveness on the severity of this bug. I'm kicking it back to Major, as I've just confirmed that once Koha has mis-calculated that total the user cannot manually correct it.
Comment 3 Martin Renvoize (ashimema) 2021-03-05 14:23:54 UTC
:(, I should have predicted this. It's the same problem throughout Koha, but the point of sale system highlights it more often.

We really need to start dealing with money differently system wide.
Comment 4 Esther Melander 2021-09-24 16:29:55 UTC
Created attachment 125287 [details]
Calculation error
Comment 5 Esther Melander 2021-09-24 16:30:47 UTC
On version 21.05.14.

The combination of the certain numbers appears to result in being 1 penny off.

0.6 x 3 = 1.79
0.7 x 3 = 2.09

Other combinations appear to be correct.

In this case, only one item is added to the sale box.

Screenshot attached to ticket.
Comment 6 Martin Renvoize (ashimema) 2021-12-03 15:31:43 UTC
Created attachment 128228 [details] [review]
Bug 27801: Fix javascript price calculations

This patch ensures we're formatting the price values consistently for
the table total and the amount to pay input field.

Test plan
1) Add an item to charge at 0.10.
2) Add this same item 8 or 9 times (Do not use the 'quantity')
3) Note that the table total and the 'Amount paid' values do not match
4) Apply the patch and repeat the above steps.. the values should now
   match.
Comment 7 Martin Renvoize (ashimema) 2021-12-03 15:32:45 UTC
Created attachment 128229 [details] [review]
Bug 27801: Fix javascript price calculations

This patch ensures we're formatting the price values consistently for
the table total and the amount to pay input field.

Test plan
1) Add an item to charge at 0.10.
2) Add this same item 8 or 9 times (Do not use the 'quantity')
3) Note that the table total and the 'Amount paid' values do not match
4) Apply the patch and repeat the above steps.. the values should now
   match.
Comment 8 Andrew Fuerste-Henry 2021-12-03 20:59:04 UTC
Created attachment 128234 [details] [review]
Bug 27801: Fix javascript price calculations

This patch ensures we're formatting the price values consistently for
the table total and the amount to pay input field.

Test plan
1) Add an item to charge at 0.10.
2) Add this same item 8 or 9 times (Do not use the 'quantity')
3) Note that the table total and the 'Amount paid' values do not match
4) Apply the patch and repeat the above steps.. the values should now
   match.

Signed-off-by: Andrew Fuerste-Henry <andrew@bywatersolutions.com>
Comment 9 Andrew Fuerste-Henry 2021-12-03 20:59:43 UTC
I also confirmed the errors Esther mentioned were present without the patch and fixed with it.
Thanks, Martin!
Comment 10 Martin Renvoize (ashimema) 2021-12-08 10:08:32 UTC
Created attachment 128358 [details] [review]
Bug 27801: Fix javascript price calculations

This patch ensures we're formatting the price values consistently for
the table total and the amount to pay input field.

Test plan
1) Add an item to charge at 0.10.
2) Add this same item 8 or 9 times (Do not use the 'quantity')
3) Note that the table total and the 'Amount paid' values do not match
4) Apply the patch and repeat the above steps.. the values should now
   match.

Signed-off-by: Andrew Fuerste-Henry <andrew@bywatersolutions.com>
Signed-off-by: Sally <sally.healey@cheshiresharedservices.gov.uk>
Comment 11 Martin Renvoize (ashimema) 2021-12-08 10:09:26 UTC
Also tested, and in live operation, at Cheshire libraries.
Comment 12 Tomás Cohen Arazi (tcohen) 2021-12-13 11:45:42 UTC
Created attachment 128449 [details] [review]
Bug 27801: Fix javascript price calculations

This patch ensures we're formatting the price values consistently for
the table total and the amount to pay input field.

Test plan
1) Add an item to charge at 0.10.
2) Add this same item 8 or 9 times (Do not use the 'quantity')
3) Note that the table total and the 'Amount paid' values do not match
4) Apply the patch and repeat the above steps.. the values should now
   match.

Signed-off-by: Andrew Fuerste-Henry <andrew@bywatersolutions.com>
Signed-off-by: Sally <sally.healey@cheshiresharedservices.gov.uk>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Comment 13 Fridolin Somers 2021-12-15 21:50:39 UTC
Pushed to master for 22.05, thanks to everybody involved ﷐[U+1F984]﷑
Comment 14 Andrew Fuerste-Henry 2021-12-17 21:18:50 UTC
Pushed to 21.05.x for 21.05.08
Comment 15 Victor Grousset/tuxayo 2021-12-23 00:40:15 UTC
Backported: Pushed to 20.11.x branch for 20.11.13
Comment 16 Caroline Cyr La Rose 2022-04-07 14:00:53 UTC
This causes a major problem with the FR currencyformat, see Bug 30139