LP1904036 Update Inventory checkin modifier fix
authorBill Erickson <berickxx@gmail.com>
Fri, 18 Mar 2022 20:14:35 +0000 (16:14 -0400)
committerGalen Charlton <gmc@equinoxOLI.org>
Fri, 28 Oct 2022 00:13:40 +0000 (20:13 -0400)
Signed-off-by: Bill Erickson <berickxx@gmail.com>
Signed-off-by: Jane Sandberg <js7389@princeton.edu>
Signed-off-by: Galen Charlton <gmc@equinoxOLI.org>
Open-ILS/src/eg2/src/app/staff/share/circ/circ.service.ts

index 9c51f50..443612c 100644 (file)
@@ -774,7 +774,7 @@ export class CircService {
 
     fleshCommonData(result: CircResultCommon): Promise<CircResultCommon> {
 
-        console.warn('fleshCommonData()');
+        console.debug('fleshCommonData()');
 
         const copy = result.copy;
         const volume = result.volume;
@@ -934,12 +934,29 @@ export class CircService {
             result.mbts = parent_circ.billable_transaction().summary();
         }
 
-        return this.fleshCommonData(result).then(_ => {
+        return this.fleshCommonData(result)
+        .then(_ => this.updateInventory(result))
+        .then(_ => {
             this.addWorkLog('checkin', result);
             return result;
         });
     }
 
+    updateInventory(result: CheckinResult): Promise<any> {
+
+        if (result?.firstEvent?.payload?.do_inventory_update) {
+            const inv = result?.firstEvent?.payload?.latest_inventory;
+
+            if (inv.id()) {
+                return this.pcrud.update(inv).toPromise();
+            } else {
+                return this.pcrud.create(inv).toPromise();
+            }
+        }
+
+        return Promise.resolve();
+    }
+
     processCheckinResult(result: CheckinResult): Promise<CheckinResult> {
         const params = result.params;
         const allEvents = result.allEvents;