gemcap-be-common 1.5.19 → 1.5.20

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.19",
3
+ "version": "1.5.20",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -79,7 +79,7 @@ export declare class LoanPaymentsService {
79
79
  success: boolean;
80
80
  message: string;
81
81
  }>;
82
- getExpectedPayments(userId: string, forDate: Date): Promise<any[] | {
82
+ getExpectedPayments(userId: string): Promise<any[] | {
83
83
  borrowers: {
84
84
  borrowerId: string;
85
85
  borrowerTitle: string;
@@ -400,7 +400,7 @@ class LoanPaymentsService {
400
400
  console.error(e);
401
401
  }
402
402
  }
403
- async getExpectedPayments(userId, forDate) {
403
+ async getExpectedPayments(userId) {
404
404
  const user = await this.usersService.getUserById(userId);
405
405
  if (!user) {
406
406
  return [];
@@ -411,7 +411,7 @@ class LoanPaymentsService {
411
411
  .filter((borrower) => borrower.active)
412
412
  .map(async (borrower) => {
413
413
  const loanStatementService = this.getLoanStatementService();
414
- const dueAmounts = await loanStatementService.getBorrowerProductTotals(borrower._id.toString(), forDate);
414
+ const dueAmounts = await loanStatementService.getBorrowerProductTotals(borrower._id.toString());
415
415
  return {
416
416
  borrowerId: borrower._id.toString(),
417
417
  borrowerTitle: borrower.name,
@@ -442,7 +442,7 @@ class LoanPaymentsService {
442
442
  const borrowerProducts = await this.loanChargesService.getLoanProducts(borrower._id.toString());
443
443
  const revolverProduct = borrowerProducts.find((product) => product.type === loan_types_enum_1.ELoanTypes.REVOLVER && (0, date_helper_1.isProductActive)(product.startDate, product.deactivationDate, selectedDate));
444
444
  const loanStatementService = this.getLoanStatementService();
445
- const dueAmounts = await loanStatementService.getBorrowerProductTotals(borrower._id.toString(), selectedDate);
445
+ const dueAmounts = await loanStatementService.getBorrowerProductTotals(borrower._id.toString());
446
446
  if (dueAmounts.total === 0) {
447
447
  console.log('no payment for this borrower');
448
448
  return;
@@ -447,7 +447,7 @@ export class LoanPaymentsService {
447
447
  }
448
448
  }
449
449
 
450
- async getExpectedPayments(userId: string, forDate: Date) {
450
+ async getExpectedPayments(userId: string) {
451
451
  const user = await this.usersService.getUserById(userId);
452
452
  if (!user) {
453
453
  return [];
@@ -458,7 +458,7 @@ export class LoanPaymentsService {
458
458
  .filter((borrower) => borrower.active)
459
459
  .map(async (borrower) => {
460
460
  const loanStatementService = this.getLoanStatementService();
461
- const dueAmounts = await loanStatementService.getBorrowerProductTotals(borrower._id.toString(), forDate);
461
+ const dueAmounts = await loanStatementService.getBorrowerProductTotals(borrower._id.toString());
462
462
  return {
463
463
  borrowerId: borrower._id.toString(),
464
464
  borrowerTitle: borrower.name,
@@ -493,7 +493,7 @@ export class LoanPaymentsService {
493
493
  const borrowerProducts = await this.loanChargesService.getLoanProducts(borrower._id.toString());
494
494
  const revolverProduct = borrowerProducts.find((product) => product.type === ELoanTypes.REVOLVER && isProductActive(product.startDate, product.deactivationDate, selectedDate));
495
495
  const loanStatementService = this.getLoanStatementService();
496
- const dueAmounts = await loanStatementService.getBorrowerProductTotals(borrower._id.toString(), selectedDate);
496
+ const dueAmounts = await loanStatementService.getBorrowerProductTotals(borrower._id.toString());
497
497
  if (dueAmounts.total === 0) {
498
498
  console.log('no payment for this borrower');
499
499
  return;
@@ -173,7 +173,7 @@ export declare class LoanStatementService {
173
173
  }>;
174
174
  private getOutstandingStatements;
175
175
  getOutstandingStatementsExcel(borrowerIds: string[], selectedDate: Date, fullMonth: boolean): Promise<any>;
176
- getBorrowerProductTotals(borrowerId: string, forDate: Date): Promise<{
176
+ getBorrowerProductTotals(borrowerId: string): Promise<{
177
177
  productTotals: {
178
178
  [productId: string]: number;
179
179
  };
@@ -723,7 +723,7 @@ class LoanStatementService {
723
723
  return (0, loan_statement_db_1.getStatementBorrowersTransactions)(start, end, selectedPeriod, selectedBorrowerIds, ledgerType);
724
724
  }
725
725
  async getBorrowerComplianceData(borrowerId, date) {
726
- const end = (0, dayjs_1.default)(date).utcOffset(0).subtract(1, 'month').endOf('month');
726
+ const end = dayjs_1.default.utc(date).subtract(1, 'month').endOf('month');
727
727
  const start = end.startOf('month');
728
728
  const products = await this.loanChargesService.getLoanProducts(borrowerId);
729
729
  const data = {
@@ -889,8 +889,8 @@ class LoanStatementService {
889
889
  });
890
890
  return await this.uploadsService.convertDataToFile([{ data: [...header, ...onlyData] }]);
891
891
  }
892
- async getBorrowerProductTotals(borrowerId, forDate) {
893
- return await this.getBorrowerComplianceData(borrowerId, forDate);
892
+ async getBorrowerProductTotals(borrowerId) {
893
+ return await this.getBorrowerComplianceData(borrowerId, new Date());
894
894
  }
895
895
  async getProductsTotals(productIds) {
896
896
  const totals = {};
@@ -817,7 +817,7 @@ export class LoanStatementService {
817
817
  }
818
818
 
819
819
  async getBorrowerComplianceData(borrowerId: string, date: Date) {
820
- const end = dayjs(date).utcOffset(0).subtract(1, 'month').endOf('month');
820
+ const end = dayjs.utc(date).subtract(1, 'month').endOf('month');
821
821
  const start = end.startOf('month');
822
822
  const products = await this.loanChargesService.getLoanProducts(borrowerId);
823
823
  const data = {
@@ -992,8 +992,8 @@ export class LoanStatementService {
992
992
  return await this.uploadsService.convertDataToFile([{ data: [...header, ...onlyData] }]);
993
993
  }
994
994
 
995
- async getBorrowerProductTotals(borrowerId: string, forDate: Date) {
996
- return await this.getBorrowerComplianceData(borrowerId, forDate);
995
+ async getBorrowerProductTotals(borrowerId: string) {
996
+ return await this.getBorrowerComplianceData(borrowerId, new Date());
997
997
  }
998
998
 
999
999
  async getProductsTotals(productIds: string[]) {