law-common 2.6.0 → 2.6.1-beta.1

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,6 +1,7 @@
1
- import { IAuditColumnEntity, IBillingTimesheetDetail, PaymentStatusEnum, BillingStatusEnum } from "../../entities";
1
+ import { BillingActionsEnum, BillingStatusEnum, IAuditColumnEntity, IBillingEntity, IBillingTimesheetDetail, PaymentStatusEnum } from "../../entities";
2
2
  import { IBillingApiEntity } from "./billing.entity.api";
3
3
  import { IBillingTimesheetApiEntity } from "./billing.timesheet.entity.api";
4
+ import { IUpdateBillingDto } from "./billing.update.dto.interface";
4
5
  export interface IBillingEntityResponse extends IAuditColumnEntity {
5
6
  id: number;
6
7
  startDate: string;
@@ -39,3 +40,17 @@ export type IBillingEntityUpdateGet = {
39
40
  timesheets: IBillingTimesheetApiEntity[];
40
41
  };
41
42
  export type IBillingEntityGetArray = IBillingEntityGet[];
43
+ export type IBillingFlowConfig = {
44
+ [key in BillingStatusEnum]?: {
45
+ actions: {
46
+ [key in BillingActionsEnum]?: {
47
+ permissions: string[];
48
+ next: (data: IBillingFlowContextData) => BillingStatusEnum;
49
+ };
50
+ };
51
+ };
52
+ };
53
+ export type IBillingFlowContextData = {
54
+ currentBilling?: IBillingEntity;
55
+ dto?: IUpdateBillingDto;
56
+ };
@@ -13,3 +13,6 @@ export declare enum BillingActionsEnum {
13
13
  WRITE_OFF = "writeOff",
14
14
  TDS = "tds"
15
15
  }
16
+ export declare namespace BillingActionsEnum {
17
+ function getLabel(action: BillingActionsEnum): string;
18
+ }
@@ -1,6 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.BillingActionsEnum = void 0;
4
+ const error_key_enum_1 = require("../../enums/error.key.enum");
5
+ const exceptions_1 = require("../../exceptions");
4
6
  var BillingActionsEnum;
5
7
  (function (BillingActionsEnum) {
6
8
  BillingActionsEnum["APPROVE"] = "approve";
@@ -17,3 +19,37 @@ var BillingActionsEnum;
17
19
  BillingActionsEnum["WRITE_OFF"] = "writeOff";
18
20
  BillingActionsEnum["TDS"] = "tds";
19
21
  })(BillingActionsEnum || (exports.BillingActionsEnum = BillingActionsEnum = {}));
22
+ (function (BillingActionsEnum) {
23
+ const actionLabelMap = {
24
+ [BillingActionsEnum.APPROVE]: "Approve",
25
+ [BillingActionsEnum.REJECT]: "Reject",
26
+ [BillingActionsEnum.EDIT]: "Edit",
27
+ [BillingActionsEnum.REQUEST_FOR_CHANGES]: "Request for Changes",
28
+ [BillingActionsEnum.SENT_FOR_APPROVAL]: "Sent for Approval",
29
+ [BillingActionsEnum.SEND_FOR_CLIENT_REVIEW]: "Send for Client Review",
30
+ [BillingActionsEnum.CLIENT_REVISION]: "Client Revision",
31
+ [BillingActionsEnum.SEND_INVOICE]: "Send Invoice",
32
+ [BillingActionsEnum.APPROVAL]: "Approval",
33
+ [BillingActionsEnum.UPDATE_PAYMENT]: "Update Payment",
34
+ [BillingActionsEnum.CREDIT_NOTE]: "Credit Note",
35
+ [BillingActionsEnum.WRITE_OFF]: "Write Off",
36
+ [BillingActionsEnum.TDS]: "TDS",
37
+ };
38
+ function getLabel(action) {
39
+ if (!Object.values(BillingActionsEnum).includes(action)) {
40
+ throw new exceptions_1.AppBadRequestException({
41
+ key: error_key_enum_1.ErrorKeyEnum.BILLING_FLOW_ACTION,
42
+ message: ["Invalid action value"],
43
+ });
44
+ }
45
+ const label = actionLabelMap[action];
46
+ if (!label) {
47
+ throw new exceptions_1.AppBadRequestException({
48
+ key: error_key_enum_1.ErrorKeyEnum.BILLING_FLOW_ACTION,
49
+ message: ["Invalid action value"],
50
+ });
51
+ }
52
+ return label;
53
+ }
54
+ BillingActionsEnum.getLabel = getLabel;
55
+ })(BillingActionsEnum || (exports.BillingActionsEnum = BillingActionsEnum = {}));
@@ -1,7 +1,6 @@
1
1
  export declare enum BillingStatusEnum {
2
2
  PENDING_APPROVAL = "PENDING_APPROVAL",
3
3
  REQUEST_CHANGES = "REQUEST_CHANGES",
4
- CHANGES_SAVED = "CHANGES_SAVED",
5
4
  INTERNAL_APPROVED = "INTERNAL_APPROVED",
6
5
  PENDING_CLIENT_REVIEW = "PENDING_CLIENT_REVIEW",
7
6
  CLIENT_REVISION_APPROVAL = "CLIENT_REVISION_APPROVAL",
@@ -9,5 +8,5 @@ export declare enum BillingStatusEnum {
9
8
  REJECT_CLIENT_REVISION = "REJECT_CLIENT_REVISION",
10
9
  INVOICE_SENT = "INVOICE_SENT",
11
10
  PENDING_PAYMENT = "PENDING_PAYMENT",
12
- PAYMENT_DONE = "PAYMENT_DONE"
11
+ SETTLED = "SETTLED"
13
12
  }
@@ -5,7 +5,6 @@ var BillingStatusEnum;
5
5
  (function (BillingStatusEnum) {
6
6
  BillingStatusEnum["PENDING_APPROVAL"] = "PENDING_APPROVAL";
7
7
  BillingStatusEnum["REQUEST_CHANGES"] = "REQUEST_CHANGES";
8
- BillingStatusEnum["CHANGES_SAVED"] = "CHANGES_SAVED";
9
8
  BillingStatusEnum["INTERNAL_APPROVED"] = "INTERNAL_APPROVED";
10
9
  BillingStatusEnum["PENDING_CLIENT_REVIEW"] = "PENDING_CLIENT_REVIEW";
11
10
  BillingStatusEnum["CLIENT_REVISION_APPROVAL"] = "CLIENT_REVISION_APPROVAL";
@@ -13,5 +12,5 @@ var BillingStatusEnum;
13
12
  BillingStatusEnum["REJECT_CLIENT_REVISION"] = "REJECT_CLIENT_REVISION";
14
13
  BillingStatusEnum["INVOICE_SENT"] = "INVOICE_SENT";
15
14
  BillingStatusEnum["PENDING_PAYMENT"] = "PENDING_PAYMENT";
16
- BillingStatusEnum["PAYMENT_DONE"] = "PAYMENT_DONE";
15
+ BillingStatusEnum["SETTLED"] = "SETTLED";
17
16
  })(BillingStatusEnum || (exports.BillingStatusEnum = BillingStatusEnum = {}));
@@ -1,4 +1,4 @@
1
1
  export declare enum PaymentStatusEnum {
2
2
  PENDING = "pending",
3
- COMPLETED = "completed"
3
+ SETTLED = "settled"
4
4
  }
@@ -4,5 +4,5 @@ exports.PaymentStatusEnum = void 0;
4
4
  var PaymentStatusEnum;
5
5
  (function (PaymentStatusEnum) {
6
6
  PaymentStatusEnum["PENDING"] = "pending";
7
- PaymentStatusEnum["COMPLETED"] = "completed";
7
+ PaymentStatusEnum["SETTLED"] = "settled";
8
8
  })(PaymentStatusEnum || (exports.PaymentStatusEnum = PaymentStatusEnum = {}));
@@ -1,10 +1,7 @@
1
- import { IUpdateBillingDto } from "../../api";
2
- import { BillingActionsEnum } from "../enums/billing.action.enum";
3
1
  import { BillingImpactEnum } from "../enums/billing.impact.enum";
4
2
  import { BillingStatusEnum } from "../enums/billing.status.enum";
5
3
  import { BillingTimesheetStatusEnum } from "../enums/billing.timesheet.change.status.enum";
6
4
  import { PaymentStatusEnum } from "../enums/payment_status.enum";
7
- import { UserRoleEnum } from "../enums/user.entity.enum";
8
5
  import { IAuditColumnEntity } from "./audit-column.entity.interface";
9
6
  import { IEntityCreateDto, IEntityFilterData } from "./entity.utils.interface";
10
7
  export interface IBillingEntity extends IAuditColumnEntity {
@@ -59,14 +56,3 @@ export interface IBillingEntityFilterDto extends IEntityFilterData<IBillingEntit
59
56
  }
60
57
  export interface IBillingTimesheetEntityFilterDto extends IEntityFilterData<IBillingTimesheetEntity> {
61
58
  }
62
- export type IBillingFlowConfig = {
63
- [key in BillingStatusEnum]?: Array<{
64
- roles: UserRoleEnum[];
65
- actions: {
66
- [key in BillingActionsEnum]?: {
67
- label: string;
68
- next: (currentBilling?: IBillingEntity, dto?: IUpdateBillingDto) => BillingStatusEnum;
69
- };
70
- };
71
- }>;
72
- };
@@ -1,5 +1,6 @@
1
1
  export declare enum ErrorKeyEnum {
2
2
  TIME_UNIT = "TIME_UNIT",
3
3
  CURRENCY = "CURRENCY",
4
- TIMESHEET_FLOW_ACTION = "TIMESHEET_FLOW_ACTION"
4
+ TIMESHEET_FLOW_ACTION = "TIMESHEET_FLOW_ACTION",
5
+ BILLING_FLOW_ACTION = "BILLING_FLOW_ACTION"
5
6
  }
@@ -6,4 +6,5 @@ var ErrorKeyEnum;
6
6
  ErrorKeyEnum["TIME_UNIT"] = "TIME_UNIT";
7
7
  ErrorKeyEnum["CURRENCY"] = "CURRENCY";
8
8
  ErrorKeyEnum["TIMESHEET_FLOW_ACTION"] = "TIMESHEET_FLOW_ACTION";
9
+ ErrorKeyEnum["BILLING_FLOW_ACTION"] = "BILLING_FLOW_ACTION";
9
10
  })(ErrorKeyEnum || (exports.ErrorKeyEnum = ErrorKeyEnum = {}));
