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.
- package/db/brokers.db.d.ts +10 -166
- package/db/brokers.db.js +5 -5
- package/db/brokers.db.ts +15 -15
- package/models/LoanBroker.model.d.ts +23 -49
- package/models/LoanBroker.model.js +17 -4
- package/models/LoanBroker.model.ts +40 -10
- package/models/ProductBroker.model.d.ts +19 -19
- package/models/ProductBroker.model.js +9 -3
- package/models/ProductBroker.model.ts +13 -10
- package/package.json +1 -1
- package/services/borrowers.service.d.ts +2 -2
- package/services/brokers.service.d.ts +12 -166
- package/services/brokers.service.js +12 -18
- package/services/brokers.service.ts +23 -25
- package/services/compliance-borrowers.service.d.ts +1 -1
- package/services/quickbooks.service.js +13 -13
- package/services/quickbooks.service.ts +18 -18
- package/tsconfig.tsbuildinfo +1 -1
|
@@ -3,7 +3,7 @@ import dayjs from 'dayjs';
|
|
|
3
3
|
import Decimal from 'decimal.js';
|
|
4
4
|
import _ from 'lodash';
|
|
5
5
|
|
|
6
|
-
import {
|
|
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).
|
|
306
|
-
end: dayjs(reportDate).
|
|
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).
|
|
313
|
-
const end = dayjs(reportDate).
|
|
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).
|
|
325
|
-
const end = dayjs(reportDate).
|
|
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).
|
|
366
|
-
const reportDateTrFormatted = dayjs(reportDate).
|
|
367
|
-
const currentDateTrFormatted = dayjs(new Date).
|
|
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:
|
|
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:
|
|
481
|
-
[ELoanChargeType.INTEREST_FEE]: async (broker:
|
|
482
|
-
[ELoanChargeType.OTHER]: async (broker:
|
|
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).
|
|
573
|
-
const reportDateTrFormatted = dayjs(reportDate).
|
|
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).
|
|
576
|
-
const endDate = dayjs(reportDate).
|
|
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();
|