gemcap-be-common 1.5.7 → 1.5.9
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/helpers/date.helper.js
CHANGED
|
@@ -7,10 +7,12 @@ exports.isProductActive = exports.getShiftedMonth = exports.getDays = exports.ge
|
|
|
7
7
|
const dayjs_1 = __importDefault(require("dayjs"));
|
|
8
8
|
const utc_1 = __importDefault(require("dayjs/plugin/utc"));
|
|
9
9
|
const timezone_1 = __importDefault(require("dayjs/plugin/timezone"));
|
|
10
|
+
const isSameOrAfter_1 = __importDefault(require("dayjs/plugin/isSameOrAfter"));
|
|
10
11
|
const objectSupport_1 = __importDefault(require("dayjs/plugin/objectSupport"));
|
|
11
12
|
dayjs_1.default.extend(objectSupport_1.default);
|
|
12
13
|
dayjs_1.default.extend(utc_1.default);
|
|
13
14
|
dayjs_1.default.extend(timezone_1.default);
|
|
15
|
+
dayjs_1.default.extend(isSameOrAfter_1.default);
|
|
14
16
|
exports.defaultDateFormat = 'MM-DD-YYYY';
|
|
15
17
|
const normalizeDate = (date, type) => {
|
|
16
18
|
return type === 'start'
|
package/helpers/date.helper.ts
CHANGED
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import dayjs, { Dayjs, OpUnitType, QUnitType } from 'dayjs';
|
|
2
2
|
import utc from 'dayjs/plugin/utc';
|
|
3
3
|
import timezone from 'dayjs/plugin/timezone';
|
|
4
|
+
import isSameOrAfter from 'dayjs/plugin/isSameOrAfter';
|
|
4
5
|
import objectSupport from 'dayjs/plugin/objectSupport';
|
|
5
6
|
|
|
6
7
|
dayjs.extend(objectSupport);
|
|
7
8
|
dayjs.extend(utc);
|
|
8
9
|
dayjs.extend(timezone);
|
|
10
|
+
dayjs.extend(isSameOrAfter);
|
|
9
11
|
|
|
10
12
|
export interface ISelectedMonth {
|
|
11
13
|
year: number;
|
package/package.json
CHANGED
|
@@ -168,6 +168,11 @@ class LoanStatementService {
|
|
|
168
168
|
if (!statementDate) {
|
|
169
169
|
statementDate = (0, dayjs_1.default)().utc().startOf('day').toDate();
|
|
170
170
|
}
|
|
171
|
+
const product = await this.loanChargesService.getLoanProductById(productId);
|
|
172
|
+
// If product is already deactivated for this statement date (inclusive) — skip everything early
|
|
173
|
+
if (product.deactivationDate && (0, dayjs_1.default)(statementDate).isSameOrAfter((0, dayjs_1.default)(product.deactivationDate))) {
|
|
174
|
+
return;
|
|
175
|
+
}
|
|
171
176
|
const primeRate = await this.financialIndexesService.getFinancialIndexValue(financial_indexes_service_1.EFinancialIndex.PRIME_RATE, statementDate);
|
|
172
177
|
if (!primeRate) {
|
|
173
178
|
return;
|
|
@@ -178,7 +183,6 @@ class LoanStatementService {
|
|
|
178
183
|
const loanStatementEffectsService = this.getLoanStatementEffectsService();
|
|
179
184
|
await loanStatementEffectsService.saveMonthData(productId, statementDate);
|
|
180
185
|
const charges = await this.loanChargesService.getLoanChargeForProduct(productId);
|
|
181
|
-
const product = await this.loanChargesService.getLoanProductById(productId);
|
|
182
186
|
const daysPerYear = 360;
|
|
183
187
|
const dayInMonth = (0, dayjs_1.default)(period.end).diff(period.start, 'days') + 1;
|
|
184
188
|
let orderIndex = 0;
|
|
@@ -289,19 +293,21 @@ class LoanStatementService {
|
|
|
289
293
|
};
|
|
290
294
|
fee = checkMinAmount(fee);
|
|
291
295
|
if (fee !== null && fee > 0) {
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
296
|
+
if ((0, dayjs_1.default)(statementDate).isSame((0, dayjs_1.default)(charge.applyFrom)) || (0, dayjs_1.default)(statementDate).isAfter((0, dayjs_1.default)(charge.applyFrom))) {
|
|
297
|
+
const newStatement = {
|
|
298
|
+
order: orderIndex,
|
|
299
|
+
date: statementDate,
|
|
300
|
+
chargeId: charge._id,
|
|
301
|
+
amount: fee,
|
|
302
|
+
amountPaid: 0,
|
|
303
|
+
isSystem: true,
|
|
304
|
+
memo: 'System Generated',
|
|
305
|
+
balance: 0,
|
|
306
|
+
};
|
|
307
|
+
const newStatementDoc = await LoanStatementTransaction_model_1.LoanStatementTransactionModel.create(newStatement);
|
|
308
|
+
await newStatementDoc.save();
|
|
309
|
+
orderIndex = orderIndex + 1;
|
|
310
|
+
}
|
|
305
311
|
}
|
|
306
312
|
}
|
|
307
313
|
}
|
|
@@ -203,6 +203,14 @@ export class LoanStatementService {
|
|
|
203
203
|
if (!statementDate) {
|
|
204
204
|
statementDate = dayjs().utc().startOf('day').toDate();
|
|
205
205
|
}
|
|
206
|
+
|
|
207
|
+
const product = await this.loanChargesService.getLoanProductById(productId);
|
|
208
|
+
|
|
209
|
+
// If product is already deactivated for this statement date (inclusive) — skip everything early
|
|
210
|
+
if (product.deactivationDate && dayjs(statementDate).isSameOrAfter(dayjs(product.deactivationDate))) {
|
|
211
|
+
return;
|
|
212
|
+
}
|
|
213
|
+
|
|
206
214
|
const primeRate = await this.financialIndexesService.getFinancialIndexValue(EFinancialIndex.PRIME_RATE, statementDate);
|
|
207
215
|
if (!primeRate) {
|
|
208
216
|
return;
|
|
@@ -215,7 +223,6 @@ export class LoanStatementService {
|
|
|
215
223
|
await loanStatementEffectsService.saveMonthData(productId, statementDate);
|
|
216
224
|
|
|
217
225
|
const charges = await this.loanChargesService.getLoanChargeForProduct(productId);
|
|
218
|
-
const product = await this.loanChargesService.getLoanProductById(productId);
|
|
219
226
|
|
|
220
227
|
const daysPerYear = 360;
|
|
221
228
|
const dayInMonth = dayjs(period.end).diff(period.start, 'days') + 1;
|
|
@@ -333,19 +340,21 @@ export class LoanStatementService {
|
|
|
333
340
|
fee = checkMinAmount(fee);
|
|
334
341
|
|
|
335
342
|
if (fee !== null && fee > 0) {
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
343
|
+
if (dayjs(statementDate).isSame(dayjs(charge.applyFrom)) || dayjs(statementDate).isAfter(dayjs(charge.applyFrom))) {
|
|
344
|
+
const newStatement: ILoanStatementTransaction = {
|
|
345
|
+
order: orderIndex,
|
|
346
|
+
date: statementDate,
|
|
347
|
+
chargeId: charge._id,
|
|
348
|
+
amount: fee,
|
|
349
|
+
amountPaid: 0,
|
|
350
|
+
isSystem: true,
|
|
351
|
+
memo: 'System Generated',
|
|
352
|
+
balance: 0,
|
|
353
|
+
};
|
|
354
|
+
const newStatementDoc = await LoanStatementTransactionModel.create(newStatement);
|
|
355
|
+
await newStatementDoc.save();
|
|
356
|
+
orderIndex = orderIndex + 1;
|
|
357
|
+
}
|
|
349
358
|
}
|
|
350
359
|
}
|
|
351
360
|
}
|