law-common 10.45.3-beta.9 → 10.46.0

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.
Files changed (25) hide show
  1. package/dist/src/api/interface/billing.create.dto.interface.d.ts +2 -1
  2. package/dist/src/api/interface/expense_type.update.dto.d.ts +4 -1
  3. package/dist/src/entities/enums/billing.transaction.enum.d.ts +2 -1
  4. package/dist/src/entities/enums/billing.transaction.enum.js +2 -1
  5. package/dist/src/entities/index.d.ts +23 -23
  6. package/dist/src/entities/index.js +23 -23
  7. package/dist/src/entities/interface/billing.entity.interface.d.ts +1 -0
  8. package/dist/src/entities/interface/billing_transaction.entity.interface.d.ts +1 -0
  9. package/dist/src/entities/model/billing-transaction.model.d.ts +2 -0
  10. package/dist/src/entities/model/billing-transaction.model.js +13 -1
  11. package/dist/src/entities/model/billing.entity.model.d.ts +16 -0
  12. package/dist/src/entities/model/billing.entity.model.js +84 -14
  13. package/dist/src/entities/model/interface/billing.model.interface.d.ts +10 -0
  14. package/dist/src/entities/model/interface/billing.model.interface.js +2 -0
  15. package/dist/src/enums/error.key.enum.d.ts +2 -1
  16. package/dist/src/enums/error.key.enum.js +1 -0
  17. package/dist/src/misc/config/app-file-config.d.ts +7 -0
  18. package/dist/src/misc/config/app-file-config.js +2 -0
  19. package/dist/src/misc/index.d.ts +3 -1
  20. package/dist/src/misc/index.js +3 -1
  21. package/dist/src/misc/type/delete-document-details.type.d.ts +1 -0
  22. package/dist/src/misc/type/delete-document-details.type.js +2 -0
  23. package/dist/src/utils/helper.fn.util.d.ts +54 -9
  24. package/dist/src/utils/helper.fn.util.js +76 -14
  25. package/package.json +37 -37
@@ -1,5 +1,5 @@
1
1
  import { BillingImpactEnum, BillingReimbursementExpenseChangedStatusEnum, BillingStatusEnum, IBillingEntity, IBillingTimesheetEntity, IEntityCreateDto, IProjectEntity, ITimesheetEntity } from "../../entities";
2
- export type IBillingCreateExclude = "paymentStatus" | "status" | "writeoffAmount" | "tdsAmount" | "totalAmountPaid" | "creditNoteAmount" | "invoicePdfUrl" | "startDate" | "endDate";
2
+ export type IBillingCreateExclude = "paymentStatus" | "status" | "writeoffAmount" | "tdsAmount" | "totalAmountPaid" | "creditNoteAmount" | "refundAmount" | "invoicePdfUrl" | "startDate" | "endDate";
3
3
  export interface IBillingCreateDto extends Omit<IEntityCreateDto<IBillingEntity>, IBillingCreateExclude | "particulars"> {
4
4
  timesheets?: IBillingTimesheetsDto;
5
5
  status?: BillingStatusEnum;
@@ -9,6 +9,7 @@ export interface IBillingCreateDto extends Omit<IEntityCreateDto<IBillingEntity>
9
9
  endDate?: string;
10
10
  }
