law-common 10.45.3-beta.17 → 10.45.3-beta.19

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,6 @@
1
+ export * from "./enums/organization.entity.enum";
1
2
  export * from "./enums/task.entity.enum";
2
3
  export * from "./enums/user.entity.enum";
3
- export * from "./enums/organization.entity.enum";
4
4
  export * from "./interface/entity.utils.interface";
5
5
  export * from "./interface/organization.entity.interface";
6
6
  export * from "./interface/task.entity.interface";
@@ -47,12 +47,12 @@ export * from "./enums/entity_search_constraint_type.enum";
47
47
  export * from "./enums/bank_action.enum";
48
48
  export * from "./enums/bank_status.enum";
49
49
  export * from "./interface/bank_history.entity.interface";
50
+ export * from "./enums/duration-type.enum";
51
+ export * from "./enums/leave-type.enum";
50
52
  export * from "./enums/leave.action.enum";
51
53
  export * from "./enums/leave.status.enum";
52
54
  export * from "./interface/leave.entity.interface";
53
55
  export * from "./interface/leave_history.entity.interface";
54
- export * from "./enums/duration-type.enum";
55
- export * from "./enums/leave-type.enum";
56
56
  export * from "./enums/work.from.home.action.enum";
57
57
  export * from "./enums/work.from.home.status.enum";
58
58
  export * from "./interface/work_from_home.entity.interface";
@@ -61,56 +61,56 @@ export * from "./interface/country.entity.interface";
61
61
  export * from "./enums/billing_invoice_type.enum";
62
62
  export * from "./interface/billing_timesheet.entity.interface";
63
63
  export * from "./interface/intermediary_bank.entity.interface";
64
+ export * from "./interface/address-book.entity.interface";
64
65
  export * from "./interface/holiday-list.entity.interface";
65
66
  export * from "./interface/holiday.entity.interface";
66
- export * from "./interface/address-book.entity.interface";
67
- export * from "./model/leave.entity.model";
68
- export * from "./model/leave_count.entity.model";
69
- export * from "./model/holiday.entity.model";
67
+ export * from "./enums/configuration-key.enum";
70
68
  export * from "./enums/cron-jobs-name.enum";
71
69
  export * from "./enums/cron-jobs-status.enum";
72
- export * from "./enums/configuration-key.enum";
73
70
  export * from "./enums/timezone.enum";
74
71
  export * from "./interface/cron-job.entity.interface";
75
- export * from "./model/configuration.model";
76
72
  export * from "./interface/to-do.entity.interface";
77
- export * from "./enums/billing-type.enum";
78
- export * from "./interface/billing-reimbursement-expense.entity.interface";
73
+ export * from "./model/configuration.model";
74
+ export * from "./model/holiday.entity.model";
75
+ export * from "./model/leave.entity.model";
76
+ export * from "./model/leave_count.entity.model";
77
+ export * from "./enums/billing-reimburement-expense-impact.enum";
79
78
  export * from "./enums/billing-reimbursement-expense-change-status.enum";
79
+ export * from "./enums/billing-type.enum";
80
80
  export * from "./interface/billing-reimbursement-expense-history.entity.interface";
81
- export * from "./enums/billing-reimburement-expense-impact.enum";
81
+ export * from "./interface/billing-reimbursement-expense.entity.interface";
82
82
  export * from "./model/bank.entity.model";
83
83
  export * from "./model/base.entity.model";
84
84
  export * from "./model/billing-reimbursement-expense.entity.model";
85
+ export * from "./model/billing-timesheet.entity.model";
85
86
  export * from "./model/billing.entity.model";
87
+ export * from "./model/client-affiliate.entity.model";
88
+ export * from "./model/client.entity.model";
89
+ export * from "./model/configuration.model";
90
+ export * from "./model/country.entity.model";
91
+ export * from "./model/designation.entity.model";
86
92
  export * from "./model/entity.model.interface";
87
93
  export * from "./model/project-user-mapping.entity.model";
88
94
  export * from "./model/project.entity.model";
89
95
  export * from "./model/reimbursement-expense.entity.model";
90
96
  export * from "./model/reimbursement.entity.model";
91
97
  export * from "./model/task.entity.model";
