@openinc/parse-server-opendash 4.0.17 → 4.0.18

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -12,6 +12,17 @@ async function init() {
12
12
  });
13
13
  (0, index_js_1.afterSaveHook)(index_js_2.BDE_WorkTime, async (request) => {
14
14
  const { object, original, user } = request;
15
- // TODO
15
+ await addToWorkOrder(object);
16
16
  });
17
17
  }
18
+ /**
19
+ * Adds amountGood and amountScrap from the workTime to the related workOrder.
20
+ */
21
+ async function addToWorkOrder(workTime) {
22
+ const workOrder = await workTime.workOrder?.fetch({ useMasterKey: true });
23
+ if (!workOrder)
24
+ return;
25
+ workOrder.set("amountGood", (workOrder.amountGood || 0) + workTime.amountGood);
26
+ workOrder.set("amountScrap", (workOrder.amountScrap || 0) + workTime.amountScrap);
27
+ await workOrder.save(null, { useMasterKey: true });
28
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openinc/parse-server-opendash",
3
- "version": "4.0.17",
3
+ "version": "4.0.18",
4
4
  "description": "Parse Server Cloud Code for open.INC Stack.",
5
5
  "packageManager": "pnpm@10.33.0",
6
6
  "keywords": [