law-common 2.8.1-beta.2 → 2.8.1-beta.4

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.
@@ -1,4 +1,4 @@
1
- import { IApiEntity, IReimbursementEntity } from "../../entities";
1
+ import { IApiEntity, IReimbursementEntity, ReimbursementStatusEnum } from "../../entities";
2
2
  import { IProjectEntityGet } from "./project.entity.response";
3
3
  import { IUserApiEntity } from "./user.entity.api";
4
4
  export type IReimbursementApiEntity = IApiEntity<IReimbursementEntity>;
@@ -10,3 +10,13 @@ export type IReimbursementEntityGet = {
10
10
  };
11
11
  projects: IProjectEntityGet;
12
12
  };
13
+ export type IReimbursementFlowConfig = {
14
+ [key in ReimbursementStatusEnum]?: {
15
+ actions: {
16
+ [key in string]?: {
17
+ permissions: string[];
18
+ next?: (newReimbursementEntity: IReimbursementEntity) => ReimbursementStatusEnum;
19
+ };
20
+ };
21
+ };
22
+ };
@@ -17,7 +17,8 @@ export declare enum ReimbursementStatusEnum {
17
17
  REJECTED = "REJECTED",
18
18
  PARTIALLY_APPROVED = "PARTIALLY_APPROVED",
19
19
  PAYMENT_PENDING = "PAYMENT_PENDING",
20
- PAYMENT_DISBURSE = "PAYMENT_DISBURSE"
20
+ PAYMENT_DISBURSE = "PAYMENT_DISBURSE",
21
+ DELETED = "DELETED"
21
22
  }