92
- export * from "./model/user.entity.model";
93
- export * from "./model/client.entity.model";
94
- export * from "./model/configuration.model";
95
- export * from "./model/designation.entity.model";
96
98
  export * from "./model/timesheet.entity.model";
97
99
  export * from "./model/user.entity.model";
98
- export * from "./model/client-affiliate.entity.model";
99
- export * from "./model/billing-timesheet.entity.model";
100
- export * from "./model/country.entity.model";
101
100
  export * from "./interface/entity-audit-columns.interface";
102
101
  export * from "./enums/billing-transaction-action.enum";
103
102
  export * from "./enums/billing-transaction-status.enum";
104
103
  export * from "./interface/billing-transaction-history.entity";
105
104
  export * from "./model/billing-transaction.model";
106
- export * from "./interface/address-book.entity.interface";
107
105
  export * from "./enums/address_book_status_enum";
108
- export * from "./interface/state.entity.interface";
106
+ export * from "./interface/address-book.entity.interface";
109
107
  export * from "./enums/state_status_enum";
108
+ export * from "./interface/state.entity.interface";
110
109
  export * from "./model/state.entity.model";
111
- export * from "./interface/gst_rate.entity.interface";
112
110
  export * from "./enums/gst_rate_status_enum";
111
+ export * from "./interface/gst_rate.entity.interface";
113
112
  export * from "./model/gst_rate.entity.model";
114
- export * from "./interface/organization_type.entity.interface";
115
113
  export * from "./enums/organization_type_status_enum";
114
+ export * from "./interface/organization_type.entity.interface";
116
115
  export * from "./model/organization_type.entity.model";
116
+ export * from "./model/interface/billing.model.interface";
@@ -14,9 +14,9 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./enums/organization.entity.enum"), exports);
17
18
  __exportStar(require("./enums/task.entity.enum"), exports);
18
19
  __exportStar(require("./enums/user.entity.enum"), exports);
19
- __exportStar(require("./enums/organization.entity.enum"), exports);
20
20
  __exportStar(require("./interface/entity.utils.interface"), exports);
21
21
  __exportStar(require("./interface/organization.entity.interface"), exports);
22
22
  __exportStar(require("./interface/task.entity.interface"), exports);
@@ -63,12 +63,12 @@ __exportStar(require("./enums/entity_search_constraint_type.enum"), exports);
63
63
  __exportStar(require("./enums/bank_action.enum"), exports);
64
64
  __exportStar(require("./enums/bank_status.enum"), exports);
65
65
  __exportStar(require("./interface/bank_history.entity.interface"), exports);
66
+ __exportStar(require("./enums/duration-type.enum"), exports);
67
+ __exportStar(require("./enums/leave-type.enum"), exports);
66
68
  __exportStar(require("./enums/leave.action.enum"), exports);
67
69
  __exportStar(require("./enums/leave.status.enum"), exports);
68
70
  __exportStar(require("./interface/leave.entity.interface"), exports);
69
71
  __exportStar(require("./interface/leave_history.entity.interface"), exports);
70
- __exportStar(require("./enums/duration-type.enum"), exports);
71
- __exportStar(require("./enums/leave-type.enum"), exports);
72
72
  __exportStar(require("./enums/work.from.home.action.enum"), exports);
73
73
  __exportStar(require("./enums/work.from.home.status.enum"), exports);
74
74
  __exportStar(require("./interface/work_from_home.entity.interface"), exports);
@@ -77,56 +77,56 @@ __exportStar(require("./interface/country.entity.interface"), exports);
77
77
  __exportStar(require("./enums/billing_invoice_type.enum"), exports);
78
78
  __exportStar(require("./interface/billing_timesheet.entity.interface"), exports);
79
79
  __exportStar(require("./interface/intermediary_bank.entity.interface"), exports);
80
+ __exportStar(require("./interface/address-book.entity.interface"), exports);
80
81
  __exportStar(require("./interface/holiday-list.entity.interface"), exports);
81
82
  __exportStar(require("./interface/holiday.entity.interface"), exports);
