law-common 11.3.1-beta.2 → 11.3.2

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.
Files changed (57) hide show
  1. package/dist/src/api/index.d.ts +2 -0
  2. package/dist/src/api/index.js +2 -0
  3. package/dist/src/api/interface/state.update.dto.interface.d.ts +6 -3
  4. package/dist/src/api/interface/state.update.dto.interface.js +6 -2
  5. package/dist/src/api/interface/vendor-invoice.entity.response.d.ts +3 -3
  6. package/dist/src/api/interface/vendor-invoice.entity.response.js +2 -2
  7. package/dist/src/api/interface/vendor_invoice.create.dto.interface.d.ts +1 -1
  8. package/dist/src/api/interface/vendor_invoice.update.dto.interface.d.ts +4 -2
  9. package/dist/src/api/interface/vendor_invoice_payment.create.dto.interface.d.ts +5 -0
  10. package/dist/src/api/interface/vendor_invoice_payment.create.dto.interface.js +2 -0
  11. package/dist/src/api/interface/vendor_invoice_payment.update.dto.interface.d.ts +18 -0
  12. package/dist/src/api/interface/vendor_invoice_payment.update.dto.interface.js +13 -0
  13. package/dist/src/constants/billing_constants.js +1 -1
  14. package/dist/src/entities/enums/state_status_enum.d.ts +10 -3
  15. package/dist/src/entities/enums/state_status_enum.js +13 -3
  16. package/dist/src/entities/enums/vendor_invoice_action.enum.d.ts +3 -1
  17. package/dist/src/entities/enums/vendor_invoice_action.enum.js +2 -0
  18. package/dist/src/entities/enums/vendor_invoice_action_status_enum.autocode.js +1 -1
  19. package/dist/src/entities/enums/vendor_invoice_action_status_enum.d.ts +1 -1
  20. package/dist/src/entities/enums/vendor_invoice_action_status_enum.js +13 -13
  21. package/dist/src/entities/enums/vendor_invoice_payment_mode_enum.d.ts +7 -0
  22. package/dist/src/entities/enums/vendor_invoice_payment_mode_enum.js +11 -0
  23. package/dist/src/entities/enums/vendor_invoice_payment_status_enum.d.ts +10 -0
  24. package/dist/src/entities/enums/vendor_invoice_payment_status_enum.js +14 -0
  25. package/dist/src/entities/enums/vendor_invoice_status_enum.autocode.js +1 -1
  26. package/dist/src/entities/enums/vendor_invoice_status_enum.d.ts +1 -1
  27. package/dist/src/entities/enums/vendor_invoice_status_enum.js +6 -6
  28. package/dist/src/entities/flow-configs/state_flow.config.js +263 -58
  29. package/dist/src/entities/flow-configs/vendor-invoice-flow.config.d.ts +11 -2
  30. package/dist/src/entities/flow-configs/vendor-invoice-flow.config.js +136 -197
  31. package/dist/src/entities/flow-configs/vendor_invoice_payment_flow.config.d.ts +6 -0
  32. package/dist/src/entities/flow-configs/vendor_invoice_payment_flow.config.js +205 -0
  33. package/dist/src/entities/index.d.ts +5 -0
  34. package/dist/src/entities/index.js +5 -0
  35. package/dist/src/entities/interface/client_quote.entity.interface.d.ts +3 -9
  36. package/dist/src/entities/interface/client_quote_rate.entity.interface.d.ts +1 -6
  37. package/dist/src/entities/interface/entity.utils.interface.d.ts +5 -2
  38. package/dist/src/entities/interface/entity.utils.interface.js +1 -0
  39. package/dist/src/entities/interface/vendor_invoice.entity.interface.autocode.js +4 -4
  40. package/dist/src/entities/interface/vendor_invoice.entity.interface.d.ts +5 -3
  41. package/dist/src/entities/interface/vendor_invoice_payment.entity.interface.d.ts +14 -0
  42. package/dist/src/entities/interface/vendor_invoice_payment.entity.interface.js +2 -0
  43. package/dist/src/entities/model/client_quote.entity.model.d.ts +2 -8
  44. package/dist/src/entities/model/client_quote.entity.model.js +7 -9
  45. package/dist/src/entities/model/client_quote_rate.entity.model.d.ts +1 -6
  46. package/dist/src/entities/model/client_quote_rate.entity.model.js +1 -6
  47. package/dist/src/entities/model/entity.model.interface.js +2 -0
  48. package/dist/src/entities/model/state.entity.model.js +1 -1
  49. package/dist/src/entities/model/vendor_invoice.entity.model.autocode.js +4 -4
  50. package/dist/src/entities/model/vendor_invoice.entity.model.d.ts +8 -5
  51. package/dist/src/entities/model/vendor_invoice.entity.model.js +99 -51
  52. package/dist/src/entities/model/vendor_invoice_item.entity.model.js +1 -1
  53. package/dist/src/entities/model/vendor_invoice_payment.entity.model.d.ts +62 -0
  54. package/dist/src/entities/model/vendor_invoice_payment.entity.model.js +209 -0
  55. package/dist/src/enums/error.key.enum.d.ts +2 -1
  56. package/dist/src/enums/error.key.enum.js +1 -0
  57. package/package.json +47 -42
