law-common 10.45.3-beta.18 → 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.
@@ -102,4 +102,5 @@ export declare class BillingEntityModel extends BaseEntityModel<EntityEnum.BILLI
102
102
  getTotalAmountRecieved(): number;
103
103
  getTotalRecievableAmount(): number;
104
104
  validateAdvanceBillingId(adjustedBillingTransactions: IBillingTransactionEntity[]): void;
105
+ getApprovedBillingTransactionsTotalAmount(): number;
105
106
  }
@@ -5,6 +5,7 @@ const enums_1 = require("../../enums");
5
5
  const error_key_enum_1 = require("../../enums/error.key.enum");
6
6
  const exceptions_1 = require("../../exceptions");
7
7
  const utils_1 = require("../../utils");
8
+ const billing_transaction_status_enum_1 = require("../enums/billing-transaction-status.enum");
8
9
  const billing_type_enum_1 = require("../enums/billing-type.enum");
9
10
  const billing_status_enum_1 = require("../enums/billing.status.enum");
10
11
  const billing_transaction_enum_1 = require("../enums/billing.transaction.enum");
@@ -207,17 +208,6 @@ class BillingEntityModel extends base_entity_model_1.BaseEntityModel {
207
208
  }
208
209
  getUsedTDSAmount(adjustedBillingTransactions) {
209
210
  return (0, utils_1.sumNormalised)(adjustedBillingTransactions.filter((transaction) => transaction.type === billing_transaction_enum_1.BillingTransactionType.TDS), "amount");
210
- // sumArray(
211
- // adjustedBillingTransactions
212
- // .filter(
213
- // (transaction) => transaction.type === BillingTransactionType.TDS,
214
- // )
215
- // .map((transaction) => ({
216
- // ...transaction,
217
- // amount: getDecimalNumberFromString(transaction.amount),
218
- // })),
219
- // "amount",
220
- // );
221
211
  }
222
212
  getTotalTDSAmount(adjustedBillingTransactions) {
223
213
  return (this.getUseableTDSAmount(adjustedBillingTransactions) +
@@ -233,17 +223,6 @@ class BillingEntityModel extends base_entity_model_1.BaseEntityModel {
233
223
  }
234
224
  getUsedRecieptAmount(adjustedBillingTransactions) {
235
225
  return (0, utils_1.sumNormalised)(adjustedBillingTransactions.filter((transaction) => transaction.type === billing_transaction_enum_1.BillingTransactionType.RECEIPT), "amount");
236
- // sumArray(
237
- // adjustedBillingTransactions
238
- // .filter(
239
- // (transaction) => transaction.type === BillingTransactionType.RECEIPT,
240
- // )
241
- // .map((transaction) => ({
242
- // ...transaction,
243
- // amount: getDecimalNumberFromString(transaction.amount),
244
- // })),
245
- // "amount",
246
- // );
247
226
  }
248
227
  getUseableAmount(adjustedBillingTransactions) {
249
228
  return (this.getUseableRecieptAmount(adjustedBillingTransactions) +
@@ -255,22 +234,7 @@ class BillingEntityModel extends base_entity_model_1.BaseEntityModel {
255
234
  }
256
235
  getTotalAmountRecieved() {
257
236
  var _a, _b, _c, _d;
258
- const amountRecieved =
259
- // sumArray(
260
- // this.billingTransactions
261
- // ?.filter((transaction) =>
262
- // [
263
- // BillingTransactionType.TDS,
264
- // BillingTransactionType.RECEIPT,
265
- // ].includes(transaction.type),
266
- // )
267
- // .map((transaction) => ({
268
- // ...transaction,
269
- // amount: getDecimalNumberFromString(transaction.amount),
270
- // })) ?? [],
271
- // "amount",
272
- // ) -
273
- (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") -
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") -
274
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");
275
239
  return amountRecieved;
276
240
  }
@@ -281,20 +245,7 @@ class BillingEntityModel extends base_entity_model_1.BaseEntityModel {
281
245
  (0, utils_1.sumNormalised)((_b = (_a = this.billingTransactions) === null || _a === void 0 ? void 0 : _a.filter((transaction) => [
282
246
  billing_transaction_enum_1.BillingTransactionType.CREDIT_NOTE,
283
247
  billing_transaction_enum_1.BillingTransactionType.WRITE_OFF,
284
- ].includes(transaction.type))) !== null && _b !== void 0 ? _b : [], "amount"))
285
- // sumArray(
286
- // getNormalisedFromKey(
287
- // this.billingTransactions?.filter((transaction) =>
288
- // [
289
- // BillingTransactionType.CREDIT_NOTE,
290
- // BillingTransactionType.WRITE_OFF,
291
- // ].includes(transaction.type),
292
- // ) ?? [],
293
- // "amount",
294
- // ),
295
- // "amount",
296
- // )
297
- );
248
+ ].includes(transaction.type))) !== null && _b !== void 0 ? _b : [], "amount")));
298
249
  }