package/package.json CHANGED
@@ -1,35 +1,35 @@
1
- {
2
- "name": "law-common",
3
- "version": "2.6.0",
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
- },
19
- "keywords": [],
20
- "author": "",
21
- "license": "ISC",
22
- "devDependencies": {
23
- "@types/jest": "^29.5.13",
24
- "@types/node": "^22.6.1",
25
- "jest": "^29.7.0",
26
- "ts-jest": "^29.2.5",
27
- "ts-node": "^10.9.2",
28
- "typescript": "^5.6.2"
29
- },
30
- "dependencies": {
31
- "@types/express": "^5.0.0",
32
- "@types/multer": "^1.4.12",
33
- "date-fns": "^4.1.0"
34
- }
35
- }
1
+ {
2
+ "name": "law-common",
3
+ "version": "2.6.1-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",
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
+ },
19
+ "keywords": [],
20
+ "author": "",
21
+ "license": "ISC",
22
+ "devDependencies": {
23
+ "@types/jest": "^29.5.13",
24
+ "@types/node": "^22.6.1",
25
+ "jest": "^29.7.0",
26
+ "ts-jest": "^29.2.5",
27
+ "ts-node": "^10.9.2",
28
+ "typescript": "^5.6.2"
29
+ },
30
+ "dependencies": {
31
+ "@types/express": "^5.0.0",
32
+ "@types/multer": "^1.4.12",
33
+ "date-fns": "^4.1.0"
34
+ }
35
+ }