@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.
- package/dist/hooks/BDE_WorkTime.js +12 -1
- package/package.json +1 -1
|
@@ -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
|
-
|
|
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
|
+
}
|