gemcap-be-common 1.5.122 → 1.5.125
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/groups.d.ts +1 -1
- package/db/groups.db.d.ts +3 -37
- package/db/groups.db.js +5 -3
- package/db/groups.db.ts +6 -4
- package/db/groups.js +2 -2
- package/db/groups.ts +2 -2
- package/models/Borrower.model.d.ts +13 -12
- package/models/Borrower.model.ts +1 -0
- package/models/BorrowerCompliance.model.d.ts +58 -58
- package/models/CategoryGroup.model.d.ts +75 -0
- package/models/CategoryGroup.model.js +23 -0
- package/models/CategoryGroup.model.ts +44 -0
- package/models/CustomerAPGroup.model.d.ts +21 -11
- package/models/CustomerAPGroup.model.js +2 -4
- package/models/CustomerAPGroup.model.ts +20 -7
- package/models/CustomerGroup.model.d.ts +21 -8
- package/models/CustomerGroup.model.js +2 -2
- package/models/CustomerGroup.model.ts +21 -3
- package/models/FinancialCompliance.model.d.ts +7 -7
- package/models/LoanProducts.model.d.ts +15 -15
- package/models/PostponedTransactions.model.d.ts +3 -3
- package/models/QueryResult.model.d.ts +1 -1
- package/models/_index.d.ts +3 -3
- package/package.json +1 -1
- package/services/availability.service.js +6 -6
- package/services/availability.service.ts +6 -6
- package/services/groups.service.js +1 -10
- package/services/groups.service.ts +4 -13
- package/services/inventory.service.js +1 -1
- package/services/inventory.service.ts +2 -2
- package/tsconfig.tsbuildinfo +1 -1
|
@@ -1,13 +1,28 @@
|
|
|
1
|
-
import mongoose
|
|
1
|
+
import mongoose from 'mongoose';
|
|
2
2
|
|
|
3
3
|
import { MODEL_NAMES } from './_models';
|
|
4
4
|
import { IBorrowerGroup } from '../interfaces/group.interface';
|
|
5
5
|
|
|
6
|
-
|
|
6
|
+
export interface ICustomerAPGroup extends IBorrowerGroup {
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export interface ICustomerAPGroupLean extends ICustomerAPGroup {
|
|
10
|
+
_id: mongoose.Types.ObjectId;
|
|
11
|
+
createdAt: Date;
|
|
12
|
+
updatedAt: Date;
|
|
13
|
+
}
|
|
7
14
|
|
|
8
|
-
interface
|
|
15
|
+
export interface ICustomerAPGroupPlain extends Omit<ICustomerAPGroup, 'borrowerId'> {
|
|
16
|
+
_id: string;
|
|
17
|
+
borrowerId: string;
|
|
18
|
+
createdAt: Date;
|
|
19
|
+
updatedAt: Date;
|
|
9
20
|
}
|
|
10
21
|
|
|
22
|
+
export type TCustomerAPGroupDoc = mongoose.HydratedDocument<ICustomerAPGroup>;
|
|
23
|
+
|
|
24
|
+
export type TICustomerAPGroupModel = mongoose.Model<ICustomerAPGroup>;
|
|
25
|
+
|
|
11
26
|
export const CustomerAPGroupSchema = new mongoose.Schema(
|
|
12
27
|
{
|
|
13
28
|
groupName: {
|
|
@@ -23,9 +38,7 @@ export const CustomerAPGroupSchema = new mongoose.Schema(
|
|
|
23
38
|
items: [String],
|
|
24
39
|
__v: { type: Number, select: false },
|
|
25
40
|
},
|
|
26
|
-
{ timestamps: true }
|
|
41
|
+
{ timestamps: true },
|
|
27
42
|
);
|
|
28
43
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
export default mongoose.model<ICustomerAPGroupDocument>(MODEL_NAMES.customerAPGroups, CustomerAPGroupSchema);
|
|
44
|
+
export const CustomerAPGroup = mongoose.model<ICustomerAPGroup, TICustomerAPGroupModel>(MODEL_NAMES.customerAPGroups, CustomerAPGroupSchema);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
/// <reference types="mongoose/types/document" />
|
|
2
|
-
/// <reference types="mongoose/types/models" />
|
|
3
1
|
/// <reference types="mongoose/types/types" />
|
|
2
|
+
/// <reference types="mongoose/types/models" />
|
|
4
3
|
/// <reference types="mongoose/types/utility" />
|
|
4
|
+
/// <reference types="mongoose/types/document" />
|
|
5
5
|
/// <reference types="mongoose/types/aggregate" />
|
|
6
6
|
/// <reference types="mongoose/types/callback" />
|
|
7
7
|
/// <reference types="mongoose/types/collection" />
|
|
@@ -26,37 +26,50 @@
|
|
|
26
26
|
/// <reference types="mongoose/types/validation" />
|
|
27
27
|
/// <reference types="mongoose/types/virtuals" />
|
|
28
28
|
/// <reference types="mongoose/types/inferschematype" />
|
|
29
|
-
import mongoose
|
|
29
|
+
import mongoose from 'mongoose';
|
|
30
30
|
import { IBorrowerGroup } from '../interfaces/group.interface';
|
|
31
|
-
export interface
|
|
31
|
+
export interface ICustomerGroup extends IBorrowerGroup {
|
|
32
|
+
}
|
|
33
|
+
export interface ICustomerGroupLean extends ICustomerGroup {
|
|
34
|
+
_id: mongoose.Types.ObjectId;
|
|
35
|
+
createdAt: Date;
|
|
36
|
+
updatedAt: Date;
|
|
37
|
+
}
|
|
38
|
+
export interface ICustomerGroupPlain extends Omit<ICustomerGroup, 'borrowerId'> {
|
|
39
|
+
_id: string;
|
|
40
|
+
borrowerId: string;
|
|
41
|
+
createdAt: Date;
|
|
42
|
+
updatedAt: Date;
|
|
32
43
|
}
|
|
44
|
+
export type TCustomerGroupDoc = mongoose.HydratedDocument<ICustomerGroup>;
|
|
45
|
+
export type TCustomerGroupModel = mongoose.Model<ICustomerGroup>;
|
|
33
46
|
export declare const CustomerGroupSchema: mongoose.Schema<any, mongoose.Model<any, any, any, any, any, any>, {}, {}, {}, {}, {
|
|
34
47
|
timestamps: true;
|
|
35
48
|
}, {
|
|
36
49
|
createdAt: NativeDate;
|
|
37
50
|
updatedAt: NativeDate;
|
|
38
51
|
} & {
|
|
39
|
-
groupName: string;
|
|
40
52
|
borrowerId: mongoose.Types.ObjectId;
|
|
53
|
+
groupName: string;
|
|
41
54
|
items: string[];
|
|
42
55
|
__v?: number;
|
|
43
56
|
}, mongoose.Document<unknown, {}, mongoose.FlatRecord<{
|
|
44
57
|
createdAt: NativeDate;
|
|
45
58
|
updatedAt: NativeDate;
|
|
46
59
|
} & {
|
|
47
|
-
groupName: string;
|
|
48
60
|
borrowerId: mongoose.Types.ObjectId;
|
|
61
|
+
groupName: string;
|
|
49
62
|
items: string[];
|
|
50
63
|
__v?: number;
|
|
51
64
|
}>> & mongoose.FlatRecord<{
|
|
52
65
|
createdAt: NativeDate;
|
|
53
66
|
updatedAt: NativeDate;
|
|
54
67
|
} & {
|
|
55
|
-
groupName: string;
|
|
56
68
|
borrowerId: mongoose.Types.ObjectId;
|
|
69
|
+
groupName: string;
|
|
57
70
|
items: string[];
|
|
58
71
|
__v?: number;
|
|
59
72
|
}> & {
|
|
60
73
|
_id: mongoose.Types.ObjectId;
|
|
61
74
|
}>;
|
|
62
|
-
export declare const
|
|
75
|
+
export declare const CustomerGroup: TCustomerGroupModel;
|
|
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.
|
|
6
|
+
exports.CustomerGroup = exports.CustomerGroupSchema = void 0;
|
|
7
7
|
const mongoose_1 = __importDefault(require("mongoose"));
|
|
8
8
|
const _models_1 = require("./_models");
|
|
9
9
|
exports.CustomerGroupSchema = new mongoose_1.default.Schema({
|
|
@@ -20,4 +20,4 @@ exports.CustomerGroupSchema = new mongoose_1.default.Schema({
|
|
|
20
20
|
items: [String],
|
|
21
21
|
__v: { type: Number, select: false },
|
|
22
22
|
}, { timestamps: true });
|
|
23
|
-
exports.
|
|
23
|
+
exports.CustomerGroup = mongoose_1.default.model(_models_1.MODEL_NAMES.customerGroups, exports.CustomerGroupSchema);
|
|
@@ -1,11 +1,29 @@
|
|
|
1
|
-
import mongoose
|
|
1
|
+
import mongoose from 'mongoose';
|
|
2
2
|
|
|
3
3
|
import { MODEL_NAMES } from './_models';
|
|
4
4
|
import { IBorrowerGroup } from '../interfaces/group.interface';
|
|
5
|
+
import { ICategoryGroup } from './CategoryGroup.model';
|
|
5
6
|
|
|
6
|
-
export interface
|
|
7
|
+
export interface ICustomerGroup extends IBorrowerGroup {
|
|
7
8
|
}
|
|
8
9
|
|
|
10
|
+
export interface ICustomerGroupLean extends ICustomerGroup {
|
|
11
|
+
_id: mongoose.Types.ObjectId;
|
|
12
|
+
createdAt: Date;
|
|
13
|
+
updatedAt: Date;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export interface ICustomerGroupPlain extends Omit<ICustomerGroup, 'borrowerId'> {
|
|
17
|
+
_id: string;
|
|
18
|
+
borrowerId: string;
|
|
19
|
+
createdAt: Date;
|
|
20
|
+
updatedAt: Date;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export type TCustomerGroupDoc = mongoose.HydratedDocument<ICustomerGroup>;
|
|
24
|
+
|
|
25
|
+
export type TCustomerGroupModel = mongoose.Model<ICustomerGroup>;
|
|
26
|
+
|
|
9
27
|
export const CustomerGroupSchema = new mongoose.Schema(
|
|
10
28
|
{
|
|
11
29
|
groupName: {
|
|
@@ -24,4 +42,4 @@ export const CustomerGroupSchema = new mongoose.Schema(
|
|
|
24
42
|
{ timestamps: true }
|
|
25
43
|
);
|
|
26
44
|
|
|
27
|
-
export const
|
|
45
|
+
export const CustomerGroup = mongoose.model<ICustomerGroup, TCustomerGroupModel>(MODEL_NAMES.customerGroups, CustomerGroupSchema);
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/// <reference types="mongoose/types/document" />
|
|
2
2
|
/// <reference types="mongoose/types/models" />
|
|
3
3
|
/// <reference types="mongoose/types/schemaoptions" />
|
|
4
|
-
/// <reference types="mongoose/types/utility" />
|
|
5
4
|
/// <reference types="mongoose/types/types" />
|
|
5
|
+
/// <reference types="mongoose/types/utility" />
|
|
6
6
|
/// <reference types="mongoose/types/aggregate" />
|
|
7
7
|
/// <reference types="mongoose/types/callback" />
|
|
8
8
|
/// <reference types="mongoose/types/collection" />
|
|
@@ -41,13 +41,13 @@ export interface IFinancialComplianceSettingsDocument extends IFinancialComplian
|
|
|
41
41
|
export declare const FinancialComplianceSettingsSchema: mongoose.Schema<any, mongoose.Model<any, any, any, any, any, any>, {}, {}, {}, {}, mongoose.DefaultSchemaOptions, {
|
|
42
42
|
isDeleted: boolean;
|
|
43
43
|
financialEmails: mongoose.Types.DocumentArray<{
|
|
44
|
-
email?: string;
|
|
45
44
|
title?: string;
|
|
45
|
+
email?: string;
|
|
46
46
|
isActive?: boolean;
|
|
47
47
|
}>;
|
|
48
48
|
managementEmails: mongoose.Types.DocumentArray<{
|
|
49
|
-
email?: string;
|
|
50
49
|
title?: string;
|
|
50
|
+
email?: string;
|
|
51
51
|
isActive?: boolean;
|
|
52
52
|
}>;
|
|
53
53
|
__v?: number;
|
|
@@ -57,13 +57,13 @@ export declare const FinancialComplianceSettingsSchema: mongoose.Schema<any, mon
|
|
|
57
57
|
}, mongoose.Document<unknown, {}, mongoose.FlatRecord<{
|
|
58
58
|
isDeleted: boolean;
|
|
59
59
|
financialEmails: mongoose.Types.DocumentArray<{
|
|
60
|
-
email?: string;
|
|
61
60
|
title?: string;
|
|
61
|
+
email?: string;
|
|
62
62
|
isActive?: boolean;
|
|
63
63
|
}>;
|
|
64
64
|
managementEmails: mongoose.Types.DocumentArray<{
|
|
65
|
-
email?: string;
|
|
66
65
|
title?: string;
|
|
66
|
+
email?: string;
|
|
67
67
|
isActive?: boolean;
|
|
68
68
|
}>;
|
|
69
69
|
__v?: number;
|
|
@@ -73,13 +73,13 @@ export declare const FinancialComplianceSettingsSchema: mongoose.Schema<any, mon
|
|
|
73
73
|
}>> & mongoose.FlatRecord<{
|
|
74
74
|
isDeleted: boolean;
|
|
75
75
|
financialEmails: mongoose.Types.DocumentArray<{
|
|
76
|
-
email?: string;
|
|
77
76
|
title?: string;
|
|
77
|
+
email?: string;
|
|
78
78
|
isActive?: boolean;
|
|
79
79
|
}>;
|
|
80
80
|
managementEmails: mongoose.Types.DocumentArray<{
|
|
81
|
-
email?: string;
|
|
82
81
|
title?: string;
|
|
82
|
+
email?: string;
|
|
83
83
|
isActive?: boolean;
|
|
84
84
|
}>;
|
|
85
85
|
__v?: number;
|
|
@@ -89,15 +89,15 @@ export declare const LoanProductSchema: mongoose.Schema<any, mongoose.Model<any,
|
|
|
89
89
|
createdAt: NativeDate;
|
|
90
90
|
updatedAt: NativeDate;
|
|
91
91
|
} & {
|
|
92
|
-
|
|
93
|
-
type: string;
|
|
92
|
+
code: string;
|
|
94
93
|
name: string;
|
|
95
|
-
order: number;
|
|
96
94
|
active: boolean;
|
|
97
|
-
|
|
95
|
+
type: string;
|
|
96
|
+
order: number;
|
|
97
|
+
borrowerId: mongoose.Types.ObjectId;
|
|
98
|
+
commitment: number;
|
|
98
99
|
startDate: Date;
|
|
99
100
|
maturityDate: Date;
|
|
100
|
-
commitment: number;
|
|
101
101
|
isBalanceActual: boolean;
|
|
102
102
|
isFloatedBalanceActual: boolean;
|
|
103
103
|
masterLoanProductId: mongoose.Types.ObjectId;
|
|
@@ -117,15 +117,15 @@ export declare const LoanProductSchema: mongoose.Schema<any, mongoose.Model<any,
|
|
|
117
117
|
createdAt: NativeDate;
|
|
118
118
|
updatedAt: NativeDate;
|
|
119
119
|
} & {
|
|
120
|
-
|
|
121
|
-
type: string;
|
|
120
|
+
code: string;
|
|
122
121
|
name: string;
|
|
123
|
-
order: number;
|
|
124
122
|
active: boolean;
|
|
125
|
-
|
|
123
|
+
type: string;
|
|
124
|
+
order: number;
|
|
125
|
+
borrowerId: mongoose.Types.ObjectId;
|
|
126
|
+
commitment: number;
|
|
126
127
|
startDate: Date;
|
|
127
128
|
maturityDate: Date;
|
|
128
|
-
commitment: number;
|
|
129
129
|
isBalanceActual: boolean;
|
|
130
130
|
isFloatedBalanceActual: boolean;
|
|
131
131
|
masterLoanProductId: mongoose.Types.ObjectId;
|
|
@@ -145,15 +145,15 @@ export declare const LoanProductSchema: mongoose.Schema<any, mongoose.Model<any,
|
|
|
145
145
|
createdAt: NativeDate;
|
|
146
146
|
updatedAt: NativeDate;
|
|
147
147
|
} & {
|
|
148
|
-
|
|
149
|
-
type: string;
|
|
148
|
+
code: string;
|
|
150
149
|
name: string;
|
|
151
|
-
order: number;
|
|
152
150
|
active: boolean;
|
|
153
|
-
|
|
151
|
+
type: string;
|
|
152
|
+
order: number;
|
|
153
|
+
borrowerId: mongoose.Types.ObjectId;
|
|
154
|
+
commitment: number;
|
|
154
155
|
startDate: Date;
|
|
155
156
|
maturityDate: Date;
|
|
156
|
-
commitment: number;
|
|
157
157
|
isBalanceActual: boolean;
|
|
158
158
|
isFloatedBalanceActual: boolean;
|
|
159
159
|
masterLoanProductId: mongoose.Types.ObjectId;
|
|
@@ -56,18 +56,18 @@ export declare const PostponedTransactionSchema: mongoose.Schema<any, mongoose.M
|
|
|
56
56
|
timestamps: false;
|
|
57
57
|
}, {
|
|
58
58
|
productId: mongoose.Types.ObjectId;
|
|
59
|
-
transactionId: mongoose.Types.ObjectId;
|
|
60
59
|
postponedToDate: string;
|
|
60
|
+
transactionId: mongoose.Types.ObjectId;
|
|
61
61
|
__v?: number;
|
|
62
62
|
}, mongoose.Document<unknown, {}, mongoose.FlatRecord<{
|
|
63
63
|
productId: mongoose.Types.ObjectId;
|
|
64
|
-
transactionId: mongoose.Types.ObjectId;
|
|
65
64
|
postponedToDate: string;
|
|
65
|
+
transactionId: mongoose.Types.ObjectId;
|
|
66
66
|
__v?: number;
|
|
67
67
|
}>> & mongoose.FlatRecord<{
|
|
68
68
|
productId: mongoose.Types.ObjectId;
|
|
69
|
-
transactionId: mongoose.Types.ObjectId;
|
|
70
69
|
postponedToDate: string;
|
|
70
|
+
transactionId: mongoose.Types.ObjectId;
|
|
71
71
|
__v?: number;
|
|
72
72
|
}> & {
|
|
73
73
|
_id: mongoose.Types.ObjectId;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/// <reference types="mongoose/types/types" />
|
|
2
2
|
/// <reference types="mongoose/types/document" />
|
|
3
|
-
/// <reference types="mongoose/types/models" />
|
|
4
3
|
/// <reference types="mongoose/types/schemaoptions" />
|
|
5
4
|
/// <reference types="mongoose/types/utility" />
|
|
5
|
+
/// <reference types="mongoose/types/models" />
|
|
6
6
|
/// <reference types="mongoose/types/aggregate" />
|
|
7
7
|
/// <reference types="mongoose/types/callback" />
|
|
8
8
|
/// <reference types="mongoose/types/collection" />
|
package/models/_index.d.ts
CHANGED
|
@@ -36,9 +36,9 @@ export declare const allSchemas: {
|
|
|
36
36
|
updatedAt: NativeDate;
|
|
37
37
|
} & {
|
|
38
38
|
order: number;
|
|
39
|
+
amount: number;
|
|
39
40
|
bbcSheetId: import("mongoose").Types.ObjectId;
|
|
40
41
|
apDate: Date;
|
|
41
|
-
amount: number;
|
|
42
42
|
__v?: number;
|
|
43
43
|
poNumber?: string;
|
|
44
44
|
customerName?: string;
|
|
@@ -50,9 +50,9 @@ export declare const allSchemas: {
|
|
|
50
50
|
updatedAt: NativeDate;
|
|
51
51
|
} & {
|
|
52
52
|
order: number;
|
|
53
|
+
amount: number;
|
|
53
54
|
bbcSheetId: import("mongoose").Types.ObjectId;
|
|
54
55
|
apDate: Date;
|
|
55
|
-
amount: number;
|
|
56
56
|
__v?: number;
|
|
57
57
|
poNumber?: string;
|
|
58
58
|
customerName?: string;
|
|
@@ -64,9 +64,9 @@ export declare const allSchemas: {
|
|
|
64
64
|
updatedAt: NativeDate;
|
|
65
65
|
} & {
|
|
66
66
|
order: number;
|
|
67
|
+
amount: number;
|
|
67
68
|
bbcSheetId: import("mongoose").Types.ObjectId;
|
|
68
69
|
apDate: Date;
|
|
69
|
-
amount: number;
|
|
70
70
|
__v?: number;
|
|
71
71
|
poNumber?: string;
|
|
72
72
|
customerName?: string;
|
package/package.json
CHANGED
|
@@ -21,7 +21,7 @@ const bbcSheets_db_1 = require("../db/bbcSheets.db");
|
|
|
21
21
|
const CustomerGroup_model_1 = require("../models/CustomerGroup.model");
|
|
22
22
|
const partially_paid_restated_1 = require("../queries/receivable/partially-paid-restated");
|
|
23
23
|
const MappedGroup_model_1 = __importDefault(require("../models/MappedGroup.model"));
|
|
24
|
-
const CustomerAPGroup_model_1 =
|
|
24
|
+
const CustomerAPGroup_model_1 = require("../models/CustomerAPGroup.model");
|
|
25
25
|
const reserve_db_1 = require("../db/reserve.db");
|
|
26
26
|
const inventory_availability_results_enum_1 = require("../enums/inventory-availability-results.enum");
|
|
27
27
|
exports.START_PAGINATORS = {
|
|
@@ -55,7 +55,7 @@ class AvailabilityService {
|
|
|
55
55
|
const customerGroupMapped = await Promise.all(calculationsSettings[settingsKey].map(async (customerGroup) => {
|
|
56
56
|
const idIsValid = (0, mongo_helper_1.isValidId)(customerGroup.customer);
|
|
57
57
|
if (idIsValid) {
|
|
58
|
-
const foundCustomerGroup = await CustomerGroup_model_1.
|
|
58
|
+
const foundCustomerGroup = await CustomerGroup_model_1.CustomerGroup.findById(customerGroup.customer);
|
|
59
59
|
if (foundCustomerGroup) {
|
|
60
60
|
return foundCustomerGroup.items.reduce((innerAcc, item) => ({
|
|
61
61
|
...innerAcc,
|
|
@@ -103,7 +103,7 @@ class AvailabilityService {
|
|
|
103
103
|
return calculation;
|
|
104
104
|
}
|
|
105
105
|
calculation.borrowerId = new mongoose_1.default.Types.ObjectId(receivables.borrowerId.toString());
|
|
106
|
-
const allCustomerGroups = await CustomerGroup_model_1.
|
|
106
|
+
const allCustomerGroups = await CustomerGroup_model_1.CustomerGroup.find({ borrowerId: receivables.borrowerId }).lean();
|
|
107
107
|
const enrichedEnrichedSettings = await this.recombineGroups(calculationsSettings);
|
|
108
108
|
const getBucket = (bbcDate, item, permittedDays, isExcluded = false) => {
|
|
109
109
|
const invoiceDate = (0, dayjs_1.default)(item.invoiceDate).startOf('day');
|
|
@@ -317,7 +317,7 @@ class AvailabilityService {
|
|
|
317
317
|
const foundCustomerGroup = allCustomerGroups.find((group) => group.items.includes(data.customerTitle));
|
|
318
318
|
if (foundCustomerGroup) {
|
|
319
319
|
data.customer = foundCustomerGroup.groupName;
|
|
320
|
-
data.customerGroupId = foundCustomerGroup.
|
|
320
|
+
data.customerGroupId = foundCustomerGroup._id;
|
|
321
321
|
data.customerGroup = foundCustomerGroup.groupName;
|
|
322
322
|
}
|
|
323
323
|
const foundInvoice = partiallyPaidData.partiallyPaidInvoices.find((pInvoice) => {
|
|
@@ -366,11 +366,11 @@ class AvailabilityService {
|
|
|
366
366
|
switch (group.groupType) {
|
|
367
367
|
case 'contras':
|
|
368
368
|
if ((0, mongo_helper_1.isValidId)(group.group1)) {
|
|
369
|
-
const foundGroup = await CustomerGroup_model_1.
|
|
369
|
+
const foundGroup = await CustomerGroup_model_1.CustomerGroup.findById(group.group1).lean();
|
|
370
370
|
groupCopy.items = foundGroup ? foundGroup.items.slice() : [];
|
|
371
371
|
}
|
|
372
372
|
if ((0, mongo_helper_1.isValidId)(group.group2)) {
|
|
373
|
-
const foundGroup = await CustomerAPGroup_model_1.
|
|
373
|
+
const foundGroup = await CustomerAPGroup_model_1.CustomerAPGroup.findById(group.group2).lean();
|
|
374
374
|
groupCopy.customersAP = foundGroup ? foundGroup.items.slice() : [];
|
|
375
375
|
}
|
|
376
376
|
}
|
|
@@ -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 {
|
|
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
|
|
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
|
|
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.
|
|
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
|
|
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)) {
|
|
@@ -26,16 +26,7 @@ class GroupsService {
|
|
|
26
26
|
}));
|
|
27
27
|
}
|
|
28
28
|
async getBorrowerGroups(borrowerId, relationshipGroups) {
|
|
29
|
-
|
|
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 {
|
|
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:
|
|
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
|
-
|
|
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.
|
|
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 {
|
|
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
|
|
253
|
+
const customerGroup = await CustomerGroup.findById(mappedGroup[0].group1);
|
|
254
254
|
if (customerGroup) {
|
|
255
255
|
contra.newAPName = customerAPGroup.groupName;
|
|
256
256
|
contra.contra = 1;
|