82
- __exportStar(require("./interface/address-book.entity.interface"), exports);
83
- __exportStar(require("./model/leave.entity.model"), exports);
84
- __exportStar(require("./model/leave_count.entity.model"), exports);
85
- __exportStar(require("./model/holiday.entity.model"), exports);
83
+ __exportStar(require("./enums/configuration-key.enum"), exports);
86
84
  __exportStar(require("./enums/cron-jobs-name.enum"), exports);
87
85
  __exportStar(require("./enums/cron-jobs-status.enum"), exports);
88
- __exportStar(require("./enums/configuration-key.enum"), exports);
89
86
  __exportStar(require("./enums/timezone.enum"), exports);
90
87
  __exportStar(require("./interface/cron-job.entity.interface"), exports);
91
- __exportStar(require("./model/configuration.model"), exports);
92
88
  __exportStar(require("./interface/to-do.entity.interface"), exports);
93
- __exportStar(require("./enums/billing-type.enum"), exports);
94
- __exportStar(require("./interface/billing-reimbursement-expense.entity.interface"), exports);
89
+ __exportStar(require("./model/configuration.model"), exports);
90
+ __exportStar(require("./model/holiday.entity.model"), exports);
91
+ __exportStar(require("./model/leave.entity.model"), exports);
92
+ __exportStar(require("./model/leave_count.entity.model"), exports);
93
+ __exportStar(require("./enums/billing-reimburement-expense-impact.enum"), exports);
95
94
  __exportStar(require("./enums/billing-reimbursement-expense-change-status.enum"), exports);
95
+ __exportStar(require("./enums/billing-type.enum"), exports);
96
96
  __exportStar(require("./interface/billing-reimbursement-expense-history.entity.interface"), exports);
97
- __exportStar(require("./enums/billing-reimburement-expense-impact.enum"), exports);
97
+ __exportStar(require("./interface/billing-reimbursement-expense.entity.interface"), exports);
98
98
  __exportStar(require("./model/bank.entity.model"), exports);
99
99
  __exportStar(require("./model/base.entity.model"), exports);
100
100
  __exportStar(require("./model/billing-reimbursement-expense.entity.model"), exports);
101
+ __exportStar(require("./model/billing-timesheet.entity.model"), exports);
101
102
  __exportStar(require("./model/billing.entity.model"), exports);
103
+ __exportStar(require("./model/client-affiliate.entity.model"), exports);
104
+ __exportStar(require("./model/client.entity.model"), exports);
105
+ __exportStar(require("./model/configuration.model"), exports);
106
+ __exportStar(require("./model/country.entity.model"), exports);
107
+ __exportStar(require("./model/designation.entity.model"), exports);
102
108
  __exportStar(require("./model/entity.model.interface"), exports);
103
109
  __exportStar(require("./model/project-user-mapping.entity.model"), exports);
104
110
  __exportStar(require("./model/project.entity.model"), exports);
105
111
  __exportStar(require("./model/reimbursement-expense.entity.model"), exports);
106
112
  __exportStar(require("./model/reimbursement.entity.model"), exports);
107
113
  __exportStar(require("./model/task.entity.model"), exports);
108
- __exportStar(require("./model/user.entity.model"), exports);
109
- __exportStar(require("./model/client.entity.model"), exports);
110
- __exportStar(require("./model/configuration.model"), exports);
111
- __exportStar(require("./model/designation.entity.model"), exports);
112
114
  __exportStar(require("./model/timesheet.entity.model"), exports);
113
115
  __exportStar(require("./model/user.entity.model"), exports);
114
- __exportStar(require("./model/client-affiliate.entity.model"), exports);
115
- __exportStar(require("./model/billing-timesheet.entity.model"), exports);
116
- __exportStar(require("./model/country.entity.model"), exports);
117
116
  __exportStar(require("./interface/entity-audit-columns.interface"), exports);
118
117
  __exportStar(require("./enums/billing-transaction-action.enum"), exports);
119
118
  __exportStar(require("./enums/billing-transaction-status.enum"), exports);
120
119
  __exportStar(require("./interface/billing-transaction-history.entity"), exports);
121
120
  __exportStar(require("./model/billing-transaction.model"), exports);
122
- __exportStar(require("./interface/address-book.entity.interface"), exports);
123
121
  __exportStar(require("./enums/address_book_status_enum"), exports);
