gemcap-be-common 1.5.129 → 1.5.131

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.
@@ -3,7 +3,7 @@ import dayjs from 'dayjs';
3
3
  import Decimal from 'decimal.js';
4
4
  import _ from 'lodash';
5
5
 
6
- import { IProductBrokerDocWithBroker } from '../models/ProductBroker.model';
6
+ import { IProductBrokerDocWithLoanBroker } from '../models/ProductBroker.model';
7
7
  import { ELoanChargeType } from '../enums/loan-charge-type.enum';
8
8
  import { ELoanTypes } from '../enums/loan-types.enum';
9
9
  import { LoanProduct } from '../models/LoanProducts.model';
@@ -302,15 +302,15 @@ export class QuickbooksService {
302
302
  }
303
303
  const transactionsFilter = {
304
304
  productIds: productIds,
305
- start: dayjs(reportDate).utcOffset(0).startOf('month').toDate(),
306
- end: dayjs(reportDate).utcOffset(0).endOf('month').toDate(),
305
+ start: dayjs.utc(reportDate).startOf('month').toDate(),
306
+ end: dayjs.utc(reportDate).endOf('month').toDate(),
307
307
  };
308
308
  return await this.loanChargesService.getLoanStatementsForProduct(transactionsFilter);
309
309
  }
310
310
 
311
311
  async getChargeTransactionsForPayments(productIds: string[], reportDate: Date) {
312
- const start = dayjs(reportDate).utcOffset(0).startOf('day').toDate();
313
- const end = dayjs(reportDate).utcOffset(0).endOf('day').toDate();
312
+ const start = dayjs.utc(reportDate).startOf('day').toDate();
313
+ const end = dayjs.utc(reportDate).endOf('day').toDate();
314
314
  const payments = await this.loanPaymentsService.getPaymentsForPeriod(productIds, start, end);
315
315
  if (!payments.length) {
316
316
  return [];
@@ -321,8 +321,8 @@ export class QuickbooksService {
321
321
  }
322
322
 
323
323
  async getPrincipalTransactionsForPayments(productId: string, reportDate: Date) {
324
- const start = dayjs(reportDate).utcOffset(0).startOf('day').toDate();
325
- const end = dayjs(reportDate).utcOffset(0).endOf('day').toDate();
324
+ const start = dayjs.utc(reportDate).startOf('day').toDate();
325
+ const end = dayjs.utc(reportDate).endOf('day').toDate();
326
326
  const payments = await this.loanPaymentsService.getPaymentsForPeriod([productId], start, end);
327
327
  if (!payments.length) {
328
328
  return <{ [settlementCode: string]: number }>{};
@@ -362,9 +362,9 @@ export class QuickbooksService {
362
362
  const companyFilter = { companyId: { $in: params.companyIds.map((id) => new mongoose.Types.ObjectId(id)) } };
363
363
 
364
364
  const { reportType, productIds, chargeTypes, reportDate } = params;
365
- const reportDateFormatted = dayjs(reportDate).utcOffset(0).format('MM/DD/YYYY').toUpperCase();
366
- const reportDateTrFormatted = dayjs(reportDate).utcOffset(0).format(transactionsDateFormat).toUpperCase();
367
- const currentDateTrFormatted = dayjs(new Date).utcOffset(0).format(transactionsDateFormat).toUpperCase();
365
+ const reportDateFormatted = dayjs.utc(reportDate).format('MM/DD/YYYY').toUpperCase();
366
+ const reportDateTrFormatted = dayjs.utc(reportDate).format(transactionsDateFormat).toUpperCase();
367
+ const currentDateTrFormatted = dayjs.utc(new Date).format(transactionsDateFormat).toUpperCase();
368
368
  const isAccrual = reportType === 'accrual';
369
369
  const mainData: IQBReportTransaction[] = [];
370
370
 
@@ -446,7 +446,7 @@ export class QuickbooksService {
446
446
 
447
447
  if (chargeTypes.includes('BROKERS') && isAccrual) {
448
448
 
449
- const handleFee = async (broker: IProductBrokerDocWithBroker, shareName: 'adminShare' | 'interestShare' | 'otherShare') => {
449
+ const handleFee = async (broker: IProductBrokerDocWithLoanBroker, shareName: 'adminShare' | 'interestShare' | 'otherShare') => {
450
450
 
451
451
  const quickbooksAccountBrokerBS = await QuickbooksAccount.findOne({ accountCode: broker.BSCode, ...companyFilter }).lean();
452
452
  const quickbooksAccountBrokerPL = await QuickbooksAccount.findOne({ accountCode: broker.PLCode, ...companyFilter }).lean();
@@ -477,9 +477,9 @@ export class QuickbooksService {
477
477
  };
478
478
 
479
479
  const handlers = {
480
- [ELoanChargeType.ADMIN_FEE]: async (broker: IProductBrokerDocWithBroker) => await handleFee(broker, 'adminShare'),
481
- [ELoanChargeType.INTEREST_FEE]: async (broker: IProductBrokerDocWithBroker) => await handleFee(broker, 'interestShare'),
482
- [ELoanChargeType.OTHER]: async (broker: IProductBrokerDocWithBroker) => await handleFee(broker, 'otherShare'),
480
+ [ELoanChargeType.ADMIN_FEE]: async (broker: IProductBrokerDocWithLoanBroker) => await handleFee(broker, 'adminShare'),
481
+ [ELoanChargeType.INTEREST_FEE]: async (broker: IProductBrokerDocWithLoanBroker) => await handleFee(broker, 'interestShare'),
482
+ [ELoanChargeType.OTHER]: async (broker: IProductBrokerDocWithLoanBroker) => await handleFee(broker, 'otherShare'),
483
483
  };
484
484
  await Promise.all(productBrokers.map(async (broker) => {
485
485
  if (handlers[charge.chargeType]) {
@@ -569,11 +569,11 @@ export class QuickbooksService {
569
569
  }) {
570
570
  const reportErrorsSet = new Set<string>();
571
571
  const { reportType, productIds, chargeTypes, reportDate } = params;
572
- const reportDateFormatted = dayjs(reportDate).utcOffset(0).format('MM/DD/YYYY').toUpperCase();
573
- const reportDateTrFormatted = dayjs(reportDate).utcOffset(0).format(transactionsDateFormat).toUpperCase();
572
+ const reportDateFormatted = dayjs.utc(reportDate).format('MM/DD/YYYY').toUpperCase();
573
+ const reportDateTrFormatted = dayjs.utc(reportDate).format(transactionsDateFormat).toUpperCase();
574
574
 
575
- const startDate = dayjs(reportDate).utcOffset(0).startOf('day').toDate();
576
- const endDate = dayjs(reportDate).utcOffset(0).endOf('day').toDate();
575
+ const startDate = dayjs.utc(reportDate).startOf('day').toDate();
576
+ const endDate = dayjs.utc(reportDate).endOf('day').toDate();
577
577
  const transactions = await this.bankUploadedTransactionsService.getUploadedBankTransactions(startDate, endDate);
578
578
  const { references, products } = await this.cashAllocationService.getAllCashAllocations();
579
579
  const allAccounts = await this.getAllAccounts();