gemcap-be-common 1.4.131 → 1.4.133

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.
@@ -32,6 +32,9 @@ export interface IBank {
32
32
  ledgerAccountCodes: {
33
33
  [companyId: string]: mongoose.Types.ObjectId;
34
34
  };
35
+ reportSettings?: {
36
+ consolidatedAllAccounts?: boolean;
37
+ };
35
38
  }
36
39
  export interface IBankWithId extends IBank {
37
40
  _id: mongoose.Types.ObjectId;
@@ -36,5 +36,11 @@ exports.BankSchema = new mongoose_1.default.Schema({
36
36
  of: { type: mongoose_1.default.Schema.Types.ObjectId, ref: _models_1.MODEL_NAMES.quickbooksAccounts },
37
37
  default: {},
38
38
  },
39
+ reportSettings: {
40
+ consolidatedAllAccounts: {
41
+ type: Boolean,
42
+ default: false,
43
+ },
44
+ },
39
45
  }, { timestamps: true });
40
46
  exports.Bank = mongoose_1.default.model(_models_1.MODEL_NAMES.banks, exports.BankSchema);
@@ -11,6 +11,9 @@ export interface IBank {
11
11
  ledgerAccountCodes: {
12
12
  [companyId: string]: mongoose.Types.ObjectId;
13
13
  };
14
+ reportSettings?: {
15
+ consolidatedAllAccounts?: boolean;
16
+ };
14
17
  }
15
18
 
16
19
  export interface IBankWithId extends IBank {
@@ -73,6 +76,12 @@ export const BankSchema = new mongoose.Schema<IBank, IBankModel>(
73
76
  of: { type: mongoose.Schema.Types.ObjectId, ref: MODEL_NAMES.quickbooksAccounts },
74
77
  default: {},
75
78
  },
79
+ reportSettings: {
80
+ consolidatedAllAccounts: {
81
+ type: Boolean,
82
+ default: false,
83
+ },
84
+ },
76
85
  },
77
86
  { timestamps: true },
78
87
  );
