gemcap-be-common 1.4.115 → 1.4.116

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.4.115",
3
+ "version": "1.4.116",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -822,20 +822,22 @@ class LoanStatementService {
822
822
  }, fees);
823
823
  let principal = 0;
824
824
  let principalExpectedDate = null;
825
- const termLoan = await TermLoan_model_1.TermLoanModel.findOne({ productId: product._id.toString(), actual: true });
826
- if (termLoan) {
827
- const calculatedTermLoan = await TermLoanCalculated_model_1.TermLoanCalculatedModel.findOne({
828
- termLoanId: termLoan._id.toString(),
829
- relevantStatement: relevantStatementEndMonth.format('YYYY-MM-DD'),
830
- });
831
- if (calculatedTermLoan) {
832
- if (calculatedTermLoan.payments && calculatedTermLoan.payments.length > 0) {
833
- const totalPayment = calculatedTermLoan.payments.reduce((acc, p) => new decimal_js_1.default(acc ?? 0).add(p.amount ?? 0).toNumber(), 0);
834
- principal = new decimal_js_1.default(calculatedTermLoan.monthlyPrincipal).sub(totalPayment).toDP(2).toNumber();
835
- }
836
- else {
837
- principal = calculatedTermLoan.monthlyPrincipal;
838
- principalExpectedDate = calculatedTermLoan.paymentDueDate;
825
+ if (product.type === loan_types_enum_1.ELoanTypes.TERM) {
826
+ const termLoan = await TermLoan_model_1.TermLoanModel.findOne({ productId: product._id.toString(), actual: true });
827
+ if (termLoan) {
828
+ const calculatedTermLoan = await TermLoanCalculated_model_1.TermLoanCalculatedModel.findOne({
829
+ termLoanId: termLoan._id.toString(),
830
+ relevantStatement: relevantStatementEndMonth.format('YYYY-MM-DD'),
831
+ });
832
+ if (calculatedTermLoan) {
833
+ if (calculatedTermLoan.payments && calculatedTermLoan.payments.length > 0) {
834
+ const totalPayment = calculatedTermLoan.payments.reduce((acc, p) => new decimal_js_1.default(acc ?? 0).add(p.amount ?? 0).toNumber(), 0);
835
+ principal = new decimal_js_1.default(calculatedTermLoan.monthlyPrincipal).sub(totalPayment).toDP(2).toNumber();
836
+ }
837
+ else {
838
+ principal = calculatedTermLoan.monthlyPrincipal;
839
+ principalExpectedDate = calculatedTermLoan.paymentDueDate;
840
+ }
839
841
  }
840
842
  }
841
843
  }
@@ -920,19 +920,21 @@ export class LoanStatementService {
920
920
 
921
921
  let principal = 0;
922
922
  let principalExpectedDate = null;
923
- const termLoan = await TermLoanModel.findOne({ productId: product._id.toString(), actual: true });
924
- if (termLoan) {
925
- const calculatedTermLoan = await TermLoanCalculatedModel.findOne({
926
- termLoanId: termLoan._id.toString(),
927
- relevantStatement: relevantStatementEndMonth.format('YYYY-MM-DD'),
928
- });
929
- if (calculatedTermLoan) {
930
- if (calculatedTermLoan.payments && calculatedTermLoan.payments.length > 0) {
931
- const totalPayment = calculatedTermLoan.payments.reduce((acc, p) => new Decimal(acc ?? 0).add(p.amount ?? 0).toNumber(), 0);
932
- principal = new Decimal(calculatedTermLoan.monthlyPrincipal).sub(totalPayment).toDP(2).toNumber();
933
- } else {
934
- principal = calculatedTermLoan.monthlyPrincipal;
935
- principalExpectedDate = calculatedTermLoan.paymentDueDate;
923
+ if (product.type === ELoanTypes.TERM) {
924
+ const termLoan = await TermLoanModel.findOne({ productId: product._id.toString(), actual: true });
925
+ if (termLoan) {
926
+ const calculatedTermLoan = await TermLoanCalculatedModel.findOne({
927
+ termLoanId: termLoan._id.toString(),
928
+ relevantStatement: relevantStatementEndMonth.format('YYYY-MM-DD'),
929
+ });
930
+ if (calculatedTermLoan) {
931
+ if (calculatedTermLoan.payments && calculatedTermLoan.payments.length > 0) {
932
+ const totalPayment = calculatedTermLoan.payments.reduce((acc, p) => new Decimal(acc ?? 0).add(p.amount ?? 0).toNumber(), 0);
933
+ principal = new Decimal(calculatedTermLoan.monthlyPrincipal).sub(totalPayment).toDP(2).toNumber();
934
+ } else {
935
+ principal = calculatedTermLoan.monthlyPrincipal;
936
+ principalExpectedDate = calculatedTermLoan.paymentDueDate;
937
+ }
936
938
  }
937
939
  }
938
940
  }
@@ -325,6 +325,9 @@ class ReportsService {
325
325
  if (product.isParticipant) {
326
326
  return null;
327
327
  }
328
+ if ((0, dayjs_1.default)(product.deactivationDate).isBefore((0, dayjs_1.default)(date))) {
329
+ return null;
330
+ }
328
331
  const isRevolver = product.type === loan_types_enum_1.ELoanTypes.REVOLVER;
329
332
  const productMainData = {
330
333
  borrowerId,
@@ -428,6 +428,9 @@ export class ReportsService {
428
428
  if (product.isParticipant) {
429
429
  return null as IBankReportData;
430
430
  }
431
+ if (dayjs(product.deactivationDate).isBefore(dayjs(date))) {
432
+ return null as IBankReportData;
433
+ }
431
434
  const isRevolver = product.type === ELoanTypes.REVOLVER;
432
435
  const productMainData: Partial<IBankReportData> = {
433
436
  borrowerId,