gemcap-be-common 1.3.184 → 1.3.185
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/package.json
CHANGED
|
@@ -152,7 +152,7 @@ class LoanStatementService {
|
|
|
152
152
|
await Promise.all(periods.map(async (period) => {
|
|
153
153
|
const days = this.getDays(period);
|
|
154
154
|
for (const day of days) {
|
|
155
|
-
await this.calculateStatement(productId, period,
|
|
155
|
+
await this.calculateStatement(productId, period, dayjs_1.default.utc(day).toDate());
|
|
156
156
|
}
|
|
157
157
|
const statementDate = this.loanStatementStatusService.getStatementDateFromPeriod(period);
|
|
158
158
|
await this.loanStatementStatusService.updateStatementStatus(productId, statementDate, true);
|
|
@@ -166,14 +166,14 @@ class LoanStatementService {
|
|
|
166
166
|
}
|
|
167
167
|
async calculateStatement(productId, period, statementDate) {
|
|
168
168
|
if (!statementDate) {
|
|
169
|
-
statementDate = (0, dayjs_1.default)(
|
|
169
|
+
statementDate = (0, dayjs_1.default)().utc().startOf('day').toDate();
|
|
170
170
|
}
|
|
171
171
|
const primeRate = await this.financialIndexesService.getFinancialIndexValue(financial_indexes_service_1.EFinancialIndex.PRIME_RATE, statementDate);
|
|
172
172
|
if (!primeRate) {
|
|
173
173
|
return;
|
|
174
174
|
}
|
|
175
175
|
await this.cleanProductStatement(productId, statementDate);
|
|
176
|
-
const balance = await this.loanChargesService.getLoanProductBalance(productId, statementDate);
|
|
176
|
+
const balance = await this.loanChargesService.getLoanProductBalance(productId, dayjs_1.default.utc(statementDate).add(1, 'day').toDate());
|
|
177
177
|
const loanStatementEffectsService = this.getLoanStatementEffectsService();
|
|
178
178
|
await loanStatementEffectsService.saveMonthData(productId, statementDate);
|
|
179
179
|
const charges = await this.loanChargesService.getLoanChargeForProduct(productId);
|
|
@@ -181,12 +181,10 @@ class LoanStatementService {
|
|
|
181
181
|
const daysPerYear = 360;
|
|
182
182
|
const dayInMonth = (0, dayjs_1.default)(period.end).diff(period.start, 'days') + 1;
|
|
183
183
|
let orderIndex = 0;
|
|
184
|
-
console.log({ statementDate, balance });
|
|
185
184
|
for (const charge of charges) {
|
|
186
185
|
if (charge.applyFrom.getTime() > statementDate.getTime()) {
|
|
187
186
|
return;
|
|
188
187
|
}
|
|
189
|
-
console.log('applying');
|
|
190
188
|
const statementDateFormat = (0, dayjs_1.default)(statementDate).format('YYYY-MM-DD');
|
|
191
189
|
let calculateFee = false;
|
|
192
190
|
switch (charge.frequency) {
|
|
@@ -230,7 +228,6 @@ class LoanStatementService {
|
|
|
230
228
|
const getBalance = () => {
|
|
231
229
|
return Math.max(0, useFloating ? balance.floatedBalance : balance.balance);
|
|
232
230
|
};
|
|
233
|
-
console.log({ calculateFee });
|
|
234
231
|
if (calculateFee) {
|
|
235
232
|
let fee = 0;
|
|
236
233
|
let calculatedFee = 0;
|
|
@@ -242,7 +239,6 @@ class LoanStatementService {
|
|
|
242
239
|
percentFee = Math.min(Math.max(percentFee, minPercent), maxPercent);
|
|
243
240
|
}
|
|
244
241
|
const dailyPercent = new decimal_js_1.default(percentFee).div(daysPerYear).toNumber();
|
|
245
|
-
console.log(charge);
|
|
246
242
|
switch (charge.calculationBasis) {
|
|
247
243
|
case loan_types_enum_1.EChargeCalculationBasis.DAILY_BALANCE:
|
|
248
244
|
if ((0, dayjs_1.default)(statementDate).isAfter((0, dayjs_1.default)(charge.applyFrom)) || (0, dayjs_1.default)(statementDate).isSame((0, dayjs_1.default)(charge.applyFrom))) {
|
|
@@ -290,9 +286,7 @@ class LoanStatementService {
|
|
|
290
286
|
}
|
|
291
287
|
return fee;
|
|
292
288
|
};
|
|
293
|
-
console.log({ fee });
|
|
294
289
|
fee = checkMinAmount(fee);
|
|
295
|
-
console.log({ fee });
|
|
296
290
|
if (fee !== null && fee > 0) {
|
|
297
291
|
const newStatement = {
|
|
298
292
|
order: orderIndex,
|
|
@@ -338,7 +332,7 @@ class LoanStatementService {
|
|
|
338
332
|
async getBalancesDaily(productId, period) {
|
|
339
333
|
const days = this.getDays({ start: (0, dayjs_1.default)(period.start).utcOffset(0), end: (0, dayjs_1.default)(period.end).utcOffset(0) });
|
|
340
334
|
return Promise.all(days.map(async (day) => {
|
|
341
|
-
const balance = await this.loanChargesService.getLoanProductBalance(productId,
|
|
335
|
+
const balance = await this.loanChargesService.getLoanProductBalance(productId, dayjs_1.default.utc(day).toDate());
|
|
342
336
|
return { day, ...balance };
|
|
343
337
|
}));
|
|
344
338
|
}
|
|
@@ -185,7 +185,7 @@ export class LoanStatementService {
|
|
|
185
185
|
await Promise.all(periods.map(async (period) => {
|
|
186
186
|
const days = this.getDays(period);
|
|
187
187
|
for (const day of days) {
|
|
188
|
-
await this.calculateStatement(productId, period,
|
|
188
|
+
await this.calculateStatement(productId, period, dayjs.utc(day).toDate());
|
|
189
189
|
}
|
|
190
190
|
const statementDate = this.loanStatementStatusService.getStatementDateFromPeriod(period);
|
|
191
191
|
await this.loanStatementStatusService.updateStatementStatus(productId, statementDate, true);
|
|
@@ -201,14 +201,14 @@ export class LoanStatementService {
|
|
|
201
201
|
|
|
202
202
|
async calculateStatement(productId: string, period: IStatementPeriod, statementDate?: Date) {
|
|
203
203
|
if (!statementDate) {
|
|
204
|
-
statementDate = dayjs(
|
|
204
|
+
statementDate = dayjs().utc().startOf('day').toDate();
|
|
205
205
|
}
|
|
206
206
|
const primeRate = await this.financialIndexesService.getFinancialIndexValue(EFinancialIndex.PRIME_RATE, statementDate);
|
|
207
207
|
if (!primeRate) {
|
|
208
208
|
return;
|
|
209
209
|
}
|
|
210
210
|
await this.cleanProductStatement(productId, statementDate);
|
|
211
|
-
const balance = await this.loanChargesService.getLoanProductBalance(productId, statementDate);
|
|
211
|
+
const balance = await this.loanChargesService.getLoanProductBalance(productId, dayjs.utc(statementDate).add(1, 'day').toDate());
|
|
212
212
|
|
|
213
213
|
const loanStatementEffectsService = this.getLoanStatementEffectsService();
|
|
214
214
|
await loanStatementEffectsService.saveMonthData(productId, statementDate);
|
|
@@ -219,12 +219,10 @@ export class LoanStatementService {
|
|
|
219
219
|
const daysPerYear = 360;
|
|
220
220
|
const dayInMonth = dayjs(period.end).diff(period.start, 'days') + 1;
|
|
221
221
|
let orderIndex = 0;
|
|
222
|
-
console.log({ statementDate, balance });
|
|
223
222
|
for (const charge of charges) {
|
|
224
223
|
if (charge.applyFrom.getTime() > statementDate.getTime()) {
|
|
225
224
|
return;
|
|
226
225
|
}
|
|
227
|
-
console.log('applying');
|
|
228
226
|
const statementDateFormat = dayjs(statementDate).format('YYYY-MM-DD');
|
|
229
227
|
let calculateFee = false;
|
|
230
228
|
switch (charge.frequency) {
|
|
@@ -271,8 +269,6 @@ export class LoanStatementService {
|
|
|
271
269
|
return Math.max(0, useFloating ? balance.floatedBalance : balance.balance);
|
|
272
270
|
};
|
|
273
271
|
|
|
274
|
-
console.log({ calculateFee });
|
|
275
|
-
|
|
276
272
|
if (calculateFee) {
|
|
277
273
|
let fee = 0;
|
|
278
274
|
let calculatedFee = 0;
|
|
@@ -284,7 +280,6 @@ export class LoanStatementService {
|
|
|
284
280
|
percentFee = Math.min(Math.max(percentFee, minPercent), maxPercent);
|
|
285
281
|
}
|
|
286
282
|
const dailyPercent = new Decimal(percentFee).div(daysPerYear).toNumber();
|
|
287
|
-
console.log(charge);
|
|
288
283
|
switch (charge.calculationBasis) {
|
|
289
284
|
case EChargeCalculationBasis.DAILY_BALANCE:
|
|
290
285
|
if (dayjs(statementDate).isAfter(dayjs(charge.applyFrom)) || dayjs(statementDate).isSame(dayjs(charge.applyFrom))) {
|
|
@@ -334,12 +329,8 @@ export class LoanStatementService {
|
|
|
334
329
|
return fee;
|
|
335
330
|
};
|
|
336
331
|
|
|
337
|
-
console.log({ fee });
|
|
338
|
-
|
|
339
332
|
fee = checkMinAmount(fee);
|
|
340
333
|
|
|
341
|
-
console.log({ fee });
|
|
342
|
-
|
|
343
334
|
if (fee !== null && fee > 0) {
|
|
344
335
|
const newStatement: ILoanStatementTransaction = {
|
|
345
336
|
order: orderIndex,
|
|
@@ -388,7 +379,7 @@ export class LoanStatementService {
|
|
|
388
379
|
async getBalancesDaily(productId: string, period: { start: Date, end: Date }) {
|
|
389
380
|
const days = this.getDays({ start: dayjs(period.start).utcOffset(0), end: dayjs(period.end).utcOffset(0) });
|
|
390
381
|
return Promise.all(days.map(async (day) => {
|
|
391
|
-
const balance = await this.loanChargesService.getLoanProductBalance(productId,
|
|
382
|
+
const balance = await this.loanChargesService.getLoanProductBalance(productId, dayjs.utc(day).toDate());
|
|
392
383
|
return { day, ...balance };
|
|
393
384
|
}));
|
|
394
385
|
}
|