law-common 13.0.1-beta.9 → 13.0.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/dist/src/api/interface/bank.entity.response.d.ts +8 -11
- package/dist/src/api/interface/document_upload.create.dto.interface.d.ts +2 -1
- package/dist/src/api/interface/reimbursement.entity.response.d.ts +9 -23
- package/dist/src/api/interface/timesheet.entity.response.interface.d.ts +7 -13
- package/dist/src/entities/enums/document_upload_status_enum.d.ts +5 -0
- package/dist/src/entities/enums/document_upload_status_enum.js +9 -0
- package/dist/src/entities/flow-configs/bank_flow.config.d.ts +9 -0
- package/dist/src/entities/flow-configs/bank_flow.config.js +110 -0
- package/dist/src/entities/flow-configs/base-flow-config.factory.d.ts +20 -1
- package/dist/src/entities/flow-configs/base-flow-config.factory.js +1 -16
- package/dist/src/entities/flow-configs/{billing.flow.config.d.ts → billing_flow.config.d.ts} +1 -1
- package/dist/src/entities/flow-configs/billing_flow.config.js +305 -0
- package/dist/src/entities/flow-configs/billing_transaction_flow.config.d.ts +24 -0
- package/dist/src/entities/flow-configs/billing_transaction_flow.config.js +111 -0
- package/dist/src/entities/flow-configs/flow-config.type.d.ts +26 -2
- package/dist/src/entities/flow-configs/leave_flow.config.d.ts +7 -0
- package/dist/src/entities/flow-configs/leave_flow.config.js +117 -65
- package/dist/src/entities/flow-configs/moving_timesheet_flow.config.js +21 -8
- package/dist/src/entities/flow-configs/reimbursement_expense_flow.config.d.ts +8 -0
- package/dist/src/entities/flow-configs/reimbursement_expense_flow.config.js +64 -0
- package/dist/src/entities/flow-configs/reimbursement_flow.config.d.ts +17 -0
- package/dist/src/entities/flow-configs/reimbursement_flow.config.js +131 -0
- package/dist/src/entities/flow-configs/timesheet_flow.config.d.ts +5 -0
- package/dist/src/entities/flow-configs/timesheet_flow.config.js +420 -0
- package/dist/src/entities/flow-configs/vendor_flow.config.js +74 -60
- package/dist/src/entities/index.d.ts +7 -2
- package/dist/src/entities/index.js +7 -2
- package/dist/src/entities/interface/document_upload.entity.interface.d.ts +2 -0
- package/dist/src/entities/interface/field-constraint/document_upload_field_constraints.interface.d.ts +1 -1
- package/dist/src/entities/model/document_upload.entity.model.d.ts +2 -0
- package/dist/src/entities/model/document_upload.entity.model.js +2 -0
- package/package.json +1 -1
- package/dist/src/entities/flow-configs/billing.flow.config.js +0 -209
- package/dist/src/entities/flow-configs/billing_transaction.flow.config.d.ts +0 -19
- package/dist/src/entities/flow-configs/billing_transaction.flow.config.js +0 -83
|
@@ -1,14 +1,11 @@
|
|
|
1
|
-
import { BankActionEnum, BankStatusEnum, IBankEntity, IIntermediaryBankEntity } from "../../entities";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
};
|
|
10
|
-
};
|
|
11
|
-
};
|
|
1
|
+
import { BankActionEnum, BankStatusEnum, FlowConfig, IBankEntity, IIntermediaryBankEntity } from "../../entities";
|
|
2
|
+
/**
|
|
3
|
+
* LW-828: this used to re-declare the flow-config shape by hand. It is now an alias of the shared
|
|
4
|
+
* `FlowConfig`, instantiated with `void` as the context type because `next` here is called with no
|
|
5
|
+
* arguments (`BankService.getBankNextStatus`). Kept as a named type so every consumer — including
|
|
6
|
+
* law-admin-web, which receives this config over `GET /bank/flow-config` — keeps compiling unchanged.
|
|
7
|
+
*/
|
|
8
|
+
export type IBankFlowConfig = FlowConfig<BankStatusEnum, BankActionEnum, void>;
|
|
12
9
|
export interface IBankEntityGet extends IBankEntity {
|
|
13
10
|
intermediaryBankDetails?: IIntermediaryBankEntity[];
|
|
14
11
|
}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { IEntityCreateDto, Nullable } from "../../entities";
|
|
2
2
|
import { IAppFileConfig, IFilePayload, MulterFileWithUrl } from "../../misc";
|
|
3
3
|
import { IDocumentUploadEntity } from "../../entities/interface/document_upload.entity.interface";
|
|
4
|
-
|
|
4
|
+
/** status is set by the entity flow, never by the client */
|
|
5
|
+
export type IDocumentUploadCreateExclude = "gstDocument" | "additionalDocuments" | "status";
|
|
5
6
|
export interface IDocumentUploadCreateDto extends Omit<IEntityCreateDto<IDocumentUploadEntity>, IDocumentUploadCreateExclude> {
|
|
6
7
|
gstDocument?: Nullable<MulterFileWithUrl>;
|
|
7
8
|
additionalDocuments?: Nullable<MulterFileWithUrl[]>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { IReimbursementEntity, IReimbursementExpenseEntity, IUserEntity, ReimbursementActionEnum, ReimbursementExpenseActionEnum, ReimbursementExpenseState, ReimbursementStatusEnum } from "../../entities";
|
|
1
|
+
import { IReimbursementEntity, IReimbursementExpenseEntity, IUserEntity, ParentChildFlowConfig, ReimbursementActionEnum, ReimbursementExpenseActionEnum, ReimbursementExpenseState, ReimbursementStatusEnum } from "../../entities";
|
|
2
2
|
import { IProjectEntityGet } from "./project.entity.response";
|
|
3
3
|
export type IReimbursementEntityGet = {
|
|
4
4
|
reimbursements: IReimbursementResponse[];
|
|
@@ -7,28 +7,14 @@ export type IReimbursementEntityGet = {
|
|
|
7
7
|
};
|
|
8
8
|
projects: IProjectEntityGet;
|
|
9
9
|
};
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
};
|
|
19
|
-
};
|
|
20
|
-
};
|
|
21
|
-
child: {
|
|
22
|
-
[key in ReimbursementExpenseState]?: {
|
|
23
|
-
actions: {
|
|
24
|
-
[key in ReimbursementExpenseActionEnum]?: {
|
|
25
|
-
permissions: string[];
|
|
26
|
-
next?: () => ReimbursementExpenseState;
|
|
27
|
-
};
|
|
28
|
-
};
|
|
29
|
-
};
|
|
30
|
-
};
|
|
31
|
-
};
|
|
10
|
+
/**
|
|
11
|
+
* LW-828: this used to re-declare the parent/child flow-config shape by hand. It is now an alias of the
|
|
12
|
+
* shared `ParentChildFlowConfig`, instantiated with `IReimbursementFlowContextData` for the parent and
|
|
13
|
+
* `void` for the child — the child's `next` is called with no argument in
|
|
14
|
+
* `ReimbursementExpenseService.getReimbursementNextStatusForChild`. Kept as a named type so every
|
|
15
|
+
* existing consumer keeps compiling unchanged.
|
|
16
|
+
*/
|
|
17
|
+
export type IReimbursementFlowConfig = ParentChildFlowConfig<ReimbursementStatusEnum, ReimbursementActionEnum, ReimbursementExpenseState, ReimbursementExpenseActionEnum, IReimbursementFlowContextData, void>;
|
|
32
18
|
export type IReimbursementFlowContextData = {
|
|
33
19
|
expenseDetails: IReimbursementExpenseEntity[];
|
|
34
20
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { IProjectUserMappingEntity, ITimesheetEntity, IUserEntity, TimesheetActionEnum, TimesheetEntityModel, TimesheetStatusEnum } from "../../entities";
|
|
1
|
+
import { FlowConfig, IProjectUserMappingEntity, ITimesheetEntity, IUserEntity, TimesheetActionEnum, TimesheetEntityModel, TimesheetStatusEnum } from "../../entities";
|
|
2
2
|
import { IClientApiEntityDependent } from "./client.entity.response";
|
|
3
3
|
import { IProjectApiEntityDependent } from "./project.entity.response";
|
|
4
4
|
import { ITimesheetEntityUpdateDto } from "./timesheet.update.dto.interface";
|
|
@@ -15,18 +15,12 @@ export type ITimesheetEntityGet = {
|
|
|
15
15
|
};
|
|
16
16
|
tasks: string[];
|
|
17
17
|
};
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
next: (data: ITimesheetFlowContextData) => TimesheetStatusEnum;
|
|
25
|
-
validActionPastThreshold?: boolean;
|
|
26
|
-
};
|
|
27
|
-
};
|
|
28
|
-
};
|
|
29
|
-
};
|
|
18
|
+
/**
|
|
19
|
+
* LW-828: this used to re-declare the flow-config shape by hand. It is now an alias of the shared
|
|
20
|
+
* `FlowConfig`, whose action config carries the optional `isApplicable` and `validActionPastThreshold`
|
|
21
|
+
* this entity relies on. Kept as a named type so every existing consumer keeps compiling unchanged.
|
|
22
|
+
*/
|
|
23
|
+
export type ITimesheetFlowConfig = FlowConfig<TimesheetStatusEnum, TimesheetActionEnum, ITimesheetFlowContextData>;
|
|
30
24
|
export type ITimesheetFlowContextData = {
|
|
31
25
|
currentTimesheet?: TimesheetEntityModel;
|
|
32
26
|
projectUserMapping?: IProjectUserMappingEntity;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DocumentUploadStatusEnum = void 0;
|
|
4
|
+
var DocumentUploadStatusEnum;
|
|
5
|
+
(function (DocumentUploadStatusEnum) {
|
|
6
|
+
DocumentUploadStatusEnum["APPROVED"] = "APPROVED";
|
|
7
|
+
DocumentUploadStatusEnum["DEACTIVATED"] = "DEACTIVATED";
|
|
8
|
+
DocumentUploadStatusEnum["DELETED"] = "DELETED";
|
|
9
|
+
})(DocumentUploadStatusEnum || (exports.DocumentUploadStatusEnum = DocumentUploadStatusEnum = {}));
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { BankActionEnum } from "../enums/bank_action_enum";
|
|
2
|
+
import { BankStatusEnum } from "../enums/bank_status_enum";
|
|
3
|
+
import { FlowConfig } from "./flow-config.type";
|
|
4
|
+
/**
|
|
5
|
+
* Typed with `FlowConfig` directly rather than importing `IBankFlowConfig` from `src/api`, so that
|
|
6
|
+
* `entities` does not reach into `api` for a type it can express itself. `IBankFlowConfig` is now an
|
|
7
|
+
* alias of this same instantiation, so the two cannot drift.
|
|
8
|
+
*/
|
|
9
|
+
export declare const bankFlowConfig: FlowConfig<BankStatusEnum, BankActionEnum, void>;
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.bankFlowConfig = void 0;
|
|
4
|
+
const bank_action_enum_1 = require("../enums/bank_action_enum");
|
|
5
|
+
const bank_status_enum_1 = require("../enums/bank_status_enum");
|
|
6
|
+
const base_flow_config_factory_1 = require("./base-flow-config.factory");
|
|
7
|
+
const BANK_APPROVER_PERMISSION = ["BANK_APPROVER_ORG"];
|
|
8
|
+
const BANK_UPDATE_PERMISSION = ["BANK_UPDATE_ORG"];
|
|
9
|
+
const ACTION_MAP = {
|
|
10
|
+
// VIEW and CREATE are declared on BankActionEnum but carry no transition in this flow. They are
|
|
11
|
+
// listed so the map covers every enum member; the empty reachable set makes createActionConfig
|
|
12
|
+
// uncallable for them.
|
|
13
|
+
[bank_action_enum_1.BankActionEnum.VIEW]: {
|
|
14
|
+
reachableStatues: [],
|
|
15
|
+
permissions: [],
|
|
16
|
+
},
|
|
17
|
+
[bank_action_enum_1.BankActionEnum.CREATE]: {
|
|
18
|
+
reachableStatues: [],
|
|
19
|
+
permissions: [],
|
|
20
|
+
},
|
|
21
|
+
[bank_action_enum_1.BankActionEnum.UPDATE]: {
|
|
22
|
+
reachableStatues: [bank_status_enum_1.BankStatusEnum.CREATE_APPROVAL_PENDING, bank_status_enum_1.BankStatusEnum.UPDATE_APPROVAL_PENDING],
|
|
23
|
+
permissions: BANK_UPDATE_PERMISSION,
|
|
24
|
+
},
|
|
25
|
+
[bank_action_enum_1.BankActionEnum.DELETE]: {
|
|
26
|
+
reachableStatues: [bank_status_enum_1.BankStatusEnum.DELETE_APPROVAL_PENDING, bank_status_enum_1.BankStatusEnum.DELETED],
|
|
27
|
+
permissions: BANK_UPDATE_PERMISSION,
|
|
28
|
+
},
|
|
29
|
+
[bank_action_enum_1.BankActionEnum.APPROVE]: {
|
|
30
|
+
reachableStatues: [bank_status_enum_1.BankStatusEnum.APPROVED, bank_status_enum_1.BankStatusEnum.DELETED],
|
|
31
|
+
permissions: BANK_APPROVER_PERMISSION,
|
|
32
|
+
},
|
|
33
|
+
[bank_action_enum_1.BankActionEnum.REJECT]: {
|
|
34
|
+
reachableStatues: [bank_status_enum_1.BankStatusEnum.REJECTED, bank_status_enum_1.BankStatusEnum.RESOLVED_REJECTED],
|
|
35
|
+
permissions: BANK_APPROVER_PERMISSION,
|
|
36
|
+
},
|
|
37
|
+
[bank_action_enum_1.BankActionEnum.RECALL]: {
|
|
38
|
+
reachableStatues: [bank_status_enum_1.BankStatusEnum.DELETED],
|
|
39
|
+
permissions: BANK_UPDATE_PERMISSION,
|
|
40
|
+
},
|
|
41
|
+
};
|
|
42
|
+
/**
|
|
43
|
+
* The context type is `void` rather than `never` or an empty interface, because `IBankFlowConfig`
|
|
44
|
+
* declares `next: () => BankStatusEnum` and `BankService.getBankNextStatus` calls
|
|
45
|
+
* `matchingPermissionConfig.next()` with no arguments. A `void` parameter may be omitted at the call
|
|
46
|
+
* site, so that call keeps compiling; `never` would have required an argument nobody can produce.
|
|
47
|
+
*/
|
|
48
|
+
const { createActionConfig } = (0, base_flow_config_factory_1.createFlowConfigFactory)()(ACTION_MAP);
|
|
49
|
+
// CREATE_APPROVAL_PENDING status transitions
|
|
50
|
+
const transitionCreateApprovalPendingStatusApproveAction = createActionConfig(bank_action_enum_1.BankActionEnum.APPROVE, bank_status_enum_1.BankStatusEnum.APPROVED);
|
|
51
|
+
const transitionCreateApprovalPendingStatusUpdateAction = createActionConfig(bank_action_enum_1.BankActionEnum.UPDATE, bank_status_enum_1.BankStatusEnum.CREATE_APPROVAL_PENDING);
|
|
52
|
+
const transitionCreateApprovalPendingStatusRejectAction = createActionConfig(bank_action_enum_1.BankActionEnum.REJECT, bank_status_enum_1.BankStatusEnum.REJECTED);
|
|
53
|
+
const transitionCreateApprovalPendingStatusDeleteAction = createActionConfig(bank_action_enum_1.BankActionEnum.DELETE, bank_status_enum_1.BankStatusEnum.DELETED);
|
|
54
|
+
// UPDATE_APPROVAL_PENDING status transitions
|
|
55
|
+
const transitionUpdateApprovalPendingStatusApproveAction = createActionConfig(bank_action_enum_1.BankActionEnum.APPROVE, bank_status_enum_1.BankStatusEnum.APPROVED);
|
|
56
|
+
const transitionUpdateApprovalPendingStatusUpdateAction = createActionConfig(bank_action_enum_1.BankActionEnum.UPDATE, bank_status_enum_1.BankStatusEnum.UPDATE_APPROVAL_PENDING);
|
|
57
|
+
const transitionUpdateApprovalPendingStatusRejectAction = createActionConfig(bank_action_enum_1.BankActionEnum.REJECT, bank_status_enum_1.BankStatusEnum.RESOLVED_REJECTED);
|
|
58
|
+
const transitionUpdateApprovalPendingStatusRecallAction = createActionConfig(bank_action_enum_1.BankActionEnum.RECALL, bank_status_enum_1.BankStatusEnum.DELETED);
|
|
59
|
+
// DELETE_APPROVAL_PENDING status transitions
|
|
60
|
+
const transitionDeleteApprovalPendingStatusApproveAction = createActionConfig(bank_action_enum_1.BankActionEnum.APPROVE, bank_status_enum_1.BankStatusEnum.DELETED);
|
|
61
|
+
const transitionDeleteApprovalPendingStatusRejectAction = createActionConfig(bank_action_enum_1.BankActionEnum.REJECT, bank_status_enum_1.BankStatusEnum.RESOLVED_REJECTED);
|
|
62
|
+
const transitionDeleteApprovalPendingStatusRecallAction = createActionConfig(bank_action_enum_1.BankActionEnum.RECALL, bank_status_enum_1.BankStatusEnum.DELETED);
|
|
63
|
+
// APPROVED status transitions
|
|
64
|
+
const transitionApprovedStatusUpdateAction = createActionConfig(bank_action_enum_1.BankActionEnum.UPDATE, bank_status_enum_1.BankStatusEnum.UPDATE_APPROVAL_PENDING);
|
|
65
|
+
const transitionApprovedStatusDeleteAction = createActionConfig(bank_action_enum_1.BankActionEnum.DELETE, bank_status_enum_1.BankStatusEnum.DELETE_APPROVAL_PENDING);
|
|
66
|
+
// RESOLVED_REJECTED status transitions
|
|
67
|
+
const transitionResolvedRejectedStatusUpdateAction = createActionConfig(bank_action_enum_1.BankActionEnum.UPDATE, bank_status_enum_1.BankStatusEnum.UPDATE_APPROVAL_PENDING);
|
|
68
|
+
const transitionResolvedRejectedStatusDeleteAction = createActionConfig(bank_action_enum_1.BankActionEnum.DELETE, bank_status_enum_1.BankStatusEnum.DELETE_APPROVAL_PENDING);
|
|
69
|
+
/**
|
|
70
|
+
* Typed with `FlowConfig` directly rather than importing `IBankFlowConfig` from `src/api`, so that
|
|
71
|
+
* `entities` does not reach into `api` for a type it can express itself. `IBankFlowConfig` is now an
|
|
72
|
+
* alias of this same instantiation, so the two cannot drift.
|
|
73
|
+
*/
|
|
74
|
+
exports.bankFlowConfig = {
|
|
75
|
+
[bank_status_enum_1.BankStatusEnum.CREATE_APPROVAL_PENDING]: {
|
|
76
|
+
actions: {
|
|
77
|
+
[bank_action_enum_1.BankActionEnum.APPROVE]: transitionCreateApprovalPendingStatusApproveAction,
|
|
78
|
+
[bank_action_enum_1.BankActionEnum.UPDATE]: transitionCreateApprovalPendingStatusUpdateAction,
|
|
79
|
+
[bank_action_enum_1.BankActionEnum.REJECT]: transitionCreateApprovalPendingStatusRejectAction,
|
|
80
|
+
[bank_action_enum_1.BankActionEnum.DELETE]: transitionCreateApprovalPendingStatusDeleteAction,
|
|
81
|
+
},
|
|
82
|
+
},
|
|
83
|
+
[bank_status_enum_1.BankStatusEnum.UPDATE_APPROVAL_PENDING]: {
|
|
84
|
+
actions: {
|
|
85
|
+
[bank_action_enum_1.BankActionEnum.APPROVE]: transitionUpdateApprovalPendingStatusApproveAction,
|
|
86
|
+
[bank_action_enum_1.BankActionEnum.UPDATE]: transitionUpdateApprovalPendingStatusUpdateAction,
|
|
87
|
+
[bank_action_enum_1.BankActionEnum.REJECT]: transitionUpdateApprovalPendingStatusRejectAction,
|
|
88
|
+
[bank_action_enum_1.BankActionEnum.RECALL]: transitionUpdateApprovalPendingStatusRecallAction,
|
|
89
|
+
},
|
|
90
|
+
},
|
|
91
|
+
[bank_status_enum_1.BankStatusEnum.DELETE_APPROVAL_PENDING]: {
|
|
92
|
+
actions: {
|
|
93
|
+
[bank_action_enum_1.BankActionEnum.APPROVE]: transitionDeleteApprovalPendingStatusApproveAction,
|
|
94
|
+
[bank_action_enum_1.BankActionEnum.REJECT]: transitionDeleteApprovalPendingStatusRejectAction,
|
|
95
|
+
[bank_action_enum_1.BankActionEnum.RECALL]: transitionDeleteApprovalPendingStatusRecallAction,
|
|
96
|
+
},
|
|
97
|
+
},
|
|
98
|
+
[bank_status_enum_1.BankStatusEnum.APPROVED]: {
|
|
99
|
+
actions: {
|
|
100
|
+
[bank_action_enum_1.BankActionEnum.UPDATE]: transitionApprovedStatusUpdateAction,
|
|
101
|
+
[bank_action_enum_1.BankActionEnum.DELETE]: transitionApprovedStatusDeleteAction,
|
|
102
|
+
},
|
|
103
|
+
},
|
|
104
|
+
[bank_status_enum_1.BankStatusEnum.RESOLVED_REJECTED]: {
|
|
105
|
+
actions: {
|
|
106
|
+
[bank_action_enum_1.BankActionEnum.UPDATE]: transitionResolvedRejectedStatusUpdateAction,
|
|
107
|
+
[bank_action_enum_1.BankActionEnum.DELETE]: transitionResolvedRejectedStatusDeleteAction,
|
|
108
|
+
},
|
|
109
|
+
},
|
|
110
|
+
};
|
|
@@ -107,8 +107,27 @@ export type ActionMap<A extends string, S extends string> = {
|
|
|
107
107
|
*
|
|
108
108
|
* @returns A function that accepts an `ActionMap` and returns `createActionConfig`.
|
|
109
109
|
*/
|
|
110
|
+
/**
|
|
111
|
+
* Optional per-transition extras. Both are spread onto the action config only when supplied, so a
|
|
112
|
+
* call site that does not pass them produces exactly the object it produced before this argument
|
|
113
|
+
* existed — the sixteen already-converted flow configs are byte-identical.
|
|
114
|
+
*
|
|
115
|
+
* @property isApplicable runtime guard evaluated against the same context as `next()`
|
|
116
|
+
* @property validActionPastThreshold whether the action survives a consumer's data-entry threshold
|
|
117
|
+
* @property description human-readable copy for this transition. Already part of
|
|
118
|
+
* `IFlowConfigActionConfig` and rendered by the entity-flow
|
|
119
|
+
* component, so a converted config must be able to emit it.
|
|
120
|
+
*/
|
|
121
|
+
export type ActionConfigOptions<CTX> = {
|
|
122
|
+
isApplicable?: (context: CTX) => boolean;
|
|
123
|
+
validActionPastThreshold?: boolean;
|
|
124
|
+
description?: string;
|
|
125
|
+
};
|
|
110
126
|
export declare function createFlowConfigFactory<CTX = never>(): <A extends string, S extends string, AM extends ActionMap<A, S>>(actionMap: AM) => {
|
|
111
|
-
createActionConfig: <Act extends A, Subset extends { [key in A]: AM[key]["reachableStatues"]; }[Act][number] = { [key in A]: AM[key]["reachableStatues"]; }[Act][number]>(action: Act, nextStatus: Subset | ((context: CTX) => Subset), overridePermissions?: string[]) => {
|
|
127
|
+
createActionConfig: <Act extends A, Subset extends { [key in A]: AM[key]["reachableStatues"]; }[Act][number] = { [key in A]: AM[key]["reachableStatues"]; }[Act][number]>(action: Act, nextStatus: Subset | ((context: CTX) => Subset), overridePermissions?: string[], options?: ActionConfigOptions<CTX>) => {
|
|
128
|
+
description?: string | undefined;
|
|
129
|
+
validActionPastThreshold?: boolean | undefined;
|
|
130
|
+
isApplicable?: ((context: CTX) => boolean) | undefined;
|
|
112
131
|
permissions: string[];
|
|
113
132
|
next: (context: CTX) => Subset;
|
|
114
133
|
};
|
|
@@ -75,18 +75,6 @@
|
|
|
75
75
|
*/
|
|
76
76
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
77
77
|
exports.createFlowConfigFactory = createFlowConfigFactory;
|
|
78
|
-
/**
|
|
79
|
-
* Curried factory — call with the context-data type first, then pass the
|
|
80
|
-
* action map. This two-step pattern lets TypeScript infer the precise action
|
|
81
|
-
* map type (preserving `as const` tuple narrowing) while still allowing the
|
|
82
|
-
* caller to set the context-data type explicitly.
|
|
83
|
-
*
|
|
84
|
-
* @template CTX - Shape of the context object passed to function-based
|
|
85
|
-
* transition resolvers. Use `never` for flows where `next()`
|
|
86
|
-
* needs no runtime data (equivalent to `() => status`).
|
|
87
|
-
*
|
|
88
|
-
* @returns A function that accepts an `ActionMap` and returns `createActionConfig`.
|
|
89
|
-
*/
|
|
90
78
|
function createFlowConfigFactory() {
|
|
91
79
|
return function (actionMap) {
|
|
92
80
|
const createTransition = (transition) => (context) => {
|
|
@@ -111,10 +99,7 @@ function createFlowConfigFactory() {
|
|
|
111
99
|
* (currentStatus, action) pair. Must be a subtype of
|
|
112
100
|
* `StatusForAction<Act>`.
|
|
113
101
|
*/
|
|
114
|
-
const createActionConfig = (action, nextStatus, overridePermissions) => ({
|
|
115
|
-
permissions: overridePermissions !== null && overridePermissions !== void 0 ? overridePermissions : actionMap[action].permissions,
|
|
116
|
-
next: createTransition(nextStatus),
|
|
117
|
-
});
|
|
102
|
+
const createActionConfig = (action, nextStatus, overridePermissions, options) => (Object.assign(Object.assign(Object.assign({ permissions: overridePermissions !== null && overridePermissions !== void 0 ? overridePermissions : actionMap[action].permissions, next: createTransition(nextStatus) }, ((options === null || options === void 0 ? void 0 : options.isApplicable) !== undefined ? { isApplicable: options.isApplicable } : {})), ((options === null || options === void 0 ? void 0 : options.validActionPastThreshold) !== undefined ? { validActionPastThreshold: options.validActionPastThreshold } : {})), ((options === null || options === void 0 ? void 0 : options.description) !== undefined ? { description: options.description } : {})));
|
|
118
103
|
return { createActionConfig, createTransition };
|
|
119
104
|
};
|
|
120
105
|
}
|
package/dist/src/entities/flow-configs/{billing.flow.config.d.ts → billing_flow.config.d.ts}
RENAMED
|
@@ -2,5 +2,5 @@ import { IBillingFlowContextData } from "../../api";
|
|
|
2
2
|
import { BillingActionsEnum } from "../enums/billing_action_enum";
|
|
3
3
|
import { BillingStatusEnum } from "../enums/billing_status_enum";
|
|
4
4
|
import { FlowConfig } from "./flow-config.type";
|
|
5
|
-
export declare
|
|
5
|
+
export declare const billingFlowConfig: FlowConfig<BillingStatusEnum, BillingActionsEnum, IBillingFlowContextData>;
|
|
6
6
|
export declare function getNextStatusTotalAmount(data: IBillingFlowContextData): BillingStatusEnum;
|
|
@@ -0,0 +1,305 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.billingFlowConfig = void 0;
|
|
4
|
+
exports.getNextStatusTotalAmount = getNextStatusTotalAmount;
|
|
5
|
+
const error_key_enum_1 = require("../../enums/error.key.enum");
|
|
6
|
+
const exceptions_1 = require("../../exceptions");
|
|
7
|
+
const billing_action_enum_1 = require("../enums/billing_action_enum");
|
|
8
|
+
const billing_status_enum_1 = require("../enums/billing_status_enum");
|
|
9
|
+
const base_flow_config_factory_1 = require("./base-flow-config.factory");
|
|
10
|
+
const BILLING_APPROVER_PERMISSION = ["BILLING_APPROVER_ORG", "BILLING_APPROVER_PROJECT"];
|
|
11
|
+
const BILLING_AMENDMENT_PERMISSION = ["BILLING_AMENDMENT_ORG"];
|
|
12
|
+
const BILLING_REGENERATE_PERMISSION = ["BILLING_UPDATE"];
|
|
13
|
+
const BILLING_PDF_VIEW_PERMISSION = ["BILLING_VIEW_PDF"];
|
|
14
|
+
/**
|
|
15
|
+
* Every status this flow declares a block for. PDF_VIEW is an identity transition available from each
|
|
16
|
+
* of them, so this is exactly its reachable set.
|
|
17
|
+
*
|
|
18
|
+
* CANCELLED is a target (REJECT, REGENERATE) but has no block of its own — it is terminal.
|
|
19
|
+
*/
|
|
20
|
+
const BILLING_FLOW_STATUSES = [
|
|
21
|
+
billing_status_enum_1.BillingStatusEnum.PENDING_APPROVAL,
|
|
22
|
+
billing_status_enum_1.BillingStatusEnum.REQUEST_CHANGES,
|
|
23
|
+
billing_status_enum_1.BillingStatusEnum.INTERNAL_APPROVED,
|
|
24
|
+
billing_status_enum_1.BillingStatusEnum.PENDING_CLIENT_REVIEW,
|
|
25
|
+
billing_status_enum_1.BillingStatusEnum.CLIENT_REVISION_APPROVAL,
|
|
26
|
+
billing_status_enum_1.BillingStatusEnum.REJECT_CLIENT_REVISION,
|
|
27
|
+
billing_status_enum_1.BillingStatusEnum.INVOICE_SENT,
|
|
28
|
+
billing_status_enum_1.BillingStatusEnum.PENDING_PAYMENT,
|
|
29
|
+
billing_status_enum_1.BillingStatusEnum.SETTLED,
|
|
30
|
+
];
|
|
31
|
+
const ACTION_MAP = {
|
|
32
|
+
[billing_action_enum_1.BillingActionsEnum.APPROVE]: {
|
|
33
|
+
reachableStatues: [billing_status_enum_1.BillingStatusEnum.INTERNAL_APPROVED],
|
|
34
|
+
permissions: BILLING_APPROVER_PERMISSION,
|
|
35
|
+
},
|
|
36
|
+
[billing_action_enum_1.BillingActionsEnum.REJECT]: {
|
|
37
|
+
reachableStatues: [billing_status_enum_1.BillingStatusEnum.CANCELLED, billing_status_enum_1.BillingStatusEnum.REJECT_CLIENT_REVISION],
|
|
38
|
+
permissions: BILLING_APPROVER_PERMISSION,
|
|
39
|
+
},
|
|
40
|
+
/**
|
|
41
|
+
* UPDATE is the one action whose permission is not constant across its transitions: four of the five
|
|
42
|
+
* use the approver list, but REQUEST_CHANGES uses the amendment list. The approver list is the default
|
|
43
|
+
* here and REQUEST_CHANGES passes the amendment list as an override.
|
|
44
|
+
*/
|
|
45
|
+
[billing_action_enum_1.BillingActionsEnum.UPDATE]: {
|
|
46
|
+
reachableStatues: [
|
|
47
|
+
billing_status_enum_1.BillingStatusEnum.PENDING_APPROVAL,
|
|
48
|
+
billing_status_enum_1.BillingStatusEnum.REQUEST_CHANGES,
|
|
49
|
+
billing_status_enum_1.BillingStatusEnum.CLIENT_REVISION_APPROVAL,
|
|
50
|
+
billing_status_enum_1.BillingStatusEnum.INVOICE_SENT,
|
|
51
|
+
],
|
|
52
|
+
permissions: BILLING_APPROVER_PERMISSION,
|
|
53
|
+
},
|
|
54
|
+
[billing_action_enum_1.BillingActionsEnum.REQUEST_FOR_CHANGES]: {
|
|
55
|
+
reachableStatues: [billing_status_enum_1.BillingStatusEnum.REQUEST_CHANGES],
|
|
56
|
+
permissions: BILLING_APPROVER_PERMISSION,
|
|
57
|
+
},
|
|
58
|
+
[billing_action_enum_1.BillingActionsEnum.SENT_FOR_APPROVAL]: {
|
|
59
|
+
reachableStatues: [billing_status_enum_1.BillingStatusEnum.PENDING_APPROVAL],
|
|
60
|
+
permissions: BILLING_AMENDMENT_PERMISSION,
|
|
61
|
+
},
|
|
62
|
+
[billing_action_enum_1.BillingActionsEnum.SEND_FOR_CLIENT_REVIEW]: {
|
|
63
|
+
reachableStatues: [billing_status_enum_1.BillingStatusEnum.PENDING_CLIENT_REVIEW],
|
|
64
|
+
permissions: BILLING_AMENDMENT_PERMISSION,
|
|
65
|
+
},
|
|
66
|
+
[billing_action_enum_1.BillingActionsEnum.CLIENT_REVISION]: {
|
|
67
|
+
reachableStatues: [billing_status_enum_1.BillingStatusEnum.CLIENT_REVISION_APPROVAL],
|
|
68
|
+
permissions: BILLING_AMENDMENT_PERMISSION,
|
|
69
|
+
},
|
|
70
|
+
[billing_action_enum_1.BillingActionsEnum.SEND_INVOICE]: {
|
|
71
|
+
reachableStatues: [billing_status_enum_1.BillingStatusEnum.PENDING_PAYMENT, billing_status_enum_1.BillingStatusEnum.INVOICE_SENT],
|
|
72
|
+
permissions: BILLING_AMENDMENT_PERMISSION,
|
|
73
|
+
},
|
|
74
|
+
[billing_action_enum_1.BillingActionsEnum.APPROVAL]: {
|
|
75
|
+
reachableStatues: [billing_status_enum_1.BillingStatusEnum.REQUEST_CHANGES],
|
|
76
|
+
permissions: BILLING_APPROVER_PERMISSION,
|
|
77
|
+
},
|
|
78
|
+
/**
|
|
79
|
+
* UPDATE_PAYMENT is context-driven: `getNextStatusTotalAmount` returns SETTLED once the outstanding
|
|
80
|
+
* amount reaches zero and PENDING_PAYMENT otherwise. The from-status is also reachable, because both
|
|
81
|
+
* transitions fall back to it when called without context — which the entity-flow component does.
|
|
82
|
+
*/
|
|
83
|
+
[billing_action_enum_1.BillingActionsEnum.UPDATE_PAYMENT]: {
|
|
84
|
+
reachableStatues: [billing_status_enum_1.BillingStatusEnum.SETTLED, billing_status_enum_1.BillingStatusEnum.PENDING_PAYMENT, billing_status_enum_1.BillingStatusEnum.INVOICE_SENT],
|
|
85
|
+
permissions: BILLING_AMENDMENT_PERMISSION,
|
|
86
|
+
},
|
|
87
|
+
[billing_action_enum_1.BillingActionsEnum.REGENERATE]: {
|
|
88
|
+
reachableStatues: [billing_status_enum_1.BillingStatusEnum.CANCELLED],
|
|
89
|
+
permissions: BILLING_REGENERATE_PERMISSION,
|
|
90
|
+
},
|
|
91
|
+
[billing_action_enum_1.BillingActionsEnum.PDF_VIEW]: {
|
|
92
|
+
reachableStatues: BILLING_FLOW_STATUSES,
|
|
93
|
+
permissions: BILLING_PDF_VIEW_PERMISSION,
|
|
94
|
+
},
|
|
95
|
+
// CREDIT_NOTE, WRITE_OFF and TDS are declared on BillingActionsEnum but carry no transition in this
|
|
96
|
+
// flow. They are listed so the map covers every enum member; the empty reachable set makes
|
|
97
|
+
// createActionConfig uncallable for them.
|
|
98
|
+
[billing_action_enum_1.BillingActionsEnum.CREDIT_NOTE]: {
|
|
99
|
+
reachableStatues: [],
|
|
100
|
+
permissions: [],
|
|
101
|
+
},
|
|
102
|
+
[billing_action_enum_1.BillingActionsEnum.WRITE_OFF]: {
|
|
103
|
+
reachableStatues: [],
|
|
104
|
+
permissions: [],
|
|
105
|
+
},
|
|
106
|
+
[billing_action_enum_1.BillingActionsEnum.TDS]: {
|
|
107
|
+
reachableStatues: [],
|
|
108
|
+
permissions: [],
|
|
109
|
+
},
|
|
110
|
+
};
|
|
111
|
+
const { createActionConfig } = (0, base_flow_config_factory_1.createFlowConfigFactory)()(ACTION_MAP);
|
|
112
|
+
// PENDING_APPROVAL status transitions
|
|
113
|
+
const transitionPendingApprovalStatusApproveAction = createActionConfig(billing_action_enum_1.BillingActionsEnum.APPROVE, billing_status_enum_1.BillingStatusEnum.INTERNAL_APPROVED, undefined, {
|
|
114
|
+
description: "Internal Approved state signifies that the Proforma Invoice has been reviewed and verified by internal stakeholders.",
|
|
115
|
+
});
|
|
116
|
+
const transitionPendingApprovalStatusRejectAction = createActionConfig(billing_action_enum_1.BillingActionsEnum.REJECT, billing_status_enum_1.BillingStatusEnum.CANCELLED, undefined, {
|
|
117
|
+
description: "Rejected state indicates that the Proforma Invoice was not approved and has been cancelled.",
|
|
118
|
+
});
|
|
119
|
+
const transitionPendingApprovalStatusUpdateAction = createActionConfig(billing_action_enum_1.BillingActionsEnum.UPDATE, billing_status_enum_1.BillingStatusEnum.PENDING_APPROVAL, undefined, {
|
|
120
|
+
description: "Allows stakeholders to edit the Proforma Invoice while keeping it in Pending Approval status.",
|
|
121
|
+
});
|
|
122
|
+
const transitionPendingApprovalStatusRequestForChangesAction = createActionConfig(billing_action_enum_1.BillingActionsEnum.REQUEST_FOR_CHANGES, billing_status_enum_1.BillingStatusEnum.REQUEST_CHANGES, undefined, { description: "Stakeholders have requested changes before approving the Proforma Invoice." });
|
|
123
|
+
// REQUEST_CHANGES status transitions
|
|
124
|
+
const transitionRequestChangesStatusUpdateAction = createActionConfig(billing_action_enum_1.BillingActionsEnum.UPDATE, billing_status_enum_1.BillingStatusEnum.REQUEST_CHANGES, BILLING_AMENDMENT_PERMISSION, // differs from the action default — amendment, not approver
|
|
125
|
+
{ description: "Allows modification of the Proforma Invoice based on stakeholder feedback." });
|
|
126
|
+
const transitionRequestChangesStatusSentForApprovalAction = createActionConfig(billing_action_enum_1.BillingActionsEnum.SENT_FOR_APPROVAL, billing_status_enum_1.BillingStatusEnum.PENDING_APPROVAL, undefined, { description: "Resubmits the updated Proforma Invoice for stakeholder approval." });
|
|
127
|
+
// INTERNAL_APPROVED status transitions
|
|
128
|
+
const transitionInternalApprovedStatusSendForClientReviewAction = createActionConfig(billing_action_enum_1.BillingActionsEnum.SEND_FOR_CLIENT_REVIEW, billing_status_enum_1.BillingStatusEnum.PENDING_CLIENT_REVIEW, undefined, { description: "Invoice has been internally approved and is sent to the client for review." });
|
|
129
|
+
// PENDING_CLIENT_REVIEW status transitions
|
|
130
|
+
const transitionPendingClientReviewStatusClientRevisionAction = createActionConfig(billing_action_enum_1.BillingActionsEnum.CLIENT_REVISION, billing_status_enum_1.BillingStatusEnum.CLIENT_REVISION_APPROVAL, undefined, { description: "Client has requested revisions to the Proforma Invoice." });
|
|
131
|
+
const transitionPendingClientReviewStatusSendInvoiceAction = createActionConfig(billing_action_enum_1.BillingActionsEnum.SEND_INVOICE, billing_status_enum_1.BillingStatusEnum.PENDING_PAYMENT, undefined, {
|
|
132
|
+
description: "Final invoice has been shared with the client and payment is awaited.",
|
|
133
|
+
});
|
|
134
|
+
// CLIENT_REVISION_APPROVAL status transitions
|
|
135
|
+
const transitionClientRevisionApprovalStatusApprovalAction = createActionConfig(billing_action_enum_1.BillingActionsEnum.APPROVAL, billing_status_enum_1.BillingStatusEnum.REQUEST_CHANGES, undefined, {
|
|
136
|
+
description: "Client revision has been reviewed and approved for further amendments.",
|
|
137
|
+
});
|
|
138
|
+
const transitionClientRevisionApprovalStatusRejectAction = createActionConfig(billing_action_enum_1.BillingActionsEnum.REJECT, billing_status_enum_1.BillingStatusEnum.REJECT_CLIENT_REVISION, undefined, {
|
|
139
|
+
description: "Client revision request has been rejected by stakeholders.",
|
|
140
|
+
});
|
|
141
|
+
const transitionClientRevisionApprovalStatusUpdateAction = createActionConfig(billing_action_enum_1.BillingActionsEnum.UPDATE, billing_status_enum_1.BillingStatusEnum.CLIENT_REVISION_APPROVAL, undefined, { description: "Allows editing while client revision approval is in progress." });
|
|
142
|
+
const transitionClientRevisionApprovalStatusRequestForChangesAction = createActionConfig(billing_action_enum_1.BillingActionsEnum.REQUEST_FOR_CHANGES, billing_status_enum_1.BillingStatusEnum.REQUEST_CHANGES, undefined, { description: "Requests additional changes before approving the client revision." });
|
|
143
|
+
// REJECT_CLIENT_REVISION status transitions
|
|
144
|
+
const transitionRejectClientRevisionStatusSendInvoiceAction = createActionConfig(billing_action_enum_1.BillingActionsEnum.SEND_INVOICE, billing_status_enum_1.BillingStatusEnum.INVOICE_SENT, undefined, {
|
|
145
|
+
description: "Invoice has been sent despite client revision rejection.",
|
|
146
|
+
});
|
|
147
|
+
// INVOICE_SENT status transitions
|
|
148
|
+
const transitionInvoiceSentStatusUpdatePaymentAction = createActionConfig(billing_action_enum_1.BillingActionsEnum.UPDATE_PAYMENT, (data) => {
|
|
149
|
+
return data ? getNextStatusTotalAmount(data) : billing_status_enum_1.BillingStatusEnum.INVOICE_SENT;
|
|
150
|
+
}, undefined, { description: "Updates received payment details and recalculates outstanding amount." });
|
|
151
|
+
const transitionInvoiceSentStatusRejectAction = createActionConfig(billing_action_enum_1.BillingActionsEnum.REJECT, billing_status_enum_1.BillingStatusEnum.CANCELLED, undefined, {
|
|
152
|
+
description: "Rejected state indicates that the Proforma Invoice was not approved and has been cancelled.",
|
|
153
|
+
});
|
|
154
|
+
const transitionInvoiceSentStatusUpdateAction = createActionConfig(billing_action_enum_1.BillingActionsEnum.UPDATE, billing_status_enum_1.BillingStatusEnum.INVOICE_SENT, undefined, {
|
|
155
|
+
description: "Allows stakeholders to edit the invoice while keeping it in Invoice Sent status.",
|
|
156
|
+
});
|
|
157
|
+
const transitionInvoiceSentStatusRegenerateAction = createActionConfig(billing_action_enum_1.BillingActionsEnum.REGENERATE, billing_status_enum_1.BillingStatusEnum.CANCELLED, undefined, {
|
|
158
|
+
description: "Regenerates the billing by cancelling the current one and creating a replacement",
|
|
159
|
+
});
|
|
160
|
+
// PENDING_PAYMENT status transitions
|
|
161
|
+
const transitionPendingPaymentStatusUpdatePaymentAction = createActionConfig(billing_action_enum_1.BillingActionsEnum.UPDATE_PAYMENT, (data) => {
|
|
162
|
+
return data ? getNextStatusTotalAmount(data) : billing_status_enum_1.BillingStatusEnum.PENDING_PAYMENT;
|
|
163
|
+
}, undefined, { description: "Tracks partial or full payments until the invoice is completely settled." });
|
|
164
|
+
const transitionPendingPaymentStatusRejectAction = createActionConfig(billing_action_enum_1.BillingActionsEnum.REJECT, billing_status_enum_1.BillingStatusEnum.CANCELLED, undefined, {
|
|
165
|
+
description: "Rejected state indicates that the Proforma Invoice was not approved and has been cancelled.",
|
|
166
|
+
});
|
|
167
|
+
const transitionPendingPaymentStatusUpdateAction = createActionConfig(billing_action_enum_1.BillingActionsEnum.UPDATE, billing_status_enum_1.BillingStatusEnum.INVOICE_SENT, undefined, {
|
|
168
|
+
description: "Allows stakeholders to edit the invoice while keeping it in Invoice Sent status.",
|
|
169
|
+
});
|
|
170
|
+
const transitionPendingPaymentStatusRegenerateAction = createActionConfig(billing_action_enum_1.BillingActionsEnum.REGENERATE, billing_status_enum_1.BillingStatusEnum.CANCELLED, undefined, {
|
|
171
|
+
description: "Regenerates the billing by cancelling the current one and creating a replacement",
|
|
172
|
+
});
|
|
173
|
+
/**
|
|
174
|
+
* PDF_VIEW status transitions — one per status block, each keeping the row where it is. These were
|
|
175
|
+
* previously attached by mutating the config through `addPdfViewToAllStatuses` after definition; they
|
|
176
|
+
* are written out explicitly so the exported object is complete and immutable.
|
|
177
|
+
*/
|
|
178
|
+
const transitionPendingApprovalStatusPdfViewAction = createActionConfig(billing_action_enum_1.BillingActionsEnum.PDF_VIEW, billing_status_enum_1.BillingStatusEnum.PENDING_APPROVAL, undefined, {
|
|
179
|
+
description: "",
|
|
180
|
+
});
|
|
181
|
+
const transitionRequestChangesStatusPdfViewAction = createActionConfig(billing_action_enum_1.BillingActionsEnum.PDF_VIEW, billing_status_enum_1.BillingStatusEnum.REQUEST_CHANGES, undefined, {
|
|
182
|
+
description: "",
|
|
183
|
+
});
|
|
184
|
+
const transitionInternalApprovedStatusPdfViewAction = createActionConfig(billing_action_enum_1.BillingActionsEnum.PDF_VIEW, billing_status_enum_1.BillingStatusEnum.INTERNAL_APPROVED, undefined, {
|
|
185
|
+
description: "",
|
|
186
|
+
});
|
|
187
|
+
const transitionPendingClientReviewStatusPdfViewAction = createActionConfig(billing_action_enum_1.BillingActionsEnum.PDF_VIEW, billing_status_enum_1.BillingStatusEnum.PENDING_CLIENT_REVIEW, undefined, {
|
|
188
|
+
description: "",
|
|
189
|
+
});
|
|
190
|
+
const transitionClientRevisionApprovalStatusPdfViewAction = createActionConfig(billing_action_enum_1.BillingActionsEnum.PDF_VIEW, billing_status_enum_1.BillingStatusEnum.CLIENT_REVISION_APPROVAL, undefined, { description: "" });
|
|
191
|
+
const transitionRejectClientRevisionStatusPdfViewAction = createActionConfig(billing_action_enum_1.BillingActionsEnum.PDF_VIEW, billing_status_enum_1.BillingStatusEnum.REJECT_CLIENT_REVISION, undefined, {
|
|
192
|
+
description: "",
|
|
193
|
+
});
|
|
194
|
+
const transitionInvoiceSentStatusPdfViewAction = createActionConfig(billing_action_enum_1.BillingActionsEnum.PDF_VIEW, billing_status_enum_1.BillingStatusEnum.INVOICE_SENT, undefined, {
|
|
195
|
+
description: "",
|
|
196
|
+
});
|
|
197
|
+
const transitionPendingPaymentStatusPdfViewAction = createActionConfig(billing_action_enum_1.BillingActionsEnum.PDF_VIEW, billing_status_enum_1.BillingStatusEnum.PENDING_PAYMENT, undefined, {
|
|
198
|
+
description: "",
|
|
199
|
+
});
|
|
200
|
+
const transitionSettledStatusPdfViewAction = createActionConfig(billing_action_enum_1.BillingActionsEnum.PDF_VIEW, billing_status_enum_1.BillingStatusEnum.SETTLED, undefined, { description: "" });
|
|
201
|
+
exports.billingFlowConfig = {
|
|
202
|
+
[billing_status_enum_1.BillingStatusEnum.PENDING_APPROVAL]: {
|
|
203
|
+
description: "The Proforma Invoice has been created and is awaiting review and approval by internal stakeholders (org or project approvers).",
|
|
204
|
+
actions: {
|
|
205
|
+
[billing_action_enum_1.BillingActionsEnum.APPROVE]: transitionPendingApprovalStatusApproveAction,
|
|
206
|
+
[billing_action_enum_1.BillingActionsEnum.REJECT]: transitionPendingApprovalStatusRejectAction,
|
|
207
|
+
[billing_action_enum_1.BillingActionsEnum.UPDATE]: transitionPendingApprovalStatusUpdateAction,
|
|
208
|
+
[billing_action_enum_1.BillingActionsEnum.REQUEST_FOR_CHANGES]: transitionPendingApprovalStatusRequestForChangesAction,
|
|
209
|
+
[billing_action_enum_1.BillingActionsEnum.PDF_VIEW]: transitionPendingApprovalStatusPdfViewAction,
|
|
210
|
+
},
|
|
211
|
+
},
|
|
212
|
+
[billing_status_enum_1.BillingStatusEnum.REQUEST_CHANGES]: {
|
|
213
|
+
description: "Stakeholders have reviewed the Proforma Invoice and requested modifications before it can be approved. The invoice is pending amendments by the billing team.",
|
|
214
|
+
actions: {
|
|
215
|
+
[billing_action_enum_1.BillingActionsEnum.UPDATE]: transitionRequestChangesStatusUpdateAction,
|
|
216
|
+
[billing_action_enum_1.BillingActionsEnum.SENT_FOR_APPROVAL]: transitionRequestChangesStatusSentForApprovalAction,
|
|
217
|
+
[billing_action_enum_1.BillingActionsEnum.PDF_VIEW]: transitionRequestChangesStatusPdfViewAction,
|
|
218
|
+
},
|
|
219
|
+
},
|
|
220
|
+
[billing_status_enum_1.BillingStatusEnum.INTERNAL_APPROVED]: {
|
|
221
|
+
description: "The Proforma Invoice has been reviewed and approved by internal stakeholders. It is now ready to be forwarded to the client for review.",
|
|
222
|
+
actions: {
|
|
223
|
+
[billing_action_enum_1.BillingActionsEnum.SEND_FOR_CLIENT_REVIEW]: transitionInternalApprovedStatusSendForClientReviewAction,
|
|
224
|
+
[billing_action_enum_1.BillingActionsEnum.PDF_VIEW]: transitionInternalApprovedStatusPdfViewAction,
|
|
225
|
+
},
|
|
226
|
+
},
|
|
227
|
+
[billing_status_enum_1.BillingStatusEnum.PENDING_CLIENT_REVIEW]: {
|
|
228
|
+
description: "The Proforma Invoice has been shared with the client and is awaiting their response. The client may either accept the invoice or request revisions.",
|
|
229
|
+
actions: {
|
|
230
|
+
[billing_action_enum_1.BillingActionsEnum.CLIENT_REVISION]: transitionPendingClientReviewStatusClientRevisionAction,
|
|
231
|
+
[billing_action_enum_1.BillingActionsEnum.SEND_INVOICE]: transitionPendingClientReviewStatusSendInvoiceAction,
|
|
232
|
+
[billing_action_enum_1.BillingActionsEnum.PDF_VIEW]: transitionPendingClientReviewStatusPdfViewAction,
|
|
233
|
+
},
|
|
234
|
+
},
|
|
235
|
+
[billing_status_enum_1.BillingStatusEnum.CLIENT_REVISION_APPROVAL]: {
|
|
236
|
+
description: "The client has requested revisions to the invoice. Internal stakeholders are reviewing whether to approve the revision request, reject it, or ask for further changes.",
|
|
237
|
+
actions: {
|
|
238
|
+
[billing_action_enum_1.BillingActionsEnum.APPROVAL]: transitionClientRevisionApprovalStatusApprovalAction,
|
|
239
|
+
[billing_action_enum_1.BillingActionsEnum.REJECT]: transitionClientRevisionApprovalStatusRejectAction,
|
|
240
|
+
[billing_action_enum_1.BillingActionsEnum.UPDATE]: transitionClientRevisionApprovalStatusUpdateAction,
|
|
241
|
+
[billing_action_enum_1.BillingActionsEnum.REQUEST_FOR_CHANGES]: transitionClientRevisionApprovalStatusRequestForChangesAction,
|
|
242
|
+
[billing_action_enum_1.BillingActionsEnum.PDF_VIEW]: transitionClientRevisionApprovalStatusPdfViewAction,
|
|
243
|
+
},
|
|
244
|
+
},
|
|
245
|
+
[billing_status_enum_1.BillingStatusEnum.REJECT_CLIENT_REVISION]: {
|
|
246
|
+
description: "The client's revision request has been rejected by internal stakeholders. The billing team can proceed to send the original invoice to the client.",
|
|
247
|
+
actions: {
|
|
248
|
+
[billing_action_enum_1.BillingActionsEnum.SEND_INVOICE]: transitionRejectClientRevisionStatusSendInvoiceAction,
|
|
249
|
+
[billing_action_enum_1.BillingActionsEnum.PDF_VIEW]: transitionRejectClientRevisionStatusPdfViewAction,
|
|
250
|
+
},
|
|
251
|
+
},
|
|
252
|
+
[billing_status_enum_1.BillingStatusEnum.INVOICE_SENT]: {
|
|
253
|
+
description: "The final invoice has been issued to the client following a rejected revision request. Payment is being tracked; partial payments may be recorded until the invoice is fully settled.",
|
|
254
|
+
actions: {
|
|
255
|
+
[billing_action_enum_1.BillingActionsEnum.UPDATE_PAYMENT]: transitionInvoiceSentStatusUpdatePaymentAction,
|
|
256
|
+
[billing_action_enum_1.BillingActionsEnum.REJECT]: transitionInvoiceSentStatusRejectAction,
|
|
257
|
+
[billing_action_enum_1.BillingActionsEnum.UPDATE]: transitionInvoiceSentStatusUpdateAction,
|
|
258
|
+
[billing_action_enum_1.BillingActionsEnum.REGENERATE]: transitionInvoiceSentStatusRegenerateAction,
|
|
259
|
+
[billing_action_enum_1.BillingActionsEnum.PDF_VIEW]: transitionInvoiceSentStatusPdfViewAction,
|
|
260
|
+
},
|
|
261
|
+
},
|
|
262
|
+
[billing_status_enum_1.BillingStatusEnum.PENDING_PAYMENT]: {
|
|
263
|
+
description: "The final invoice has been sent to the client and payment is awaited. Partial or full payments can be recorded; the invoice remains in this state until the total amount is fully settled.",
|
|
264
|
+
actions: {
|
|
265
|
+
[billing_action_enum_1.BillingActionsEnum.UPDATE_PAYMENT]: transitionPendingPaymentStatusUpdatePaymentAction,
|
|
266
|
+
[billing_action_enum_1.BillingActionsEnum.REJECT]: transitionPendingPaymentStatusRejectAction,
|
|
267
|
+
[billing_action_enum_1.BillingActionsEnum.UPDATE]: transitionPendingPaymentStatusUpdateAction,
|
|
268
|
+
[billing_action_enum_1.BillingActionsEnum.REGENERATE]: transitionPendingPaymentStatusRegenerateAction,
|
|
269
|
+
[billing_action_enum_1.BillingActionsEnum.PDF_VIEW]: transitionPendingPaymentStatusPdfViewAction,
|
|
270
|
+
},
|
|
271
|
+
},
|
|
272
|
+
[billing_status_enum_1.BillingStatusEnum.SETTLED]: {
|
|
273
|
+
description: "The invoice has been fully settled. The total amount due has been accounted for through a combination of payments, credit notes, write-offs, TDS, and refunds. No further actions are required.",
|
|
274
|
+
actions: {
|
|
275
|
+
[billing_action_enum_1.BillingActionsEnum.PDF_VIEW]: transitionSettledStatusPdfViewAction,
|
|
276
|
+
},
|
|
277
|
+
},
|
|
278
|
+
};
|
|
279
|
+
function getNextStatusTotalAmount(data) {
|
|
280
|
+
var _a, _b, _c, _d, _e;
|
|
281
|
+
const { currentBilling, dto } = data;
|
|
282
|
+
if (!currentBilling) {
|
|
283
|
+
throw new exceptions_1.AppBadRequestException({
|
|
284
|
+
key: error_key_enum_1.ErrorKeyEnum.BILLING,
|
|
285
|
+
message: ["Current billing entity is required"],
|
|
286
|
+
});
|
|
287
|
+
}
|
|
288
|
+
if (!dto) {
|
|
289
|
+
throw new exceptions_1.AppBadRequestException({
|
|
290
|
+
key: error_key_enum_1.ErrorKeyEnum.BILLING,
|
|
291
|
+
message: ["Current billing entity is required"],
|
|
292
|
+
});
|
|
293
|
+
}
|
|
294
|
+
if (Number(currentBilling.totalAmount) ===
|
|
295
|
+
Number((_a = dto.totalAmountPaid) !== null && _a !== void 0 ? _a : currentBilling.totalAmountPaid) +
|
|
296
|
+
Number((_b = dto.creditNoteAmount) !== null && _b !== void 0 ? _b : currentBilling.creditNoteAmount) +
|
|
297
|
+
Number((_c = dto.writeoffAmount) !== null && _c !== void 0 ? _c : currentBilling.writeoffAmount) +
|
|
298
|
+
Number((_d = dto.tdsAmount) !== null && _d !== void 0 ? _d : currentBilling.tdsAmount) -
|
|
299
|
+
Number((_e = dto.refundAmount) !== null && _e !== void 0 ? _e : currentBilling.refundAmount)) {
|
|
300
|
+
return billing_status_enum_1.BillingStatusEnum.SETTLED;
|
|
301
|
+
}
|
|
302
|
+
else {
|
|
303
|
+
return billing_status_enum_1.BillingStatusEnum.PENDING_PAYMENT;
|
|
304
|
+
}
|
|
305
|
+
}
|