JBAS-1728 SCKO email receipts passive repairs
authorBill Erickson <berickxx@gmail.com>
Wed, 22 Nov 2017 17:11:47 +0000 (12:11 -0500)
committerBill Erickson <berickxx@gmail.com>
Thu, 21 Mar 2019 19:46:23 +0000 (15:46 -0400)
Avoid firing passive (SCKO receipt) email events in real time.  Create
the events, then let the regular A/T processor handle firing the emails.

Signed-off-by: Bill Erickson <berickxx@gmail.com>
Open-ILS/src/perlmods/lib/OpenILS/Application/Circ.pm
Open-ILS/web/js/ui/kcls/circ/selfcheck/selfcheck.js

index 71dc92b..c7feb25 100644 (file)
@@ -1918,6 +1918,18 @@ sub fire_circ_events {
                   # failure down the line if handling many targets
 
     return undef unless @$targets;
+
+    if ($hook eq 'email.selfcheck.checkout') {
+        # KCLS JBAS-1728
+        # Avoid firing passive email events here.  Create the events,
+        # then let them fire via the regular A/T processor.
+        for my $target (@$targets) {
+            $U->create_events_for_hook(
+                $hook, $target, $org_id, $granularity, $user_data);
+        }
+        return 1; # indicate successy-ness
+    } 
+
     return $U->fire_object_event($event_def, $hook, $targets, $org_id, $granularity, $user_data);
 }
 
index 22cbbc9..81159d1 100644 (file)
@@ -1545,7 +1545,7 @@ SelfCheckManager.prototype.emailSessionReceipt = function(callback) {
         this.staff.ws_ou(),
         null,
         'email.selfcheck.checkout',
-        'print-on-demand',
+        '', // granularity
         circIds,
         circCtx
     ];
@@ -1558,16 +1558,13 @@ SelfCheckManager.prototype.emailSessionReceipt = function(callback) {
             params : params,
             oncomplete : function(r) {
                 var resp = openils.Util.readResponse(r);
-                var output = resp.template_output();
-                  if(output) {
-                        if (callback) callback();
-                  } else {
-                    var error = resp.error_output();
-                    if(error) {
-                        throw new Error("Error creating receipt: " + error.data());
-                    } else {
-                        throw new Error("No receipt data returned from server");
-                    }
+                var evt = openils.Event.parse(resp);
+                // Email events are passive, so all we're doing here is
+                // creating an event that will be fired later.  
+                if (evt) {
+                    throw new Error("Error creating receipt email: " + evt);
+                } else {
+                    if (callback) callback();
                 }
             }
         }