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++;
}
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);
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)
})
});
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);