law-common 10.45.3-beta.16 → 10.45.3-beta.18
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/src/api/interface/billing.create.dto.interface.d.ts +0 -1
- package/dist/src/entities/enums/billing.transaction.enum.d.ts +1 -1
- package/dist/src/entities/enums/billing.transaction.enum.js +1 -1
- package/dist/src/entities/index.d.ts +23 -23
- package/dist/src/entities/index.js +23 -23
- package/dist/src/entities/interface/billing.entity.interface.d.ts +1 -1
- package/dist/src/entities/model/billing-transaction.model.d.ts +1 -0
- package/dist/src/entities/model/billing-transaction.model.js +12 -1
- package/dist/src/entities/model/billing.entity.model.d.ts +15 -1
- package/dist/src/entities/model/billing.entity.model.js +124 -0
- package/dist/src/entities/model/interface/billing.model.interface.d.ts +10 -0
- package/dist/src/entities/model/interface/billing.model.interface.js +2 -0
- package/dist/src/utils/helper.fn.util.d.ts +38 -0
- package/dist/src/utils/helper.fn.util.js +49 -0
- package/package.json +1 -1
|
@@ -9,7 +9,6 @@ export interface IBillingCreateDto extends Omit<IEntityCreateDto<IBillingEntity>
|
|
|
9
9
|
endDate?: string;
|
|
10
10
|
}
|
|
11
11
|
export interface IBillingParticulars {
|
|
12
|
-
invoiceDescription: string;
|
|
13
12
|
invoiceText?: string;
|
|
14
13
|
debitNoteText?: string;
|
|
15
14
|
includeDebitNoteSummary: boolean;
|
|
@@ -8,7 +8,7 @@ var BillingTransactionType;
|
|
|
8
8
|
BillingTransactionType["TDS"] = "TDS";
|
|
9
9
|
BillingTransactionType["WRITE_OFF"] = "WRITE_OFF";
|
|
10
10
|
BillingTransactionType["CREDIT_NOTE"] = "CREDIT_NOTE";
|
|
11
|
-
BillingTransactionType["
|
|
11
|
+
BillingTransactionType["RECEIPT"] = "RECEIPT";
|
|
12
12
|
BillingTransactionType["REFUND"] = "REFUND";
|
|
13
13
|
})(BillingTransactionType || (exports.BillingTransactionType = BillingTransactionType = {}));
|
|
14
14
|
(function (BillingTransactionType) {
|
|
@@ -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 "./
|
|
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 "./
|
|
78
|
-
export * from "./
|
|
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 "./
|
|
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/
|
|
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("./
|
|
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("./
|
|
94
|
-
__exportStar(require("./
|
|
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("./
|
|
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/
|
|
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
|
|
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");
|
|
@@ -12,7 +13,7 @@ class BillingTransactionEntityModel extends base_entity_model_1.BaseEntityModel
|
|
|
12
13
|
this.id = 0;
|
|
13
14
|
this.billingId = 0;
|
|
14
15
|
this.advanceBillingId = 0;
|
|
15
|
-
this.type = billing_transaction_enum_1.BillingTransactionType.
|
|
16
|
+
this.type = billing_transaction_enum_1.BillingTransactionType.RECEIPT;
|
|
16
17
|
this.amount = 0;
|
|
17
18
|
this.details = "";
|
|
18
19
|
this.status = billing_transaction_status_enum_1.BillingTransactionStatusEnum.APPROVED;
|
|
@@ -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
|
|
45
|
+
refundAmount: number;
|
|
44
46
|
invoiceEntityId: number;
|
|
45
47
|
invoiceEntityType: BillingInvoiceTypeEnum;
|
|
46
48
|
invoicePdfUrl?: string | null;
|
|
@@ -88,4 +90,16 @@ 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;
|
|
91
105
|
}
|
|
@@ -2,9 +2,12 @@
|
|
|
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");
|
|
6
8
|
const billing_type_enum_1 = require("../enums/billing-type.enum");
|
|
7
9
|
const billing_status_enum_1 = require("../enums/billing.status.enum");
|
|
10
|
+
const billing_transaction_enum_1 = require("../enums/billing.transaction.enum");
|
|
8
11
|
const billing_invoice_type_enum_1 = require("../enums/billing_invoice_type.enum");
|
|
9
12
|
const payment_status_enum_1 = require("../enums/payment_status.enum");
|
|
10
13
|
const relation_type_enum_1 = require("../enums/relation-type.enum");
|
|
@@ -182,6 +185,127 @@ class BillingEntityModel extends base_entity_model_1.BaseEntityModel {
|
|
|
182
185
|
getRelationConfigs() {
|
|
183
186
|
return this.constructor.prototype.constructor.relationConfigs || [];
|
|
184
187
|
}
|
|
188
|
+
getAdvanceBillingTransactionsSummary(adjustedBillingTransactions) {
|
|
189
|
+
this.validateAdvanceBillingId(adjustedBillingTransactions);
|
|
190
|
+
if (this.type === billing_type_enum_1.BillingTypeEnum.ADVANCE) {
|
|
191
|
+
return {
|
|
192
|
+
useAbleTdsAmount: this.getUseableTDSAmount(adjustedBillingTransactions),
|
|
193
|
+
usedTdsAmount: this.getUsedTDSAmount(adjustedBillingTransactions),
|
|
194
|
+
useableRecieptAmount: this.getUseableRecieptAmount(adjustedBillingTransactions),
|
|
195
|
+
usedRecieptAmount: this.getUsedRecieptAmount(adjustedBillingTransactions),
|
|
196
|
+
totalUsableAmount: this.getUseableAmount(adjustedBillingTransactions),
|
|
197
|
+
totalUsedAmount: this.getUsedAmount(adjustedBillingTransactions),
|
|
198
|
+
totalTDSAmount: this.getTotalTDSAmount(adjustedBillingTransactions),
|
|
199
|
+
totalRecieptAmount: this.getTotalRecieptAmount(adjustedBillingTransactions),
|
|
200
|
+
};
|
|
201
|
+
}
|
|
202
|
+
return {};
|
|
203
|
+
}
|
|
204
|
+
getUseableTDSAmount(adjustedBillingTransactions) {
|
|
205
|
+
return ((0, utils_1.getDecimalNumberFromString)(this.tdsAmount) -
|
|
206
|
+
this.getUsedTDSAmount(adjustedBillingTransactions));
|
|
207
|
+
}
|
|
208
|
+
getUsedTDSAmount(adjustedBillingTransactions) {
|
|
209
|
+
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
|
+
}
|
|
222
|
+
getTotalTDSAmount(adjustedBillingTransactions) {
|
|
223
|
+
return (this.getUseableTDSAmount(adjustedBillingTransactions) +
|
|
224
|
+
this.getUsedTDSAmount(adjustedBillingTransactions));
|
|
225
|
+
}
|
|
226
|
+
getTotalRecieptAmount(adjustedBillingTransactions) {
|
|
227
|
+
return (this.getUseableRecieptAmount(adjustedBillingTransactions) +
|
|
228
|
+
this.getUsedRecieptAmount(adjustedBillingTransactions));
|
|
229
|
+
}
|
|
230
|
+
getUseableRecieptAmount(adjustedBillingTransactions) {
|
|
231
|
+
return ((0, utils_1.getDecimalNumberFromString)(this.totalAmountPaid) -
|
|
232
|
+
this.getUsedRecieptAmount(adjustedBillingTransactions));
|
|
233
|
+
}
|
|
234
|
+
getUsedRecieptAmount(adjustedBillingTransactions) {
|
|
235
|
+
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
|
+
}
|
|
248
|
+
getUseableAmount(adjustedBillingTransactions) {
|
|
249
|
+
return (this.getUseableRecieptAmount(adjustedBillingTransactions) +
|
|
250
|
+
this.getUseableTDSAmount(adjustedBillingTransactions));
|
|
251
|
+
}
|
|
252
|
+
getUsedAmount(adjustedBillingTransactions) {
|
|
253
|
+
return (this.getUsedRecieptAmount(adjustedBillingTransactions) +
|
|
254
|
+
this.getUsedTDSAmount(adjustedBillingTransactions));
|
|
255
|
+
}
|
|
256
|
+
getTotalAmountRecieved() {
|
|
257
|
+
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") -
|
|
274
|
+
(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
|
+
return amountRecieved;
|
|
276
|
+
}
|
|
277
|
+
getTotalRecievableAmount() {
|
|
278
|
+
var _a, _b;
|
|
279
|
+
return ((0, utils_1.getDecimalNumberFromString)(this.totalAmount) -
|
|
280
|
+
(this.getTotalAmountRecieved() +
|
|
281
|
+
(0, utils_1.sumNormalised)((_b = (_a = this.billingTransactions) === null || _a === void 0 ? void 0 : _a.filter((transaction) => [
|
|
282
|
+
billing_transaction_enum_1.BillingTransactionType.CREDIT_NOTE,
|
|
283
|
+
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
|
+
);
|
|
298
|
+
}
|
|
299
|
+
validateAdvanceBillingId(adjustedBillingTransactions) {
|
|
300
|
+
for (const item of adjustedBillingTransactions) {
|
|
301
|
+
if (item.advanceBillingId === null) {
|
|
302
|
+
throw new exceptions_1.AppBadRequestException({
|
|
303
|
+
key: error_key_enum_1.ErrorKeyEnum.BANK_FLOW_ACTION,
|
|
304
|
+
message: [`Lorem`],
|
|
305
|
+
});
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
}
|
|
185
309
|
}
|
|
186
310
|
exports.BillingEntityModel = BillingEntityModel;
|
|
187
311
|
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
|
+
}
|
|
@@ -350,3 +350,41 @@ export declare function epochToDateTime(epoch: number): string;
|
|
|
350
350
|
*/
|
|
351
351
|
export declare function toEpochSeconds(date: Date): number;
|
|
352
352
|
export declare function dateTimeToEpoch(dateInput: string | Date): number;
|
|
353
|
+
export declare function checkEmptyObj<T extends Record<string, any>>(obj: T): boolean;
|
|
354
|
+
/**
|
|
355
|
+
* Normalises the value of a given key in an array of objects.
|
|
356
|
+
*
|
|
357
|
+
* If the value is a string or number, it is converted into a decimal number
|
|
358
|
+
* using `getDecimalNumberFromString`. Other value types are left unchanged.
|
|
359
|
+
*
|
|
360
|
+
* @template T
|
|
361
|
+
*
|
|
362
|
+
* @param {T[]} input - Array of objects to be normalised.
|
|
363
|
+
* @param {keyof T} key - The object key whose value should be normalised.
|
|
364
|
+
*
|
|
365
|
+
* @returns {T[]} A new array with the specified key normalised.
|
|
366
|
+
*
|
|
367
|
+
* @example
|
|
368
|
+
* getNormalisedFromKey([{ amount: "1,200.50" }], "amount");
|
|
369
|
+
* // Returns: [{ amount: 1200.5 }]
|
|
370
|
+
*/
|
|
371
|
+
export declare function getNormalisedFromKey<T>(input: T[], key: keyof T): T[];
|
|
372
|
+
/**
|
|
373
|
+
* Normalises the value of a given key in an array of objects
|
|
374
|
+
* and returns the sum of the normalised values.
|
|
375
|
+
*
|
|
376
|
+
* Internally, this function first normalises the values using
|
|
377
|
+
* `getNormalisedFromKey` and then sums them using `sumArray`.
|
|
378
|
+
*
|
|
379
|
+
* @template T
|
|
380
|
+
*
|
|
381
|
+
* @param {T[]} input - Array of objects whose values should be summed.
|
|
382
|
+
* @param {keyof T} key - The object key to normalise and sum.
|
|
383
|
+
*
|
|
384
|
+
* @returns {number} The sum of the normalised values for the given key.
|
|
385
|
+
*
|
|
386
|
+
* @example
|
|
387
|
+
* sumNormalised([{ amount: "100" }, { amount: "200.5" }], "amount");
|
|
388
|
+
* // Returns: 300.5
|
|
389
|
+
*/
|
|
390
|
+
export declare function sumNormalised<T>(input: T[], key: keyof T): number;
|
|
@@ -44,6 +44,9 @@ exports.convertToNumberType = convertToNumberType;
|
|
|
44
44
|
exports.epochToDateTime = epochToDateTime;
|
|
45
45
|
exports.toEpochSeconds = toEpochSeconds;
|
|
46
46
|
exports.dateTimeToEpoch = dateTimeToEpoch;
|
|
47
|
+
exports.checkEmptyObj = checkEmptyObj;
|
|
48
|
+
exports.getNormalisedFromKey = getNormalisedFromKey;
|
|
49
|
+
exports.sumNormalised = sumNormalised;
|
|
47
50
|
const date_fns_1 = require("date-fns");
|
|
48
51
|
const lodash_1 = require("lodash");
|
|
49
52
|
const util_constants_1 = require("../constants/util.constants");
|
|
@@ -709,3 +712,49 @@ function dateTimeToEpoch(dateInput) {
|
|
|
709
712
|
const date = typeof dateInput === "string" ? new Date(dateInput) : dateInput;
|
|
710
713
|
return Math.floor(date.getTime() / 1000);
|
|
711
714
|
}
|
|
715
|
+
function checkEmptyObj(obj) {
|
|
716
|
+
return Object.keys(obj).length === 0;
|
|
717
|
+
}
|
|
718
|
+
/**
|
|
719
|
+
* Normalises the value of a given key in an array of objects.
|
|
720
|
+
*
|
|
721
|
+
* If the value is a string or number, it is converted into a decimal number
|
|
722
|
+
* using `getDecimalNumberFromString`. Other value types are left unchanged.
|
|
723
|
+
*
|
|
724
|
+
* @template T
|
|
725
|
+
*
|
|
726
|
+
* @param {T[]} input - Array of objects to be normalised.
|
|
727
|
+
* @param {keyof T} key - The object key whose value should be normalised.
|
|
728
|
+
*
|
|
729
|
+
* @returns {T[]} A new array with the specified key normalised.
|
|
730
|
+
*
|
|
731
|
+
* @example
|
|
732
|
+
* getNormalisedFromKey([{ amount: "1,200.50" }], "amount");
|
|
733
|
+
* // Returns: [{ amount: 1200.5 }]
|
|
734
|
+
*/
|
|
735
|
+
function getNormalisedFromKey(input, key) {
|
|
736
|
+
return input.map((inp) => (Object.assign(Object.assign({}, inp), { [key]: typeof inp[key] === "string" || typeof inp[key] === "number"
|
|
737
|
+
? getDecimalNumberFromString(inp[key])
|
|
738
|
+
: inp[key] })));
|
|
739
|
+
}
|
|
740
|
+
/**
|
|
741
|
+
* Normalises the value of a given key in an array of objects
|
|
742
|
+
* and returns the sum of the normalised values.
|
|
743
|
+
*
|
|
744
|
+
* Internally, this function first normalises the values using
|
|
745
|
+
* `getNormalisedFromKey` and then sums them using `sumArray`.
|
|
746
|
+
*
|
|
747
|
+
* @template T
|
|
748
|
+
*
|
|
749
|
+
* @param {T[]} input - Array of objects whose values should be summed.
|
|
750
|
+
* @param {keyof T} key - The object key to normalise and sum.
|
|
751
|
+
*
|
|
752
|
+
* @returns {number} The sum of the normalised values for the given key.
|
|
753
|
+
*
|
|
754
|
+
* @example
|
|
755
|
+
* sumNormalised([{ amount: "100" }, { amount: "200.5" }], "amount");
|
|
756
|
+
* // Returns: 300.5
|
|
757
|
+
*/
|
|
758
|
+
function sumNormalised(input, key) {
|
|
759
|
+
return sumArray(getNormalisedFromKey(input, key), key);
|
|
760
|
+
}
|