11
11
  export interface IBillingParticulars {
12
+ invoiceDescription: string;
12
13
  invoiceText?: string;
13
14
  debitNoteText?: string;
14
15
  includeDebitNoteSummary: boolean;
@@ -1,6 +1,9 @@
1
- import { ExpenseTypeEnum } from "../../entities";
1
+ import { ExpenseTypeEnum, IExpenseTypeEntity } from "../../entities";
2
2
  export interface IExpenseTypeUpdateDto {
3
3
  name?: string;
4
4
  description?: string;
5
5
  type?: ExpenseTypeEnum;
6
6
  }
7
+ export interface IExpenseTypeUpdateDtoValidationData {
8
+ existingEntity: IExpenseTypeEntity;
9
+ }
@@ -2,7 +2,8 @@ export declare enum BillingTransactionType {
2
2
  TDS = "TDS",
3
3
  WRITE_OFF = "WRITE_OFF",
4
4
  CREDIT_NOTE = "CREDIT_NOTE",
5
- PAYMENT = "PAYMENT"
5
+ RECEIPT = "RECEIPT",
6
+ REFUND = "REFUND"
6
7
  }
7
8
  export declare namespace BillingTransactionType {
8
9
  function getNames(): string[];
@@ -8,7 +8,8 @@ var BillingTransactionType;
8
8
  BillingTransactionType["TDS"] = "TDS";
9
9
  BillingTransactionType["WRITE_OFF"] = "WRITE_OFF";
10
10
  BillingTransactionType["CREDIT_NOTE"] = "CREDIT_NOTE";
11
- BillingTransactionType["PAYMENT"] = "PAYMENT";
11
+ BillingTransactionType["RECEIPT"] = "RECEIPT";
12
+ BillingTransactionType["REFUND"] = "REFUND";
12
13
  })(BillingTransactionType || (exports.BillingTransactionType = BillingTransactionType = {}));