124
- __exportStar(require("./interface/state.entity.interface"), exports);
122
+ __exportStar(require("./interface/address-book.entity.interface"), exports);
125
123
  __exportStar(require("./enums/state_status_enum"), exports);
124
+ __exportStar(require("./interface/state.entity.interface"), exports);
126
125
  __exportStar(require("./model/state.entity.model"), exports);
127
- __exportStar(require("./interface/gst_rate.entity.interface"), exports);
128
126
  __exportStar(require("./enums/gst_rate_status_enum"), exports);
127
+ __exportStar(require("./interface/gst_rate.entity.interface"), exports);
129
128
  __exportStar(require("./model/gst_rate.entity.model"), exports);
130
- __exportStar(require("./interface/organization_type.entity.interface"), exports);
131
129
  __exportStar(require("./enums/organization_type_status_enum"), exports);
130
+ __exportStar(require("./interface/organization_type.entity.interface"), exports);
132
131
  __exportStar(require("./model/organization_type.entity.model"), exports);
132
+ __exportStar(require("./model/interface/billing.model.interface"), exports);
@@ -20,7 +20,7 @@ export interface IBillingEntity extends IEntityAuditColumn {
20
20
  totalAmountPaid: number;
21
21
  tdsAmount: number;
22
22
  creditNoteAmount: number;
23
- refundAmount?: number;
23
+ refundAmount: number;
24
24
  invoiceEntityId: number;
25
25
  invoiceEntityType: BillingInvoiceTypeEnum;
26
26
  invoicePdfUrl?: string | null;
@@ -36,4 +36,5 @@ export declare class BillingTransactionEntityModel extends BaseEntityModel<Entit
36
36
  EntityEnum.BILLING
37
37
  ], EnumEntityType<EntityEnum.BILLING_TRANSACTION>>;
38
38
  static fromEntity(entity: IBillingTransactionEntity): BillingTransactionEntityModel;
39
+ static sumAmounts(transactions: BillingTransactionEntityModel[]): number;
39
40
  }
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.BillingTransactionEntityModel = void 0;
4
+ const utils_1 = require("../../utils");
4
5
  const billing_transaction_status_enum_1 = require("../enums/billing-transaction-status.enum");
5
6
  const billing_transaction_enum_1 = require("../enums/billing.transaction.enum");
6
7
  const relation_type_enum_1 = require("../enums/relation-type.enum");
@@ -31,6 +32,16 @@ class BillingTransactionEntityModel extends base_entity_model_1.BaseEntityModel
31
32
  Object.assign(result, entity);
32
33
  return result;
33
34
  }
35
+ static sumAmounts(transactions) {
36
+ return (0, utils_1.sumArray)(transactions.map((t) => {
37
+ var _a;
38
+ return ({
39
+ amount: typeof t.amount === "string"
40
+ ? (0, utils_1.getDecimalNumberFromString)(t.amount)
41
+ : ((_a = t.amount) !== null && _a !== void 0 ? _a : 0),
42
+ });
43
+ }), "amount");
44
+ }
34
45
  }
35
46
  exports.BillingTransactionEntityModel = BillingTransactionEntityModel;
