Bug 30003 - Register entries doubled up if form fails validation on first submission
Summary: Register entries doubled up if form fails validation on first submission
Status: CLOSED FIXED
Alias: None
Product: Koha
Classification: Unclassified
Component: Fines and fees (show other bugs)
Version: master
Hardware: All All
: P5 - low major (vote)
Assignee: Jake Deery
QA Contact: Katrin Fischer
URL:
Keywords:
: 28163 (view as bug list)
Depends on:
Blocks:
 
Reported: 2022-02-02 11:51 UTC by Jake Deery
Modified: 2023-12-28 20:43 UTC (History)
7 users (show)

See Also:
Change sponsored?: ---
Patch complexity: Trivial patch
Documentation contact:
Documentation submission:
Text to go in the release notes:
Version(s) released in:
22.05.00,21.11.05


Attachments
Applied a fix to stop point-of-sale items being added twice to till transaction lists (1.25 KB, patch)
2022-02-08 11:57 UTC, Jake Deery
Details | Diff | Splinter Review
Applied a fix to stop point-of-sale items being added twice to till transaction lists (1.31 KB, patch)
2022-02-10 10:32 UTC, Kyle M Hall
Details | Diff | Splinter Review
Bug 30003: Fix to stop point-of-sale items being added twice to transactions (1.24 KB, patch)
2022-02-10 10:54 UTC, Jake Deery
Details | Diff | Splinter Review
Bug 30003: Fix to stop point-of-sale items being added twice to transactions (1.31 KB, patch)
2022-02-10 10:58 UTC, Jake Deery
Details | Diff | Splinter Review
Bug 30003: Prevent double up of point-of-sale items (1.73 KB, patch)
2022-02-10 11:01 UTC, Jake Deery
Details | Diff | Splinter Review
Bug 30003: Prevent double up of point-of-sale items (1.92 KB, patch)
2022-03-25 16:25 UTC, Nick Clemens
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description Jake Deery 2022-02-02 11:51:55 UTC
(Possibly related to #28163 at a code level)

Hi,

One of our customers has raised a curious bug involving the Point of Sale module within Koha. Specifically, when processing a payment in Koha, if the 'amount tendered' field is left blank, then filled in after the 'this field is mandatory' text appears, the transaction seems to be recorded twice.

Please see here for a visual demo: https://i.imgur.com/upH5zlk.gifv 

Steps to reproduce:
1.  Navigate to /cgi-bin/koha/pos/pay.pl
2.  Add an item from 'items to purchase'
3.  Under 'collect payment', click submit without altering the form
4.  See 'This field is required.'
5.  Now, fill a value in 'Amount tendered' that satisfies or exceeds 'Amount being paid'
6.  The payment should succeed 
7.  Navigate to /cgi-bin/koha/pos/register.pl
8.  See duplicate lines in Transactions

I hope we can see this resolved quickly, as it has the potential to cause major accounting issues.

Many thanks,
Jake Deery
Comment 1 Jake Deery 2022-02-02 12:17:28 UTC
Just to update, I have applied a quick-fix to IntranetUserJS. See attached. I will look into creating a proper patch tonight -
Comment 2 Jake Deery 2022-02-08 11:57:01 UTC
Created attachment 130280 [details] [review]
Applied a fix to stop point-of-sale items being added twice to till transaction lists
Comment 3 Kyle M Hall 2022-02-10 10:32:55 UTC
Created attachment 130423 [details] [review]
Applied a fix to stop point-of-sale items being added twice to till transaction lists

https://bugs.koha-community.org/show_bug.cgi?id=30003

Signed-off-by: Sally <sally.healey@cheshiresharedservices.gov.uk>
Comment 4 Sally 2022-02-10 10:34:10 UTC
Works great, thanks Jake!

We have this problem with a couple of staff at one library, and we couldn't get to the bottom of it; invariably, whenever we were watching them process a transaction, they did it perfectly.

Now we know the cause!  :)
Comment 5 Martin Renvoize 2022-02-10 10:48:52 UTC
Jake is just fixing up the commit message to adhere to guidelines.. you guys we so quick :).

I'll help him re-apply the signoff line ;)
Comment 6 Jake Deery 2022-02-10 10:54:47 UTC
Created attachment 130425 [details] [review]
Bug 30003: Fix to stop point-of-sale items being added twice to transactions
Comment 7 Jake Deery 2022-02-10 10:58:03 UTC
Created attachment 130427 [details] [review]
Bug 30003: Fix to stop point-of-sale items being added twice to transactions

https://bugs.koha-community.org/show_bug.cgi?id=30003

Signed-off-by: Sally <sally.healey@cheshiresharedservices.gov.uk>
Comment 8 Jake Deery 2022-02-10 11:01:39 UTC
Created attachment 130428 [details] [review]
Bug 30003: Prevent double up of point-of-sale items

This patch prevents the double submission of point-of-sale items when form validation fails at the first submission

Test plan
1.  Navigate to /cgi-bin/koha/pos/pay.pl
2.  Add an item from 'items to purchase'
3.  Under 'collect payment', click submit without altering the form
4.  See 'This field is required.'
5.  Now, fill a value in 'Amount tendered' that satisfies or exceeds 'Amount being paid'
6.  The payment should succeed
7.  Navigate to /cgi-bin/koha/pos/register.pl
8.  See duplicate lines in Transactions

Signed-off-by: Sally <sally.healey@cheshiresharedservices.gov.uk>
Comment 9 Jake Deery 2022-02-10 11:03:35 UTC
Right - apologies for the repeated attachments. Still getting the hang of git-bz ;-)

Big thanks to Martin and Sally for taking a look at this, and Kyle for adding the sign-off line!

Let me know how I can assist in the next steps.
Comment 10 Martin Renvoize 2022-02-10 11:13:03 UTC
*** Bug 28163 has been marked as a duplicate of this bug. ***
Comment 11 Katrin Fischer 2022-03-01 15:43:21 UTC
Hi Jake, thx for your patch and don't worry about the bugzilla noise, we all do it :)
Comment 12 Jonathan Druart 2022-03-18 13:50:07 UTC
I don't know if I am testing this correctly but with the patch I am not seeing anything on pos/register.pl
Comment 13 Nick Clemens 2022-03-25 16:25:17 UTC
Created attachment 132249 [details] [review]
Bug 30003: Prevent double up of point-of-sale items

This patch prevents the double submission of point-of-sale items when form validation fails at the first submission

Test plan
 1.  Navigate to /cgi-bin/koha/pos/pay.pl
 2.  Add an item from 'items to purchase'
 3.  Under 'collect payment', click submit without altering the form
 4.  See 'This field is required.'
 5.  Now, fill a value in 'Amount tendered' that satisfies or exceeds 'Amount being paid'
 6.  The payment should succeed
 7.  Navigate to /cgi-bin/koha/pos/register.pl
 8.  See duplicate lines in Transactions
 9.  Apply patch
10.  Repeat 2-6
11.  Navigate to /cgi-bin/koha/pos/register.pl
12.  Confirm only a single line was added

Signed-off-by: Sally <sally.healey@cheshiresharedservices.gov.uk>

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
Comment 14 Nick Clemens 2022-03-25 16:26:22 UTC
This feels slightly hacky - it seems the "This sale" table should be part of the payment form so we don't have to copy/delete lines on every attempt

This seems like a nasty bug however, passing QA
Comment 15 Fridolin Somers 2022-04-05 15:28:53 UTC
Pushed to master for 22.05, thanks to everybody involved 🦄
Comment 16 Kyle M Hall 2022-04-08 12:45:41 UTC
Pushed to 21.11.x for 21.11.05