gemcap-be-common 1.5.122 → 1.5.124

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.
@@ -31,10 +31,10 @@ import { MODEL_NAMES } from '../models/_models';
31
31
  import { setReceivableManualInputsToggle } from '../db/receivables.db';
32
32
  import { IInventoryAvailabilitySummary, InventoryAvailabilityPaginators } from '../models/InventoryAvailability.model';
33
33
  import { getBBCSheetsByType } from '../db/bbcSheets.db';
34
- import { CustomerGroupModel } from '../models/CustomerGroup.model';
34
+ import { CustomerGroup } from '../models/CustomerGroup.model';
35
35
  import { getPartialPaid } from '../queries/receivable/partially-paid-restated';
36
36
  import MappedGroup from '../models/MappedGroup.model';
37
- import CustomerAPGroup from '../models/CustomerAPGroup.model';
37
+ import { CustomerAPGroup } from '../models/CustomerAPGroup.model';
38
38
  import { getReserveDocs } from '../db/reserve.db';
39
39
  import { IReserveSummary } from '../models/Reserve.model';
40
40
  import { IEquipmentSummary } from '../models/Equipment.model';
@@ -120,7 +120,7 @@ export class AvailabilityService {
120
120
  const customerGroupMapped = await Promise.all(calculationsSettings[settingsKey].map(async (customerGroup) => {
121
121
  const idIsValid = isValidId(customerGroup.customer);
122
122
  if (idIsValid) {
123
- const foundCustomerGroup = await CustomerGroupModel.findById(customerGroup.customer);
123
+ const foundCustomerGroup = await CustomerGroup.findById(customerGroup.customer);
124
124
  if (foundCustomerGroup) {
125
125
  return foundCustomerGroup.items.reduce((innerAcc, item) => ({
126
126
  ...innerAcc,
@@ -175,7 +175,7 @@ export class AvailabilityService {
175
175
 
176
176
  calculation.borrowerId = new mongoose.Types.ObjectId(receivables.borrowerId.toString());
177
177
 
178
- const allCustomerGroups = await CustomerGroupModel.find({ borrowerId: receivables.borrowerId }).lean();
178
+ const allCustomerGroups = await CustomerGroup.find({ borrowerId: receivables.borrowerId }).lean();
179
179
 
180
180
  const enrichedEnrichedSettings = await this.recombineGroups(calculationsSettings);
181
181
 
@@ -411,7 +411,7 @@ export class AvailabilityService {
411
411
  const foundCustomerGroup = allCustomerGroups.find((group) => group.items.includes(data.customerTitle));
412
412
  if (foundCustomerGroup) {
413
413
  data.customer = foundCustomerGroup.groupName;
414
- data.customerGroupId = foundCustomerGroup.id;
414
+ data.customerGroupId = foundCustomerGroup._id;
415
415
  data.customerGroup = foundCustomerGroup.groupName;
416
416
  }
417
417
 
@@ -468,7 +468,7 @@ export class AvailabilityService {
468
468
  switch (group.groupType) {
469
469
  case 'contras':
470
470
  if (isValidId(group.group1)) {
471
- const foundGroup = await CustomerGroupModel.findById(group.group1).lean();
471
+ const foundGroup = await CustomerGroup.findById(group.group1).lean();
472
472
  groupCopy.items = foundGroup ? foundGroup.items.slice() : [];
473
473
  }
474
474
  if (isValidId(group.group2)) {
@@ -86,10 +86,10 @@ export declare class BorrowerService {
86
86
  getBorrowerCodesMap(): Promise<Map<string, string>>;
87
87
  getBorrowerStatementDetails(borrowers: IBorrowerDoc[]): Promise<{
88
88
  [x: string]: {
89
- SELECTED_PERIOD?: boolean;
90
89
  ENTIRE_LOAN?: boolean;
91
- LAST_MONTH?: boolean;
90
+ SELECTED_PERIOD?: boolean;
92
91
  CURRENT_MONTH?: boolean;
92
+ LAST_MONTH?: boolean;
93
93
  TERM_LOAN?: boolean;
94
94
  };
95
95
  }>;
@@ -60,7 +60,7 @@ export declare class ComplianceBorrowersService {
60
60
  isComplianceBorrowerAllowed(userAccess: IUserAccess, requestedBorrowerId: string): boolean;
61
61
  calculateInstanceStatuses(instance: IBorrowerItemInstance, item: IBorrowerItemLean): IInstanceStatus;
62
62
  getFullComplianceBorrowerById(complianceBorrowerId: string): Promise<IComplianceBorrowerDocumentFullWithStatuses>;
63
- getAllBorrowersShortened(userAccess: IUserAccess): Promise<Pick<IComplianceBorrowerWithBorrower, "borrower" | "fundingStatus" | "items">[]>;
63
+ getAllBorrowersShortened(userAccess: IUserAccess): Promise<Pick<IComplianceBorrowerWithBorrower, "items" | "borrower" | "fundingStatus">[]>;
64
64
  generateInstances(complianceBorrowerId: any): Promise<IComplianceBorrowerDocumentFullWithStatuses>;
65
65
  calculateAndUpdateFundingStatus(complianceBorrowerId: string): Promise<void>;
66
66
  calculateFundingStatus(complianceBorrower: IComplianceBorrowerDocumentFull): string;
@@ -26,16 +26,7 @@ class GroupsService {
26
26
  }));
27
27
  }
28
28
  async getBorrowerGroups(borrowerId, relationshipGroups) {
29
- if (typeof relationshipGroups == 'string') {
30
- relationshipGroups = [relationshipGroups];
31
- }
32
- const allCustomerGroups = await Promise.all(relationshipGroups.map(async (groupName) => {
33
- const groups = await groups_db_1.groupsMap[groupName].Model.find({ borrowerId }).sort({ 'createdAt': 1 });
34
- return { [groupName]: groups };
35
- }));
36
- return allCustomerGroups.reduce((acc, group) => {
37
- return { ...acc, ...group };
38
- }, {});
29
+ return (0, groups_db_1.getBorrowerGroups)(borrowerId, relationshipGroups);
39
30
  }
40
31
  async createMappedGroups(borrowerId, groupType, groups) {
41
32
  await MappedGroup_model_1.default.deleteMany({ borrowerId, groupType });
@@ -1,13 +1,13 @@
1
1
  import { IBorrowerGroupWithId } from '../interfaces/group.interface';
2
- import { ICustomerGroupDocument } from '../models/CustomerGroup.model';
3
- import { groupsMap } from '../db/groups.db';
2
+ import { TCustomerGroupDoc } from '../models/CustomerGroup.model';
3
+ import { getBorrowerGroups, groupsMap } from '../db/groups.db';
4
4
 
5
5
  import MappedGroup, { IMappedGroup } from '../models/MappedGroup.model';
6
6
 
7
7
  export class GroupsService {
8
8
  async createBorrowerGroups(borrowerId: string, groupType: string, groups: IBorrowerGroupWithId[]) {
9
9
  const groupIds = groups.map((group) => group._id);
10
- const allExistedGroups: ICustomerGroupDocument[] = await groupsMap[groupType].Model.find({ borrowerId }).lean();
10
+ const allExistedGroups: TCustomerGroupDoc[] = await groupsMap[groupType].Model.find({ borrowerId }).lean();
11
11
  await Promise.all(allExistedGroups.map(async (group) => {
12
12
  if (!groupIds.includes(group._id.toString())) {
13
13
  await groupsMap[groupType].Model.findByIdAndDelete(group._id.toString());
@@ -24,16 +24,7 @@ export class GroupsService {
24
24
  }
25
25
 
26
26
  async getBorrowerGroups(borrowerId: string, relationshipGroups: string | string[]) {
27
- if (typeof relationshipGroups == 'string') {
28
- relationshipGroups = [relationshipGroups];
29
- }
30
- const allCustomerGroups = await Promise.all(relationshipGroups.map(async (groupName) => {
31
- const groups = await groupsMap[groupName].Model.find({ borrowerId }).sort({ 'createdAt': 1 });
32
- return { [groupName]: groups };
33
- }))
34
- return allCustomerGroups.reduce((acc, group) => {
35
- return { ...acc, ...group };
36
- }, {});
27
+ return getBorrowerGroups(borrowerId, relationshipGroups);
37
28
  }
38
29
 
39
30
  async createMappedGroups(borrowerId: string, groupType: string, groups: IMappedGroup[]) {
@@ -214,7 +214,7 @@ class InventoryService {
214
214
  if (customerAPGroup) {
215
215
  const mappedGroup = await (0, groups_1.getMappedGroups)({ group2: customerAPGroup._id.toString() });
216
216
  if (mappedGroup && mappedGroup.length) {
217
- const customerGroup = await CustomerGroup_model_1.CustomerGroupModel.findById(mappedGroup[0].group1);
217
+ const customerGroup = await CustomerGroup_model_1.CustomerGroup.findById(mappedGroup[0].group1);
218
218
  if (customerGroup) {
219
219
  contra.newAPName = customerAPGroup.groupName;
220
220
  contra.contra = 1;
@@ -18,7 +18,7 @@ import { getInventoryTurn } from '../queries/inventory/turn';
18
18
  import { getInconsistentData } from '../queries/inventory/inconsistent-data';
19
19
  import { getInvoiceMovement } from '../queries/inventory/movement';
20
20
  import { getExtension } from '../queries/inventory/extension';
21
- import { CustomerGroupModel } from '../models/CustomerGroup.model';
21
+ import { CustomerGroup } from '../models/CustomerGroup.model';
22
22
  import { getInventoryDifference } from '../queries/inventory/invoice-difference';
23
23
 
24
24
  import {
@@ -250,7 +250,7 @@ export class InventoryService {
250
250
  if (customerAPGroup) {
251
251
  const mappedGroup = await getMappedGroups({ group2: customerAPGroup._id.toString() });
252
252
  if (mappedGroup && mappedGroup.length) {
253
- const customerGroup = await CustomerGroupModel.findById(mappedGroup[0].group1);
253
+ const customerGroup = await CustomerGroup.findById(mappedGroup[0].group1);
254
254
  if (customerGroup) {
255
255
  contra.newAPName = customerAPGroup.groupName;
256
256
  contra.contra = 1;
@@ -1,5 +1,5 @@
1
- /// <reference types="mongoose/types/document" />
2
1
  /// <reference types="mongoose/types/types" />
2
+ /// <reference types="mongoose/types/document" />
3
3
  /// <reference types="mongoose/types/aggregate" />
4
4
  /// <reference types="mongoose/types/callback" />
5
5
  /// <reference types="mongoose/types/collection" />