gemcap-be-common 1.5.8 → 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;
|
|
@@ -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;
|