law-common 2.8.1-beta.3 → 2.8.1-beta.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.
@@ -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
+ };
@@ -35,10 +35,13 @@ export declare enum ReimbursementActionEnum {
35
35
  DELETE = "delete",
36
36
  APPROVE = "approve",
37
37
  REJECT = "reject",
38
- PAYMENT_DONE = "payment_done"
38
+ UPDATE_PAYMENT = "update_payment"
39
39
  }
40
40
  export declare enum ReimbursementStatusSubRow {
41
41
  APPROVED = "approved",
42
42
  REJECTED = "rejected",
43
43
  PENDING = "pending"
44
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
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";
@@ -45,7 +47,7 @@ var ReimbursementActionEnum;
45
47
  ReimbursementActionEnum["DELETE"] = "delete";
46
48
  ReimbursementActionEnum["APPROVE"] = "approve";
47
49
  ReimbursementActionEnum["REJECT"] = "reject";
48
- ReimbursementActionEnum["PAYMENT_DONE"] = "payment_done";
50
+ ReimbursementActionEnum["UPDATE_PAYMENT"] = "update_payment";
49
51
  })(ReimbursementActionEnum || (exports.ReimbursementActionEnum = ReimbursementActionEnum = {}));
50
52
  var ReimbursementStatusSubRow;
51
53
  (function (ReimbursementStatusSubRow) {
@@ -53,3 +55,30 @@ var ReimbursementStatusSubRow;
53
55
  ReimbursementStatusSubRow["REJECTED"] = "rejected";
54
56
  ReimbursementStatusSubRow["PENDING"] = "pending";
55
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 = {}));
@@ -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.3",
3
+ "version": "2.8.1-beta.5",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "files": [