299
250
  validateAdvanceBillingId(adjustedBillingTransactions) {
300
251
  for (const item of adjustedBillingTransactions) {
@@ -306,6 +257,13 @@ class BillingEntityModel extends base_entity_model_1.BaseEntityModel {
306
257
  }
307
258
  }
308
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
+ }
309
267
  }
310
268
  exports.BillingEntityModel = BillingEntityModel;
311
269
  BillingEntityModel.relationConfigs = [
@@ -333,22 +333,6 @@ 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
- /**
337
- * Converts a JavaScript Date object into epoch seconds (UNIX timestamp).
338
- *
339
- * @param {Date} date - A JavaScript Date instance.
340
- *
341
- * @returns {number} The corresponding epoch time in seconds (number of seconds since 1970-01-01 00:00:00 UTC).
342
- *
343
- * @example
344
- * toEpochSeconds(new Date("2025-09-30 11:19:25"));
345
- * // Returns: 1759211965
346
- *
347
- * @example
348
- * toEpochSeconds(new Date());
349
- * // Returns: current epoch time in seconds
350
- */
351
- export declare function toEpochSeconds(date: Date): number;
352
336
  export declare function dateTimeToEpoch(dateInput: string | Date): number;
353
337
  export declare function checkEmptyObj<T extends Record<string, any>>(obj: T): boolean;
354
338
  /**
@@ -42,7 +42,6 @@ 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;
47
46
  exports.checkEmptyObj = checkEmptyObj;
48
47
  exports.getNormalisedFromKey = getNormalisedFromKey;
@@ -690,24 +689,6 @@ function epochToDateTime(epoch) {
690
689
  const date = new Date(epoch * 1000); // JS Date expects milliseconds
691
690
  return (0, date_fns_1.format)(date, "yyyy-MM-dd HH:mm:ss");
692
691
  }
693
- /**
694
- * Converts a JavaScript Date object into epoch seconds (UNIX timestamp).
695
- *
696
- * @param {Date} date - A JavaScript Date instance.
697
- *
698
- * @returns {number} The corresponding epoch time in seconds (number of seconds since 1970-01-01 00:00:00 UTC).
699
- *
700
- * @example
701
- * toEpochSeconds(new Date("2025-09-30 11:19:25"));
702
- * // Returns: 1759211965
703
- *
704
- * @example
705
- * toEpochSeconds(new Date());
706
- * // Returns: current epoch time in seconds
707
- */
708
- function toEpochSeconds(date) {
709
- return Math.floor(date.getTime() / 1000);
710
- }
711
692
  function dateTimeToEpoch(dateInput) {
712
693
  const date = typeof dateInput === "string" ? new Date(dateInput) : dateInput;
713
694
  return Math.floor(date.getTime() / 1000);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "law-common",
3
- "version": "10.45.3-beta.18",
3
+ "version": "10.45.3-beta.19",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "files": [