gemcap-be-common 1.5.91 → 1.5.93
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/models/FacilityCharge.model.d.ts +58 -0
- package/models/FacilityCharge.model.js +46 -0
- package/models/FacilityCharge.model.ts +78 -0
- package/models/LoanProducts.model.d.ts +12 -12
- package/models/PostponedTransactions.model.d.ts +3 -3
- package/models/Yield.model.d.ts +12 -7
- package/models/Yield.model.js +10 -0
- package/models/Yield.model.ts +22 -7
- package/models/_index.d.ts +6 -6
- package/models/_models.d.ts +1 -0
- package/models/_models.js +1 -0
- package/models/_models.ts +1 -0
- package/package.json +1 -1
- package/services/yield.service.d.ts +2 -0
- package/services/yield.service.js +25 -6
- package/services/yield.service.ts +32 -10
- package/tsconfig.tsbuildinfo +1 -1
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
/// <reference types="mongoose/types/types" />
|
|
2
|
+
/// <reference types="mongoose/types/models" />
|
|
3
|
+
/// <reference types="mongoose/types/schemaoptions" />
|
|
4
|
+
/// <reference types="mongoose/types/utility" />
|
|
5
|
+
/// <reference types="mongoose/types/document" />
|
|
6
|
+
/// <reference types="mongoose/types/aggregate" />
|
|
7
|
+
/// <reference types="mongoose/types/callback" />
|
|
8
|
+
/// <reference types="mongoose/types/collection" />
|
|
9
|
+
/// <reference types="mongoose/types/connection" />
|
|
10
|
+
/// <reference types="mongoose/types/cursor" />
|
|
11
|
+
/// <reference types="mongoose/types/document" />
|
|
12
|
+
/// <reference types="mongoose/types/error" />
|
|
13
|
+
/// <reference types="mongoose/types/expressions" />
|
|
14
|
+
/// <reference types="mongoose/types/helpers" />
|
|
15
|
+
/// <reference types="mongoose/types/middlewares" />
|
|
16
|
+
/// <reference types="mongoose/types/indexes" />
|
|
17
|
+
/// <reference types="mongoose/types/models" />
|
|
18
|
+
/// <reference types="mongoose/types/mongooseoptions" />
|
|
19
|
+
/// <reference types="mongoose/types/pipelinestage" />
|
|
20
|
+
/// <reference types="mongoose/types/populate" />
|
|
21
|
+
/// <reference types="mongoose/types/query" />
|
|
22
|
+
/// <reference types="mongoose/types/schemaoptions" />
|
|
23
|
+
/// <reference types="mongoose/types/schematypes" />
|
|
24
|
+
/// <reference types="mongoose/types/session" />
|
|
25
|
+
/// <reference types="mongoose/types/types" />
|
|
26
|
+
/// <reference types="mongoose/types/utility" />
|
|
27
|
+
/// <reference types="mongoose/types/validation" />
|
|
28
|
+
/// <reference types="mongoose/types/virtuals" />
|
|
29
|
+
/// <reference types="mongoose/types/inferschematype" />
|
|
30
|
+
import mongoose from 'mongoose';
|
|
31
|
+
import { ELoanChargeType } from '../enums/loan-charge-type.enum';
|
|
32
|
+
export interface IFacilityChargeGroup {
|
|
33
|
+
uiId: string;
|
|
34
|
+
facilityId: mongoose.Types.ObjectId;
|
|
35
|
+
name: string;
|
|
36
|
+
groupingType: ELoanChargeType;
|
|
37
|
+
chargeIds: mongoose.Types.ObjectId[];
|
|
38
|
+
order: number;
|
|
39
|
+
deletedAt?: Date;
|
|
40
|
+
}
|
|
41
|
+
export type TFacilityChargeGroupDoc = mongoose.HydratedDocument<IFacilityChargeGroup>;
|
|
42
|
+
export interface IFacilityChargeGroupLean extends IFacilityChargeGroup {
|
|
43
|
+
_id: mongoose.Types.ObjectId;
|
|
44
|
+
createdAt: Date;
|
|
45
|
+
updatedAt: Date;
|
|
46
|
+
}
|
|
47
|
+
export interface IFacilityChargeGroupPlain extends Omit<IFacilityChargeGroup, 'facilityId' | 'chargeIds'> {
|
|
48
|
+
_id: string;
|
|
49
|
+
facilityId: string;
|
|
50
|
+
chargeIds: string[];
|
|
51
|
+
createdAt: Date;
|
|
52
|
+
updatedAt: Date;
|
|
53
|
+
}
|
|
54
|
+
export type TFacilityChargeGroupModel = mongoose.Model<IFacilityChargeGroup>;
|
|
55
|
+
export declare const FacilityChargeGroupSchema: mongoose.Schema<IFacilityChargeGroup, TFacilityChargeGroupModel, {}, {}, {}, {}, mongoose.DefaultSchemaOptions, IFacilityChargeGroup, mongoose.Document<unknown, {}, mongoose.FlatRecord<IFacilityChargeGroup>> & mongoose.FlatRecord<IFacilityChargeGroup> & {
|
|
56
|
+
_id: mongoose.Types.ObjectId;
|
|
57
|
+
}>;
|
|
58
|
+
export declare const FacilityChargeGroup: TFacilityChargeGroupModel;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.FacilityChargeGroup = exports.FacilityChargeGroupSchema = void 0;
|
|
7
|
+
const mongoose_1 = __importDefault(require("mongoose"));
|
|
8
|
+
const _models_1 = require("./_models");
|
|
9
|
+
const loan_charge_type_enum_1 = require("../enums/loan-charge-type.enum");
|
|
10
|
+
exports.FacilityChargeGroupSchema = new mongoose_1.default.Schema({
|
|
11
|
+
facilityId: {
|
|
12
|
+
type: mongoose_1.default.Schema.Types.ObjectId,
|
|
13
|
+
ref: _models_1.MODEL_NAMES.facilities,
|
|
14
|
+
required: true,
|
|
15
|
+
},
|
|
16
|
+
chargeIds: [{
|
|
17
|
+
type: mongoose_1.default.Schema.Types.ObjectId,
|
|
18
|
+
ref: _models_1.MODEL_NAMES.loanCharges,
|
|
19
|
+
required: true,
|
|
20
|
+
}],
|
|
21
|
+
groupingType: {
|
|
22
|
+
type: String,
|
|
23
|
+
enum: Object.values(loan_charge_type_enum_1.ELoanChargeType),
|
|
24
|
+
required: true,
|
|
25
|
+
},
|
|
26
|
+
uiId: {
|
|
27
|
+
type: String,
|
|
28
|
+
required: true,
|
|
29
|
+
},
|
|
30
|
+
name: {
|
|
31
|
+
type: String,
|
|
32
|
+
required: true,
|
|
33
|
+
},
|
|
34
|
+
order: {
|
|
35
|
+
type: Number,
|
|
36
|
+
required: true,
|
|
37
|
+
},
|
|
38
|
+
deletedAt: {
|
|
39
|
+
type: Date,
|
|
40
|
+
},
|
|
41
|
+
}, {
|
|
42
|
+
timestamps: { createdAt: true, updatedAt: true },
|
|
43
|
+
versionKey: false,
|
|
44
|
+
});
|
|
45
|
+
exports.FacilityChargeGroupSchema.index({ facilityId: 1, uiId: 1 }, { unique: true });
|
|
46
|
+
exports.FacilityChargeGroup = mongoose_1.default.model(_models_1.MODEL_NAMES.facilityChargeGroups, exports.FacilityChargeGroupSchema);
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import mongoose from 'mongoose';
|
|
2
|
+
|
|
3
|
+
import { MODEL_NAMES } from './_models';
|
|
4
|
+
import { ELoanChargeType } from '../enums/loan-charge-type.enum';
|
|
5
|
+
|
|
6
|
+
export interface IFacilityChargeGroup {
|
|
7
|
+
uiId: string;
|
|
8
|
+
facilityId: mongoose.Types.ObjectId;
|
|
9
|
+
name: string;
|
|
10
|
+
groupingType: ELoanChargeType;
|
|
11
|
+
chargeIds: mongoose.Types.ObjectId[];
|
|
12
|
+
order: number;
|
|
13
|
+
deletedAt?: Date;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export type TFacilityChargeGroupDoc = mongoose.HydratedDocument<IFacilityChargeGroup>;
|
|
17
|
+
|
|
18
|
+
export interface IFacilityChargeGroupLean extends IFacilityChargeGroup {
|
|
19
|
+
_id: mongoose.Types.ObjectId;
|
|
20
|
+
createdAt: Date;
|
|
21
|
+
updatedAt: Date;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export interface IFacilityChargeGroupPlain extends Omit<IFacilityChargeGroup, 'facilityId' | 'chargeIds'> {
|
|
25
|
+
_id: string;
|
|
26
|
+
facilityId: string;
|
|
27
|
+
chargeIds: string[];
|
|
28
|
+
createdAt: Date;
|
|
29
|
+
updatedAt: Date;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export type TFacilityChargeGroupModel = mongoose.Model<IFacilityChargeGroup>;
|
|
33
|
+
|
|
34
|
+
export const FacilityChargeGroupSchema = new mongoose.Schema<IFacilityChargeGroup, TFacilityChargeGroupModel>(
|
|
35
|
+
{
|
|
36
|
+
facilityId: {
|
|
37
|
+
type: mongoose.Schema.Types.ObjectId,
|
|
38
|
+
ref: MODEL_NAMES.facilities,
|
|
39
|
+
required: true,
|
|
40
|
+
},
|
|
41
|
+
chargeIds: [{
|
|
42
|
+
type: mongoose.Schema.Types.ObjectId,
|
|
43
|
+
ref: MODEL_NAMES.loanCharges,
|
|
44
|
+
required: true,
|
|
45
|
+
}],
|
|
46
|
+
groupingType: {
|
|
47
|
+
type: String,
|
|
48
|
+
enum: Object.values(ELoanChargeType),
|
|
49
|
+
required: true,
|
|
50
|
+
},
|
|
51
|
+
uiId: {
|
|
52
|
+
type: String,
|
|
53
|
+
required: true,
|
|
54
|
+
},
|
|
55
|
+
name: {
|
|
56
|
+
type: String,
|
|
57
|
+
required: true,
|
|
58
|
+
},
|
|
59
|
+
order: {
|
|
60
|
+
type: Number,
|
|
61
|
+
required: true,
|
|
62
|
+
},
|
|
63
|
+
deletedAt: {
|
|
64
|
+
type: Date,
|
|
65
|
+
},
|
|
66
|
+
},
|
|
67
|
+
{
|
|
68
|
+
timestamps: { createdAt: true, updatedAt: true },
|
|
69
|
+
versionKey: false,
|
|
70
|
+
},
|
|
71
|
+
);
|
|
72
|
+
|
|
73
|
+
FacilityChargeGroupSchema.index(
|
|
74
|
+
{ facilityId: 1, uiId: 1 },
|
|
75
|
+
{ unique: true },
|
|
76
|
+
);
|
|
77
|
+
|
|
78
|
+
export const FacilityChargeGroup = mongoose.model<IFacilityChargeGroup, TFacilityChargeGroupModel>(MODEL_NAMES.facilityChargeGroups, FacilityChargeGroupSchema);
|
|
@@ -90,18 +90,19 @@ export declare const LoanProductSchema: mongoose.Schema<any, mongoose.Model<any,
|
|
|
90
90
|
updatedAt: NativeDate;
|
|
91
91
|
} & {
|
|
92
92
|
borrowerId: mongoose.Types.ObjectId;
|
|
93
|
-
|
|
93
|
+
type: string;
|
|
94
|
+
name: string;
|
|
94
95
|
order: number;
|
|
95
96
|
active: boolean;
|
|
96
97
|
code: string;
|
|
97
|
-
name: string;
|
|
98
|
-
type: string;
|
|
99
98
|
startDate: Date;
|
|
100
99
|
maturityDate: Date;
|
|
101
100
|
commitment: number;
|
|
102
101
|
isBalanceActual: boolean;
|
|
103
102
|
isFloatedBalanceActual: boolean;
|
|
103
|
+
masterLoanProductId: mongoose.Types.ObjectId;
|
|
104
104
|
isDefaultPaymentOrder: boolean;
|
|
105
|
+
__v?: number;
|
|
105
106
|
facilityId?: mongoose.Types.ObjectId;
|
|
106
107
|
masterCode?: string;
|
|
107
108
|
payoffDate?: Date;
|
|
@@ -112,24 +113,24 @@ export declare const LoanProductSchema: mongoose.Schema<any, mongoose.Model<any,
|
|
|
112
113
|
prepaymentTerms?: string;
|
|
113
114
|
settlementCode?: string;
|
|
114
115
|
deactivationDate?: Date;
|
|
115
|
-
__v?: number;
|
|
116
116
|
}, mongoose.Document<unknown, {}, mongoose.FlatRecord<{
|
|
117
117
|
createdAt: NativeDate;
|
|
118
118
|
updatedAt: NativeDate;
|
|
119
119
|
} & {
|
|
120
120
|
borrowerId: mongoose.Types.ObjectId;
|
|
121
|
-
|
|
121
|
+
type: string;
|
|
122
|
+
name: string;
|
|
122
123
|
order: number;
|
|
123
124
|
active: boolean;
|
|
124
125
|
code: string;
|
|
125
|
-
name: string;
|
|
126
|
-
type: string;
|
|
127
126
|
startDate: Date;
|
|
128
127
|
maturityDate: Date;
|
|
129
128
|
commitment: number;
|
|
130
129
|
isBalanceActual: boolean;
|
|
131
130
|
isFloatedBalanceActual: boolean;
|
|
131
|
+
masterLoanProductId: mongoose.Types.ObjectId;
|
|
132
132
|
isDefaultPaymentOrder: boolean;
|
|
133
|
+
__v?: number;
|
|
133
134
|
facilityId?: mongoose.Types.ObjectId;
|
|
134
135
|
masterCode?: string;
|
|
135
136
|
payoffDate?: Date;
|
|
@@ -140,24 +141,24 @@ export declare const LoanProductSchema: mongoose.Schema<any, mongoose.Model<any,
|
|
|
140
141
|
prepaymentTerms?: string;
|
|
141
142
|
settlementCode?: string;
|
|
142
143
|
deactivationDate?: Date;
|
|
143
|
-
__v?: number;
|
|
144
144
|
}>> & mongoose.FlatRecord<{
|
|
145
145
|
createdAt: NativeDate;
|
|
146
146
|
updatedAt: NativeDate;
|
|
147
147
|
} & {
|
|
148
148
|
borrowerId: mongoose.Types.ObjectId;
|
|
149
|
-
|
|
149
|
+
type: string;
|
|
150
|
+
name: string;
|
|
150
151
|
order: number;
|
|
151
152
|
active: boolean;
|
|
152
153
|
code: string;
|
|
153
|
-
name: string;
|
|
154
|
-
type: string;
|
|
155
154
|
startDate: Date;
|
|
156
155
|
maturityDate: Date;
|
|
157
156
|
commitment: number;
|
|
158
157
|
isBalanceActual: boolean;
|
|
159
158
|
isFloatedBalanceActual: boolean;
|
|
159
|
+
masterLoanProductId: mongoose.Types.ObjectId;
|
|
160
160
|
isDefaultPaymentOrder: boolean;
|
|
161
|
+
__v?: number;
|
|
161
162
|
facilityId?: mongoose.Types.ObjectId;
|
|
162
163
|
masterCode?: string;
|
|
163
164
|
payoffDate?: Date;
|
|
@@ -168,7 +169,6 @@ export declare const LoanProductSchema: mongoose.Schema<any, mongoose.Model<any,
|
|
|
168
169
|
prepaymentTerms?: string;
|
|
169
170
|
settlementCode?: string;
|
|
170
171
|
deactivationDate?: Date;
|
|
171
|
-
__v?: number;
|
|
172
172
|
}> & {
|
|
173
173
|
_id: mongoose.Types.ObjectId;
|
|
174
174
|
}>;
|
|
@@ -56,18 +56,18 @@ export declare const PostponedTransactionSchema: mongoose.Schema<any, mongoose.M
|
|
|
56
56
|
timestamps: false;
|
|
57
57
|
}, {
|
|
58
58
|
productId: mongoose.Types.ObjectId;
|
|
59
|
-
postponedToDate: string;
|
|
60
59
|
transactionId: mongoose.Types.ObjectId;
|
|
60
|
+
postponedToDate: string;
|
|
61
61
|
__v?: number;
|
|
62
62
|
}, mongoose.Document<unknown, {}, mongoose.FlatRecord<{
|
|
63
63
|
productId: mongoose.Types.ObjectId;
|
|
64
|
-
postponedToDate: string;
|
|
65
64
|
transactionId: mongoose.Types.ObjectId;
|
|
65
|
+
postponedToDate: string;
|
|
66
66
|
__v?: number;
|
|
67
67
|
}>> & mongoose.FlatRecord<{
|
|
68
68
|
productId: mongoose.Types.ObjectId;
|
|
69
|
-
postponedToDate: string;
|
|
70
69
|
transactionId: mongoose.Types.ObjectId;
|
|
70
|
+
postponedToDate: string;
|
|
71
71
|
__v?: number;
|
|
72
72
|
}> & {
|
|
73
73
|
_id: mongoose.Types.ObjectId;
|
package/models/Yield.model.d.ts
CHANGED
|
@@ -30,8 +30,9 @@
|
|
|
30
30
|
import Joi from 'joi';
|
|
31
31
|
import mongoose from 'mongoose';
|
|
32
32
|
import { ISelectedMonth } from '../helpers/date.helper';
|
|
33
|
-
import {
|
|
34
|
-
import {
|
|
33
|
+
import { ILoanChargePlain } from './LoanCharges.model';
|
|
34
|
+
import { ILoanProductPlain } from './LoanProducts.model';
|
|
35
|
+
import { IFacilityPlain } from './Facility.model';
|
|
35
36
|
export declare const yieldParamsValidationSchema: Joi.ObjectSchema<IYieldParams>;
|
|
36
37
|
export declare enum ETotalType {
|
|
37
38
|
AVERAGE_BALANCE = "AVERAGE_BALANCE",
|
|
@@ -57,6 +58,8 @@ export interface IYieldParams {
|
|
|
57
58
|
export interface IYieldData {
|
|
58
59
|
productId?: mongoose.Types.ObjectId;
|
|
59
60
|
chargeId?: mongoose.Types.ObjectId;
|
|
61
|
+
facilityId?: mongoose.Types.ObjectId;
|
|
62
|
+
facilityChargeGroupId?: mongoose.Types.ObjectId;
|
|
60
63
|
totalType: string;
|
|
61
64
|
year: number;
|
|
62
65
|
month: number;
|
|
@@ -65,12 +68,13 @@ export interface IYieldData {
|
|
|
65
68
|
}
|
|
66
69
|
export interface IYieldViewData {
|
|
67
70
|
order: number;
|
|
68
|
-
charge:
|
|
69
|
-
product:
|
|
71
|
+
charge: ILoanChargePlain;
|
|
72
|
+
product: ILoanProductPlain;
|
|
73
|
+
facility?: IFacilityPlain;
|
|
70
74
|
title: string;
|
|
71
75
|
class?: string;
|
|
72
|
-
[key: `value-${string}`]: number | string |
|
|
73
|
-
[key: `valuePercent-${string}`]: number | string |
|
|
76
|
+
[key: `value-${string}`]: number | string | ILoanChargePlain | ILoanProductPlain;
|
|
77
|
+
[key: `valuePercent-${string}`]: number | string | ILoanChargePlain | ILoanProductPlain;
|
|
74
78
|
}
|
|
75
79
|
export interface IYieldDataDoc extends IYieldData, mongoose.Document {
|
|
76
80
|
_id: mongoose.Types.ObjectId;
|
|
@@ -82,10 +86,11 @@ export interface IYieldDataLean extends IYieldData {
|
|
|
82
86
|
createdAt: Date;
|
|
83
87
|
updatedAt: Date;
|
|
84
88
|
}
|
|
85
|
-
export interface IYieldDataPlain extends Omit<IYieldData, 'productId' | 'chargeId'> {
|
|
89
|
+
export interface IYieldDataPlain extends Omit<IYieldData, 'productId' | 'chargeId' | 'facilityId'> {
|
|
86
90
|
_id: string;
|
|
87
91
|
productId: string;
|
|
88
92
|
chargeId: string;
|
|
93
|
+
facilityId: string;
|
|
89
94
|
}
|
|
90
95
|
export type TYieldDataModel = mongoose.Model<IYieldData>;
|
|
91
96
|
export declare const YieldDataSchema: mongoose.Schema<IYieldData, TYieldDataModel, {}, {}, {}, {}, mongoose.DefaultSchemaOptions, IYieldData, mongoose.Document<unknown, {}, mongoose.FlatRecord<IYieldData>> & mongoose.FlatRecord<IYieldData> & {
|
package/models/Yield.model.js
CHANGED
|
@@ -51,6 +51,16 @@ exports.YieldDataSchema = new mongoose_1.default.Schema({
|
|
|
51
51
|
ref: _models_1.MODEL_NAMES.loanCharges,
|
|
52
52
|
required: false,
|
|
53
53
|
},
|
|
54
|
+
facilityId: {
|
|
55
|
+
type: mongoose_1.default.Schema.Types.ObjectId,
|
|
56
|
+
ref: _models_1.MODEL_NAMES.facilities,
|
|
57
|
+
required: false,
|
|
58
|
+
},
|
|
59
|
+
facilityChargeGroupId: {
|
|
60
|
+
type: mongoose_1.default.Schema.Types.ObjectId,
|
|
61
|
+
ref: _models_1.MODEL_NAMES.facilityChargeGroups,
|
|
62
|
+
required: false,
|
|
63
|
+
},
|
|
54
64
|
totalType: {
|
|
55
65
|
type: String,
|
|
56
66
|
},
|
package/models/Yield.model.ts
CHANGED
|
@@ -3,8 +3,9 @@ import mongoose from 'mongoose';
|
|
|
3
3
|
|
|
4
4
|
import { ISelectedMonth } from '../helpers/date.helper';
|
|
5
5
|
import { MODEL_NAMES } from './_models';
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
6
|
+
import { ILoanChargePlain } from './LoanCharges.model';
|
|
7
|
+
import { ILoanProductPlain } from './LoanProducts.model';
|
|
8
|
+
import { IFacilityPlain } from './Facility.model';
|
|
8
9
|
|
|
9
10
|
export const yieldParamsValidationSchema = Joi.object<IYieldParams>({
|
|
10
11
|
periodStart: Joi.object({
|
|
@@ -58,6 +59,8 @@ export interface IYieldParams {
|
|
|
58
59
|
export interface IYieldData {
|
|
59
60
|
productId?: mongoose.Types.ObjectId;
|
|
60
61
|
chargeId?: mongoose.Types.ObjectId;
|
|
62
|
+
facilityId?: mongoose.Types.ObjectId;
|
|
63
|
+
facilityChargeGroupId?: mongoose.Types.ObjectId;
|
|
61
64
|
totalType: string;
|
|
62
65
|
year: number;
|
|
63
66
|
month: number;
|
|
@@ -67,13 +70,14 @@ export interface IYieldData {
|
|
|
67
70
|
|
|
68
71
|
export interface IYieldViewData {
|
|
69
72
|
order: number;
|
|
70
|
-
charge:
|
|
71
|
-
product:
|
|
73
|
+
charge: ILoanChargePlain;
|
|
74
|
+
product: ILoanProductPlain;
|
|
75
|
+
facility?: IFacilityPlain;
|
|
72
76
|
title: string;
|
|
73
77
|
class?: string;
|
|
74
78
|
|
|
75
|
-
[key: `value-${string}`]: number | string |
|
|
76
|
-
[key: `valuePercent-${string}`]: number | string |
|
|
79
|
+
[key: `value-${string}`]: number | string | ILoanChargePlain | ILoanProductPlain;
|
|
80
|
+
[key: `valuePercent-${string}`]: number | string | ILoanChargePlain | ILoanProductPlain;
|
|
77
81
|
}
|
|
78
82
|
|
|
79
83
|
export interface IYieldDataDoc extends IYieldData, mongoose.Document {
|
|
@@ -88,10 +92,11 @@ export interface IYieldDataLean extends IYieldData {
|
|
|
88
92
|
updatedAt: Date;
|
|
89
93
|
}
|
|
90
94
|
|
|
91
|
-
export interface IYieldDataPlain extends Omit<IYieldData, 'productId' | 'chargeId'> {
|
|
95
|
+
export interface IYieldDataPlain extends Omit<IYieldData, 'productId' | 'chargeId' | 'facilityId'> {
|
|
92
96
|
_id: string;
|
|
93
97
|
productId: string;
|
|
94
98
|
chargeId: string;
|
|
99
|
+
facilityId: string;
|
|
95
100
|
}
|
|
96
101
|
|
|
97
102
|
export type TYieldDataModel = mongoose.Model<IYieldData>;
|
|
@@ -108,6 +113,16 @@ export const YieldDataSchema = new mongoose.Schema<IYieldData, TYieldDataModel>(
|
|
|
108
113
|
ref: MODEL_NAMES.loanCharges,
|
|
109
114
|
required: false,
|
|
110
115
|
},
|
|
116
|
+
facilityId: {
|
|
117
|
+
type: mongoose.Schema.Types.ObjectId,
|
|
118
|
+
ref: MODEL_NAMES.facilities,
|
|
119
|
+
required: false,
|
|
120
|
+
},
|
|
121
|
+
facilityChargeGroupId: {
|
|
122
|
+
type: mongoose.Schema.Types.ObjectId,
|
|
123
|
+
ref: MODEL_NAMES.facilityChargeGroups,
|
|
124
|
+
required: false,
|
|
125
|
+
},
|
|
111
126
|
totalType: {
|
|
112
127
|
type: String,
|
|
113
128
|
},
|
package/models/_index.d.ts
CHANGED
|
@@ -35,10 +35,10 @@ export declare const allSchemas: {
|
|
|
35
35
|
createdAt: NativeDate;
|
|
36
36
|
updatedAt: NativeDate;
|
|
37
37
|
} & {
|
|
38
|
-
order: number;
|
|
39
|
-
amount: number;
|
|
40
38
|
bbcSheetId: import("mongoose").Types.ObjectId;
|
|
39
|
+
order: number;
|
|
41
40
|
apDate: Date;
|
|
41
|
+
amount: number;
|
|
42
42
|
__v?: number;
|
|
43
43
|
poNumber?: string;
|
|
44
44
|
customerName?: string;
|
|
@@ -49,10 +49,10 @@ export declare const allSchemas: {
|
|
|
49
49
|
createdAt: NativeDate;
|
|
50
50
|
updatedAt: NativeDate;
|
|
51
51
|
} & {
|
|
52
|
-
order: number;
|
|
53
|
-
amount: number;
|
|
54
52
|
bbcSheetId: import("mongoose").Types.ObjectId;
|
|
53
|
+
order: number;
|
|
55
54
|
apDate: Date;
|
|
55
|
+
amount: number;
|
|
56
56
|
__v?: number;
|
|
57
57
|
poNumber?: string;
|
|
58
58
|
customerName?: string;
|
|
@@ -63,10 +63,10 @@ export declare const allSchemas: {
|
|
|
63
63
|
createdAt: NativeDate;
|
|
64
64
|
updatedAt: NativeDate;
|
|
65
65
|
} & {
|
|
66
|
-
order: number;
|
|
67
|
-
amount: number;
|
|
68
66
|
bbcSheetId: import("mongoose").Types.ObjectId;
|
|
67
|
+
order: number;
|
|
69
68
|
apDate: Date;
|
|
69
|
+
amount: number;
|
|
70
70
|
__v?: number;
|
|
71
71
|
poNumber?: string;
|
|
72
72
|
customerName?: string;
|
package/models/_models.d.ts
CHANGED
package/models/_models.js
CHANGED
|
@@ -71,6 +71,7 @@ exports.MODEL_NAMES = {
|
|
|
71
71
|
earlyPayments: 'early_payments',
|
|
72
72
|
externalUserAccess: 'external_user_access',
|
|
73
73
|
facilities: 'facilities',
|
|
74
|
+
facilityChargeGroups: 'facility_charge_groups',
|
|
74
75
|
financialComplianceBorrowers: 'financialComplianceBorrowers',
|
|
75
76
|
financialComplianceSettings: 'financialComplianceSettings',
|
|
76
77
|
financialIndexes: 'financial_indexes',
|
package/models/_models.ts
CHANGED
|
@@ -68,6 +68,7 @@ export const MODEL_NAMES = {
|
|
|
68
68
|
earlyPayments : 'early_payments',
|
|
69
69
|
externalUserAccess: 'external_user_access',
|
|
70
70
|
facilities: 'facilities',
|
|
71
|
+
facilityChargeGroups: 'facility_charge_groups',
|
|
71
72
|
financialComplianceBorrowers: 'financialComplianceBorrowers',
|
|
72
73
|
financialComplianceSettings: 'financialComplianceSettings',
|
|
73
74
|
financialIndexes: 'financial_indexes',
|
package/package.json
CHANGED
|
@@ -27,6 +27,8 @@ import mongoose from 'mongoose';
|
|
|
27
27
|
import { ISelectedMonth } from '../helpers/date.helper';
|
|
28
28
|
import { IYieldParams, IYieldViewData } from '../models/Yield.model';
|
|
29
29
|
export declare class YieldService {
|
|
30
|
+
private toPlainProduct;
|
|
31
|
+
private toPlainCharge;
|
|
30
32
|
private getCalculatedYieldData;
|
|
31
33
|
getCalculatedYieldTotals(productId: string, selectedMonth: ISelectedMonth): Promise<(mongoose.FlattenMaps<import("../models/Yield.model").IYieldData> & {
|
|
32
34
|
_id: mongoose.Types.ObjectId;
|
|
@@ -13,6 +13,23 @@ const LoanProducts_model_1 = require("../models/LoanProducts.model");
|
|
|
13
13
|
const microservice_tasks_db_1 = require("../db/microservice-tasks.db");
|
|
14
14
|
const microservice_task_enum_1 = require("../enums/microservice-task.enum");
|
|
15
15
|
class YieldService {
|
|
16
|
+
toPlainProduct(product) {
|
|
17
|
+
return {
|
|
18
|
+
...product,
|
|
19
|
+
_id: product._id.toString(),
|
|
20
|
+
borrowerId: product.borrowerId.toString(),
|
|
21
|
+
facilityId: product.facilityId?.toString() ?? null,
|
|
22
|
+
masterLoanProductId: product.masterLoanProductId?.toString() ?? null,
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
toPlainCharge(charge) {
|
|
26
|
+
return {
|
|
27
|
+
...charge,
|
|
28
|
+
_id: charge._id.toString(),
|
|
29
|
+
borrowerId: charge.borrowerId.toString(),
|
|
30
|
+
productId: charge.productId.toString(),
|
|
31
|
+
};
|
|
32
|
+
}
|
|
16
33
|
async getCalculatedYieldData(charge, selectedMonth) {
|
|
17
34
|
const oldData = await Yield_model_1.YieldData.findOne({
|
|
18
35
|
chargeId: charge._id,
|
|
@@ -65,19 +82,21 @@ class YieldService {
|
|
|
65
82
|
}
|
|
66
83
|
const startDate = (0, date_helper_1.convertSelectedMonthToDate)(params.periodStart);
|
|
67
84
|
const endDate = (0, date_helper_1.convertSelectedMonthToDate)(params.periodEnd);
|
|
68
|
-
const
|
|
85
|
+
const leanCharges = await LoanCharges_model_1.LoanCharge.find({ includeInYield: true }).lean();
|
|
86
|
+
const charges = leanCharges.map((c) => this.toPlainCharge(c));
|
|
69
87
|
const productIDs = charges.reduce((acc, charge) => [...acc, charge.productId.toString()], []);
|
|
70
|
-
const
|
|
88
|
+
const leanProducts = await LoanProducts_model_1.LoanProduct
|
|
71
89
|
.find({ _id: { $in: Object.values(productIDs).map((id) => new mongoose_1.default.Types.ObjectId(id)) } })
|
|
72
90
|
.populate('borrowerId')
|
|
73
91
|
.lean();
|
|
92
|
+
const products = leanProducts.map((p) => this.toPlainProduct(p));
|
|
74
93
|
const productMap = products
|
|
75
94
|
.reduce((acc, product) => {
|
|
76
95
|
return {
|
|
77
96
|
...acc,
|
|
78
|
-
[product._id
|
|
97
|
+
[product._id]: {
|
|
79
98
|
product,
|
|
80
|
-
charges: charges.filter((charge) => charge.productId
|
|
99
|
+
charges: charges.filter((charge) => charge.productId == product._id),
|
|
81
100
|
},
|
|
82
101
|
};
|
|
83
102
|
}, {});
|
|
@@ -88,9 +107,9 @@ class YieldService {
|
|
|
88
107
|
await Promise.all(productMap[productId].charges.map(async (charge) => {
|
|
89
108
|
const monthlyData = {
|
|
90
109
|
charge,
|
|
91
|
-
product: productMap[charge.productId
|
|
110
|
+
product: productMap[charge.productId].product,
|
|
92
111
|
order: 0,
|
|
93
|
-
title: productMap[charge.productId
|
|
112
|
+
title: productMap[charge.productId].product.name,
|
|
94
113
|
};
|
|
95
114
|
await Promise.all(Object.entries(allDates).map(async ([dateView, date]) => {
|
|
96
115
|
if (!hasAllData) {
|
|
@@ -10,14 +10,33 @@ import {
|
|
|
10
10
|
YieldData,
|
|
11
11
|
yieldParamsValidationSchema,
|
|
12
12
|
} from '../models/Yield.model';
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
13
|
+
import { ILoanChargeLean, ILoanChargePlain, LoanCharge } from '../models/LoanCharges.model';
|
|
14
|
+
import { ILoanProductLean, ILoanProductPlain, LoanProduct } from '../models/LoanProducts.model';
|
|
15
15
|
import { createMicroserviceTasks } from '../db/microservice-tasks.db';
|
|
16
16
|
import { EMicroserviceTask } from '../enums/microservice-task.enum';
|
|
17
17
|
|
|
18
18
|
export class YieldService {
|
|
19
19
|
|
|
20
|
-
private
|
|
20
|
+
private toPlainProduct(product: ILoanProductLean): ILoanProductPlain {
|
|
21
|
+
return {
|
|
22
|
+
...product,
|
|
23
|
+
_id: product._id.toString(),
|
|
24
|
+
borrowerId: product.borrowerId.toString(),
|
|
25
|
+
facilityId: product.facilityId?.toString() ?? null,
|
|
26
|
+
masterLoanProductId: product.masterLoanProductId?.toString() ?? null,
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
private toPlainCharge(charge: ILoanChargeLean): ILoanChargePlain {
|
|
31
|
+
return {
|
|
32
|
+
...charge,
|
|
33
|
+
_id: charge._id.toString(),
|
|
34
|
+
borrowerId: charge.borrowerId.toString(),
|
|
35
|
+
productId: charge.productId.toString(),
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
private async getCalculatedYieldData(charge: ILoanChargePlain, selectedMonth: ISelectedMonth) {
|
|
21
40
|
const oldData = await YieldData.findOne({
|
|
22
41
|
chargeId: charge._id,
|
|
23
42
|
productId: charge.productId,
|
|
@@ -74,25 +93,28 @@ export class YieldService {
|
|
|
74
93
|
|
|
75
94
|
const startDate = convertSelectedMonthToDate(params.periodStart);
|
|
76
95
|
const endDate = convertSelectedMonthToDate(params.periodEnd);
|
|
77
|
-
const
|
|
96
|
+
const leanCharges = await LoanCharge.find({ includeInYield: true }).lean();
|
|
97
|
+
const charges = leanCharges.map((c) => this.toPlainCharge(c));
|
|
78
98
|
|
|
79
99
|
const productIDs = charges.reduce((acc, charge) => [...acc, charge.productId.toString()], <string[]>[]);
|
|
80
100
|
|
|
81
|
-
const
|
|
101
|
+
const leanProducts = await LoanProduct
|
|
82
102
|
.find({ _id: { $in: Object.values(productIDs).map((id) => new mongoose.Types.ObjectId(id)) } })
|
|
83
103
|
.populate('borrowerId')
|
|
84
104
|
.lean();
|
|
85
105
|
|
|
106
|
+
const products = leanProducts.map((p) => this.toPlainProduct(p));
|
|
107
|
+
|
|
86
108
|
const productMap = products
|
|
87
109
|
.reduce((acc, product) => {
|
|
88
110
|
return {
|
|
89
111
|
...acc,
|
|
90
|
-
[product._id
|
|
112
|
+
[product._id]: {
|
|
91
113
|
product,
|
|
92
|
-
charges: charges.filter((charge) => charge.productId
|
|
114
|
+
charges: charges.filter((charge) => charge.productId == product._id),
|
|
93
115
|
},
|
|
94
116
|
};
|
|
95
|
-
}, <{ [productId: string]: { product:
|
|
117
|
+
}, <{ [productId: string]: { product: ILoanProductPlain, charges: ILoanChargePlain[] } }>{});
|
|
96
118
|
|
|
97
119
|
const allDates = getStartOfMonthsBetweenDates(startDate, endDate);
|
|
98
120
|
|
|
@@ -106,9 +128,9 @@ export class YieldService {
|
|
|
106
128
|
|
|
107
129
|
const monthlyData = {
|
|
108
130
|
charge,
|
|
109
|
-
product: productMap[charge.productId
|
|
131
|
+
product: productMap[charge.productId].product,
|
|
110
132
|
order: 0,
|
|
111
|
-
title: productMap[charge.productId
|
|
133
|
+
title: productMap[charge.productId].product.name,
|
|
112
134
|
};
|
|
113
135
|
|
|
114
136
|
await Promise.all(Object.entries(allDates).map(async ([dateView, date]) => {
|