gemcap-be-common 1.5.9 → 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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gemcap-be-common",
3
- "version": "1.5.9",
3
+ "version": "1.5.10",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -168,11 +168,6 @@ 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
- }
176
171
  const primeRate = await this.financialIndexesService.getFinancialIndexValue(financial_indexes_service_1.EFinancialIndex.PRIME_RATE, statementDate);
177
172
  if (!primeRate) {
178
173
  return;
@@ -183,6 +178,11 @@ class LoanStatementService {
183
178
  const loanStatementEffectsService = this.getLoanStatementEffectsService();
184
179
  await loanStatementEffectsService.saveMonthData(productId, statementDate);
185
180
  const charges = await this.loanChargesService.getLoanChargeForProduct(productId);
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
+ }
186
186
  const daysPerYear = 360;
187
187
  const dayInMonth = (0, dayjs_1.default)(period.end).diff(period.start, 'days') + 1;
188
188
  let orderIndex = 0;
@@ -204,18 +204,13 @@ export class LoanStatementService {
204
204
  statementDate = dayjs().utc().startOf('day').toDate();
205
205
  }
206
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
207
 
214
208
  const primeRate = await this.financialIndexesService.getFinancialIndexValue(EFinancialIndex.PRIME_RATE, statementDate);
215
209
  if (!primeRate) {
216
210
  return;
217
211
  }
218
212
  await this.cleanProductStatement(productId, statementDate);
213
+
219
214
  const balanceDate = dayjs.utc(statementDate).add(1, 'day').subtract(1, 'second').toDate();
220
215
  const balance = await this.loanChargesService.getLoanProductBalance(productId, balanceDate);
221
216
 
@@ -223,6 +218,12 @@ export class LoanStatementService {
223
218
  await loanStatementEffectsService.saveMonthData(productId, statementDate);
224
219
 
225
220
  const charges = await this.loanChargesService.getLoanChargeForProduct(productId);
221
+ const product = await this.loanChargesService.getLoanProductById(productId);
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
+ }
226
227
 
227
228
  const daysPerYear = 360;
228
229
  const dayInMonth = dayjs(period.end).diff(period.start, 'days') + 1;