av6-core 1.8.4 → 1.8.5
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/index.js +43 -45
- package/dist/index.mjs +43 -45
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -2739,59 +2739,57 @@ var ApprovalService = class {
|
|
|
2739
2739
|
}
|
|
2740
2740
|
}
|
|
2741
2741
|
async assertPermission(step, approverId, instanceId, ccId, tx) {
|
|
2742
|
-
const result = await tx.$queryRaw
|
|
2743
|
-
|
|
2744
|
-
|
|
2745
|
-
|
|
2746
|
-
|
|
2747
|
-
|
|
2748
|
-
|
|
2749
|
-
|
|
2750
|
-
|
|
2742
|
+
const result = await tx.$queryRaw`
|
|
2743
|
+
SELECT COUNT(*) AS count
|
|
2744
|
+
FROM (
|
|
2745
|
+
SELECT am.staff_id AS staff_id
|
|
2746
|
+
FROM core_approver_mapping am
|
|
2747
|
+
WHERE am.step_id = ${step.id}
|
|
2748
|
+
AND am.is_active = TRUE
|
|
2749
|
+
AND am.cc_id = ${ccId}
|
|
2750
|
+
AND am.staff_id = ${approverId}
|
|
2751
2751
|
|
|
2752
|
-
|
|
2752
|
+
UNION
|
|
2753
2753
|
|
|
2754
|
-
|
|
2755
|
-
|
|
2756
|
-
|
|
2757
|
-
|
|
2758
|
-
|
|
2759
|
-
|
|
2760
|
-
|
|
2761
|
-
|
|
2762
|
-
|
|
2763
|
-
|
|
2764
|
-
|
|
2765
|
-
|
|
2766
|
-
|
|
2754
|
+
SELECT scc.staff_id AS staff_id
|
|
2755
|
+
FROM core_approver_mapping am
|
|
2756
|
+
LEFT JOIN staff_roles sr
|
|
2757
|
+
ON sr.role_id = am.role_id
|
|
2758
|
+
LEFT JOIN staff_collection_center scc
|
|
2759
|
+
ON scc.collection_center_id = am.cc_id
|
|
2760
|
+
AND scc.staff_id = sr.staff_id
|
|
2761
|
+
WHERE am.step_id = ${step.id}
|
|
2762
|
+
AND am.is_active = TRUE
|
|
2763
|
+
AND am.cc_id = ${ccId}
|
|
2764
|
+
AND scc.staff_id = ${approverId}
|
|
2765
|
+
) AS staff_union;
|
|
2766
|
+
`;
|
|
2767
2767
|
if (Number(result[0].count) === 0) {
|
|
2768
2768
|
throw new this.deps.helpers.ErrorHandler(403, "You are not allowed to act on this approval step");
|
|
2769
2769
|
}
|
|
2770
|
-
const
|
|
2771
|
-
|
|
2772
|
-
|
|
2773
|
-
|
|
2774
|
-
|
|
2775
|
-
|
|
2776
|
-
|
|
2777
|
-
|
|
2778
|
-
|
|
2779
|
-
|
|
2780
|
-
const actionsResult = await tx.$queryRawUnsafe(existingActsQuery, instanceId, step.level, approverId);
|
|
2770
|
+
const actionsResult = await tx.$queryRaw`
|
|
2771
|
+
SELECT COUNT(*) AS count
|
|
2772
|
+
FROM core_approval_action a
|
|
2773
|
+
JOIN core_approval_instance ai ON ai.id = a.instance_id
|
|
2774
|
+
WHERE ai.id = ${instanceId}
|
|
2775
|
+
AND a.level = ${step.level}
|
|
2776
|
+
AND a.acted_by = ${approverId}
|
|
2777
|
+
AND a.is_active = true
|
|
2778
|
+
AND ai.is_active = true
|
|
2779
|
+
`;
|
|
2781
2780
|
if (Number(actionsResult[0].count) > 0) {
|
|
2782
2781
|
throw new this.deps.helpers.ErrorHandler(409, "You have already submitted a decision for this level");
|
|
2783
2782
|
}
|
|
2784
|
-
const
|
|
2785
|
-
|
|
2786
|
-
|
|
2787
|
-
|
|
2788
|
-
|
|
2789
|
-
|
|
2790
|
-
|
|
2791
|
-
|
|
2792
|
-
|
|
2793
|
-
|
|
2794
|
-
const prevActionsResult = await tx.$queryRawUnsafe(prevApproversQuery, instanceId, step.level);
|
|
2783
|
+
const prevActionsResult = await tx.$queryRaw`
|
|
2784
|
+
SELECT COUNT(*) AS count
|
|
2785
|
+
FROM core_approval_action a
|
|
2786
|
+
JOIN core_approval_instance ai ON ai.id = a.instance_id
|
|
2787
|
+
WHERE ai.id = ${instanceId}
|
|
2788
|
+
AND a.level < ${step.level}
|
|
2789
|
+
AND a.is_active = true
|
|
2790
|
+
AND ai.is_active = true
|
|
2791
|
+
AND a.acted_by IS NOT NULL
|
|
2792
|
+
`;
|
|
2795
2793
|
if (Number(prevActionsResult[0].count) !== step.level - 1) {
|
|
2796
2794
|
throw new this.deps.helpers.ErrorHandler(403, "You must wait for previous approvers to act first");
|
|
2797
2795
|
}
|
package/dist/index.mjs
CHANGED
|
@@ -2678,59 +2678,57 @@ var ApprovalService = class {
|
|
|
2678
2678
|
}
|
|
2679
2679
|
}
|
|
2680
2680
|
async assertPermission(step, approverId, instanceId, ccId, tx) {
|
|
2681
|
-
const result = await tx.$queryRaw
|
|
2682
|
-
|
|
2683
|
-
|
|
2684
|
-
|
|
2685
|
-
|
|
2686
|
-
|
|
2687
|
-
|
|
2688
|
-
|
|
2689
|
-
|
|
2681
|
+
const result = await tx.$queryRaw`
|
|
2682
|
+
SELECT COUNT(*) AS count
|
|
2683
|
+
FROM (
|
|
2684
|
+
SELECT am.staff_id AS staff_id
|
|
2685
|
+
FROM core_approver_mapping am
|
|
2686
|
+
WHERE am.step_id = ${step.id}
|
|
2687
|
+
AND am.is_active = TRUE
|
|
2688
|
+
AND am.cc_id = ${ccId}
|
|
2689
|
+
AND am.staff_id = ${approverId}
|
|
2690
2690
|
|
|
2691
|
-
|
|
2691
|
+
UNION
|
|
2692
2692
|
|
|
2693
|
-
|
|
2694
|
-
|
|
2695
|
-
|
|
2696
|
-
|
|
2697
|
-
|
|
2698
|
-
|
|
2699
|
-
|
|
2700
|
-
|
|
2701
|
-
|
|
2702
|
-
|
|
2703
|
-
|
|
2704
|
-
|
|
2705
|
-
|
|
2693
|
+
SELECT scc.staff_id AS staff_id
|
|
2694
|
+
FROM core_approver_mapping am
|
|
2695
|
+
LEFT JOIN staff_roles sr
|
|
2696
|
+
ON sr.role_id = am.role_id
|
|
2697
|
+
LEFT JOIN staff_collection_center scc
|
|
2698
|
+
ON scc.collection_center_id = am.cc_id
|
|
2699
|
+
AND scc.staff_id = sr.staff_id
|
|
2700
|
+
WHERE am.step_id = ${step.id}
|
|
2701
|
+
AND am.is_active = TRUE
|
|
2702
|
+
AND am.cc_id = ${ccId}
|
|
2703
|
+
AND scc.staff_id = ${approverId}
|
|
2704
|
+
) AS staff_union;
|
|
2705
|
+
`;
|
|
2706
2706
|
if (Number(result[0].count) === 0) {
|
|
2707
2707
|
throw new this.deps.helpers.ErrorHandler(403, "You are not allowed to act on this approval step");
|
|
2708
2708
|
}
|
|
2709
|
-
const
|
|
2710
|
-
|
|
2711
|
-
|
|
2712
|
-
|
|
2713
|
-
|
|
2714
|
-
|
|
2715
|
-
|
|
2716
|
-
|
|
2717
|
-
|
|
2718
|
-
|
|
2719
|
-
const actionsResult = await tx.$queryRawUnsafe(existingActsQuery, instanceId, step.level, approverId);
|
|
2709
|
+
const actionsResult = await tx.$queryRaw`
|
|
2710
|
+
SELECT COUNT(*) AS count
|
|
2711
|
+
FROM core_approval_action a
|
|
2712
|
+
JOIN core_approval_instance ai ON ai.id = a.instance_id
|
|
2713
|
+
WHERE ai.id = ${instanceId}
|
|
2714
|
+
AND a.level = ${step.level}
|
|
2715
|
+
AND a.acted_by = ${approverId}
|
|
2716
|
+
AND a.is_active = true
|
|
2717
|
+
AND ai.is_active = true
|
|
2718
|
+
`;
|
|
2720
2719
|
if (Number(actionsResult[0].count) > 0) {
|
|
2721
2720
|
throw new this.deps.helpers.ErrorHandler(409, "You have already submitted a decision for this level");
|
|
2722
2721
|
}
|
|
2723
|
-
const
|
|
2724
|
-
|
|
2725
|
-
|
|
2726
|
-
|
|
2727
|
-
|
|
2728
|
-
|
|
2729
|
-
|
|
2730
|
-
|
|
2731
|
-
|
|
2732
|
-
|
|
2733
|
-
const prevActionsResult = await tx.$queryRawUnsafe(prevApproversQuery, instanceId, step.level);
|
|
2722
|
+
const prevActionsResult = await tx.$queryRaw`
|
|
2723
|
+
SELECT COUNT(*) AS count
|
|
2724
|
+
FROM core_approval_action a
|
|
2725
|
+
JOIN core_approval_instance ai ON ai.id = a.instance_id
|
|
2726
|
+
WHERE ai.id = ${instanceId}
|
|
2727
|
+
AND a.level < ${step.level}
|
|
2728
|
+
AND a.is_active = true
|
|
2729
|
+
AND ai.is_active = true
|
|
2730
|
+
AND a.acted_by IS NOT NULL
|
|
2731
|
+
`;
|
|
2734
2732
|
if (Number(prevActionsResult[0].count) !== step.level - 1) {
|
|
2735
2733
|
throw new this.deps.helpers.ErrorHandler(403, "You must wait for previous approvers to act first");
|
|
2736
2734
|
}
|