gemcap-be-common 1.4.128 → 1.4.130
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
|
@@ -15,6 +15,7 @@ const Borrower_model_1 = require("../models/Borrower.model");
|
|
|
15
15
|
const TermLoan_model_1 = require("../models/TermLoan.model");
|
|
16
16
|
const reports_db_1 = require("../db/reports.db");
|
|
17
17
|
const QuickbooksAccount_model_1 = require("../models/QuickbooksAccount.model");
|
|
18
|
+
const Company_model_1 = require("../models/Company.model");
|
|
18
19
|
const headersIIF = [
|
|
19
20
|
{
|
|
20
21
|
service: '!TRNS',
|
|
@@ -300,6 +301,10 @@ class QuickbooksService {
|
|
|
300
301
|
if (reportErrorsSet.size > 0) {
|
|
301
302
|
return { reportData: [], reportErrors: Array.from(reportErrorsSet) };
|
|
302
303
|
}
|
|
304
|
+
const assetCompany = await Company_model_1.Company.findOne({ name: 'AssetCo' }).lean();
|
|
305
|
+
if (!assetCompany) {
|
|
306
|
+
return { reportData: [], reportErrors: ['AssetCo company not found'] };
|
|
307
|
+
}
|
|
303
308
|
const { reportType, productIds, chargeTypes, reportDate } = params;
|
|
304
309
|
const reportDateFormatted = (0, dayjs_1.default)(reportDate).utcOffset(0).format('MM/DD/YYYY').toUpperCase();
|
|
305
310
|
const reportDateTrFormatted = (0, dayjs_1.default)(reportDate).utcOffset(0).format(transactionsDateFormat).toUpperCase();
|
|
@@ -351,8 +356,8 @@ class QuickbooksService {
|
|
|
351
356
|
}
|
|
352
357
|
let totalAmount = product.isParticipant ? -totalAmountValue : totalAmountValue;
|
|
353
358
|
totalAmount = isAccrual ? totalAmount : -totalAmount;
|
|
354
|
-
const quickbooksAccountBS = await QuickbooksAccount_model_1.QuickbooksAccount.findOne({ accountCode: charge.code }).lean();
|
|
355
|
-
const quickbooksAccountPL = await QuickbooksAccount_model_1.QuickbooksAccount.findOne({ accountCode: PLCode }).lean();
|
|
359
|
+
const quickbooksAccountBS = await QuickbooksAccount_model_1.QuickbooksAccount.findOne({ accountCode: charge.code, companyId: assetCompany._id.toString() }).lean();
|
|
360
|
+
const quickbooksAccountPL = await QuickbooksAccount_model_1.QuickbooksAccount.findOne({ accountCode: PLCode, companyId: assetCompany._id.toString() }).lean();
|
|
356
361
|
if (!quickbooksAccountBS || !quickbooksAccountPL) {
|
|
357
362
|
if (!quickbooksAccountBS) {
|
|
358
363
|
reportErrorsSet.add(charge.code);
|
|
@@ -376,8 +381,8 @@ class QuickbooksService {
|
|
|
376
381
|
mainData.push({ ...tr });
|
|
377
382
|
if (chargeTypes.includes('BROKERS') && isAccrual) {
|
|
378
383
|
const handleFee = async (broker, shareName) => {
|
|
379
|
-
const quickbooksAccountBrokerBS = await QuickbooksAccount_model_1.QuickbooksAccount.findOne({ accountCode: broker.BSCode }).lean();
|
|
380
|
-
const quickbooksAccountBrokerPL = await QuickbooksAccount_model_1.QuickbooksAccount.findOne({ accountCode: broker.PLCode }).lean();
|
|
384
|
+
const quickbooksAccountBrokerBS = await QuickbooksAccount_model_1.QuickbooksAccount.findOne({ accountCode: broker.BSCode, companyId: assetCompany._id.toString() }).lean();
|
|
385
|
+
const quickbooksAccountBrokerPL = await QuickbooksAccount_model_1.QuickbooksAccount.findOne({ accountCode: broker.PLCode, companyId: assetCompany._id.toString() }).lean();
|
|
381
386
|
if (!quickbooksAccountBrokerBS || !quickbooksAccountBrokerPL) {
|
|
382
387
|
if (!quickbooksAccountBrokerBS) {
|
|
383
388
|
reportErrorsSet.add(broker.BSCode);
|
|
@@ -431,8 +436,8 @@ class QuickbooksService {
|
|
|
431
436
|
settlementCode = revolverProduct.code;
|
|
432
437
|
}
|
|
433
438
|
}
|
|
434
|
-
const quickbooksAccountPaymentBS = await QuickbooksAccount_model_1.QuickbooksAccount.findOne({ accountCode: product.code }).lean();
|
|
435
|
-
const quickbooksAccountPaymentPL = await QuickbooksAccount_model_1.QuickbooksAccount.findOne({ accountCode: settlementCode }).lean();
|
|
439
|
+
const quickbooksAccountPaymentBS = await QuickbooksAccount_model_1.QuickbooksAccount.findOne({ accountCode: product.code, companyId: assetCompany._id.toString() }).lean();
|
|
440
|
+
const quickbooksAccountPaymentPL = await QuickbooksAccount_model_1.QuickbooksAccount.findOne({ accountCode: settlementCode, companyId: assetCompany._id.toString() }).lean();
|
|
436
441
|
if (!quickbooksAccountPaymentBS || !quickbooksAccountPaymentPL) {
|
|
437
442
|
if (!quickbooksAccountPaymentBS) {
|
|
438
443
|
reportErrorsSet.add(product.code);
|
|
@@ -23,6 +23,7 @@ import { CashAllocationService } from './cash-allocation.service';
|
|
|
23
23
|
import { CompaniesService } from './companies.service';
|
|
24
24
|
import { LoanChargesService } from './loan-charges.service';
|
|
25
25
|
import { LoanPaymentsService } from './loan-payments.service';
|
|
26
|
+
import { Company } from '../models/Company.model';
|
|
26
27
|
|
|
27
28
|
export type QuickBookReportType = 'accrual' | 'payment' | 'cash';
|
|
28
29
|
|
|
@@ -355,6 +356,11 @@ export class QuickbooksService {
|
|
|
355
356
|
return { reportData: [], reportErrors: Array.from(reportErrorsSet) };
|
|
356
357
|
}
|
|
357
358
|
|
|
359
|
+
const assetCompany = await Company.findOne({ name: 'AssetCo' }).lean();
|
|
360
|
+
if (!assetCompany) {
|
|
361
|
+
return { reportData: [], reportErrors: ['AssetCo company not found'] };
|
|
362
|
+
}
|
|
363
|
+
|
|
358
364
|
const { reportType, productIds, chargeTypes, reportDate } = params;
|
|
359
365
|
const reportDateFormatted = dayjs(reportDate).utcOffset(0).format('MM/DD/YYYY').toUpperCase();
|
|
360
366
|
const reportDateTrFormatted = dayjs(reportDate).utcOffset(0).format(transactionsDateFormat).toUpperCase();
|
|
@@ -412,8 +418,8 @@ export class QuickbooksService {
|
|
|
412
418
|
}
|
|
413
419
|
let totalAmount = product.isParticipant ? -totalAmountValue : totalAmountValue;
|
|
414
420
|
totalAmount = isAccrual ? totalAmount : -totalAmount;
|
|
415
|
-
const quickbooksAccountBS = await QuickbooksAccount.findOne({ accountCode: charge.code }).lean();
|
|
416
|
-
const quickbooksAccountPL = await QuickbooksAccount.findOne({ accountCode: PLCode }).lean();
|
|
421
|
+
const quickbooksAccountBS = await QuickbooksAccount.findOne({ accountCode: charge.code, companyId: assetCompany._id.toString() }).lean();
|
|
422
|
+
const quickbooksAccountPL = await QuickbooksAccount.findOne({ accountCode: PLCode, companyId: assetCompany._id.toString() }).lean();
|
|
417
423
|
if (!quickbooksAccountBS || !quickbooksAccountPL) {
|
|
418
424
|
if (!quickbooksAccountBS) {
|
|
419
425
|
reportErrorsSet.add(charge.code);
|
|
@@ -442,8 +448,8 @@ export class QuickbooksService {
|
|
|
442
448
|
|
|
443
449
|
const handleFee = async (broker: IProductBrokerDocWithBroker, shareName: 'adminShare' | 'interestShare' | 'otherShare') => {
|
|
444
450
|
|
|
445
|
-
const quickbooksAccountBrokerBS = await QuickbooksAccount.findOne({ accountCode: broker.BSCode }).lean();
|
|
446
|
-
const quickbooksAccountBrokerPL = await QuickbooksAccount.findOne({ accountCode: broker.PLCode }).lean();
|
|
451
|
+
const quickbooksAccountBrokerBS = await QuickbooksAccount.findOne({ accountCode: broker.BSCode, companyId: assetCompany._id.toString() }).lean();
|
|
452
|
+
const quickbooksAccountBrokerPL = await QuickbooksAccount.findOne({ accountCode: broker.PLCode, companyId: assetCompany._id.toString() }).lean();
|
|
447
453
|
if (!quickbooksAccountBrokerBS || !quickbooksAccountBrokerPL) {
|
|
448
454
|
if (!quickbooksAccountBrokerBS) {
|
|
449
455
|
reportErrorsSet.add(broker.BSCode);
|
|
@@ -506,8 +512,8 @@ export class QuickbooksService {
|
|
|
506
512
|
}
|
|
507
513
|
}
|
|
508
514
|
|
|
509
|
-
const quickbooksAccountPaymentBS = await QuickbooksAccount.findOne({ accountCode: product.code }).lean();
|
|
510
|
-
const quickbooksAccountPaymentPL = await QuickbooksAccount.findOne({ accountCode: settlementCode }).lean();
|
|
515
|
+
const quickbooksAccountPaymentBS = await QuickbooksAccount.findOne({ accountCode: product.code, companyId: assetCompany._id.toString() }).lean();
|
|
516
|
+
const quickbooksAccountPaymentPL = await QuickbooksAccount.findOne({ accountCode: settlementCode, companyId: assetCompany._id.toString() }).lean();
|
|
511
517
|
if (!quickbooksAccountPaymentBS || !quickbooksAccountPaymentPL) {
|
|
512
518
|
if (!quickbooksAccountPaymentBS) {
|
|
513
519
|
reportErrorsSet.add(product.code);
|