law-common 10.48.2 → 10.48.4-beta.0
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/src/api/interface/billing.entity.response.d.ts +1 -0
- package/dist/src/entities/flow-configs/billing.flow.config.d.ts +4 -0
- package/dist/src/entities/flow-configs/billing.flow.config.js +188 -0
- package/dist/src/entities/index.d.ts +1 -0
- package/dist/src/entities/index.js +1 -0
- package/dist/src/enums/error.key.enum.d.ts +2 -1
- package/dist/src/enums/error.key.enum.js +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { IBillingFlowConfig, IBillingFlowContextData } from "../../api";
|
|
2
|
+
import { BillingStatusEnum } from "../enums/billing.status.enum";
|
|
3
|
+
export declare let billingFlowConfig: IBillingFlowConfig;
|
|
4
|
+
export declare function getNextStatusTotalAmount(data: IBillingFlowContextData): BillingStatusEnum;
|
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.billingFlowConfig = void 0;
|
|
4
|
+
exports.getNextStatusTotalAmount = getNextStatusTotalAmount;
|
|
5
|
+
const error_key_enum_1 = require("../../enums/error.key.enum");
|
|
6
|
+
const exceptions_1 = require("../../exceptions");
|
|
7
|
+
const billing_action_enum_1 = require("../enums/billing.action.enum");
|
|
8
|
+
const billing_status_enum_1 = require("../enums/billing.status.enum");
|
|
9
|
+
exports.billingFlowConfig = {
|
|
10
|
+
[billing_status_enum_1.BillingStatusEnum.PENDING_APPROVAL]: {
|
|
11
|
+
actions: {
|
|
12
|
+
[billing_action_enum_1.BillingActionsEnum.APPROVE]: {
|
|
13
|
+
permissions: ["BILLING_APPROVER_ORG", "BILLING_APPROVER_PROJECT"],
|
|
14
|
+
next: () => billing_status_enum_1.BillingStatusEnum.INTERNAL_APPROVED,
|
|
15
|
+
description: "",
|
|
16
|
+
},
|
|
17
|
+
[billing_action_enum_1.BillingActionsEnum.REJECT]: {
|
|
18
|
+
permissions: ["BILLING_APPROVER_ORG", "BILLING_APPROVER_PROJECT"],
|
|
19
|
+
next: () => {
|
|
20
|
+
return billing_status_enum_1.BillingStatusEnum.CANCELLED;
|
|
21
|
+
},
|
|
22
|
+
description: "",
|
|
23
|
+
},
|
|
24
|
+
[billing_action_enum_1.BillingActionsEnum.EDIT]: {
|
|
25
|
+
permissions: ["BILLING_APPROVER_ORG", "BILLING_APPROVER_PROJECT"],
|
|
26
|
+
next: () => {
|
|
27
|
+
return billing_status_enum_1.BillingStatusEnum.PENDING_APPROVAL;
|
|
28
|
+
},
|
|
29
|
+
description: "",
|
|
30
|
+
},
|
|
31
|
+
[billing_action_enum_1.BillingActionsEnum.REQUEST_FOR_CHANGES]: {
|
|
32
|
+
permissions: ["BILLING_APPROVER_ORG", "BILLING_APPROVER_PROJECT"],
|
|
33
|
+
next: () => {
|
|
34
|
+
return billing_status_enum_1.BillingStatusEnum.REQUEST_CHANGES;
|
|
35
|
+
},
|
|
36
|
+
description: "",
|
|
37
|
+
},
|
|
38
|
+
},
|
|
39
|
+
},
|
|
40
|
+
[billing_status_enum_1.BillingStatusEnum.REQUEST_CHANGES]: {
|
|
41
|
+
actions: {
|
|
42
|
+
[billing_action_enum_1.BillingActionsEnum.EDIT]: {
|
|
43
|
+
permissions: ["BILLING_AMENDMENT_ORG"],
|
|
44
|
+
next: () => {
|
|
45
|
+
return billing_status_enum_1.BillingStatusEnum.REQUEST_CHANGES;
|
|
46
|
+
},
|
|
47
|
+
description: "",
|
|
48
|
+
},
|
|
49
|
+
[billing_action_enum_1.BillingActionsEnum.SENT_FOR_APPROVAL]: {
|
|
50
|
+
permissions: ["BILLING_AMENDMENT_ORG"],
|
|
51
|
+
next: () => {
|
|
52
|
+
return billing_status_enum_1.BillingStatusEnum.PENDING_APPROVAL;
|
|
53
|
+
},
|
|
54
|
+
description: "",
|
|
55
|
+
},
|
|
56
|
+
},
|
|
57
|
+
},
|
|
58
|
+
[billing_status_enum_1.BillingStatusEnum.INTERNAL_APPROVED]: {
|
|
59
|
+
actions: {
|
|
60
|
+
[billing_action_enum_1.BillingActionsEnum.SEND_FOR_CLIENT_REVIEW]: {
|
|
61
|
+
permissions: ["BILLING_AMENDMENT_ORG"],
|
|
62
|
+
next: () => {
|
|
63
|
+
return billing_status_enum_1.BillingStatusEnum.PENDING_CLIENT_REVIEW;
|
|
64
|
+
},
|
|
65
|
+
description: "",
|
|
66
|
+
},
|
|
67
|
+
},
|
|
68
|
+
},
|
|
69
|
+
[billing_status_enum_1.BillingStatusEnum.PENDING_CLIENT_REVIEW]: {
|
|
70
|
+
actions: {
|
|
71
|
+
[billing_action_enum_1.BillingActionsEnum.CLIENT_REVISION]: {
|
|
72
|
+
permissions: ["BILLING_AMENDMENT_ORG"],
|
|
73
|
+
next: () => billing_status_enum_1.BillingStatusEnum.CLIENT_REVISION_APPROVAL,
|
|
74
|
+
description: "",
|
|
75
|
+
},
|
|
76
|
+
[billing_action_enum_1.BillingActionsEnum.SEND_INVOICE]: {
|
|
77
|
+
permissions: ["BILLING_AMENDMENT_ORG"],
|
|
78
|
+
next: () => billing_status_enum_1.BillingStatusEnum.PENDING_PAYMENT,
|
|
79
|
+
description: "",
|
|
80
|
+
},
|
|
81
|
+
},
|
|
82
|
+
},
|
|
83
|
+
[billing_status_enum_1.BillingStatusEnum.CLIENT_REVISION_APPROVAL]: {
|
|
84
|
+
actions: {
|
|
85
|
+
[billing_action_enum_1.BillingActionsEnum.APPROVAL]: {
|
|
86
|
+
permissions: ["BILLING_APPROVER_ORG", "BILLING_APPROVER_PROJECT"],
|
|
87
|
+
next: () => billing_status_enum_1.BillingStatusEnum.REQUEST_CHANGES,
|
|
88
|
+
description: "",
|
|
89
|
+
},
|
|
90
|
+
[billing_action_enum_1.BillingActionsEnum.REJECT]: {
|
|
91
|
+
permissions: ["BILLING_APPROVER_ORG", "BILLING_APPROVER_PROJECT"],
|
|
92
|
+
next: () => billing_status_enum_1.BillingStatusEnum.REJECT_CLIENT_REVISION,
|
|
93
|
+
description: "",
|
|
94
|
+
},
|
|
95
|
+
[billing_action_enum_1.BillingActionsEnum.EDIT]: {
|
|
96
|
+
permissions: ["BILLING_APPROVER_ORG", "BILLING_APPROVER_PROJECT"],
|
|
97
|
+
next: () => billing_status_enum_1.BillingStatusEnum.CLIENT_REVISION_APPROVAL,
|
|
98
|
+
description: "",
|
|
99
|
+
},
|
|
100
|
+
[billing_action_enum_1.BillingActionsEnum.REQUEST_FOR_CHANGES]: {
|
|
101
|
+
permissions: ["BILLING_APPROVER_ORG", "BILLING_APPROVER_PROJECT"],
|
|
102
|
+
next: () => billing_status_enum_1.BillingStatusEnum.REQUEST_CHANGES,
|
|
103
|
+
description: "",
|
|
104
|
+
},
|
|
105
|
+
},
|
|
106
|
+
},
|
|
107
|
+
[billing_status_enum_1.BillingStatusEnum.REJECT_CLIENT_REVISION]: {
|
|
108
|
+
actions: {
|
|
109
|
+
[billing_action_enum_1.BillingActionsEnum.SEND_INVOICE]: {
|
|
110
|
+
permissions: ["BILLING_AMENDMENT_ORG"],
|
|
111
|
+
next: () => billing_status_enum_1.BillingStatusEnum.INVOICE_SENT,
|
|
112
|
+
description: "",
|
|
113
|
+
},
|
|
114
|
+
},
|
|
115
|
+
},
|
|
116
|
+
[billing_status_enum_1.BillingStatusEnum.INVOICE_SENT]: {
|
|
117
|
+
actions: {
|
|
118
|
+
[billing_action_enum_1.BillingActionsEnum.UPDATE_PAYMENT]: {
|
|
119
|
+
permissions: ["BILLING_AMENDMENT_ORG"],
|
|
120
|
+
next: (data) => {
|
|
121
|
+
return getNextStatusTotalAmount(data);
|
|
122
|
+
},
|
|
123
|
+
description: "",
|
|
124
|
+
},
|
|
125
|
+
},
|
|
126
|
+
},
|
|
127
|
+
[billing_status_enum_1.BillingStatusEnum.PENDING_PAYMENT]: {
|
|
128
|
+
actions: {
|
|
129
|
+
[billing_action_enum_1.BillingActionsEnum.UPDATE_PAYMENT]: {
|
|
130
|
+
permissions: ["BILLING_AMENDMENT_ORG"],
|
|
131
|
+
next: (data) => {
|
|
132
|
+
return getNextStatusTotalAmount(data);
|
|
133
|
+
},
|
|
134
|
+
description: "",
|
|
135
|
+
},
|
|
136
|
+
// [BillingActionsEnum.CLIENT_REVISION]: {
|
|
137
|
+
// permissions: ["BILLING_AMENDMENT_ORG"],
|
|
138
|
+
// next: () => {
|
|
139
|
+
// return BillingStatusEnum.SETTLED;
|
|
140
|
+
// },
|
|
141
|
+
// },
|
|
142
|
+
},
|
|
143
|
+
},
|
|
144
|
+
[billing_status_enum_1.BillingStatusEnum.SETTLED]: {
|
|
145
|
+
actions: {},
|
|
146
|
+
},
|
|
147
|
+
};
|
|
148
|
+
function getNextStatusTotalAmount(data) {
|
|
149
|
+
var _a, _b, _c, _d;
|
|
150
|
+
const { currentBilling, dto } = data;
|
|
151
|
+
if (!currentBilling) {
|
|
152
|
+
throw new exceptions_1.AppBadRequestException({
|
|
153
|
+
key: error_key_enum_1.ErrorKeyEnum.BILLING,
|
|
154
|
+
message: ["Current billing entity is required"],
|
|
155
|
+
});
|
|
156
|
+
}
|
|
157
|
+
if (!dto) {
|
|
158
|
+
throw new exceptions_1.AppBadRequestException({
|
|
159
|
+
key: error_key_enum_1.ErrorKeyEnum.BILLING,
|
|
160
|
+
message: ["Current billing entity is required"],
|
|
161
|
+
});
|
|
162
|
+
}
|
|
163
|
+
if (Number(currentBilling.totalAmount) ===
|
|
164
|
+
Number((_a = dto.totalAmountPaid) !== null && _a !== void 0 ? _a : currentBilling.totalAmountPaid) +
|
|
165
|
+
Number((_b = dto.creditNoteAmount) !== null && _b !== void 0 ? _b : currentBilling.creditNoteAmount) +
|
|
166
|
+
Number((_c = dto.writeoffAmount) !== null && _c !== void 0 ? _c : currentBilling.writeoffAmount) +
|
|
167
|
+
Number((_d = dto.tdsAmount) !== null && _d !== void 0 ? _d : currentBilling.tdsAmount)) {
|
|
168
|
+
return billing_status_enum_1.BillingStatusEnum.SETTLED;
|
|
169
|
+
}
|
|
170
|
+
else {
|
|
171
|
+
return billing_status_enum_1.BillingStatusEnum.PENDING_PAYMENT;
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
exports.billingFlowConfig = addPdfViewToAllStatuses(exports.billingFlowConfig);
|
|
175
|
+
function addPdfViewToAllStatuses(config) {
|
|
176
|
+
const PDF_VIEW_ACTION = billing_action_enum_1.BillingActionsEnum.PDF_VIEW;
|
|
177
|
+
const pdfViewActionConfig = {
|
|
178
|
+
permissions: ["BILLING_VIEW_PDF"],
|
|
179
|
+
next: (status) => status,
|
|
180
|
+
};
|
|
181
|
+
for (const [status, configEntry] of Object.entries(config)) {
|
|
182
|
+
const actions = configEntry.actions;
|
|
183
|
+
if (!actions[PDF_VIEW_ACTION]) {
|
|
184
|
+
actions[PDF_VIEW_ACTION] = Object.assign(Object.assign({}, pdfViewActionConfig), { next: () => status, description: "" });
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
return config;
|
|
188
|
+
}
|
|
@@ -120,3 +120,4 @@ export * from "./interface/tds_rate.entity.interface";
|
|
|
120
120
|
export * from "./model/tds_rate.entity.model";
|
|
121
121
|
export * from "./model/interface/billing.model.interface";
|
|
122
122
|
export * from "./flow-configs/leave.flow.config";
|
|
123
|
+
export * from "./flow-configs/billing.flow.config";
|
|
@@ -136,3 +136,4 @@ __exportStar(require("./interface/tds_rate.entity.interface"), exports);
|
|
|
136
136
|
__exportStar(require("./model/tds_rate.entity.model"), exports);
|
|
137
137
|
__exportStar(require("./model/interface/billing.model.interface"), exports);
|
|
138
138
|
__exportStar(require("./flow-configs/leave.flow.config"), exports);
|
|
139
|
+
__exportStar(require("./flow-configs/billing.flow.config"), exports);
|