gemcap-be-common 1.5.8 → 1.5.10
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
|
@@ -179,6 +179,10 @@ class LoanStatementService {
|
|
|
179
179
|
await loanStatementEffectsService.saveMonthData(productId, statementDate);
|
|
180
180
|
const charges = await this.loanChargesService.getLoanChargeForProduct(productId);
|
|
181
181
|
const product = await this.loanChargesService.getLoanProductById(productId);
|
|
182
|
+
// If product is already deactivated for this statement date (inclusive) — skip everything early
|
|
183
|
+
if (product.deactivationDate && (0, dayjs_1.default)(statementDate).isSameOrAfter((0, dayjs_1.default)(product.deactivationDate))) {
|
|
184
|
+
return;
|
|
185
|
+
}
|
|
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;
|
|
@@ -203,11 +203,14 @@ export class LoanStatementService {
|
|
|
203
203
|
if (!statementDate) {
|
|
204
204
|
statementDate = dayjs().utc().startOf('day').toDate();
|
|
205
205
|
}
|
|
206
|
+
|
|
207
|
+
|
|
206
208
|
const primeRate = await this.financialIndexesService.getFinancialIndexValue(EFinancialIndex.PRIME_RATE, statementDate);
|
|
207
209
|
if (!primeRate) {
|
|
208
210
|
return;
|
|
209
211
|
}
|
|
210
212
|
await this.cleanProductStatement(productId, statementDate);
|
|
213
|
+
|
|
211
214
|
const balanceDate = dayjs.utc(statementDate).add(1, 'day').subtract(1, 'second').toDate();
|
|
212
215
|
const balance = await this.loanChargesService.getLoanProductBalance(productId, balanceDate);
|
|
213
216
|
|
|
@@ -217,6 +220,11 @@ export class LoanStatementService {
|
|
|
217
220
|
const charges = await this.loanChargesService.getLoanChargeForProduct(productId);
|
|
218
221
|
const product = await this.loanChargesService.getLoanProductById(productId);
|
|
219
222
|
|
|
223
|
+
// If product is already deactivated for this statement date (inclusive) — skip everything early
|
|
224
|
+
if (product.deactivationDate && dayjs(statementDate).isSameOrAfter(dayjs(product.deactivationDate))) {
|
|
225
|
+
return;
|
|
226
|
+
}
|
|
227
|
+
|
|
220
228
|
const daysPerYear = 360;
|
|
221
229
|
const dayInMonth = dayjs(period.end).diff(period.start, 'days') + 1;
|
|
222
230
|
let orderIndex = 0;
|