gemcap-be-common 1.5.6 → 1.5.8

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.6",
3
+ "version": "1.5.8",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -289,19 +289,21 @@ class LoanStatementService {
289
289
  };
290
290
  fee = checkMinAmount(fee);
291
291
  if (fee !== null && fee > 0) {
292
- const newStatement = {
293
- order: orderIndex,
294
- date: statementDate,
295
- chargeId: charge._id,
296
- amount: fee,
297
- amountPaid: 0,
298
- isSystem: true,
299
- memo: 'System Generated',
300
- balance: 0,
301
- };
302
- const newStatementDoc = await LoanStatementTransaction_model_1.LoanStatementTransactionModel.create(newStatement);
303
- await newStatementDoc.save();
304
- orderIndex = orderIndex + 1;
292
+ 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))) {
293
+ const newStatement = {
294
+ order: orderIndex,
295
+ date: statementDate,
296
+ chargeId: charge._id,
297
+ amount: fee,
298
+ amountPaid: 0,
299
+ isSystem: true,
300
+ memo: 'System Generated',
301
+ balance: 0,
302
+ };
303
+ const newStatementDoc = await LoanStatementTransaction_model_1.LoanStatementTransactionModel.create(newStatement);
304
+ await newStatementDoc.save();
305
+ orderIndex = orderIndex + 1;
306
+ }
305
307
  }
306
308
  }
307
309
  }
@@ -333,19 +333,21 @@ export class LoanStatementService {
333
333
  fee = checkMinAmount(fee);
334
334
 
335
335
  if (fee !== null && fee > 0) {
336
- const newStatement: ILoanStatementTransaction = {
337
- order: orderIndex,
338
- date: statementDate,
339
- chargeId: charge._id,
340
- amount: fee,
341
- amountPaid: 0,
342
- isSystem: true,
343
- memo: 'System Generated',
344
- balance: 0,
345
- };
346
- const newStatementDoc = await LoanStatementTransactionModel.create(newStatement);
347
- await newStatementDoc.save();
348
- orderIndex = orderIndex + 1;
336
+ if (dayjs(statementDate).isSame(dayjs(charge.applyFrom)) || dayjs(statementDate).isAfter(dayjs(charge.applyFrom))) {
337
+ const newStatement: ILoanStatementTransaction = {
338
+ order: orderIndex,
339
+ date: statementDate,
340
+ chargeId: charge._id,
341
+ amount: fee,
342
+ amountPaid: 0,
343
+ isSystem: true,
344
+ memo: 'System Generated',
345
+ balance: 0,
346
+ };
347
+ const newStatementDoc = await LoanStatementTransactionModel.create(newStatement);
348
+ await newStatementDoc.save();
349
+ orderIndex = orderIndex + 1;
350
+ }
349
351
  }
350
352
  }
351
353
  }
@@ -236,7 +236,9 @@ class PdfService {
236
236
  }],
237
237
  [{ text: 'Commitment amount' }, { text: (0, numbers_helper_1.formatNumbers)(product.commitment), alignment: 'right' }],
238
238
  ];
239
- const endDate = dayjs_1.default.utc(product.deactivationDate).isBefore(dayjs_1.default.utc(end)) ? dayjs_1.default.utc(product.deactivationDate) : dayjs_1.default.utc(end);
239
+ const endDate = product.deactivationDate
240
+ ? (0, dayjs_1.default)(product.deactivationDate).isBefore((0, dayjs_1.default)(end.slice(0, 10))) ? (0, dayjs_1.default)(product.deactivationDate) : (0, dayjs_1.default)(end.slice(0, 10))
241
+ : (0, dayjs_1.default)(end.slice(0, 10));
240
242
  const preparedStatementHeader = [
241
243
  { text: `STATEMENT FOR PRODUCT: ${product.name}`, bold: true },
242
244
  { text: `Client: ${borrower.code}`, bold: true },
@@ -272,7 +272,9 @@ export class PdfService {
272
272
  [{ text: 'Commitment amount' }, { text: formatNumbers(product.commitment), alignment: 'right' }],
273
273
  ];
274
274
 
275
- const endDate = dayjs.utc(product.deactivationDate).isBefore(dayjs.utc(end)) ? dayjs.utc(product.deactivationDate) : dayjs.utc(end);
275
+ const endDate = product.deactivationDate
276
+ ? dayjs(product.deactivationDate).isBefore(dayjs(end.slice(0, 10))) ? dayjs(product.deactivationDate) : dayjs(end.slice(0, 10))
277
+ : dayjs(end.slice(0, 10));
276
278
 
277
279
  const preparedStatementHeader = [
278
280
  { text: `STATEMENT FOR PRODUCT: ${product.name}`, bold: true },