law-common 10.63.2-beta.9 → 10.63.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.
@@ -1,4 +1,6 @@
1
- import { IBillingFlowConfig, IBillingFlowContextData } from "../../api";
1
+ import { IBillingFlowContextData } from "../../api";
2
+ import { BillingActionsEnum } from "../enums/billing.action.enum";
2
3
  import { BillingStatusEnum } from "../enums/billing.status.enum";
3
- export declare let billingFlowConfig: IBillingFlowConfig;
4
+ import { FlowConfig } from "./flow-config.type";
5
+ export declare let billingFlowConfig: FlowConfig<BillingStatusEnum, BillingActionsEnum, IBillingFlowContextData>;
4
6
  export declare function getNextStatusTotalAmount(data: IBillingFlowContextData): BillingStatusEnum;
@@ -8,6 +8,7 @@ const billing_action_enum_1 = require("../enums/billing.action.enum");
8
8
  const billing_status_enum_1 = require("../enums/billing.status.enum");
9
9
  exports.billingFlowConfig = {
10
10
  [billing_status_enum_1.BillingStatusEnum.PENDING_APPROVAL]: {
11
+ description: "The Proforma Invoice has been created and is awaiting review and approval by internal stakeholders (org or project approvers).",
11
12
  actions: {
12
13
  [billing_action_enum_1.BillingActionsEnum.APPROVE]: {
13
14
  permissions: ["BILLING_APPROVER_ORG", "BILLING_APPROVER_PROJECT"],
@@ -32,6 +33,7 @@ exports.billingFlowConfig = {
32
33
  },
33
34
  },
34
35
  [billing_status_enum_1.BillingStatusEnum.REQUEST_CHANGES]: {
36
+ description: "Stakeholders have reviewed the Proforma Invoice and requested modifications before it can be approved. The invoice is pending amendments by the billing team.",
35
37
  actions: {
36
38
  [billing_action_enum_1.BillingActionsEnum.EDIT]: {
37
39
  permissions: ["BILLING_AMENDMENT_ORG"],
@@ -46,6 +48,7 @@ exports.billingFlowConfig = {
46
48
  },
47
49
  },
48
50
  [billing_status_enum_1.BillingStatusEnum.INTERNAL_APPROVED]: {
51
+ description: "The Proforma Invoice has been reviewed and approved by internal stakeholders. It is now ready to be forwarded to the client for review.",
49
52
  actions: {
50
53
  [billing_action_enum_1.BillingActionsEnum.SEND_FOR_CLIENT_REVIEW]: {
51
54
  permissions: ["BILLING_AMENDMENT_ORG"],
@@ -55,6 +58,7 @@ exports.billingFlowConfig = {
55
58
  },
56
59
  },
57
60
  [billing_status_enum_1.BillingStatusEnum.PENDING_CLIENT_REVIEW]: {
61
+ 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.",
58
62
  actions: {
59
63
  [billing_action_enum_1.BillingActionsEnum.CLIENT_REVISION]: {
60
64
  permissions: ["BILLING_AMENDMENT_ORG"],
@@ -69,6 +73,7 @@ exports.billingFlowConfig = {
69
73
  },
70
74
  },
71
75
  [billing_status_enum_1.BillingStatusEnum.CLIENT_REVISION_APPROVAL]: {
76
+ 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.",
72
77
  actions: {
73
78
  [billing_action_enum_1.BillingActionsEnum.APPROVAL]: {
74
79
  permissions: ["BILLING_APPROVER_ORG", "BILLING_APPROVER_PROJECT"],
@@ -93,6 +98,7 @@ exports.billingFlowConfig = {
93
98
  },
94
99
  },
95
100
  [billing_status_enum_1.BillingStatusEnum.REJECT_CLIENT_REVISION]: {
101
+ 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.",
96
102
  actions: {
97
103
  [billing_action_enum_1.BillingActionsEnum.SEND_INVOICE]: {
98
104
  permissions: ["BILLING_AMENDMENT_ORG"],
@@ -102,22 +108,24 @@ exports.billingFlowConfig = {
102
108
  },
103
109
  },
104
110
  [billing_status_enum_1.BillingStatusEnum.INVOICE_SENT]: {
111
+ 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.",
105
112
  actions: {
106
113
  [billing_action_enum_1.BillingActionsEnum.UPDATE_PAYMENT]: {
107
114
  permissions: ["BILLING_AMENDMENT_ORG"],
108
115
  next: (data) => {
109
- return getNextStatusTotalAmount(data);
116
+ return data ? getNextStatusTotalAmount(data) : billing_status_enum_1.BillingStatusEnum.INVOICE_SENT;
110
117
  },
111
118
  description: "Updates received payment details and recalculates outstanding amount.",
112
119
  },
113
120
  },
114
121
  },
115
122
  [billing_status_enum_1.BillingStatusEnum.PENDING_PAYMENT]: {
123
+ 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.",
116
124
  actions: {
117
125
  [billing_action_enum_1.BillingActionsEnum.UPDATE_PAYMENT]: {
118
126
  permissions: ["BILLING_AMENDMENT_ORG"],
119
127
  next: (data) => {
120
- return getNextStatusTotalAmount(data);
128
+ return data ? getNextStatusTotalAmount(data) : billing_status_enum_1.BillingStatusEnum.PENDING_PAYMENT;
121
129
  },
122
130
  description: "Tracks partial or full payments until the invoice is completely settled.",
123
131
  },
@@ -130,6 +138,7 @@ exports.billingFlowConfig = {
130
138
  },
131
139
  },
132
140
  [billing_status_enum_1.BillingStatusEnum.SETTLED]: {
141
+ 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.",
133
142
  actions: {},
134
143
  },
135
144
  };
@@ -165,12 +174,11 @@ function addPdfViewToAllStatuses(config) {
165
174
  const PDF_VIEW_ACTION = billing_action_enum_1.BillingActionsEnum.PDF_VIEW;
166
175
  const pdfViewActionConfig = {
167
176
  permissions: ["BILLING_VIEW_PDF"],
168
- next: (status) => status,
169
177
  };
170
178
  for (const [status, configEntry] of Object.entries(config)) {
171
179
  const actions = configEntry.actions;
172
180
  if (!actions[PDF_VIEW_ACTION]) {
173
- actions[PDF_VIEW_ACTION] = Object.assign(Object.assign({}, pdfViewActionConfig), { next: () => status, description: "" });
181
+ actions[PDF_VIEW_ACTION] = Object.assign(Object.assign({}, pdfViewActionConfig), { next: (data) => status, description: "" });
174
182
  }
175
183
  }
176
184
  return config;
@@ -1,13 +1,68 @@
1
+ /**
2
+ * Defines the complete state machine configuration for a domain entity.
3
+ * Maps each status to its available actions and their metadata.
4
+ *
5
+ * Used as the single source of truth for what actions are valid
6
+ * at each status, and what permissions are required to execute them.
7
+ *
8
+ * @template S - String enum of all possible statuses
9
+ * @template A - String enum of all possible actions
10
+ * @template T - Optional context data shape passed to the `next()` resolver.
11
+ * Defaults to `never` for flows where `next()` needs no runtime data.
12
+ *
13
+ * @example
14
+ * // Simple flat flow (billing, leave, vendor)
15
+ * const billingFlowConfig: FlowConfig<BillingStatusEnum, BillingActionsEnum> = {
16
+ * [BillingStatusEnum.PENDING]: {
17
+ * actions: {
18
+ * [BillingActionsEnum.APPROVE]: {
19
+ * permissions: ["BILLING_APPROVE_ORG"],
20
+ * next: () => BillingStatusEnum.APPROVED,
21
+ * },
22
+ * },
23
+ * },
24
+ * };
25
+ *
26
+ * @example
27
+ * // Flow with context data (reimbursement parent)
28
+ * const config: FlowConfig<ReimbursementStatusEnum, ReimbursementActionEnum, IReimbursementFlowContextData> = { ... }
29
+ */
1
30
  export type FlowConfig<S extends string, A extends string, T extends Record<any, any> = never> = {
2
31
  [key in S]?: {
3
32
  actions: {
4
- [key in A]?: {
5
- permissions: string[];
6
- next: (data?: T) => S;
7
- };
33
+ [key in A]?: IFlowConfigActionConfig<S, T>;
8
34
  };
35
+ description?: string;
9
36
  };
10
37
  };
38
+ /**
39
+ * Configuration for a single action within a {@link FlowConfig}.
40
+ * Defines who can execute the action and what status it transitions to.
41
+ *
42
+ * @template S - String enum of statuses, used as the return type of `next()`
43
+ * @template T - Optional context data passed to `next()` for dynamic status resolution.
44
+ * Pass `never` for actions where the next status is always static.
45
+ *
46
+ * @example
47
+ * // Static next status
48
+ * const approveAction: IFlowConfigActionConfig<BillingStatusEnum, never> = {
49
+ * permissions: ["BILLING_APPROVE_ORG"],
50
+ * next: () => BillingStatusEnum.APPROVED,
51
+ * description: "Approve this billing entry",
52
+ * };
53
+ *
54
+ * @example
55
+ * // Dynamic next status based on context
56
+ * const editAction: IFlowConfigActionConfig<ReimbursementStatusEnum, IReimbursementFlowContextData> = {
57
+ * permissions: ["REIMBURSEMENT_UPDATE_SELF"],
58
+ * next: (data) => areAllRowsApproved(data) ? ReimbursementStatusEnum.APPROVED : ReimbursementStatusEnum.APPROVAL_PENDING,
59
+ * };
60
+ */
61
+ export interface IFlowConfigActionConfig<S extends string, T> {
62
+ permissions: string[];
63
+ next: (data?: T) => S;
64
+ description?: string;
65
+ }
11
66
  export type ParentChildFlowConfig<S extends string, A extends string, CS extends string = never, CA extends string = never, T extends Record<any, any> = never> = {
12
67
  parent: FlowConfig<S, A, T>;
13
68
  child: FlowConfig<CS, CA, T>;
@@ -1,2 +1,19 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ // export type FlowConfig<S extends string, A extends string, T extends Record<any, any> = never> = {
4
+ // [key in S]?: {
5
+ // actions: {
6
+ // [key in A]?: {
7
+ // permissions: string[];
8
+ // next: (data?: T) => S;
9
+ // description?: string;
10
+ // };
11
+ // };
12
+ // description?: string;
13
+ // };
14
+ // };
15
+ // export interface IFlowConfigActionConfig<S extends string, T> {
16
+ // permissions: string[];
17
+ // next: (data?: T) => S;
18
+ // description?: string;
19
+ // }
@@ -5,6 +5,7 @@ const leave_action_enum_1 = require("../enums/leave.action.enum");
5
5
  const leave_status_enum_1 = require("../enums/leave.status.enum");
6
6
  exports.leaveFlowConfig = {
7
7
  [leave_status_enum_1.LeaveStatusEnum.PENDING_APPROVAL]: {
8
+ description: "The leave request has been submitted and is awaiting approval from the approver.",
8
9
  actions: {
9
10
  // [LeaveActionEnum.READ]: {
10
11
  // permissions: ["LEAVE_READ_ORG"],
@@ -13,22 +14,27 @@ exports.leaveFlowConfig = {
13
14
  [leave_action_enum_1.LeaveActionEnum.EDIT]: {
14
15
  permissions: ["LEAVE_UPDATE_SELF", "LEAVE_UPDATE_ORG"],
15
16
  next: () => leave_status_enum_1.LeaveStatusEnum.PENDING_APPROVAL,
17
+ description: "Allows the employee to edit the leave request while it is still awaiting approval.",
16
18
  },
17
19
  [leave_action_enum_1.LeaveActionEnum.APPROVE]: {
18
20
  permissions: ["LEAVE_APPROVER_ORG"],
19
21
  next: () => leave_status_enum_1.LeaveStatusEnum.APPROVED,
22
+ description: "Approves the leave request. The employee's leave will be marked as approved.",
20
23
  },
21
24
  [leave_action_enum_1.LeaveActionEnum.REJECT]: {
22
25
  permissions: ["LEAVE_APPROVER_ORG"],
23
26
  next: () => leave_status_enum_1.LeaveStatusEnum.REJECTED,
27
+ description: "Rejects the leave request. The employee will be notified of the rejection.",
24
28
  },
25
29
  [leave_action_enum_1.LeaveActionEnum.DELETE]: {
26
30
  permissions: ["LEAVE_DELETE_SELF"],
27
31
  next: () => leave_status_enum_1.LeaveStatusEnum.DELETED,
32
+ description: "Deletes the leave request entirely before it has been approved.",
28
33
  },
29
34
  },
30
35
  },
31
36
  [leave_status_enum_1.LeaveStatusEnum.EDIT_APPROVAL]: {
37
+ description: "An edit to an existing leave request has been submitted and is awaiting re-approval.",
32
38
  actions: {
33
39
  // [LeaveActionEnum.READ]: {
34
40
  // permissions: ["LEAVE_CREATOR", "LEAVE_APPROVER_ORG"],
@@ -37,22 +43,27 @@ exports.leaveFlowConfig = {
37
43
  [leave_action_enum_1.LeaveActionEnum.EDIT]: {
38
44
  permissions: ["LEAVE_UPDATE_SELF", "LEAVE_UPDATE_ORG"],
39
45
  next: () => leave_status_enum_1.LeaveStatusEnum.EDIT_APPROVAL,
46
+ description: "Allows further edits to the leave request while the edit is pending approval.",
40
47
  },
41
48
  [leave_action_enum_1.LeaveActionEnum.RECALL]: {
42
49
  permissions: ["LEAVE_UPDATE_SELF", "LEAVE_UPDATE_ORG"],
43
50
  next: () => leave_status_enum_1.LeaveStatusEnum.DELETE_APPROVAL, // Rolls back to previous state
51
+ description: "Recalls the edit request, rolling back the leave to its previous approved state.",
44
52
  },
45
53
  [leave_action_enum_1.LeaveActionEnum.REJECT]: {
46
54
  permissions: ["LEAVE_APPROVER_ORG"],
47
55
  next: () => leave_status_enum_1.LeaveStatusEnum.RESOLVE_REJECTED,
56
+ description: "Rejects the requested edit. The leave is moved to a resolve-rejected state for further action.",
48
57
  },
49
58
  [leave_action_enum_1.LeaveActionEnum.APPROVE]: {
50
59
  permissions: ["LEAVE_APPROVER_ORG"],
51
60
  next: () => leave_status_enum_1.LeaveStatusEnum.APPROVED,
61
+ description: "Approves the edited leave request. The updated leave details will be applied.",
52
62
  },
53
63
  },
54
64
  },
55
65
  [leave_status_enum_1.LeaveStatusEnum.DELETE_APPROVAL]: {
66
+ description: "A deletion request for this leave has been submitted and is awaiting approver confirmation.",
56
67
  actions: {
57
68
  // [LeaveActionEnum.READ]: {
58
69
  // permissions: ["LEAVE_CREATOR"],
@@ -61,22 +72,27 @@ exports.leaveFlowConfig = {
61
72
  [leave_action_enum_1.LeaveActionEnum.EDIT]: {
62
73
  permissions: ["LEAVE_UPDATE_SELF", "LEAVE_UPDATE_ORG"],
63
74
  next: () => leave_status_enum_1.LeaveStatusEnum.DELETE_APPROVAL,
75
+ description: "Allows editing the leave request while the deletion is pending approval.",
64
76
  },
65
77
  [leave_action_enum_1.LeaveActionEnum.RECALL]: {
66
78
  permissions: ["LEAVE_UPDATE_SELF", "LEAVE_UPDATE_ORG"],
67
79
  next: () => leave_status_enum_1.LeaveStatusEnum.DELETED, // Rolls back to previous state
80
+ description: "Recalls the deletion request, cancelling the leave entirely.",
68
81
  },
69
82
  [leave_action_enum_1.LeaveActionEnum.REJECT]: {
70
83
  permissions: ["LEAVE_APPROVER_ORG"],
71
84
  next: () => leave_status_enum_1.LeaveStatusEnum.RESOLVE_REJECTED,
85
+ description: "Rejects the deletion request. The leave is moved to a resolve-rejected state.",
72
86
  },
73
87
  [leave_action_enum_1.LeaveActionEnum.APPROVE]: {
74
88
  permissions: ["LEAVE_APPROVER_ORG"],
75
89
  next: () => leave_status_enum_1.LeaveStatusEnum.DELETED,
90
+ description: "Approves the deletion request. The leave record will be permanently deleted.",
76
91
  },
77
92
  },
78
93
  },
79
94
  [leave_status_enum_1.LeaveStatusEnum.APPROVED]: {
95
+ description: "The leave request has been approved. Further edits or deletion require re-approval.",
80
96
  actions: {
81
97
  // [LeaveActionEnum.READ]: {
82
98
  // permissions: ["LEAVE_CREATOR", "LEAVE_APPROVER_ORG"],
@@ -85,10 +101,12 @@ exports.leaveFlowConfig = {
85
101
  [leave_action_enum_1.LeaveActionEnum.EDIT]: {
86
102
  permissions: ["LEAVE_UPDATE_SELF", "LEAVE_UPDATE_ORG"],
87
103
  next: () => leave_status_enum_1.LeaveStatusEnum.EDIT_APPROVAL,
104
+ description: "Requests an edit to an already approved leave. The change will require re-approval.",
88
105
  },
89
106
  [leave_action_enum_1.LeaveActionEnum.DELETE]: {
90
107
  permissions: ["LEAVE_DELETE_SELF"],
91
108
  next: () => leave_status_enum_1.LeaveStatusEnum.DELETE_APPROVAL,
109
+ description: "Requests deletion of an approved leave. The deletion will require approver confirmation.",
92
110
  },
93
111
  },
94
112
  },
@@ -101,6 +119,7 @@ exports.leaveFlowConfig = {
101
119
  // },
102
120
  // },
103
121
  [leave_status_enum_1.LeaveStatusEnum.RESOLVE_REJECTED]: {
122
+ description: "A previous action was rejected and requires the employee to take corrective action.",
104
123
  actions: {
105
124
  // [LeaveActionEnum.READ]: {
106
125
  // permissions: ["LEAVE_CREATOR", "LEAVE_APPROVER_ORG"],
@@ -109,10 +128,12 @@ exports.leaveFlowConfig = {
109
128
  [leave_action_enum_1.LeaveActionEnum.EDIT]: {
110
129
  permissions: ["LEAVE_UPDATE_SELF", "LEAVE_UPDATE_ORG"],
111
130
  next: () => leave_status_enum_1.LeaveStatusEnum.EDIT_APPROVAL,
131
+ description: "Allows the employee to edit and resubmit the leave request after it was rejected.",
112
132
  },
113
133
  [leave_action_enum_1.LeaveActionEnum.DELETE]: {
114
134
  permissions: ["LEAVE_DELETE_SELF"],
115
135
  next: () => leave_status_enum_1.LeaveStatusEnum.DELETE_APPROVAL,
136
+ description: "Requests deletion of the rejected leave record.",
116
137
  },
117
138
  },
118
139
  },
@@ -323,7 +323,7 @@ class BillingEntityModel extends base_entity_model_1.BaseEntityModel {
323
323
  if (nextSeq > 999) {
324
324
  throw new Error("Monthly invoice sequence exhausted");
325
325
  }
326
- console.log("old Sequence", `${basePrefix}${String(nextSeq).padStart(3, "0")}`);
326
+ // console.log("old Sequence", `${basePrefix}${String(nextSeq).padStart(3, "0")}`);
327
327
  return `${basePrefix}${String(nextSeq).padStart(3, "0")}`;
328
328
  }
329
329
  static getNextInvoiceNumberForPastFY(params) {
@@ -71,4 +71,6 @@ export declare class LeaveEntityModel extends BaseEntityModel<EntityEnum.LEAVE>
71
71
  [key: string]: () => boolean;
72
72
  };
73
73
  getNextStatus(currentUser: UserEntityModel, dto: ILeaveUpdateDto): LeaveStatusEnum;
74
+ mapStatusLabel(status: LeaveStatusEnum): string;
75
+ static getFormattedStatus(status: LeaveStatusEnum): string;
74
76
  }
@@ -236,6 +236,32 @@ class LeaveEntityModel extends base_entity_model_1.BaseEntityModel {
236
236
  const nextStatus = matchingPermissionConfig.next();
237
237
  return nextStatus;
238
238
  }
239
+ mapStatusLabel(status) {
240
+ var _a;
241
+ const labelMap = {
242
+ [leave_status_enum_1.LeaveStatusEnum.PENDING_APPROVAL]: "Pending Approval",
243
+ [leave_status_enum_1.LeaveStatusEnum.EDIT_APPROVAL]: "Edit Pending Approval",
244
+ [leave_status_enum_1.LeaveStatusEnum.DELETE_APPROVAL]: "Delete Pending Approval",
245
+ [leave_status_enum_1.LeaveStatusEnum.RESOLVE_REJECTED]: "Resolved Rejected",
246
+ [leave_status_enum_1.LeaveStatusEnum.APPROVED]: "Approved",
247
+ [leave_status_enum_1.LeaveStatusEnum.REJECTED]: "Rejected",
248
+ [leave_status_enum_1.LeaveStatusEnum.DELETED]: "Deleted",
249
+ };
250
+ return (_a = labelMap[status]) !== null && _a !== void 0 ? _a : status;
251
+ }
252
+ static getFormattedStatus(status) {
253
+ let statusToReturn = "";
254
+ if (LeaveEntityModel.getPendingApprovalStatuses().includes(status)) {
255
+ statusToReturn = "PENDING_APPROVAL";
256
+ }
257
+ else if (status === leave_status_enum_1.LeaveStatusEnum.RESOLVE_REJECTED) {
258
+ statusToReturn = "CHANGES_REJECTED";
259
+ }
260
+ else {
261
+ statusToReturn = status.toString();
262
+ }
263
+ return (0, string_util_1.formatString)(statusToReturn);
264
+ }
239
265
  }
240
266
  exports.LeaveEntityModel = LeaveEntityModel;
241
267
  LeaveEntityModel.relationConfigs = [
@@ -49,4 +49,5 @@ export declare class UserEntityModel extends BaseEntityModel<EntityEnum.USER> im
49
49
  getRelationConfigs(): any[];
50
50
  static fromEntity(entity: IUserEntity): UserEntityModel;
51
51
  get roleEntityModel(): RoleEntityModel;
52
+ hasPermission(permissionName: string): boolean;
52
53
  }
@@ -38,7 +38,10 @@ class UserEntityModel extends base_entity_model_1.BaseEntityModel {
38
38
  return result;
39
39
  }
40
40
  get roleEntityModel() {
41
- return this.roleEntityModel;
41
+ return this.roleModel;
42
+ }
43
+ hasPermission(permissionName) {
44
+ return this.roleEntityModel.rolePermissionEntityModels.some((model) => { var _a; return ((_a = model.permission) === null || _a === void 0 ? void 0 : _a.name) === permissionName; });
42
45
  }
43
46
  }
44
47
  exports.UserEntityModel = UserEntityModel;
@@ -7,11 +7,11 @@ import { VendorInvoiceActionStatusEnum } from "../enums/vendor_invoice_action_st
7
7
  import { VendorInvoiceStatusEnum } from "../enums/vendor_invoice_status_enum";
8
8
  import { IUserEntity } from "../interface/user.entity.interface";
9
9
  import { IVendorInvoiceEntity } from "../interface/vendor_invoice.entity.interface";
10
+ import { IRowActions } from "./interface/row-actions.interface";
10
11
  import { OfficeLocationEntityModel } from "./office_location.entity.model";
12
+ import { UserEntityModel } from "./user.entity.model";
11
13
  import { VendorEntityModel } from "./vendor.entity.model";
12
14
  import { VendorInvoiceItemEntityModel } from "./vendor_invoice_item.entity.model";
13
- import { UserEntityModel } from "./user.entity.model";
14
- import { IRowActions } from "./interface/row-actions.interface";
15
15
  export declare class VendorInvoiceEntityModel extends BaseEntityModel<EntityEnum.VENDOR_INVOICE> implements IVendorInvoiceEntity {
16
16
  id: number;
17
17
  vendorId: number;
@@ -46,4 +46,19 @@ export declare class VendorInvoiceEntityModel extends BaseEntityModel<EntityEnum
46
46
  getUpdateActionVisibility(currentUser: UserEntityModel): {
47
47
  [key: string]: () => boolean;
48
48
  };
49
+ static getTotalBasicAmount<T extends {
50
+ basicAmount: number;
51
+ }>(data: T[]): number;
52
+ static getTotalInvoiceAmount<T extends {
53
+ invoiceAmount: number;
54
+ }>(data: T[]): number;
55
+ static getTotalGstAmount<T extends {
56
+ gstAmount: number;
57
+ }>(data: T[]): number;
58
+ static getTotalTdsAmount<T extends {
59
+ tdsAmount: number;
60
+ }>(data: T[]): number;
61
+ static getTotalNetAmount<T extends {
62
+ netAmount: number;
63
+ }>(data: T[]): number;
49
64
  }
@@ -5,12 +5,12 @@ const entity_utils_interface_1 = require("../interface/entity.utils.interface");
5
5
  const base_entity_model_1 = require("./base.entity.model");
6
6
  const error_key_enum_1 = require("../../enums/error.key.enum");
7
7
  const exceptions_1 = require("../../exceptions");
8
+ const utils_1 = require("../../utils");
8
9
  const relation_type_enum_1 = require("../enums/relation-type.enum");
9
10
  const vendor_invoice_action_enum_1 = require("../enums/vendor_invoice_action.enum");
10
11
  const vendor_invoice_action_status_enum_1 = require("../enums/vendor_invoice_action_status_enum");
11
12
  const vendor_invoice_status_enum_1 = require("../enums/vendor_invoice_status_enum");
12
13
  const vendor_invoice_flow_config_1 = require("../flow-configs/vendor-invoice-flow.config");
13
- const utils_1 = require("../../utils");
14
14
  class VendorInvoiceEntityModel extends base_entity_model_1.BaseEntityModel {
15
15
  constructor() {
16
16
  super(...arguments);
@@ -99,6 +99,22 @@ class VendorInvoiceEntityModel extends base_entity_model_1.BaseEntityModel {
99
99
  getUpdateActionVisibility(currentUser) {
100
100
  return {};
101
101
  }
102
+ static getTotalBasicAmount(data) {
103
+ // console.log("data", data);
104
+ return data.reduce((acc, item) => acc + item.basicAmount, 0);
105
+ }
106
+ static getTotalInvoiceAmount(data) {
107
+ return data.reduce((acc, item) => acc + item.invoiceAmount, 0);
108
+ }
109
+ static getTotalGstAmount(data) {
110
+ return data.reduce((acc, item) => acc + item.gstAmount, 0);
111
+ }
112
+ static getTotalTdsAmount(data) {
113
+ return data.reduce((acc, item) => acc + item.tdsAmount, 0);
114
+ }
115
+ static getTotalNetAmount(data) {
116
+ return data.reduce((acc, item) => acc + item.netAmount, 0);
117
+ }
102
118
  }
103
119
  exports.VendorInvoiceEntityModel = VendorInvoiceEntityModel;
104
120
  VendorInvoiceEntityModel.relationConfigs = [
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "law-common",
3
- "version": "10.63.2-beta.9",
3
+ "version": "10.63.2",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "files": [