@@ -31,8 +31,8 @@ export declare const allSchemas: {
31
31
  createdAt: NativeDate;
32
32
  updatedAt: NativeDate;
33
33
  } & {
34
- bbcSheetId: import("mongoose").Types.ObjectId;
35
34
  order: number;
35
+ bbcSheetId: import("mongoose").Types.ObjectId;
36
36
  apDate: Date;
37
37
  amount: number;
38
38
  __v?: number;
@@ -45,8 +45,8 @@ export declare const allSchemas: {
45
45
  createdAt: NativeDate;
46
46
  updatedAt: NativeDate;
47
47
  } & {
48
- bbcSheetId: import("mongoose").Types.ObjectId;
49
48
  order: number;
49
+ bbcSheetId: import("mongoose").Types.ObjectId;
50
50
  apDate: Date;
51
51
  amount: number;
52
52
  __v?: number;
@@ -59,8 +59,8 @@ export declare const allSchemas: {
59
59
  createdAt: NativeDate;
60
60
  updatedAt: NativeDate;
61
61
  } & {
62
- bbcSheetId: import("mongoose").Types.ObjectId;
63
62
  order: number;
63
+ bbcSheetId: import("mongoose").Types.ObjectId;
64
64
  apDate: Date;
65
65
  amount: number;
66
66
  __v?: number;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gemcap-be-common",
3
- "version": "1.4.131",
3
+ "version": "1.4.133",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -84,10 +84,10 @@ export declare class BorrowerService {
84
84
  getBorrowerCodesMap(): Promise<Map<string, string>>;
85
85
  getBorrowerStatementDetails(borrowers: IBorrowerDoc[]): Promise<{
86
86
  [x: string]: {
87
- LAST_MONTH?: boolean;
88
- CURRENT_MONTH?: boolean;
89
87
  ENTIRE_LOAN?: boolean;
90
88
  SELECTED_PERIOD?: boolean;
89
+ CURRENT_MONTH?: boolean;
90
+ LAST_MONTH?: boolean;
91
91
  TERM_LOAN?: boolean;
92
92
  };
93
93
  }>;
@@ -78,6 +78,7 @@ export declare class QuickbooksService {
78
78
  chargeTypes: string[];
79
79
  reportDate: Date;
80
80
  format: 'IIF' | 'CSV';
81
+ companyIds: string[];
81
82
  }): Promise<{
82
83
  reportData: IQBReportTransaction[];
83
84
  reportErrors: string[];
@@ -15,7 +15,6 @@ 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");
19
18
  const headersIIF = [
20
19
  {
21
20
  service: '!TRNS',
@@ -298,10 +297,7 @@ class QuickbooksService {
298
297
  if (reportErrorsSet.size > 0) {
299
298
  return { reportData: [], reportErrors: Array.from(reportErrorsSet) };
300
299
  }
301
- const assetCompany = await Company_model_1.Company.findOne({ name: 'AssetCo' }).lean();
302
- if (!assetCompany) {
303
- return { reportData: [], reportErrors: ['AssetCo company not found'] };
304
- }
300
+ const companyFilter = { companyId: { $in: params.companyIds.map((id) => new mongoose_1.default.Types.ObjectId(id)) } };
305
301
  const { reportType, productIds, chargeTypes, reportDate } = params;
306
302
  const reportDateFormatted = (0, dayjs_1.default)(reportDate).utcOffset(0).format('MM/DD/YYYY').toUpperCase();
307
303
  const reportDateTrFormatted = (0, dayjs_1.default)(reportDate).utcOffset(0).format(transactionsDateFormat).toUpperCase();
@@ -353,8 +349,8 @@ class QuickbooksService {
353
349
  }
354
350
  let totalAmount = product.isParticipant ? -totalAmountValue : totalAmountValue;
355
351
  totalAmount = isAccrual ? totalAmount : -totalAmount;
356
- const quickbooksAccountBS = await QuickbooksAccount_model_1.QuickbooksAccount.findOne({ accountCode: charge.code, companyId: assetCompany._id.toString() }).lean();
357
- const quickbooksAccountPL = await QuickbooksAccount_model_1.QuickbooksAccount.findOne({ accountCode: PLCode, companyId: assetCompany._id.toString() }).lean();
352
+ const quickbooksAccountBS = await QuickbooksAccount_model_1.QuickbooksAccount.findOne({ accountCode: charge.code, ...companyFilter }).lean();
353
+ const quickbooksAccountPL = await QuickbooksAccount_model_1.QuickbooksAccount.findOne({ accountCode: PLCode, ...companyFilter }).lean();
358
354
  if (!quickbooksAccountBS || !quickbooksAccountPL) {
359
355
  if (!quickbooksAccountBS) {
360
356
  reportErrorsSet.add(charge.code);
@@ -378,8 +374,8 @@ class QuickbooksService {
378
374
  mainData.push({ ...tr });
379
375
  if (chargeTypes.includes('BROKERS') && isAccrual) {
380
376
  const handleFee = async (broker, shareName) => {
381
- const quickbooksAccountBrokerBS = await QuickbooksAccount_model_1.QuickbooksAccount.findOne({ accountCode: broker.BSCode, companyId: assetCompany._id.toString() }).lean();
382
- const quickbooksAccountBrokerPL = await QuickbooksAccount_model_1.QuickbooksAccount.findOne({ accountCode: broker.PLCode, companyId: assetCompany._id.toString() }).lean();
377
+ const quickbooksAccountBrokerBS = await QuickbooksAccount_model_1.QuickbooksAccount.findOne({ accountCode: broker.BSCode, ...companyFilter }).lean();
378
+ const quickbooksAccountBrokerPL = await QuickbooksAccount_model_1.QuickbooksAccount.findOne({ accountCode: broker.PLCode, ...companyFilter }).lean();
383
379
  if (!quickbooksAccountBrokerBS || !quickbooksAccountBrokerPL) {
384
380
  if (!quickbooksAccountBrokerBS) {
385
381
  reportErrorsSet.add(broker.BSCode);
@@ -433,8 +429,8 @@ class QuickbooksService {
433
429
  settlementCode = revolverProduct.code;
434
430
  }
435
431
  }
436
- const quickbooksAccountPaymentBS = await QuickbooksAccount_model_1.QuickbooksAccount.findOne({ accountCode: product.code, companyId: assetCompany._id.toString() }).lean();
437
- const quickbooksAccountPaymentPL = await QuickbooksAccount_model_1.QuickbooksAccount.findOne({ accountCode: settlementCode, companyId: assetCompany._id.toString() }).lean();
432
+ const quickbooksAccountPaymentBS = await QuickbooksAccount_model_1.QuickbooksAccount.findOne({ accountCode: product.code, ...companyFilter }).lean();
433
+ const quickbooksAccountPaymentPL = await QuickbooksAccount_model_1.QuickbooksAccount.findOne({ accountCode: settlementCode, ...companyFilter }).lean();
438
434
  if (!quickbooksAccountPaymentBS || !quickbooksAccountPaymentPL) {
439
435
  if (!quickbooksAccountPaymentBS) {
440
436
  reportErrorsSet.add(product.code);
@@ -22,7 +22,6 @@ import { CashAllocationService } from './cash-allocation.service';
22
22
  import { CompaniesService } from './companies.service';
23
23
  import { LoanChargesService } from './loan-charges.service';
24
24
  import { LoanPaymentsService } from './loan-payments.service';
25
- import { Company } from '../models/Company.model';
26
25
 
27
26
  export type QuickBookReportType = 'accrual' | 'payment' | 'cash';
28
27
 
@@ -337,6 +336,7 @@ export class QuickbooksService {
337
336
  chargeTypes: string[],
338
337
  reportDate: Date,
339
338
  format: 'IIF' | 'CSV',
339
+ companyIds: string[],
340
340
  }) {
341
341
  const reportErrorsSet = new Set<string>();
342
342
  await Promise.all(params.productIds.map(async (productId) => {
@@ -352,10 +352,7 @@ export class QuickbooksService {
352
352
  return { reportData: [], reportErrors: Array.from(reportErrorsSet) };
353
353
  }
354
354
 
355
- const assetCompany = await Company.findOne({ name: 'AssetCo' }).lean();
356
- if (!assetCompany) {
357
- return { reportData: [], reportErrors: ['AssetCo company not found'] };
358
- }
355
+ const companyFilter = { companyId: { $in: params.companyIds.map((id) => new mongoose.Types.ObjectId(id)) } }
359
356
 
360
357
  const { reportType, productIds, chargeTypes, reportDate } = params;
361
358
  const reportDateFormatted = dayjs(reportDate).utcOffset(0).format('MM/DD/YYYY').toUpperCase();
@@ -414,8 +411,8 @@ export class QuickbooksService {
414
411
  }
415
412
  let totalAmount = product.isParticipant ? -totalAmountValue : totalAmountValue;
416
413
  totalAmount = isAccrual ? totalAmount : -totalAmount;
417
- const quickbooksAccountBS = await QuickbooksAccount.findOne({ accountCode: charge.code, companyId: assetCompany._id.toString() }).lean();
418
- const quickbooksAccountPL = await QuickbooksAccount.findOne({ accountCode: PLCode, companyId: assetCompany._id.toString() }).lean();
414
+ const quickbooksAccountBS = await QuickbooksAccount.findOne({ accountCode: charge.code, ...companyFilter }).lean();
415
+ const quickbooksAccountPL = await QuickbooksAccount.findOne({ accountCode: PLCode, ...companyFilter }).lean();
419
416
  if (!quickbooksAccountBS || !quickbooksAccountPL) {
420
417
  if (!quickbooksAccountBS) {
421
418
  reportErrorsSet.add(charge.code);
@@ -444,8 +441,8 @@ export class QuickbooksService {
444
441
 
445
442
  const handleFee = async (broker: IProductBrokerDocWithBroker, shareName: 'adminShare' | 'interestShare' | 'otherShare') => {
446
443
 
447
- const quickbooksAccountBrokerBS = await QuickbooksAccount.findOne({ accountCode: broker.BSCode, companyId: assetCompany._id.toString() }).lean();
448
- const quickbooksAccountBrokerPL = await QuickbooksAccount.findOne({ accountCode: broker.PLCode, companyId: assetCompany._id.toString() }).lean();
444
+ const quickbooksAccountBrokerBS = await QuickbooksAccount.findOne({ accountCode: broker.BSCode, ...companyFilter }).lean();
445
+ const quickbooksAccountBrokerPL = await QuickbooksAccount.findOne({ accountCode: broker.PLCode, ...companyFilter }).lean();
449
446
  if (!quickbooksAccountBrokerBS || !quickbooksAccountBrokerPL) {
450
447
  if (!quickbooksAccountBrokerBS) {
451
448
  reportErrorsSet.add(broker.BSCode);
@@ -508,8 +505,8 @@ export class QuickbooksService {
508
505
  }
509
506
  }
510
507
 
511
- const quickbooksAccountPaymentBS = await QuickbooksAccount.findOne({ accountCode: product.code, companyId: assetCompany._id.toString() }).lean();
512
- const quickbooksAccountPaymentPL = await QuickbooksAccount.findOne({ accountCode: settlementCode, companyId: assetCompany._id.toString() }).lean();
508
+ const quickbooksAccountPaymentBS = await QuickbooksAccount.findOne({ accountCode: product.code, ...companyFilter }).lean();
509
+ const quickbooksAccountPaymentPL = await QuickbooksAccount.findOne({ accountCode: settlementCode, ...companyFilter }).lean();
513
510
  if (!quickbooksAccountPaymentBS || !quickbooksAccountPaymentPL) {
514
511
  if (!quickbooksAccountPaymentBS) {
515
512
  reportErrorsSet.add(product.code);