LP#1526163 Web staff supports auto-renew tweaks
authorBill Erickson <berickxx@gmail.com>
Fri, 3 Feb 2017 19:26:09 +0000 (14:26 -0500)
committerKathy Lussier <klussier@masslnc.org>
Mon, 6 Mar 2017 03:01:17 +0000 (22:01 -0500)
Initiate the auto-renewal earlier in the checkout process, specifically
before response data is unnecessarily fleshed.  Add an explicit
auto_renew toggle to the checkout response blob to more clearly indicate
why checkout counts are not modified.

Additional code comments and logging.

Signed-off-by: Bill Erickson <berickxx@gmail.com>
Signed-off-by: Kathy Lussier <klussier@masslnc.org>
Open-ILS/web/js/ui/default/staff/circ/patron/checkout.js
Open-ILS/web/js/ui/default/staff/circ/services/circ.js

index 549933b..8fc38de 100644 (file)
@@ -151,8 +151,10 @@ function($scope , $q , $routeParams , egCore , egUser , patronSvc ,
             function(co_resp) {
                 // update stats locally so we don't have to fetch them w/
                 // each checkout.
-                //check for renew so that is doesn't update incorrectly
-                if(co_resp.evt[0].payload.parent_circ == null){
+
+                // Avoid updating checkout counts when a checkout turns
+                // into a renewal via auto_renew.
+                if (!co_resp.auto_renew) {
                     patronSvc.patron_stats.checkouts.out++;
                     patronSvc.patron_stats.checkouts.total_out++;
                 }
index 08ce484..62b6502 100644 (file)
@@ -143,6 +143,13 @@ function($uibModal , $q , egCore , egAlertDialog , egConfirmDialog,
 
                 if (!angular.isArray(evt)) evt = [evt];
 
+                if (evt[0].payload && evt[0].payload.auto_renew == 1) {
+                    // open circulation found with auto-renew toggle on.
+                    console.debug('Auto-renewing item ' + params.copy_barcode);
+                    options.auto_renew = true;
+                    return service.renew(params, options);
+                }
+
                 return service.flesh_response_data('checkout', evt, params, options)
                 .then(function() {
                     return service.handle_checkout_resp(evt, params, options);
@@ -188,6 +195,7 @@ function($uibModal , $q , egCore , egAlertDialog , egConfirmDialog,
                     return service.handle_renew_resp(evt, params, options);
                 })
                 .then(function(final_resp) {
+                    final_resp.auto_renew = options.auto_renew;
                     return service.munge_resp_data(final_resp,'renew',method)
                 })
             });
@@ -460,9 +468,7 @@ function($uibModal , $q , egCore , egAlertDialog , egConfirmDialog,
                 return service.precat_dialog(params, options);
 
             case 'OPEN_CIRCULATION_EXISTS':
-                if(evt[0].payload.auto_renew == 1){
-                    return service.renew(params, options);
-                }
+                // auto_renew checked in service.checkout()
                 egCore.audio.play('error.checkout.open_circ');
                 return service.circ_exists_dialog(evt, params, options);