@@ -0,0 +1,209 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.VendorInvoicePaymentEntityModel = void 0;
4
+ const entity_utils_interface_1 = require("../interface/entity.utils.interface");
5
+ const base_entity_model_1 = require("./base.entity.model");
6
+ const relation_type_enum_1 = require("../enums/relation-type.enum");
7
+ const exceptions_1 = require("../../exceptions");
8
+ const error_key_enum_1 = require("../../enums/error.key.enum");
9
+ const utils_1 = require("../../utils");
10
+ const vendor_invoice_payment_mode_enum_1 = require("../enums/vendor_invoice_payment_mode_enum");
11
+ const vendor_invoice_payment_status_enum_1 = require("../enums/vendor_invoice_payment_status_enum");
12
+ const vendor_invoice_payment_flow_config_1 = require("../flow-configs/vendor_invoice_payment_flow.config");
13
+ class VendorInvoicePaymentEntityModel extends base_entity_model_1.BaseEntityModel {
14
+ constructor() {
15
+ super(...arguments);
16
+ this.id = 0;
17
+ this.vendorInvoiceId = 0;
18
+ this.paymentDate = 0;
19
+ this.mode = vendor_invoice_payment_mode_enum_1.VendorInvoicePaymentModeEnum.CASH;
20
+ this.amount = 0;
21
+ this.status = vendor_invoice_payment_status_enum_1.VendorInvoicePaymentStatusEnum.DEACTIVATED;
22
+ this.createdOn = 0;
23
+ this.updatedOn = 0;
24
+ this.createdBy = 0;
25
+ this.updatedBy = 0;
26
+ }
27
+ static fromEntity(entity) {
28
+ const result = new VendorInvoicePaymentEntityModel(entity_utils_interface_1.EntityEnum.VENDOR_INVOICE_PAYMENT);
29
+ Object.assign(result, entity);
30
+ return result;
31
+ }
32
+ getRelationConfigs() {
33
+ return this.constructor.prototype.constructor.relationConfigs || [];
34
+ }
35
+ get vendor() {
36
+ // many_to_one -> many_to_one verified
37
+ // {'vendor_invoice_payment->vendor_invoice': 'many_to_one', 'vendor_invoice->vendor': 'many_to_one'}
38
+ // ['vendor_invoice_payment', 'vendor_invoice'] -> many_to_one
39
+ // ['vendor_invoice', 'vendor'] -> many_to_one
40
+ var _a;
41
+ return (_a = this.vendorInvoice) === null || _a === void 0 ? void 0 : _a.vendor;
42
+ }
43
+ get state() {
44
+ // many_to_one -> many_to_one verified
45
+ // {'vendor_invoice_payment->vendor_invoice': 'many_to_one', 'vendor_invoice->vendor': 'many_to_one', 'vendor->state': 'many_to_one'}
46
+ // ['vendor_invoice', 'vendor'] -> many_to_one
47
+ // ['vendor', 'state'] -> many_to_one
48
+ var _a;
49
+ return (_a = this.vendor) === null || _a === void 0 ? void 0 : _a.stateModel;
50
+ }
51
+ get country() {
52
+ // many_to_one -> many_to_one verified
53
+ // {'vendor_invoice_payment->vendor_invoice': 'many_to_one', 'vendor_invoice->vendor': 'many_to_one', 'vendor->country': 'many_to_one'}
54
+ // ['vendor_invoice', 'vendor'] -> many_to_one
55
+ // ['vendor', 'country'] -> many_to_one
56
+ var _a;
57
+ return (_a = this.vendor) === null || _a === void 0 ? void 0 : _a.countryModel;
58
+ }
59
+ get organizationTypes() {
60
+ // many_to_many -> many_to_many verified
61
+ // {'vendor_invoice_payment->vendor_invoice': 'many_to_one', 'vendor_invoice->vendor_invoice_item': 'one_to_many', 'vendor_invoice_item->tds_rate': 'many_to_one', 'tds_rate->organization_type': 'many_to_many'}
62
+ // ['vendor_invoice_item', 'tds_rate'] -> many_to_one
63
+ // ['tds_rate', 'organization_type'] -> many_to_many
64
+ var _a;
65
+ return (_a = this.tdsRates) === null || _a === void 0 ? void 0 : _a.flatMap((tdsRate) => tdsRate.organizationTypes).filter((organizationType) => !!organizationType).reduce((accumulator, current) => {
66
+ if (!accumulator.some((organizationType) => organizationType.id === current.id)) {
67
+ accumulator.push(current);
68
+ }
69
+ return accumulator;
70
+ }, []);
71
+ }
72
+ get vendorInvoiceItems() {
73
+ var _a;
74
+ return (_a = this.vendorInvoice) === null || _a === void 0 ? void 0 : _a.vendorInvoiceItems;
75
+ }
76
+ get tdsRates() {
77
+ // many_to_many -> many_to_many verified
78
+ // {'vendor_invoice_payment->vendor_invoice': 'many_to_one', 'vendor_invoice->vendor_invoice_item': 'one_to_many', 'vendor_invoice_item->tds_rate': 'many_to_one'}
79
+ // ['vendor_invoice', 'vendor_invoice_item'] -> one_to_many
80
+ // ['vendor_invoice_item', 'tds_rate'] -> many_to_one
81
+ var _a;
82
+ return (_a = this.vendorInvoiceItems) === null || _a === void 0 ? void 0 : _a.flatMap((vendorInvoiceItem) => vendorInvoiceItem.tdsRate).filter((tdsRate) => !!tdsRate).reduce((accumulator, current) => {
83
+ if (!accumulator.some((tdsRate) => tdsRate.id === current.id)) {
84
+ accumulator.push(current);
85
+ }
86
+ return accumulator;
87
+ }, []);
88
+ }
89
+ get voucherTypes() {
90
+ // many_to_many -> many_to_many verified
91
+ // {'vendor_invoice_payment->vendor_invoice': 'many_to_one', 'vendor_invoice->vendor_invoice_item': 'one_to_many', 'vendor_invoice_item->voucher_type': 'many_to_one'}
92
+ // ['vendor_invoice', 'vendor_invoice_item'] -> one_to_many
93
+ // ['vendor_invoice_item', 'voucher_type'] -> many_to_one
94
+ var _a;
95
+ return (_a = this.vendorInvoiceItems) === null || _a === void 0 ? void 0 : _a.flatMap((vendorInvoiceItem) => vendorInvoiceItem.voucherType).filter((voucherType) => !!voucherType).reduce((accumulator, current) => {
96
+ if (!accumulator.some((voucherType) => voucherType.id === current.id)) {
97
+ accumulator.push(current);
98
+ }
99
+ return accumulator;
100
+ }, []);
101
+ }
102
+ get expenseHeads() {
103
+ // many_to_many -> many_to_many verified
104
+ // {'vendor_invoice_payment->vendor_invoice': 'many_to_one', 'vendor_invoice->vendor_invoice_item': 'one_to_many', 'vendor_invoice_item->expense_head': 'many_to_one'}
105
+ // ['vendor_invoice', 'vendor_invoice_item'] -> one_to_many
106
+ // ['vendor_invoice_item', 'expense_head'] -> many_to_one
107
+ var _a;
108
+ return (_a = this.vendorInvoiceItems) === null || _a === void 0 ? void 0 : _a.flatMap((vendorInvoiceItem) => vendorInvoiceItem.expenseHead).filter((expenseHead) => !!expenseHead).reduce((accumulator, current) => {
109
+ if (!accumulator.some((expenseHead) => expenseHead.id === current.id)) {
110
+ accumulator.push(current);
111
+ }
112
+ return accumulator;
113
+ }, []);
114
+ }
115
+ get gstRates() {
116
+ // many_to_many -> many_to_many verified
117
+ // {'vendor_invoice_payment->vendor_invoice': 'many_to_one', 'vendor_invoice->vendor_invoice_item': 'one_to_many', 'vendor_invoice_item->gst_rate': 'many_to_one'}
118
+ // ['vendor_invoice', 'vendor_invoice_item'] -> one_to_many
119
+ // ['vendor_invoice_item', 'gst_rate'] -> many_to_one
120
+ var _a;
121
+ return (_a = this.vendorInvoiceItems) === null || _a === void 0 ? void 0 : _a.flatMap((vendorInvoiceItem) => vendorInvoiceItem.gstRate).filter((gstRate) => !!gstRate).reduce((accumulator, current) => {
122
+ if (!accumulator.some((gstRate) => gstRate.id === current.id)) {
123
+ accumulator.push(current);
124
+ }
125
+ return accumulator;
126
+ }, []);
127
+ }
128
+ get officeLocation() {
129
+ // many_to_one -> many_to_one verified
130
+ // {'vendor_invoice_payment->vendor_invoice': 'many_to_one', 'vendor_invoice->office_location': 'many_to_one'}
131
+ // ['vendor_invoice_payment', 'vendor_invoice'] -> many_to_one
132
+ // ['vendor_invoice', 'office_location'] -> many_to_one
133
+ var _a;
134
+ return (_a = this.vendorInvoice) === null || _a === void 0 ? void 0 : _a.officeLocation;
135
+ }
136
+ getNextStatus(currentUser, action, vendorInvoicePaymentFlowConfigContextData) {
137
+ if (!this.status) {
138
+ throw new exceptions_1.AppBadRequestException({
139
+ key: error_key_enum_1.ErrorKeyEnum.STATUS,
140
+ message: [`Status not found: ${this.status}`],
141
+ });
142
+ }
143
+ const flowForStatus = vendor_invoice_payment_flow_config_1.vendorInvoicePaymentFlowConfig[this.status];
144
+ if (!flowForStatus) {
145
+ throw new exceptions_1.AppBadRequestException({
146
+ key: error_key_enum_1.ErrorKeyEnum.STATUS,
147
+ message: [`No flow configuration found for status: ${this.status}`],
148
+ });
149
+ }
150
+ if (!action) {
151
+ throw new exceptions_1.AppBadRequestException({
152
+ key: error_key_enum_1.ErrorKeyEnum.ACTION_DATA,
153
+ message: ["actionData is required"],
154
+ });
155
+ }
156
+ const matchingPermissionConfig = flowForStatus.actions[action];
157
+ if (!matchingPermissionConfig) {
158
+ throw new exceptions_1.AppBadRequestException({
159
+ key: error_key_enum_1.ErrorKeyEnum.ACTION,
160
+ message: [`Action '${action}' is not valid for the current status.`],
161
+ });
162
+ }
163
+ if (!currentUser.permissions || currentUser.permissions.length === 0) {
164
+ throw new exceptions_1.AppBadRequestException({
165
+ key: error_key_enum_1.ErrorKeyEnum.PERMISSIONS,
166
+ message: ["Permission not available for currentUser"],
167
+ });
168
+ }
169
+ const hasPermission = matchingPermissionConfig.permissions.some((permission) => currentUser.permissions.includes(permission));
170
+ if (!hasPermission) {
171
+ throw new exceptions_1.AppBadRequestException({
172
+ key: error_key_enum_1.ErrorKeyEnum.PERMISSION,
173
+ message: [`Current user does not have permission to ${action} vendorInvoicePayment`],
174
+ });
175
+ }
176
+ const nextStatus = matchingPermissionConfig.next(vendorInvoicePaymentFlowConfigContextData);
177
+ return nextStatus;
178
+ }
179
+ getAvailableActions(currentUser, config) {
180
+ var _a;
181
+ const params = {
182
+ flowConfig: vendor_invoice_payment_flow_config_1.vendorInvoicePaymentFlowConfig,
183
+ currentStatus: this.status,
184
+ userPermissions: (_a = currentUser.permissions) !== null && _a !== void 0 ? _a : [],
185
+ visibilityData: this.getUpdateActionVisibility.bind(this, currentUser),
186
+ combinedActions: config === null || config === void 0 ? void 0 : config.combinedActions,
187
+ customLabels: config === null || config === void 0 ? void 0 : config.customLabels,
188
+ };
189
+ return utils_1.EntityActionFlowResolverV2.getAvailableActionsData(params);
190
+ }
191
+ getUpdateActionVisibility(currentUser) {
192
+ return {};
193
+ }
194
+ static getTotalAmount(vendorInvoicePayments) {
195
+ return vendorInvoicePayments.reduce((total, payment) => total + payment.amount, 0);
196
+ }
197
+ }
198
+ exports.VendorInvoicePaymentEntityModel = VendorInvoicePaymentEntityModel;
199
+ VendorInvoicePaymentEntityModel.relationConfigs = [
200
+ {
201
+ name: entity_utils_interface_1.EntityEnum.VENDOR_INVOICE,
202
+ relation: relation_type_enum_1.RelationType.ONE,
203
+ key: "vendorInvoice",
204
+ mapKeyConfig: {
205
+ relationKey: "id",
206
+ key: "vendorInvoiceId",
207
+ },
208
+ },
209
+ ];
@@ -34,5 +34,6 @@ export declare enum ErrorKeyEnum {
34
34
  BILLING_EXPORT_TYPE = "BILLING_EXPORT_TYPE",
35
35
  VENDOR_INVOICE_ITEMS = "VENDOR_INVOICE_ITEMS",
36
36
  PROJECT_USER_MAPPING = "PROJECT_USER_MAPPING",
37
- CONFIGURATION_KEY = "CONFIGURATION_KEY"
37
+ CONFIGURATION_KEY = "CONFIGURATION_KEY",
38
+ VENDOR_INVOICE_FLOW_CONTEXT_DATA = "VENDOR_INVOICE_FLOW_CONTEXT_DATA"
38
39
  }