13
14
  (function (BillingTransactionType) {
14
15
  function getNames() {
@@ -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,6 +20,7 @@ export interface IBillingEntity extends IEntityAuditColumn {
20
20
  totalAmountPaid: number;
21
21
  tdsAmount: number;
22
22
  creditNoteAmount: number;
23
+ refundAmount: number;
23
24
  invoiceEntityId: number;
24
25
  invoiceEntityType: BillingInvoiceTypeEnum;
25
26
  invoicePdfUrl?: string | null;
@@ -5,6 +5,7 @@ import { IEntityFilterData } from "./entity.utils.interface";
5
5
  export interface IBillingTransactionEntity extends IEntityAuditColumn {
6
6
  id: number;
7
7
  billingId: number;
8
+ advanceBillingId?: number;
8
9
  type: BillingTransactionType;
9
10
  amount: number;
10
11
  details: string;
@@ -10,6 +10,7 @@ import { UserEntityModel } from "./user.entity.model";
10
10
  export declare class BillingTransactionEntityModel extends BaseEntityModel<EntityEnum.BILLING_TRANSACTION> implements IBillingTransactionEntity {
11
11
  id: number;
12
12
  billingId: number;
13
+ advanceBillingId?: number;
13
14
  type: BillingTransactionType;
14
15
  amount: number;
15
16
  details: string;
@@ -35,4 +36,5 @@ export declare class BillingTransactionEntityModel extends BaseEntityModel<Entit
35
36
  EntityEnum.BILLING
36
37
  ], EnumEntityType<EntityEnum.BILLING_TRANSACTION>>;
37
38
  static fromEntity(entity: IBillingTransactionEntity): BillingTransactionEntityModel;
39
+ static sumAmounts(transactions: BillingTransactionEntityModel[]): number;
38
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");
@@ -11,7 +12,8 @@ class BillingTransactionEntityModel extends base_entity_model_1.BaseEntityModel
11
12
  super(...arguments);
12
13
  this.id = 0;
13
14
  this.billingId = 0;
14
- this.type = billing_transaction_enum_1.BillingTransactionType.PAYMENT;
15
+ this.advanceBillingId = 0;
16
+ this.type = billing_transaction_enum_1.BillingTransactionType.RECEIPT;
15
17
  this.amount = 0;
16
18
  this.details = "";
17
19
  this.status = billing_transaction_status_enum_1.BillingTransactionStatusEnum.APPROVED;
@@ -30,6 +32,16 @@ class BillingTransactionEntityModel extends base_entity_model_1.BaseEntityModel
30
32
  Object.assign(result, entity);
31
33
  return result;
32
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
+ }
33
45
  }
34
46
  exports.BillingTransactionEntityModel = BillingTransactionEntityModel;
35
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,6 +42,7 @@ export declare class BillingEntityModel extends BaseEntityModel<EntityEnum.BILLI
40
42
  totalAmountPaid: number;
41
43
  tdsAmount: number;
42
44
  creditNoteAmount: number;
45
+ refundAmount: number;
43
46
  invoiceEntityId: number;
44
47
  invoiceEntityType: BillingInvoiceTypeEnum;
45
48
  invoicePdfUrl?: string | null;
@@ -87,4 +90,17 @@ export declare class BillingEntityModel extends BaseEntityModel<EntityEnum.BILLI
87
90
  [key: string]: () => boolean;
88
91
  }): BillingActionsEnum[];
89
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;
90
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");
@@ -32,6 +36,7 @@ class BillingEntityModel extends base_entity_model_1.BaseEntityModel {
32
36
  this.totalAmountPaid = 0;
33
37
  this.tdsAmount = 0;
34
38
  this.creditNoteAmount = 0;
39
+ this.refundAmount = 0;
35
40
  this.invoiceEntityId = 0;
36
41
  this.invoiceEntityType = billing_invoice_type_enum_1.BillingInvoiceTypeEnum.CLIENT;
37
42
  this.invoiceContactName = "";
@@ -44,23 +49,9 @@ class BillingEntityModel extends base_entity_model_1.BaseEntityModel {
44
49
  this.updatedOn = 0;
45
50
  this.type = billing_type_enum_1.BillingTypeEnum.INVOICE;
46
51
  }
47
- // static fromEntity(entity: IBillingEntity): BillingEntityModel {
48
- // console.log("entity", entity);
49
- // const result = new BillingEntityModel(EntityEnum.BILLING);
50
- // console.log("result", result);
51
- // Object.assign(result, entity);
52
- // return result;
53
- // }
54
52
  static fromEntity(entity) {
55
- console.log("Raw input → entity.type =", entity.type); // should be "both"
56
53
  const result = new BillingEntityModel(entity_utils_interface_1.EntityEnum.BILLING);
57
- console.log("After new → result.type =", result.type);
58
- console.log("After new → result['type'] (bypass getter) =", result["type"]);
59
- console.log("After new → JSON.stringify(result) =", JSON.stringify(result, null, 2));
60
- console.log("After new → hasOwnProperty('type') =", result.hasOwnProperty("type"));
61
- console.log("After new → getOwnPropertyDescriptor =", Object.getOwnPropertyDescriptor(result, "type"));
62
54
  Object.assign(result, entity);
63
- console.log("After assign → result.type =", result.type);
64
55
  return result;
65
56
  }
66
57
  getStatusCategory() {
@@ -195,6 +186,85 @@ class BillingEntityModel extends base_entity_model_1.BaseEntityModel {
195
186
  getRelationConfigs() {
196
187
  return this.constructor.prototype.constructor.relationConfigs || [];
197
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
+ const index = adjustedBillingTransactions.findIndex((item) => item.advanceBillingId === null);
252
+ if (index !== -1) {
253
+ throw new exceptions_1.AppBadRequestException({
254
+ key: error_key_enum_1.ErrorKeyEnum.ADVANCE_BILLING_ID,
255
+ message: [
256
+ `advanceBillingId is missing in transaction at index ${index}`,
257
+ ],
258
+ });
259
+ }
260
+ }
261
+ getApprovedBillingTransactionsTotalAmount() {
262
+ var _a, _b;
263
+ return (0, utils_1.sumNormalised)((_b = (_a = this.billingTransactions) === null || _a === void 0 ? void 0 : _a.filter((entity) => ![
264
+ billing_transaction_status_enum_1.BillingTransactionStatusEnum.CREDITNOTE_APPROVAL_PENDING,
265
+ billing_transaction_status_enum_1.BillingTransactionStatusEnum.WRITEOFF_APPROVAL_PENDING,
266
+ ].includes(entity.status))) !== null && _b !== void 0 ? _b : [], "amount");
267
+ }
198
268
  }
199
269
  exports.BillingEntityModel = BillingEntityModel;
200
270
  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 });
@@ -22,5 +22,6 @@ export declare enum ErrorKeyEnum {
22
22
  WORK_FROM_HOME_FLOW = "WORK_FROM_HOME_FLOW",
23
23
  WORK_FROM_HOME_KEY = "WORK_FROM_HOME_KEY",
24
24
  RELATED_ENTITIES = "RELATED_ENTITIES",
25
- USER_ROLE = "USER_ROLE"
25
+ USER_ROLE = "USER_ROLE",
26
+ ADVANCE_BILLING_ID = "ADVANCE_BILLING_ID"
26
27
  }
@@ -27,4 +27,5 @@ var ErrorKeyEnum;
27
27
  ErrorKeyEnum["WORK_FROM_HOME_KEY"] = "WORK_FROM_HOME_KEY";
28
28
  ErrorKeyEnum["RELATED_ENTITIES"] = "RELATED_ENTITIES";
29
29
  ErrorKeyEnum["USER_ROLE"] = "USER_ROLE";
30
+ ErrorKeyEnum["ADVANCE_BILLING_ID"] = "ADVANCE_BILLING_ID";
30
31
  })(ErrorKeyEnum || (exports.ErrorKeyEnum = ErrorKeyEnum = {}));