22
23
  export declare enum ReimbursementSubRowState {
23
24
  PENDING = "pending",
@@ -34,18 +35,13 @@ export declare enum ReimbursementActionEnum {
34
35
  DELETE = "delete",
35
36
  APPROVE = "approve",
36
37
  REJECT = "reject",
37
- PAYMENT_DONE = "payment_done"
38
- }
39
- export declare enum ReimbursementStatusEnumMainRow {
40
- APPROVAL_PENDING = "approval_pending",
41
- APPROVED = "approved",
42
- REJECTED = "rejected",
43
- PARTIALLY_APPROVED = "partially_approved",
44
- PAYMENT_PENDING = "payment_pending",
45
- PAYMENT_DISBURSE = "payment_disburse"
38
+ UPDATE_PAYMENT = "update_payment"
46
39
  }
47
40
  export declare enum ReimbursementStatusSubRow {
48
41
  APPROVED = "approved",
49
42
  REJECTED = "rejected",
50
43
  PENDING = "pending"
51
44
  }
45
+ export declare namespace ReimbursementActionEnum {
46
+ function getLabel(action: ReimbursementActionEnum): string;
47
+ }
@@ -1,6 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ReimbursementStatusSubRow = exports.ReimbursementStatusEnumMainRow = exports.ReimbursementActionEnum = exports.ReimbursementPaymentStatusEnum = exports.ReimbursementSubRowState = exports.ReimbursementStatusEnum = exports.ReimbursementIncurredByEnum = exports.ReimbursementBillingPresentEnum = exports.ReimbursementBillingTypeEnum = void 0;
3
+ exports.ReimbursementStatusSubRow = exports.ReimbursementActionEnum = exports.ReimbursementPaymentStatusEnum = exports.ReimbursementSubRowState = exports.ReimbursementStatusEnum = exports.ReimbursementIncurredByEnum = exports.ReimbursementBillingPresentEnum = exports.ReimbursementBillingTypeEnum = void 0;
4
+ const error_key_enum_1 = require("../../enums/error.key.enum");
5
+ const exceptions_1 = require("../../exceptions");
4
6
  var ReimbursementBillingTypeEnum;
5
7
  (function (ReimbursementBillingTypeEnum) {
6
8
  ReimbursementBillingTypeEnum["BILLABLE"] = "BILLABLE";
@@ -25,6 +27,7 @@ var ReimbursementStatusEnum;
25
27
  ReimbursementStatusEnum["PARTIALLY_APPROVED"] = "PARTIALLY_APPROVED";
26
28
  ReimbursementStatusEnum["PAYMENT_PENDING"] = "PAYMENT_PENDING";
27
29
  ReimbursementStatusEnum["PAYMENT_DISBURSE"] = "PAYMENT_DISBURSE";
30
+ ReimbursementStatusEnum["DELETED"] = "DELETED";
28
31
  })(ReimbursementStatusEnum || (exports.ReimbursementStatusEnum = ReimbursementStatusEnum = {}));
29
32
  var ReimbursementSubRowState;
30
33
  (function (ReimbursementSubRowState) {
@@ -44,20 +47,38 @@ var ReimbursementActionEnum;
44
47
  ReimbursementActionEnum["DELETE"] = "delete";
45
48
  ReimbursementActionEnum["APPROVE"] = "approve";
46
49
  ReimbursementActionEnum["REJECT"] = "reject";
47
- ReimbursementActionEnum["PAYMENT_DONE"] = "payment_done";
50
+ ReimbursementActionEnum["UPDATE_PAYMENT"] = "update_payment";
48
51
  })(ReimbursementActionEnum || (exports.ReimbursementActionEnum = ReimbursementActionEnum = {}));
49
- var ReimbursementStatusEnumMainRow;
50
- (function (ReimbursementStatusEnumMainRow) {
51
- ReimbursementStatusEnumMainRow["APPROVAL_PENDING"] = "approval_pending";
52
- ReimbursementStatusEnumMainRow["APPROVED"] = "approved";
53
- ReimbursementStatusEnumMainRow["REJECTED"] = "rejected";
54
- ReimbursementStatusEnumMainRow["PARTIALLY_APPROVED"] = "partially_approved";
55
- ReimbursementStatusEnumMainRow["PAYMENT_PENDING"] = "payment_pending";
56
- ReimbursementStatusEnumMainRow["PAYMENT_DISBURSE"] = "payment_disburse";
57
- })(ReimbursementStatusEnumMainRow || (exports.ReimbursementStatusEnumMainRow = ReimbursementStatusEnumMainRow = {}));
58
52
  var ReimbursementStatusSubRow;
59
53
  (function (ReimbursementStatusSubRow) {
60
54
  ReimbursementStatusSubRow["APPROVED"] = "approved";
61
55
  ReimbursementStatusSubRow["REJECTED"] = "rejected";
62
56
  ReimbursementStatusSubRow["PENDING"] = "pending";
63
57
  })(ReimbursementStatusSubRow || (exports.ReimbursementStatusSubRow = ReimbursementStatusSubRow = {}));
58
+ (function (ReimbursementActionEnum) {
59
+ const actionLabelMap = {
60
+ [ReimbursementActionEnum.VIEW]: "View",
61
+ [ReimbursementActionEnum.EDIT]: "Edit",
62
+ [ReimbursementActionEnum.DELETE]: "Delete",
63
+ [ReimbursementActionEnum.APPROVE]: "Approve",
64
+ [ReimbursementActionEnum.REJECT]: "Reject",
65
+ [ReimbursementActionEnum.UPDATE_PAYMENT]: "Update Payment",
66
+ };
67
+ function getLabel(action) {
68
+ if (!Object.values(ReimbursementActionEnum).includes(action)) {
69
+ throw new exceptions_1.AppBadRequestException({
70
+ key: error_key_enum_1.ErrorKeyEnum.REIMBURSEMENT_FLOW_ACTION,
71
+ message: ["Invalid action value"],
72
+ });
73
+ }
74
+ const label = actionLabelMap[action];
75
+ if (!label) {
76
+ throw new exceptions_1.AppBadRequestException({
77
+ key: error_key_enum_1.ErrorKeyEnum.REIMBURSEMENT_FLOW_ACTION,
78
+ message: ["Invalid action value"],
79
+ });
80
+ }
81
+ return label;
82
+ }
83
+ ReimbursementActionEnum.getLabel = getLabel;
84
+ })(ReimbursementActionEnum || (exports.ReimbursementActionEnum = ReimbursementActionEnum = {}));
@@ -28,7 +28,7 @@ export interface IReimbursementExpenseDetails {
28
28
  details?: IReimbursementExpenseAllocation[];
29
29
  }
30
30
  export interface IReimbursementExpenseAllocation {
31
- userIds: number[];
31
+ userId: number;
32
32
  projectId: number;
33
33
  amount: number;
34
34
  state?: ReimbursementSubRowState;
@@ -49,3 +49,6 @@ export interface IReimbursementActionDataDto {
49
49
  action: ReimbursementActionEnum;
50
50
  remark?: string;
51
51
  }
52
+ export interface IReimbursementUpdateDto extends IEntityUpdateDto<IReimbursementEntity> {
53
+ actionData: IReimbursementActionDataDto;
54
+ }
@@ -2,5 +2,6 @@ export declare enum ErrorKeyEnum {
2
2
  TIME_UNIT = "TIME_UNIT",
3
3
  CURRENCY = "CURRENCY",
4
4
  TIMESHEET_FLOW_ACTION = "TIMESHEET_FLOW_ACTION",
5
- BILLING_FLOW_ACTION = "BILLING_FLOW_ACTION"
5
+ BILLING_FLOW_ACTION = "BILLING_FLOW_ACTION",
6
+ REIMBURSEMENT_FLOW_ACTION = "REIMBURSEMENT_FLOW_ACTION"
6
7
  }
@@ -7,4 +7,5 @@ var ErrorKeyEnum;
7
7
  ErrorKeyEnum["CURRENCY"] = "CURRENCY";
8
8
  ErrorKeyEnum["TIMESHEET_FLOW_ACTION"] = "TIMESHEET_FLOW_ACTION";
9
9
  ErrorKeyEnum["BILLING_FLOW_ACTION"] = "BILLING_FLOW_ACTION";
10
+ ErrorKeyEnum["REIMBURSEMENT_FLOW_ACTION"] = "REIMBURSEMENT_FLOW_ACTION";
10
11
  })(ErrorKeyEnum || (exports.ErrorKeyEnum = ErrorKeyEnum = {}));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "law-common",
3
- "version": "2.8.1-beta.2",
3
+ "version": "2.8.1-beta.4",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "files": [