Bug 26208: Perform batch checkin/renewals serially rather than asynchronously
authorNick Clemens <nick@bywatersolutions.com>
Thu, 3 Dec 2020 19:13:15 +0000 (19:13 +0000)
committerJonathan Druart <jonathan.druart@bugs.koha-community.org>
Tue, 23 Feb 2021 12:07:45 +0000 (13:07 +0100)
The issue here seems to be that when multiple requests hit at once they may not register that the renewal
performed by the request should lift restrictions on the account.

To mitigate this we can simply perform the renewals one after the other.

To test:
1 - have multiple overdue items on one patron
2 - run overdues.pl with triggers set to generate a restriction
3 - renew all overdues with the Renew All button
4 - restriction is not removed even though patron no longer has overdue items
5 - Apply patch
6 - Make all items overdue again
7 - Click Renew All
8 - Items are renewed and restriction removed
9 - Checkout items to patron again (overdue or not)
10 - Click 'Select all' in checkin column
11 - Click 'Renew/Checkin selected items'
12 - Confirm checkin succeeds as before patches

Signed-off-by: Kelly McElligott <kelly@bywatersolutions.com>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Bug 26208: (follow-up) Remove debugging statements

Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
koha-tmpl/intranet-tmpl/prog/js/checkouts.js

index b5347c0..fc67a26 100644 (file)
@@ -110,24 +110,30 @@ $(document).ready(function() {
                 exempt_fine:    $("#exemptfine").is(':checked')
             };
 
-            $.post( "/cgi-bin/koha/svc/checkin", params, function( data ) {
-                id = "#checkin_" + data.itemnumber;
-
-                content = "";
-                if ( data.returned ) {
-                    content = __("Checked in");
-                    $(id).parent().parent().addClass('ok');
-                    $('#date_due_' + data.itemnumber).html( __("Checked in") );
-                    if ( data.patronnote != null ) {
-                        $('.patron_note_' + data.itemnumber).html( __("Patron note") + ": " + data.patronnote);
+            $.post({
+                url: "/cgi-bin/koha/svc/checkin",
+                data: params,
+                success: function( data ) {
+                    id = "#checkin_" + data.itemnumber;
+
+                    content = "";
+                    if ( data.returned ) {
+                        content = __("Checked in");
+                        $(id).parent().parent().addClass('ok');
+                        $('#date_due_' + data.itemnumber).html( __("Checked in") );
+                        if ( data.patronnote != null ) {
+                            $('.patron_note_' + data.itemnumber).html( __("Patron note") + ": " + data.patronnote);
+                        }
+                    } else {
+                        content = __("Unable to check in");
+                        $(id).parent().parent().addClass('warn');
                     }
-                } else {
-                    content = __("Unable to check in");
-                    $(id).parent().parent().addClass('warn');
-                }
 
-                $(id).replaceWith( content );
-            }, "json")
+                    $(id).replaceWith( content );
+                },
+                dataType: "json",
+                async: false,
+            });
         });
 
         $(".confirm:checked:visible").each(function() {
@@ -170,36 +176,42 @@ $(document).ready(function() {
                 params.date_due = dueDate
             }
 
-            $.post( "/cgi-bin/koha/svc/renew", params, function( data ) {
-                var id = "#renew_" + data.itemnumber;
-
-                var content = "";
-                if ( data.renew_okay ) {
-                    content = __("Renewed, due:") + " " + data.date_due;
-                    $('#date_due_' + data.itemnumber).replaceWith( data.date_due );
-                } else {
-                    content = __("Renew failed:") + " ";
-                    if ( data.error == "no_checkout" ) {
-                        content += __("not checked out");
-                    } else if ( data.error == "too_many" ) {
-                        content += __("too many renewals");
-                    } else if ( data.error == "too_unseen" ) {
-                        content += __("too many consecutive renewals without being seen by the library");
-                    } else if ( data.error == "on_reserve" ) {
-                        content += __("on hold");
-                    } else if ( data.error == "restriction" ) {
-                        content += __("Not allowed: patron restricted");
-                    } else if ( data.error == "overdue" ) {
-                        content += __("Not allowed: overdue");
-                    } else if ( data.error ) {
-                        content += data.error;
+            $.post({
+                url: "/cgi-bin/koha/svc/renew",
+                data: params,
+                success: function( data ) {
+                    var id = "#renew_" + data.itemnumber;
+
+                    var content = "";
+                    if ( data.renew_okay ) {
+                        content = __("Renewed, due:") + " " + data.date_due;
+                        $('#date_due_' + data.itemnumber).replaceWith( data.date_due );
                     } else {
-                        content += __("reason unknown");
+                        content = __("Renew failed:") + " ";
+                        if ( data.error == "no_checkout" ) {
+                            content += __("not checked out");
+                        } else if ( data.error == "too_many" ) {
+                            content += __("too many renewals");
+                        } else if ( data.error == "too_unseen" ) {
+                            content += __("too many consecutive renewals without being seen by the library");
+                        } else if ( data.error == "on_reserve" ) {
+                            content += __("on hold");
+                        } else if ( data.error == "restriction" ) {
+                            content += __("Not allowed: patron restricted");
+                        } else if ( data.error == "overdue" ) {
+                            content += __("Not allowed: overdue");
+                        } else if ( data.error ) {
+                            content += data.error;
+                        } else {
+                            content += __("reason unknown");
+                        }
                     }
-                }
 
-                $(id).replaceWith( content );
-            }, "json")
+                    $(id).replaceWith( content );
+            },
+            dataType: "json",
+            async: false,
+            });
         });
 
         // Refocus on barcode field if it exists