@@ -0,0 +1,7 @@
1
+ export interface IAppFileConfig {
2
+ name: string;
3
+ size: number;
4
+ count?: number;
5
+ isRequired?: boolean;
6
+ format: string[];
7
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,4 +1,6 @@
1
+ export * from "./config/app-file-config";
1
2
  export * from "./interface/modify.interface";
2
3
  export * from "./interface/upload-multer-file.interface";
3
- export * from "./type/arrayed.type";
4
4
  export * from "./models/dto-validation-type";
5
+ export * from "./type/arrayed.type";
6
+ export * from "./type/delete-document-details.type";
@@ -14,7 +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("./config/app-file-config"), exports);
17
18
  __exportStar(require("./interface/modify.interface"), exports);
18
19
  __exportStar(require("./interface/upload-multer-file.interface"), exports);
19
- __exportStar(require("./type/arrayed.type"), exports);
20
20
  __exportStar(require("./models/dto-validation-type"), exports);
21
+ __exportStar(require("./type/arrayed.type"), exports);
22
+ __exportStar(require("./type/delete-document-details.type"), exports);
@@ -0,0 +1 @@
1
+ export type IDeleteDocumentDetails<T> = Partial<Record<keyof T, string[]>>;
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -333,20 +333,65 @@ 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;
375
+ /**
376
+ * Converts a camelCase or PascalCase string into a human-readable
377
+ * title-cased string with spaces.
378
+ *
379
+ * This is useful for generating user-friendly field names in
380
+ * validation or error messages.
381
+ *
382
+ * @example
383
+ * camelCaseToTitle("noteDocument");
384
+ * // → "Note Document"
385
+ *
386
+ * @example
387
+ * camelCaseToTitle("additionalDocuments");
388
+ * // → "Additional Documents"
389
+ *
390
+ * @example
391
+ * camelCaseToTitle("PDFDocument");
392
+ * // → "PDF Document"
393
+ *
394
+ * @param input - The camelCase or PascalCase string to convert
395
+ * @returns A title-cased, space-separated string
396
+ */
397
+ export declare function camelCaseToTitle(input: string): string;
@@ -42,13 +42,16 @@ 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;
49
+ exports.camelCaseToTitle = camelCaseToTitle;
47
50
  const date_fns_1 = require("date-fns");