@@ -39,4 +39,5 @@ var ErrorKeyEnum;
39
39
  ErrorKeyEnum["VENDOR_INVOICE_ITEMS"] = "VENDOR_INVOICE_ITEMS";
40
40
  ErrorKeyEnum["PROJECT_USER_MAPPING"] = "PROJECT_USER_MAPPING";
41
41
  ErrorKeyEnum["CONFIGURATION_KEY"] = "CONFIGURATION_KEY";
42
+ ErrorKeyEnum["VENDOR_INVOICE_FLOW_CONTEXT_DATA"] = "VENDOR_INVOICE_FLOW_CONTEXT_DATA";
42
43
  })(ErrorKeyEnum || (exports.ErrorKeyEnum = ErrorKeyEnum = {}));
package/package.json CHANGED
@@ -1,42 +1,47 @@
1
- {
2
- "name": "law-common",
3
- "version": "11.3.1-beta.2",
4
- "description": "",
5
- "main": "dist/index.js",
6
- "files": [
7
- "dist/**/*"
8
- ],
9
- "scripts": {
10
- "clean": "rm -rf dist",
11
- "build": "npm run clean && tsc",
12
- "publish:beta": "npm version prerelease --preid beta && git push && npm run build && npm publish --tag beta",
13
- "publish:patch": "npm version patch && git push && npm run build && npm publish",
14
- "publish:minor": "npm version minor && git push && npm run build && npm publish",
15
- "publish:major": "npm version major && git push && npm run build && npm publish",
16
- "link": "npm run build && npm link",
17
- "test": "jest",
18
- "format": "prettier --write .",
19
- "check-format": "prettier --check .",
20
- "pull:link": "git pull && npm run link",
21
- "check-version": "npm view law-common versions --json | jq -r '.[-1]'"
22
- },
23
- "keywords": [],
24
- "author": "",
25
- "license": "ISC",
26
- "devDependencies": {
27
- "@types/jest": "^29.5.13",
28
- "@types/lodash": "^4.17.21",
29
- "@types/node": "^22.6.1",
30
- "jest": "^29.7.0",
31
- "prettier": "3.8.1",
32
- "ts-jest": "^29.2.5",
33
- "ts-node": "^10.9.2",
34
- "typescript": "^5.6.2"
35
- },
36
- "dependencies": {
37
- "@types/express": "^5.0.0",
38
- "@types/multer": "^1.4.12",
39
- "date-fns": "^4.1.0",
40
- "lodash": "4.17.21"
41
- }
42
- }
1
+ {
2
+ "name": "law-common",
3
+ "version": "11.3.2",
4
+ "description": "",
5
+ "main": "dist/index.js",
6
+ "files": [
7
+ "dist/**/*"
8
+ ],
9
+ "scripts": {
10
+ "clean": "rm -rf dist",
11
+ "build": "npm run clean && tsc",
12
+ "publish:beta": "npm run build && npm version prerelease --preid beta && git push && npm publish --tag beta",
13
+ "publish:beta:link": "npm run build && npm version prerelease --preid beta && git push && npm publish --tag beta && npm run link",
14
+ "publish:patch": "npm version patch && git push && npm run build && npm publish",
15
+ "publish:minor": "npm version minor && git push && npm run build && npm publish",
16
+ "publish:major": "npm verYsion major && git push && npm run build && npm publish",
17
+ "link": "npm run build && npm link",
18
+ "test": "jest",
19
+ "format": "prettier --write .",
20
+ "check-format": "prettier --check .",
21
+ "pull:link": "git pull && npm run link",
22
+ "check-version": "npm view law-common versions --json | jq -r '.[-1]'",
23
+ "script:publish": "node scripts/publish.js",
24
+ "script:publish:latest:beta": "npm run build && node scripts/publish.js prerelease beta && git push",
25
+ "script:publish:latest:patch": "npm run build && node scripts/publish.js patch && git push"
26
+ },
27
+ "keywords": [],
28
+ "author": "",
29
+ "license": "ISC",
30
+ "devDependencies": {
31
+ "@types/jest": "^29.5.13",
32
+ "@types/lodash": "^4.17.21",
33
+ "@types/node": "^22.6.1",
34
+ "jest": "^29.7.0",
35
+ "prettier": "3.8.1",
36
+ "semver": "^7.8.1",
37
+ "ts-jest": "^29.2.5",
38
+ "ts-node": "^10.9.2",
39
+ "typescript": "^5.6.2"
40
+ },
41
+ "dependencies": {
42
+ "@types/express": "^5.0.0",
43
+ "@types/multer": "^1.4.12",
44
+ "date-fns": "^4.1.0",
45
+ "lodash": "4.17.21"
46
+ }
47
+ }