36
47
  BillingTransactionEntityModel.relationConfigs = [
@@ -6,6 +6,7 @@ import { BillingStatusEnum } from "../enums/billing.status.enum";
6
6
  import { BillingInvoiceTypeEnum } from "../enums/billing_invoice_type.enum";
7
7
  import { PaymentStatusEnum } from "../enums/payment_status.enum";
8
8
  import { IBillingEntity } from "../interface/billing.entity.interface";
9
+ import { IBillingTransactionEntity } from "../interface/billing_transaction.entity.interface";
9
10
  import { EntityEnum, EnumEntityType } from "../interface/entity.utils.interface";
10
11
  import { RelationConfigs } from "../interface/relation-config.interface";
11
12
  import { BankEntityModel } from "./bank.entity.model";
@@ -14,6 +15,7 @@ import { BillingReimbursementExpneseEntityModel } from "./billing-reimbursement-
14
15
  import { BillingTimesheetEntityModel } from "./billing-timesheet.entity.model";
15
16
  import { BillingTransactionEntityModel } from "./billing-transaction.model";
16
17
  import { ClientEntityModel } from "./client.entity.model";
18
+ import { IAdvanceBillingTransactionsSummary } from "./interface/billing.model.interface";
17
19
  import { ProjectEntityModel } from "./project.entity.model";
18
20
  import { ReimbursementExpenseEntityModel } from "./reimbursement-expense.entity.model";
19
21
  import { UserEntityModel } from "./user.entity.model";
@@ -40,7 +42,7 @@ export declare class BillingEntityModel extends BaseEntityModel<EntityEnum.BILLI
40
42
  totalAmountPaid: number;
41
43
  tdsAmount: number;
42
44
  creditNoteAmount: number;
43
- refundAmount?: number;
45
+ refundAmount: number;
44
46
  invoiceEntityId: number;
45
47
  invoiceEntityType: BillingInvoiceTypeEnum;
46
48
  invoicePdfUrl?: string | null;
@@ -88,4 +90,17 @@ export declare class BillingEntityModel extends BaseEntityModel<EntityEnum.BILLI
88
90
  [key: string]: () => boolean;
89
91
  }): BillingActionsEnum[];
90
92
  getRelationConfigs(): any;
93
+ getAdvanceBillingTransactionsSummary(adjustedBillingTransactions: IBillingTransactionEntity[]): IAdvanceBillingTransactionsSummary;
94
+ private getUseableTDSAmount;
95
+ private getUsedTDSAmount;
96
+ private getTotalTDSAmount;
97
+ private getTotalRecieptAmount;
98
+ private getUseableRecieptAmount;
99
+ private getUsedRecieptAmount;
100
+ private getUseableAmount;
101
+ private getUsedAmount;
102
+ getTotalAmountRecieved(): number;
103
+ getTotalRecievableAmount(): number;
104
+ validateAdvanceBillingId(adjustedBillingTransactions: IBillingTransactionEntity[]): void;
105
+ getApprovedBillingTransactionsTotalAmount(): number;
91
106
  }
@@ -2,9 +2,13 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.BillingEntityModel = exports.BillingStatusCategoryEnumForUI = void 0;
4
4
  const enums_1 = require("../../enums");
5
+ const error_key_enum_1 = require("../../enums/error.key.enum");
6
+ const exceptions_1 = require("../../exceptions");
5
7
  const utils_1 = require("../../utils");
8
+ const billing_transaction_status_enum_1 = require("../enums/billing-transaction-status.enum");
6
9
  const billing_type_enum_1 = require("../enums/billing-type.enum");
7
10
  const billing_status_enum_1 = require("../enums/billing.status.enum");
11
+ const billing_transaction_enum_1 = require("../enums/billing.transaction.enum");
8
12
  const billing_invoice_type_enum_1 = require("../enums/billing_invoice_type.enum");
9
13
  const payment_status_enum_1 = require("../enums/payment_status.enum");
10
14
  const relation_type_enum_1 = require("../enums/relation-type.enum");
