law-common 10.68.2-beta.1 → 10.68.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.
package/README.md CHANGED
@@ -1 +1 @@
1
- # law-common
1
+ # law-common
@@ -211,4 +211,3 @@ export * from "./enums/project-revenue-split-mapping-status.enum";
211
211
  export * from "./enums/project-revenue-split.enum";
212
212
  export * from "./interface/project-revenue-split-mapping.entity";
213
213
  export * from "./model/project-revenue-split-mapping.model";
214
- export * from "./flow-configs/billing-transaction.flow.config";
@@ -227,4 +227,3 @@ __exportStar(require("./enums/project-revenue-split-mapping-status.enum"), expor
227
227
  __exportStar(require("./enums/project-revenue-split.enum"), exports);
228
228
  __exportStar(require("./interface/project-revenue-split-mapping.entity"), exports);
229
229
  __exportStar(require("./model/project-revenue-split-mapping.model"), exports);
230
- __exportStar(require("./flow-configs/billing-transaction.flow.config"), exports);
@@ -1,4 +1,4 @@
1
- import { EntityEnum, IEntityUpdateDto, Nullable } from "../interface/entity.utils.interface";
1
+ import { EntityEnum, Nullable } from "../interface/entity.utils.interface";
2
2
  import { RelationConfigs } from "../interface/relation-config.interface";
3
3
  import { BaseEntityModel } from "./base.entity.model";
4
4
  import { IVendorActionDataDto } from "../../api";
@@ -65,9 +65,7 @@ export declare class VendorEntityModel extends BaseEntityModel<EntityEnum.VENDOR
65
65
  static relationConfigs: RelationConfigs<[EntityEnum.STATE], EntityEnum.VENDOR>;
66
66
  static fromEntity(entity: IVendorEntity): VendorEntityModel;
67
67
  getRelationConfigs(): any[];
68
- getNextStatus(currentUser: IUserEntity, dto: IEntityUpdateDto<IVendorEntity> & {
69
- actionData: IVendorActionDataDto;
70
- }): VendorStatusEnum;
68
+ getNextStatus(currentUser: IUserEntity, actionData: IVendorActionDataDto): VendorStatusEnum;
71
69
  getAvailableActions(currentUser: UserEntityModel, config?: {
72
70
  combinedActions?: Record<string, {
73
71
  combineActions: VendorActionEnum[];
@@ -57,7 +57,7 @@ class VendorEntityModel extends base_entity_model_1.BaseEntityModel {
57
57
  getRelationConfigs() {
58
58
  return this.constructor.prototype.constructor.relationConfigs || [];
59
59
  }
60
- getNextStatus(currentUser, dto) {
60
+ getNextStatus(currentUser, actionData) {
61
61
  if (!this.status) {
62
62
  throw new exceptions_1.AppBadRequestException({
63
63
  key: error_key_enum_1.ErrorKeyEnum.STATUS,
@@ -71,17 +71,17 @@ class VendorEntityModel extends base_entity_model_1.BaseEntityModel {
71
71
  message: [`No flow configuration found for status: ${this.status}`],
72
72
  });
73
73
  }
74
- if (!(dto === null || dto === void 0 ? void 0 : dto.actionData)) {
74
+ if (!actionData) {
75
75
  throw new exceptions_1.AppBadRequestException({
76
76
  key: error_key_enum_1.ErrorKeyEnum.ACTION_DATA,
77
- message: ["dto.actionData is required"],
77
+ message: ["actionData is required"],
78
78
  });
79
79
  }
80
- const matchingPermissionConfig = flowForStatus.actions[dto.actionData.action];
80
+ const matchingPermissionConfig = flowForStatus.actions[actionData.action];
81
81
  if (!matchingPermissionConfig) {
82
82
  throw new exceptions_1.AppBadRequestException({
83
83
  key: error_key_enum_1.ErrorKeyEnum.ACTION,
84
- message: [`Action '${dto.actionData.action}' is not valid for the current status.`],
84
+ message: [`Action '${actionData.action}' is not valid for the current status.`],
85
85
  });
86
86
  }
87
87
  if (!currentUser.permissions || currentUser.permissions.length === 0) {
@@ -94,7 +94,7 @@ class VendorEntityModel extends base_entity_model_1.BaseEntityModel {
94
94
  if (!hasPermission) {
95
95
  throw new exceptions_1.AppBadRequestException({
96
96
  key: error_key_enum_1.ErrorKeyEnum.PERMISSION,
97
- message: [`Current user does not have permission to ${dto.actionData.action} vendor`],
97
+ message: [`Current user does not have permission to ${actionData.action} vendor`],
98
98
  });
99
99
  }
100
100
  const nextStatus = matchingPermissionConfig.next();
package/package.json CHANGED
@@ -1,41 +1,41 @@
1
- {
2
- "name": "law-common",
3
- "version": "10.68.2-beta.1",
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 && npm run link",
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
- },
22
- "keywords": [],
23
- "author": "",
24
- "license": "ISC",
25
- "devDependencies": {
26
- "@types/jest": "^29.5.13",
27
- "@types/lodash": "^4.17.21",
28
- "@types/node": "^22.6.1",
29
- "jest": "^29.7.0",
30
- "prettier": "3.8.1",
31
- "ts-jest": "^29.2.5",
32
- "ts-node": "^10.9.2",
33
- "typescript": "^5.6.2"
34
- },
35
- "dependencies": {
36
- "@types/express": "^5.0.0",
37
- "@types/multer": "^1.4.12",
38
- "date-fns": "^4.1.0",
39
- "lodash": "4.17.21"
40
- }
41
- }
1
+ {
2
+ "name": "law-common",
3
+ "version": "10.68.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 && npm run link",
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
+ },
22
+ "keywords": [],
23
+ "author": "",
24
+ "license": "ISC",
25
+ "devDependencies": {
26
+ "@types/jest": "^29.5.13",
27
+ "@types/lodash": "^4.17.21",
28
+ "@types/node": "^22.6.1",
29
+ "jest": "^29.7.0",
30
+ "prettier": "3.8.1",
31
+ "ts-jest": "^29.2.5",
32
+ "ts-node": "^10.9.2",
33
+ "typescript": "^5.6.2"
34
+ },
35
+ "dependencies": {
36
+ "@types/express": "^5.0.0",
37
+ "@types/multer": "^1.4.12",
38
+ "date-fns": "^4.1.0",
39
+ "lodash": "4.17.21"
40
+ }
41
+ }
@@ -1,2 +0,0 @@
1
- import { IBillingTransactionFlowConfig } from "../../api";
2
- export declare let billingTransactionFlowConfig: IBillingTransactionFlowConfig;
@@ -1,66 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.billingTransactionFlowConfig = void 0;
4
- const billing_transaction_action_enum_1 = require("../enums/billing-transaction-action.enum");
5
- const billing_transaction_status_enum_1 = require("../enums/billing-transaction-status.enum");
6
- const billing_transaction_enum_1 = require("../enums/billing.transaction.enum");
7
- exports.billingTransactionFlowConfig = {
8
- [billing_transaction_status_enum_1.BillingTransactionStatusEnum.APPROVED]: {
9
- actions: {
10
- [billing_transaction_action_enum_1.BillingTransactionActionEnum.EDIT]: {
11
- permissions: ["BILLING_TRANSACTION_UPDATE_SELF"],
12
- next: (data) => decideNextStatus(data),
13
- },
14
- },
15
- },
16
- [billing_transaction_status_enum_1.BillingTransactionStatusEnum.WRITEOFF_APPROVAL_PENDING]: {
17
- actions: {
18
- [billing_transaction_action_enum_1.BillingTransactionActionEnum.APPROVE]: {
19
- permissions: ["BILLING_TRANSACTION_APPROVER_PROJECT", "BILLING_TRANSACTION_APPROVER_ORG"],
20
- next: () => billing_transaction_status_enum_1.BillingTransactionStatusEnum.APPROVED,
21
- },
22
- [billing_transaction_action_enum_1.BillingTransactionActionEnum.REJECT]: {
23
- permissions: ["BILLING_TRANSACTION_APPROVER_PROJECT", "BILLING_TRANSACTION_APPROVER_ORG"],
24
- next: () => billing_transaction_status_enum_1.BillingTransactionStatusEnum.REJECTED,
25
- },
26
- [billing_transaction_action_enum_1.BillingTransactionActionEnum.EDIT]: {
27
- permissions: ["BILLING_TRANSACTION_UPDATE_SELF"],
28
- next: (data) => decideNextStatus(data),
29
- },
30
- },
31
- },
32
- [billing_transaction_status_enum_1.BillingTransactionStatusEnum.CREDITNOTE_APPROVAL_PENDING]: {
33
- actions: {
34
- [billing_transaction_action_enum_1.BillingTransactionActionEnum.APPROVE]: {
35
- permissions: ["BILLING_TRANSACTION_APPROVER_PROJECT", "BILLING_TRANSACTION_APPROVER_ORG"],
36
- next: () => billing_transaction_status_enum_1.BillingTransactionStatusEnum.APPROVED,
37
- },
38
- [billing_transaction_action_enum_1.BillingTransactionActionEnum.REJECT]: {
39
- permissions: ["BILLING_TRANSACTION_APPROVER_PROJECT", "BILLING_TRANSACTION_APPROVER_ORG"],
40
- next: () => billing_transaction_status_enum_1.BillingTransactionStatusEnum.REJECTED,
41
- },
42
- [billing_transaction_action_enum_1.BillingTransactionActionEnum.EDIT]: {
43
- permissions: ["BILLING_TRANSACTION_UPDATE_SELF"],
44
- next: (data) => decideNextStatus(data),
45
- },
46
- },
47
- },
48
- };
49
- function decideNextStatus(data) {
50
- var _a;
51
- const { currentBillingTransactionEntity, dto } = data;
52
- const typeStatusMapping = {
53
- [billing_transaction_enum_1.BillingTransactionType.WRITE_OFF]: billing_transaction_status_enum_1.BillingTransactionStatusEnum.WRITEOFF_APPROVAL_PENDING,
54
- [billing_transaction_enum_1.BillingTransactionType.CREDIT_NOTE]: billing_transaction_status_enum_1.BillingTransactionStatusEnum.CREDITNOTE_APPROVAL_PENDING,
55
- };
56
- if (currentBillingTransactionEntity.type === dto.type) {
57
- return currentBillingTransactionEntity.status;
58
- }
59
- else {
60
- if (dto.type && dto.type in typeStatusMapping) {
61
- return (_a = typeStatusMapping[dto.type]) !== null && _a !== void 0 ? _a : currentBillingTransactionEntity.status;
62
- }
63
- // otherwise → retain current status
64
- return currentBillingTransactionEntity.status;
65
- }
66
- }