51
+ const lodash_1 = require("lodash");
48
52
  const util_constants_1 = require("../constants/util.constants");
49
53
  const error_key_enum_1 = require("../enums/error.key.enum");
50
54
  const exceptions_1 = require("../exceptions");
51
- const lodash_1 = require("lodash");
52
55
  function groupByFunction(list, keyGetter) {
53
56
  const map = new Map();
54
57
  list.forEach((item) => {
@@ -687,25 +690,84 @@ function epochToDateTime(epoch) {
687
690
  const date = new Date(epoch * 1000); // JS Date expects milliseconds
688
691
  return (0, date_fns_1.format)(date, "yyyy-MM-dd HH:mm:ss");
689
692
  }
693
+ function dateTimeToEpoch(dateInput) {
694
+ const date = typeof dateInput === "string" ? new Date(dateInput) : dateInput;
695
+ return Math.floor(date.getTime() / 1000);
696
+ }
697
+ function checkEmptyObj(obj) {
698
+ return Object.keys(obj).length === 0;
699
+ }
690
700
  /**
691
- * Converts a JavaScript Date object into epoch seconds (UNIX timestamp).
701
+ * Normalises the value of a given key in an array of objects.
702
+ *
703
+ * If the value is a string or number, it is converted into a decimal number
704
+ * using `getDecimalNumberFromString`. Other value types are left unchanged.
692
705
  *
693
- * @param {Date} date - A JavaScript Date instance.
706
+ * @template T
694
707
  *
695
- * @returns {number} The corresponding epoch time in seconds (number of seconds since 1970-01-01 00:00:00 UTC).
708
+ * @param {T[]} input - Array of objects to be normalised.
709
+ * @param {keyof T} key - The object key whose value should be normalised.
710
+ *
711
+ * @returns {T[]} A new array with the specified key normalised.
696
712
  *
697
713
  * @example
698
- * toEpochSeconds(new Date("2025-09-30 11:19:25"));
699
- * // Returns: 1759211965
714
+ * getNormalisedFromKey([{ amount: "1,200.50" }], "amount");
715
+ * // Returns: [{ amount: 1200.5 }]
716
+ */
717
+ function getNormalisedFromKey(input, key) {
718
+ return input.map((inp) => (Object.assign(Object.assign({}, inp), { [key]: typeof inp[key] === "string" || typeof inp[key] === "number"
719
+ ? getDecimalNumberFromString(inp[key])
720
+ : inp[key] })));
721
+ }
722
+ /**
723
+ * Normalises the value of a given key in an array of objects
724
+ * and returns the sum of the normalised values.
725
+ *
726
+ * Internally, this function first normalises the values using
727
+ * `getNormalisedFromKey` and then sums them using `sumArray`.
728
+ *
729
+ * @template T
730
+ *
731
+ * @param {T[]} input - Array of objects whose values should be summed.
732
+ * @param {keyof T} key - The object key to normalise and sum.
733
+ *
734
+ * @returns {number} The sum of the normalised values for the given key.
700
735
  *
701
736
  * @example
702
- * toEpochSeconds(new Date());
703
- * // Returns: current epoch time in seconds
737
+ * sumNormalised([{ amount: "100" }, { amount: "200.5" }], "amount");
738
+ * // Returns: 300.5
704
739
  */
705
- function toEpochSeconds(date) {
706
- return Math.floor(date.getTime() / 1000);
740
+ function sumNormalised(input, key) {
741
+ return sumArray(getNormalisedFromKey(input, key), key);
707
742
  }
708
- function dateTimeToEpoch(dateInput) {
709
- const date = typeof dateInput === "string" ? new Date(dateInput) : dateInput;
710
- return Math.floor(date.getTime() / 1000);
743
+ /**
744
+ * Converts a camelCase or PascalCase string into a human-readable
745
+ * title-cased string with spaces.
746
+ *
747
+ * This is useful for generating user-friendly field names in
748
+ * validation or error messages.
749
+ *
750
+ * @example
751
+ * camelCaseToTitle("noteDocument");
752
+ * // → "Note Document"
753
+ *
754
+ * @example
755
+ * camelCaseToTitle("additionalDocuments");
756
+ * // → "Additional Documents"
757
+ *
758
+ * @example
759
+ * camelCaseToTitle("PDFDocument");
760
+ * // → "PDF Document"
761
+ *
762
+ * @param input - The camelCase or PascalCase string to convert
763
+ * @returns A title-cased, space-separated string
764
+ */
765
+ function camelCaseToTitle(input) {
766
+ if (input.length === 0)
767
+ return input;
768
+ return (input
769
+ // insert space before capital letters
770
+ .replace(/([a-z])([A-Z])/g, "$1 $2")
771
+ // capitalize first letter
772
+ .replace(/^./, (char) => char.toUpperCase()));
711
773
  }
package/package.json CHANGED
@@ -1,37 +1,37 @@
1
- {
2
- "name": "law-common",
3
- "version": "10.45.3-beta.9",
4
- "description": "",
5
- "main": "dist/index.js",
6
- "files": [
7
- "dist/**/*"
8
- ],
9
- "scripts": {
10
- "clean": "rm -rf dist",
11
- "build": "npm run clean && tsc",
12
- "publish:beta": "npm version prerelease --preid beta && git push && npm run build && npm publish --tag beta",
13
- "publish:patch": "npm version patch && git push && npm run build && npm publish",
14
- "publish:minor": "npm version minor && git push && npm run build && npm publish",
15
- "publish:major": "npm version major && git push && npm run build && npm publish",
16
- "link": "npm run build && npm link",
17
- "test": "jest"
18
- },
19
- "keywords": [],
20
- "author": "",
21
- "license": "ISC",
22
- "devDependencies": {
23
- "@types/jest": "^29.5.13",
24
- "@types/lodash": "^4.17.21",
25
- "@types/node": "^22.6.1",
26
- "jest": "^29.7.0",
27
- "ts-jest": "^29.2.5",
28
- "ts-node": "^10.9.2",
29
- "typescript": "^5.6.2"
30
- },
31
- "dependencies": {
32
- "@types/express": "^5.0.0",
33
- "@types/multer": "^1.4.12",
34
- "date-fns": "^4.1.0",
35
- "lodash": "4.17.21"
36
- }
37
- }
1
+ {
2
+ "name": "law-common",
3
+ "version": "10.46.0",
4
+ "description": "",
5
+ "main": "dist/index.js",
6
+ "files": [
7
+ "dist/**/*"
8
+ ],
9
+ "scripts": {
10
+ "clean": "rm -rf dist",
11
+ "build": "npm run clean && tsc",
12
+ "publish:beta": "npm version prerelease --preid beta && git push && npm run build && npm publish --tag beta",
13
+ "publish:patch": "npm version patch && git push && npm run build && npm publish",
14
+ "publish:minor": "npm version minor && git push && npm run build && npm publish",
15
+ "publish:major": "npm version major && git push && npm run build && npm publish",
16
+ "link": "npm run build && npm link",
17
+ "test": "jest"
18
+ },
19
+ "keywords": [],
20
+ "author": "",
21
+ "license": "ISC",
22
+ "devDependencies": {
23
+ "@types/jest": "^29.5.13",
24
+ "@types/lodash": "^4.17.21",
25
+ "@types/node": "^22.6.1",
26
+ "jest": "^29.7.0",
27
+ "ts-jest": "^29.2.5",
28
+ "ts-node": "^10.9.2",
29
+ "typescript": "^5.6.2"
30
+ },
31
+ "dependencies": {
32
+ "@types/express": "^5.0.0",
33
+ "@types/multer": "^1.4.12",
34
+ "date-fns": "^4.1.0",
35
+ "lodash": "4.17.21"
36
+ }
37
+ }