@@ -182,6 +186,84 @@ class BillingEntityModel extends base_entity_model_1.BaseEntityModel {
182
186
  getRelationConfigs() {
183
187
  return this.constructor.prototype.constructor.relationConfigs || [];
184
188
  }
189
+ getAdvanceBillingTransactionsSummary(adjustedBillingTransactions) {
190
+ this.validateAdvanceBillingId(adjustedBillingTransactions);
191
+ if (this.type === billing_type_enum_1.BillingTypeEnum.ADVANCE) {
192
+ return {
193
+ useAbleTdsAmount: this.getUseableTDSAmount(adjustedBillingTransactions),
194
+ usedTdsAmount: this.getUsedTDSAmount(adjustedBillingTransactions),
195
+ useableRecieptAmount: this.getUseableRecieptAmount(adjustedBillingTransactions),
196
+ usedRecieptAmount: this.getUsedRecieptAmount(adjustedBillingTransactions),
197
+ totalUsableAmount: this.getUseableAmount(adjustedBillingTransactions),
198
+ totalUsedAmount: this.getUsedAmount(adjustedBillingTransactions),
199
+ totalTDSAmount: this.getTotalTDSAmount(adjustedBillingTransactions),
200
+ totalRecieptAmount: this.getTotalRecieptAmount(adjustedBillingTransactions),
201
+ };
202
+ }
203
+ return {};
204
+ }
205
+ getUseableTDSAmount(adjustedBillingTransactions) {
206
+ return ((0, utils_1.getDecimalNumberFromString)(this.tdsAmount) -
207
+ this.getUsedTDSAmount(adjustedBillingTransactions));
208
+ }
209
+ getUsedTDSAmount(adjustedBillingTransactions) {
210
+ return (0, utils_1.sumNormalised)(adjustedBillingTransactions.filter((transaction) => transaction.type === billing_transaction_enum_1.BillingTransactionType.TDS), "amount");
211
+ }
212
+ getTotalTDSAmount(adjustedBillingTransactions) {
213
+ return (this.getUseableTDSAmount(adjustedBillingTransactions) +
214
+ this.getUsedTDSAmount(adjustedBillingTransactions));
215
+ }
216
+ getTotalRecieptAmount(adjustedBillingTransactions) {
217
+ return (this.getUseableRecieptAmount(adjustedBillingTransactions) +
218
+ this.getUsedRecieptAmount(adjustedBillingTransactions));
219
+ }
220
+ getUseableRecieptAmount(adjustedBillingTransactions) {
221
+ return ((0, utils_1.getDecimalNumberFromString)(this.totalAmountPaid) -
222
+ this.getUsedRecieptAmount(adjustedBillingTransactions));
223
+ }
224
+ getUsedRecieptAmount(adjustedBillingTransactions) {
225
+ return (0, utils_1.sumNormalised)(adjustedBillingTransactions.filter((transaction) => transaction.type === billing_transaction_enum_1.BillingTransactionType.RECEIPT), "amount");
226
+ }
227
+ getUseableAmount(adjustedBillingTransactions) {
228
+ return (this.getUseableRecieptAmount(adjustedBillingTransactions) +
229
+ this.getUseableTDSAmount(adjustedBillingTransactions));
230
+ }
231
+ getUsedAmount(adjustedBillingTransactions) {
232
+ return (this.getUsedRecieptAmount(adjustedBillingTransactions) +
233
+ this.getUsedTDSAmount(adjustedBillingTransactions));
234
+ }
235
+ getTotalAmountRecieved() {
236
+ var _a, _b, _c, _d;
237
+ const amountRecieved = (0, utils_1.sumNormalised)((_b = (_a = this.billingTransactions) === null || _a === void 0 ? void 0 : _a.filter((transaction) => [billing_transaction_enum_1.BillingTransactionType.TDS, billing_transaction_enum_1.BillingTransactionType.RECEIPT].includes(transaction.type))) !== null && _b !== void 0 ? _b : [], "amount") -
238
+ (0, utils_1.sumNormalised)((_d = (_c = this.billingTransactions) === null || _c === void 0 ? void 0 : _c.filter((transaction) => transaction.type === billing_transaction_enum_1.BillingTransactionType.REFUND)) !== null && _d !== void 0 ? _d : [], "amount");
239
+ return amountRecieved;
240
+ }
241
+ getTotalRecievableAmount() {
242
+ var _a, _b;
243
+ return ((0, utils_1.getDecimalNumberFromString)(this.totalAmount) -
244
+ (this.getTotalAmountRecieved() +
245
+ (0, utils_1.sumNormalised)((_b = (_a = this.billingTransactions) === null || _a === void 0 ? void 0 : _a.filter((transaction) => [
246
+ billing_transaction_enum_1.BillingTransactionType.CREDIT_NOTE,
247
+ billing_transaction_enum_1.BillingTransactionType.WRITE_OFF,
248
+ ].includes(transaction.type))) !== null && _b !== void 0 ? _b : [], "amount")));
249
+ }
250
+ validateAdvanceBillingId(adjustedBillingTransactions) {
251
+ for (const item of adjustedBillingTransactions) {
252
+ if (item.advanceBillingId === null) {
253
+ throw new exceptions_1.AppBadRequestException({
254
+ key: error_key_enum_1.ErrorKeyEnum.BANK_FLOW_ACTION,
255
+ message: [`Lorem`],
256
+ });
257
+ }
258
+ }
259
+ }
260
+ getApprovedBillingTransactionsTotalAmount() {
261
+ var _a, _b;
262
+ return (0, utils_1.sumNormalised)((_b = (_a = this.billingTransactions) === null || _a === void 0 ? void 0 : _a.filter((entity) => ![
263
+ billing_transaction_status_enum_1.BillingTransactionStatusEnum.CREDITNOTE_APPROVAL_PENDING,
264
+ billing_transaction_status_enum_1.BillingTransactionStatusEnum.WRITEOFF_APPROVAL_PENDING,
265
+ ].includes(entity.status))) !== null && _b !== void 0 ? _b : [], "amount");
266
+ }
185
267
  }
186
268
  exports.BillingEntityModel = BillingEntityModel;
187
269
  BillingEntityModel.relationConfigs = [
@@ -0,0 +1,10 @@
1
+ export interface IAdvanceBillingTransactionsSummary {
2
+ useAbleTdsAmount: number;
3
+ usedTdsAmount: number;
4
+ useableRecieptAmount: number;
5
+ usedRecieptAmount: number;
6
+ totalUsableAmount: number;
7
+ totalUsedAmount: number;
8
+ totalTDSAmount: number;
9
+ totalRecieptAmount: number;
10
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -333,20 +333,42 @@ export declare function convertToNumberType<T extends string | number>(value: T)
333
333
  * // Returns: "1970-01-01 05:30:00" // if your system timezone is IST (UTC+5:30)
334
334
  */
335
335
  export declare function epochToDateTime(epoch: number): string;
336
+ export declare function dateTimeToEpoch(dateInput: string | Date): number;
337
+ export declare function checkEmptyObj<T extends Record<string, any>>(obj: T): boolean;
336
338
  /**
337
- * Converts a JavaScript Date object into epoch seconds (UNIX timestamp).
339
+ * Normalises the value of a given key in an array of objects.
340
+ *
341
+ * If the value is a string or number, it is converted into a decimal number
342
+ * using `getDecimalNumberFromString`. Other value types are left unchanged.
343
+ *
344
+ * @template T
338
345
  *
339
- * @param {Date} date - A JavaScript Date instance.
346
+ * @param {T[]} input - Array of objects to be normalised.
347
+ * @param {keyof T} key - The object key whose value should be normalised.
340
348
  *
341
- * @returns {number} The corresponding epoch time in seconds (number of seconds since 1970-01-01 00:00:00 UTC).
349
+ * @returns {T[]} A new array with the specified key normalised.
342
350
  *
343
351
  * @example
344
- * toEpochSeconds(new Date("2025-09-30 11:19:25"));
345
- * // Returns: 1759211965
352
+ * getNormalisedFromKey([{ amount: "1,200.50" }], "amount");
353
+ * // Returns: [{ amount: 1200.5 }]
354
+ */
355
+ export declare function getNormalisedFromKey<T>(input: T[], key: keyof T): T[];
356
+ /**
357
+ * Normalises the value of a given key in an array of objects
358
+ * and returns the sum of the normalised values.
359
+ *
360
+ * Internally, this function first normalises the values using
361
+ * `getNormalisedFromKey` and then sums them using `sumArray`.
362
+ *
363
+ * @template T
364
+ *
365
+ * @param {T[]} input - Array of objects whose values should be summed.
366
+ * @param {keyof T} key - The object key to normalise and sum.
367
+ *
368
+ * @returns {number} The sum of the normalised values for the given key.
346
369
  *
347
370
  * @example
348
- * toEpochSeconds(new Date());
349
- * // Returns: current epoch time in seconds
371
+ * sumNormalised([{ amount: "100" }, { amount: "200.5" }], "amount");
372
+ * // Returns: 300.5
350
373
  */
351
- export declare function toEpochSeconds(date: Date): number;
352
- export declare function dateTimeToEpoch(dateInput: string | Date): number;
374
+ export declare function sumNormalised<T>(input: T[], key: keyof T): number;
@@ -42,8 +42,10 @@ exports.getDecimalNumberFromString = getDecimalNumberFromString;
42
42
  exports.hasProperty = hasProperty;
43
43
  exports.convertToNumberType = convertToNumberType;
44
44
  exports.epochToDateTime = epochToDateTime;
45
- exports.toEpochSeconds = toEpochSeconds;
46
45
  exports.dateTimeToEpoch = dateTimeToEpoch;
46
+ exports.checkEmptyObj = checkEmptyObj;
47
+ exports.getNormalisedFromKey = getNormalisedFromKey;
48
+ exports.sumNormalised = sumNormalised;
47
49
  const date_fns_1 = require("date-fns");
48
50
  const lodash_1 = require("lodash");
49
51
  const util_constants_1 = require("../constants/util.constants");
@@ -687,25 +689,53 @@ function epochToDateTime(epoch) {
687
689
  const date = new Date(epoch * 1000); // JS Date expects milliseconds
688
690
  return (0, date_fns_1.format)(date, "yyyy-MM-dd HH:mm:ss");
689
691
  }
692
+ function dateTimeToEpoch(dateInput) {
693
+ const date = typeof dateInput === "string" ? new Date(dateInput) : dateInput;
694
+ return Math.floor(date.getTime() / 1000);
695
+ }
696
+ function checkEmptyObj(obj) {
697
+ return Object.keys(obj).length === 0;
698
+ }
690
699
  /**
691
- * Converts a JavaScript Date object into epoch seconds (UNIX timestamp).
700
+ * Normalises the value of a given key in an array of objects.
692
701
  *
693
- * @param {Date} date - A JavaScript Date instance.
702
+ * If the value is a string or number, it is converted into a decimal number
703
+ * using `getDecimalNumberFromString`. Other value types are left unchanged.
694
704
  *
695
- * @returns {number} The corresponding epoch time in seconds (number of seconds since 1970-01-01 00:00:00 UTC).
705
+ * @template T
696
706
  *
697
- * @example
698
- * toEpochSeconds(new Date("2025-09-30 11:19:25"));
699
- * // Returns: 1759211965
707
+ * @param {T[]} input - Array of objects to be normalised.
708
+ * @param {keyof T} key - The object key whose value should be normalised.
709
+ *
710
+ * @returns {T[]} A new array with the specified key normalised.
700
711
  *
701
712
  * @example
702
- * toEpochSeconds(new Date());
703
- * // Returns: current epoch time in seconds
713
+ * getNormalisedFromKey([{ amount: "1,200.50" }], "amount");
714
+ * // Returns: [{ amount: 1200.5 }]
704
715
  */
705
- function toEpochSeconds(date) {
706
- return Math.floor(date.getTime() / 1000);
716
+ function getNormalisedFromKey(input, key) {
717
+ return input.map((inp) => (Object.assign(Object.assign({}, inp), { [key]: typeof inp[key] === "string" || typeof inp[key] === "number"
718
+ ? getDecimalNumberFromString(inp[key])
719
+ : inp[key] })));
707
720
  }
708
- function dateTimeToEpoch(dateInput) {
709
- const date = typeof dateInput === "string" ? new Date(dateInput) : dateInput;
710
- return Math.floor(date.getTime() / 1000);
721
+ /**
722
+ * Normalises the value of a given key in an array of objects
723
+ * and returns the sum of the normalised values.
724
+ *
725
+ * Internally, this function first normalises the values using
726
+ * `getNormalisedFromKey` and then sums them using `sumArray`.
727
+ *
728
+ * @template T
729
+ *
730
+ * @param {T[]} input - Array of objects whose values should be summed.
731
+ * @param {keyof T} key - The object key to normalise and sum.
732
+ *
733
+ * @returns {number} The sum of the normalised values for the given key.
734
+ *
735
+ * @example
736
+ * sumNormalised([{ amount: "100" }, { amount: "200.5" }], "amount");
737
+ * // Returns: 300.5
738
+ */
739
+ function sumNormalised(input, key) {
740
+ return sumArray(getNormalisedFromKey(input, key), key);
711
741
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "law-common",
3
- "version": "10.45.3-beta.17",
3
+ "version": "10.45.3-beta.19",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "files": [