gemcap-be-common 1.4.1 → 1.4.3
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/collaterals.db.d.ts +1 -1
- package/interfaces/auth-user.interface.d.ts +7 -0
- package/interfaces/auth-user.interface.ts +8 -0
- package/models/AvailabilitySigns.model.d.ts +11 -11
- package/models/AvailabilitySigns.model.js +2 -4
- package/models/AvailabilitySigns.model.ts +7 -9
- package/models/ReceivableAvailability.model.d.ts +8 -8
- package/models/ReceivableAvailability.model.ts +2 -2
- package/models/_index.d.ts +6 -6
- package/package.json +1 -1
- package/services/availability.service.d.ts +5 -5
- package/services/availability.service.js +1 -1
- package/services/availability.service.ts +6 -7
- package/services/compliance-borrowers.service.d.ts +3 -3
- package/services/compliance-borrowers.service.js +1 -1
- package/services/compliance-borrowers.service.ts +3 -4
- package/services/signs.service.d.ts +2 -3
- package/services/signs.service.js +8 -9
- package/services/signs.service.ts +11 -13
- package/services/users.service.d.ts +3 -2
- package/services/users.service.js +9 -1
- package/services/users.service.ts +13 -4
- package/tsconfig.tsbuildinfo +1 -1
package/db/collaterals.db.d.ts
CHANGED
|
@@ -75,7 +75,7 @@ export declare const createQuery: (groupFields: {
|
|
|
75
75
|
};
|
|
76
76
|
};
|
|
77
77
|
itemQueries: any;
|
|
78
|
-
enumKey: "INVENTORY" | "
|
|
78
|
+
enumKey: "INVENTORY" | "RECEIVABLE" | "ACCOUNT_PAYABLE" | "OTHER" | "CASH" | "LOAN_TRANSACTIONS" | "QUICKBOOKS" | "UPLOADED_BANK_TRANSACTIONS";
|
|
79
79
|
};
|
|
80
80
|
export declare const ITEMS_PAGINATION: (paginatorOptions: IPaginatorOptions) => ({
|
|
81
81
|
$skip: number;
|
|
@@ -23,19 +23,19 @@
|
|
|
23
23
|
/// <reference types="mongoose/types/virtuals" />
|
|
24
24
|
/// <reference types="mongoose/types/inferschematype" />
|
|
25
25
|
import mongoose from 'mongoose';
|
|
26
|
-
import {
|
|
26
|
+
import { IUser } from '../interfaces/auth-user.interface';
|
|
27
27
|
export declare const REQUIRED_SIGNS = 2;
|
|
28
28
|
export interface IAvailabilitySignItem {
|
|
29
|
-
userSignedId:
|
|
29
|
+
userSignedId: string;
|
|
30
30
|
signedAt: Date;
|
|
31
|
-
userRevokedId?:
|
|
31
|
+
userRevokedId?: string;
|
|
32
32
|
revokedAt?: Date;
|
|
33
33
|
}
|
|
34
34
|
export interface IAvailabilitySignItemView {
|
|
35
35
|
_id: mongoose.Types.ObjectId;
|
|
36
|
-
userSigned:
|
|
36
|
+
userSigned: IUser;
|
|
37
37
|
signedAt: Date;
|
|
38
|
-
userRevoked?:
|
|
38
|
+
userRevoked?: IUser;
|
|
39
39
|
revokedAt?: Date;
|
|
40
40
|
}
|
|
41
41
|
export interface IAvailabilitySign {
|
|
@@ -60,9 +60,9 @@ export declare const IAvailabilitySignSchema: mongoose.Schema<any, mongoose.Mode
|
|
|
60
60
|
bbcDateId: mongoose.Types.ObjectId;
|
|
61
61
|
requiredSigns: number;
|
|
62
62
|
signs: mongoose.Types.DocumentArray<{
|
|
63
|
-
userSignedId:
|
|
63
|
+
userSignedId: string;
|
|
64
64
|
signedAt: Date;
|
|
65
|
-
userRevokedId?:
|
|
65
|
+
userRevokedId?: string;
|
|
66
66
|
revokedAt?: Date;
|
|
67
67
|
}>;
|
|
68
68
|
__v?: number;
|
|
@@ -73,9 +73,9 @@ export declare const IAvailabilitySignSchema: mongoose.Schema<any, mongoose.Mode
|
|
|
73
73
|
bbcDateId: mongoose.Types.ObjectId;
|
|
74
74
|
requiredSigns: number;
|
|
75
75
|
signs: mongoose.Types.DocumentArray<{
|
|
76
|
-
userSignedId:
|
|
76
|
+
userSignedId: string;
|
|
77
77
|
signedAt: Date;
|
|
78
|
-
userRevokedId?:
|
|
78
|
+
userRevokedId?: string;
|
|
79
79
|
revokedAt?: Date;
|
|
80
80
|
}>;
|
|
81
81
|
__v?: number;
|
|
@@ -86,9 +86,9 @@ export declare const IAvailabilitySignSchema: mongoose.Schema<any, mongoose.Mode
|
|
|
86
86
|
bbcDateId: mongoose.Types.ObjectId;
|
|
87
87
|
requiredSigns: number;
|
|
88
88
|
signs: mongoose.Types.DocumentArray<{
|
|
89
|
-
userSignedId:
|
|
89
|
+
userSignedId: string;
|
|
90
90
|
signedAt: Date;
|
|
91
|
-
userRevokedId?:
|
|
91
|
+
userRevokedId?: string;
|
|
92
92
|
revokedAt?: Date;
|
|
93
93
|
}>;
|
|
94
94
|
__v?: number;
|
|
@@ -22,8 +22,7 @@ exports.IAvailabilitySignSchema = new mongoose_1.default.Schema({
|
|
|
22
22
|
signs: [
|
|
23
23
|
{
|
|
24
24
|
userSignedId: {
|
|
25
|
-
type:
|
|
26
|
-
ref: _models_1.MODEL_NAMES.users,
|
|
25
|
+
type: String,
|
|
27
26
|
required: true,
|
|
28
27
|
},
|
|
29
28
|
signedAt: {
|
|
@@ -31,8 +30,7 @@ exports.IAvailabilitySignSchema = new mongoose_1.default.Schema({
|
|
|
31
30
|
required: true,
|
|
32
31
|
},
|
|
33
32
|
userRevokedId: {
|
|
34
|
-
type:
|
|
35
|
-
ref: _models_1.MODEL_NAMES.users,
|
|
33
|
+
type: String,
|
|
36
34
|
required: false,
|
|
37
35
|
},
|
|
38
36
|
revokedAt: {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import mongoose from 'mongoose';
|
|
2
2
|
|
|
3
|
-
import {
|
|
3
|
+
import { IUser } from '../interfaces/auth-user.interface';
|
|
4
4
|
import { MODEL_NAMES } from './_models';
|
|
5
5
|
|
|
6
6
|
const mongooseLeanId = require('../plugins/id.plugin');
|
|
@@ -8,17 +8,17 @@ const mongooseLeanId = require('../plugins/id.plugin');
|
|
|
8
8
|
export const REQUIRED_SIGNS = 2;
|
|
9
9
|
|
|
10
10
|
export interface IAvailabilitySignItem {
|
|
11
|
-
userSignedId:
|
|
11
|
+
userSignedId: string;
|
|
12
12
|
signedAt: Date;
|
|
13
|
-
userRevokedId?:
|
|
13
|
+
userRevokedId?: string;
|
|
14
14
|
revokedAt?: Date;
|
|
15
15
|
}
|
|
16
16
|
|
|
17
17
|
export interface IAvailabilitySignItemView {
|
|
18
18
|
_id: mongoose.Types.ObjectId;
|
|
19
|
-
userSigned:
|
|
19
|
+
userSigned: IUser;
|
|
20
20
|
signedAt: Date;
|
|
21
|
-
userRevoked?:
|
|
21
|
+
userRevoked?: IUser;
|
|
22
22
|
revokedAt?: Date;
|
|
23
23
|
}
|
|
24
24
|
|
|
@@ -53,8 +53,7 @@ export const IAvailabilitySignSchema = new mongoose.Schema(
|
|
|
53
53
|
signs: [
|
|
54
54
|
{
|
|
55
55
|
userSignedId: {
|
|
56
|
-
type:
|
|
57
|
-
ref: MODEL_NAMES.users,
|
|
56
|
+
type: String,
|
|
58
57
|
required: true,
|
|
59
58
|
},
|
|
60
59
|
signedAt: {
|
|
@@ -62,8 +61,7 @@ export const IAvailabilitySignSchema = new mongoose.Schema(
|
|
|
62
61
|
required: true,
|
|
63
62
|
},
|
|
64
63
|
userRevokedId: {
|
|
65
|
-
type:
|
|
66
|
-
ref: MODEL_NAMES.users,
|
|
64
|
+
type: String,
|
|
67
65
|
required: false,
|
|
68
66
|
},
|
|
69
67
|
revokedAt: {
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
/// <reference types="mongoose/types/inferschematype" />
|
|
25
25
|
import mongoose, { Document } from 'mongoose';
|
|
26
26
|
import { IReceivableAvailabilityItem, IReceivableAvailabilityItemView } from './ReceivableAvailabilityItem.model';
|
|
27
|
-
import {
|
|
27
|
+
import { IUser } from '../interfaces/auth-user.interface';
|
|
28
28
|
import { SummaryMultipliers } from './ReceivableAvailabilityManualSummary.model';
|
|
29
29
|
export declare enum ELimitSettings {
|
|
30
30
|
EXCLUDED_CUSTOMERS = "excludedCustomers",
|
|
@@ -94,7 +94,7 @@ export interface IReceivableAvailabilityView extends IReceivableAvailabilityDoc
|
|
|
94
94
|
items: IReceivableAvailabilityItemView[];
|
|
95
95
|
uniqueCustomers: string[];
|
|
96
96
|
totalItems: number;
|
|
97
|
-
userCalculated?:
|
|
97
|
+
userCalculated?: IUser;
|
|
98
98
|
}
|
|
99
99
|
export declare const summarySchemeDesc: {
|
|
100
100
|
invoiceAmount: {
|
|
@@ -184,13 +184,12 @@ export declare const AvailabilitySchema: mongoose.Schema<any, mongoose.Model<any
|
|
|
184
184
|
createdAt: NativeDate;
|
|
185
185
|
updatedAt: NativeDate;
|
|
186
186
|
} & {
|
|
187
|
-
bbcDateId: mongoose.Types.ObjectId;
|
|
188
187
|
borrowerId: mongoose.Types.ObjectId;
|
|
188
|
+
bbcDateId: mongoose.Types.ObjectId;
|
|
189
189
|
useManualInputs: boolean;
|
|
190
190
|
__v?: number;
|
|
191
191
|
summary?: {
|
|
192
192
|
invoiceAmount: number;
|
|
193
|
-
ARReserves: number;
|
|
194
193
|
grossAR: number;
|
|
195
194
|
balanceAfterCrossAge: number;
|
|
196
195
|
permittedOver: number;
|
|
@@ -208,6 +207,7 @@ export declare const AvailabilitySchema: mongoose.Schema<any, mongoose.Model<any
|
|
|
208
207
|
insuredAvailability: number;
|
|
209
208
|
uninsuredAvailability: number;
|
|
210
209
|
creditNotesNegative: number;
|
|
210
|
+
ARReserves: number;
|
|
211
211
|
ARAvailability: number;
|
|
212
212
|
};
|
|
213
213
|
userCalculatedId?: mongoose.Types.ObjectId;
|
|
@@ -244,13 +244,12 @@ export declare const AvailabilitySchema: mongoose.Schema<any, mongoose.Model<any
|
|
|
244
244
|
createdAt: NativeDate;
|
|
245
245
|
updatedAt: NativeDate;
|
|
246
246
|
} & {
|
|
247
|
-
bbcDateId: mongoose.Types.ObjectId;
|
|
248
247
|
borrowerId: mongoose.Types.ObjectId;
|
|
248
|
+
bbcDateId: mongoose.Types.ObjectId;
|
|
249
249
|
useManualInputs: boolean;
|
|
250
250
|
__v?: number;
|
|
251
251
|
summary?: {
|
|
252
252
|
invoiceAmount: number;
|
|
253
|
-
ARReserves: number;
|
|
254
253
|
grossAR: number;
|
|
255
254
|
balanceAfterCrossAge: number;
|
|
256
255
|
permittedOver: number;
|
|
@@ -268,6 +267,7 @@ export declare const AvailabilitySchema: mongoose.Schema<any, mongoose.Model<any
|
|
|
268
267
|
insuredAvailability: number;
|
|
269
268
|
uninsuredAvailability: number;
|
|
270
269
|
creditNotesNegative: number;
|
|
270
|
+
ARReserves: number;
|
|
271
271
|
ARAvailability: number;
|
|
272
272
|
};
|
|
273
273
|
userCalculatedId?: mongoose.Types.ObjectId;
|
|
@@ -304,13 +304,12 @@ export declare const AvailabilitySchema: mongoose.Schema<any, mongoose.Model<any
|
|
|
304
304
|
createdAt: NativeDate;
|
|
305
305
|
updatedAt: NativeDate;
|
|
306
306
|
} & {
|
|
307
|
-
bbcDateId: mongoose.Types.ObjectId;
|
|
308
307
|
borrowerId: mongoose.Types.ObjectId;
|
|
308
|
+
bbcDateId: mongoose.Types.ObjectId;
|
|
309
309
|
useManualInputs: boolean;
|
|
310
310
|
__v?: number;
|
|
311
311
|
summary?: {
|
|
312
312
|
invoiceAmount: number;
|
|
313
|
-
ARReserves: number;
|
|
314
313
|
grossAR: number;
|
|
315
314
|
balanceAfterCrossAge: number;
|
|
316
315
|
permittedOver: number;
|
|
@@ -328,6 +327,7 @@ export declare const AvailabilitySchema: mongoose.Schema<any, mongoose.Model<any
|
|
|
328
327
|
insuredAvailability: number;
|
|
329
328
|
uninsuredAvailability: number;
|
|
330
329
|
creditNotesNegative: number;
|
|
330
|
+
ARReserves: number;
|
|
331
331
|
ARAvailability: number;
|
|
332
332
|
};
|
|
333
333
|
userCalculatedId?: mongoose.Types.ObjectId;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import mongoose, { Document } from 'mongoose';
|
|
2
2
|
|
|
3
3
|
import { IReceivableAvailabilityItem, IReceivableAvailabilityItemView } from './ReceivableAvailabilityItem.model';
|
|
4
|
-
import {
|
|
4
|
+
import { IUser } from '../interfaces/auth-user.interface';
|
|
5
5
|
import { MODEL_NAMES } from './_models';
|
|
6
6
|
import { SummaryMultipliers } from './ReceivableAvailabilityManualSummary.model';
|
|
7
7
|
|
|
@@ -83,7 +83,7 @@ export interface IReceivableAvailabilityView extends IReceivableAvailabilityDoc
|
|
|
83
83
|
items: IReceivableAvailabilityItemView[];
|
|
84
84
|
uniqueCustomers: string[];
|
|
85
85
|
totalItems: number;
|
|
86
|
-
userCalculated?:
|
|
86
|
+
userCalculated?: IUser;
|
|
87
87
|
}
|
|
88
88
|
|
|
89
89
|
export const summarySchemeDesc = {
|
package/models/_index.d.ts
CHANGED
|
@@ -31,10 +31,10 @@ export declare const allSchemas: {
|
|
|
31
31
|
createdAt: NativeDate;
|
|
32
32
|
updatedAt: NativeDate;
|
|
33
33
|
} & {
|
|
34
|
-
order: number;
|
|
35
|
-
amount: number;
|
|
36
34
|
bbcSheetId: import("mongoose").Types.ObjectId;
|
|
35
|
+
order: number;
|
|
37
36
|
apDate: Date;
|
|
37
|
+
amount: number;
|
|
38
38
|
__v?: number;
|
|
39
39
|
poNumber?: string;
|
|
40
40
|
customerName?: string;
|
|
@@ -45,10 +45,10 @@ export declare const allSchemas: {
|
|
|
45
45
|
createdAt: NativeDate;
|
|
46
46
|
updatedAt: NativeDate;
|
|
47
47
|
} & {
|
|
48
|
-
order: number;
|
|
49
|
-
amount: number;
|
|
50
48
|
bbcSheetId: import("mongoose").Types.ObjectId;
|
|
49
|
+
order: number;
|
|
51
50
|
apDate: Date;
|
|
51
|
+
amount: number;
|
|
52
52
|
__v?: number;
|
|
53
53
|
poNumber?: string;
|
|
54
54
|
customerName?: string;
|
|
@@ -59,10 +59,10 @@ export declare const allSchemas: {
|
|
|
59
59
|
createdAt: NativeDate;
|
|
60
60
|
updatedAt: NativeDate;
|
|
61
61
|
} & {
|
|
62
|
-
order: number;
|
|
63
|
-
amount: number;
|
|
64
62
|
bbcSheetId: import("mongoose").Types.ObjectId;
|
|
63
|
+
order: number;
|
|
65
64
|
apDate: Date;
|
|
65
|
+
amount: number;
|
|
66
66
|
__v?: number;
|
|
67
67
|
poNumber?: string;
|
|
68
68
|
customerName?: string;
|
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ELimitSettings, IReceivableAvailability, IAvailabilityLimits, IAvailabilitySettings, IAvailabilitySummary, IReceivableAvailabilityView } from '../models/ReceivableAvailability.model';
|
|
2
|
-
import {
|
|
2
|
+
import { IUser } from '../interfaces/auth-user.interface';
|
|
3
3
|
import { IReceivableAvailabilityItemView } from '../models/ReceivableAvailabilityItem.model';
|
|
4
4
|
import { IPaginatorOptions } from '../interfaces/collaterals.interface';
|
|
5
5
|
import { IInventoryAvailabilitySummary, InventoryAvailabilityPaginators } from '../models/InventoryAvailability.model';
|
|
@@ -49,14 +49,14 @@ export declare class AvailabilityService {
|
|
|
49
49
|
private readonly signsService;
|
|
50
50
|
constructor(collateralAdjustmentsService: CollateralAdjustmentsService, collateralsService: CollateralsService, equipmentService: EquipmentService, inventoryAvailabilityService: InventoryAvailabilityService, loanStatementService: LoanStatementService, loanTransactionsService: LoanTransactionsService, manualEntryService: ManualEntryService, reserveService: ReserveService, signsService: SignsService);
|
|
51
51
|
recombineGroups(calculationsSettings: IAvailabilitySettings): Promise<IMappedSettings>;
|
|
52
|
-
calculateAvailability(bbcDateId: string, paginatorOptions: IPaginatorOptions, user:
|
|
53
|
-
getAvailability(bbcDateId: string, paginatorOptions: IPaginatorOptions, user:
|
|
52
|
+
calculateAvailability(bbcDateId: string, paginatorOptions: IPaginatorOptions, user: IUser): Promise<IReceivableAvailabilityView>;
|
|
53
|
+
getAvailability(bbcDateId: string, paginatorOptions: IPaginatorOptions, user: IUser): Promise<IReceivableAvailabilityView>;
|
|
54
54
|
getAvailabilityItemsWithFilter(bbcDateId: string, itemsFilter: string): Promise<{
|
|
55
55
|
itemsFilter: any;
|
|
56
56
|
invoiceItems: any[];
|
|
57
57
|
customerItems: any[];
|
|
58
58
|
}>;
|
|
59
|
-
foundOrCreateAvailability(bbcDateId: string, paginatorOptions: IPaginatorOptions, user:
|
|
59
|
+
foundOrCreateAvailability(bbcDateId: string, paginatorOptions: IPaginatorOptions, user: IUser): Promise<IReceivableAvailabilityView>;
|
|
60
60
|
findCalculatedAvailability(bbcDateId: string): Promise<IReceivableAvailabilityView>;
|
|
61
61
|
saveCalculatedAvailabilitySettings(bbcDateId: string, settings: IAvailabilitySettings): Promise<void>;
|
|
62
62
|
saveLimitSettings(bbcDateId: string, limitSettings: {
|
|
@@ -70,7 +70,7 @@ export declare class AvailabilityService {
|
|
|
70
70
|
getUniqueCustomers(availabilityId: string): Promise<{
|
|
71
71
|
customerTitle: string;
|
|
72
72
|
}[]>;
|
|
73
|
-
getAllSummaries(bbcDateId: string, user:
|
|
73
|
+
getAllSummaries(bbcDateId: string, user: IUser): Promise<IAvailabilityFullSummary>;
|
|
74
74
|
isBBCEditable(bbcDateId: string): Promise<boolean>;
|
|
75
75
|
toggleManualReceivableAvailability(bbcDateId: string, useManualInputs: boolean): Promise<void>;
|
|
76
76
|
}
|
|
@@ -91,7 +91,7 @@ class AvailabilityService {
|
|
|
91
91
|
const calculation = {
|
|
92
92
|
borrowerId: null,
|
|
93
93
|
bbcDateId: new mongoose_1.default.Types.ObjectId(bbcDateId),
|
|
94
|
-
userCalculatedId: user?.
|
|
94
|
+
userCalculatedId: user?.id ? new mongoose_1.default.Types.ObjectId(String(user.id)) : null,
|
|
95
95
|
calculatedAt: new Date(),
|
|
96
96
|
actual: true,
|
|
97
97
|
settings: calculationsSettings,
|
|
@@ -14,7 +14,7 @@ import {
|
|
|
14
14
|
IAvailabilitySummary,
|
|
15
15
|
IReceivableAvailabilityView,
|
|
16
16
|
} from '../models/ReceivableAvailability.model';
|
|
17
|
-
import {
|
|
17
|
+
import { IUser } from '../interfaces/auth-user.interface';
|
|
18
18
|
import { roundToXDigits } from '../helpers/numbers.helper';
|
|
19
19
|
import { AccountPayableItemModel } from '../models/AccountPayableItem.model';
|
|
20
20
|
import { ECollaterals } from '../enums/collaterals.enum';
|
|
@@ -34,7 +34,6 @@ import { IInventoryAvailabilitySummary, InventoryAvailabilityPaginators } from '
|
|
|
34
34
|
import { getBBCSheetsByType } from '../db/bbcSheets.db';
|
|
35
35
|
import { CustomerGroupModel } from '../models/CustomerGroup.model';
|
|
36
36
|
import { getPartialPaid } from '../queries/receivable/partially-paid-restated';
|
|
37
|
-
|
|
38
37
|
import MappedGroup from '../models/MappedGroup.model';
|
|
39
38
|
import CustomerAPGroup from '../models/CustomerAPGroup.model';
|
|
40
39
|
import { getReserveDocs } from '../db/reserve.db';
|
|
@@ -151,7 +150,7 @@ export class AvailabilityService {
|
|
|
151
150
|
return groupedSettings;
|
|
152
151
|
}
|
|
153
152
|
|
|
154
|
-
async calculateAvailability(bbcDateId: string, paginatorOptions: IPaginatorOptions, user:
|
|
153
|
+
async calculateAvailability(bbcDateId: string, paginatorOptions: IPaginatorOptions, user: IUser): Promise<IReceivableAvailabilityView> {
|
|
155
154
|
|
|
156
155
|
const calculationsSettings = await this.getCalculationSettings(bbcDateId);
|
|
157
156
|
|
|
@@ -161,7 +160,7 @@ export class AvailabilityService {
|
|
|
161
160
|
const calculation: IReceivableAvailability = {
|
|
162
161
|
borrowerId: null,
|
|
163
162
|
bbcDateId: new mongoose.Types.ObjectId(bbcDateId),
|
|
164
|
-
userCalculatedId: user?.
|
|
163
|
+
userCalculatedId: user?.id ? new mongoose.Types.ObjectId(String(user.id)) : null,
|
|
165
164
|
calculatedAt: new Date(),
|
|
166
165
|
actual: true,
|
|
167
166
|
settings: calculationsSettings,
|
|
@@ -560,7 +559,7 @@ export class AvailabilityService {
|
|
|
560
559
|
return await this.getAvailability(bbcDateId, paginatorOptions, user);
|
|
561
560
|
}
|
|
562
561
|
|
|
563
|
-
async getAvailability(bbcDateId: string, paginatorOptions: IPaginatorOptions, user:
|
|
562
|
+
async getAvailability(bbcDateId: string, paginatorOptions: IPaginatorOptions, user: IUser) {
|
|
564
563
|
return await this.foundOrCreateAvailability(bbcDateId, paginatorOptions, user);
|
|
565
564
|
}
|
|
566
565
|
|
|
@@ -655,7 +654,7 @@ export class AvailabilityService {
|
|
|
655
654
|
return { itemsFilter: filterField, invoiceItems, customerItems: customerItemsWithTotal };
|
|
656
655
|
}
|
|
657
656
|
|
|
658
|
-
async foundOrCreateAvailability(bbcDateId: string, paginatorOptions: IPaginatorOptions, user:
|
|
657
|
+
async foundOrCreateAvailability(bbcDateId: string, paginatorOptions: IPaginatorOptions, user: IUser) {
|
|
659
658
|
const foundAvailability = await this.findCalculatedAvailability(bbcDateId);
|
|
660
659
|
if (foundAvailability) {
|
|
661
660
|
foundAvailability.items = await this.getAvailabilityItems(foundAvailability._id.toString(), paginatorOptions);
|
|
@@ -989,7 +988,7 @@ export class AvailabilityService {
|
|
|
989
988
|
]);
|
|
990
989
|
}
|
|
991
990
|
|
|
992
|
-
async getAllSummaries(bbcDateId: string, user:
|
|
991
|
+
async getAllSummaries(bbcDateId: string, user: IUser): Promise<IAvailabilityFullSummary> {
|
|
993
992
|
const equipment = await this.equipmentService.getEquipmentForBBC(bbcDateId);
|
|
994
993
|
const reserve = await this.reserveService.getReserve(bbcDateId);
|
|
995
994
|
const loanBalances = await this.loanTransactionsService.getLoanBalanceForBBCDateId(bbcDateId);
|
|
@@ -26,7 +26,7 @@ import mongoose from 'mongoose';
|
|
|
26
26
|
import { IEmailRecipient } from '../models/ComplianceItem.model';
|
|
27
27
|
import { IGroupedEmailsUpdate } from '../interfaces/email-addresses.interface';
|
|
28
28
|
import { IComplianceBorrowerDocument, IComplianceBorrowerDocumentFull } from '../models/BorrowerCompliance.model';
|
|
29
|
-
import {
|
|
29
|
+
import { IUser } from '../interfaces/auth-user.interface';
|
|
30
30
|
import { FileManagerService } from './file-manager.service';
|
|
31
31
|
import { UploadsService } from './uploads.service';
|
|
32
32
|
export declare class ComplianceBorrowersService {
|
|
@@ -45,7 +45,7 @@ export declare class ComplianceBorrowersService {
|
|
|
45
45
|
};
|
|
46
46
|
};
|
|
47
47
|
getFullComplianceBorrowerById(complianceBorrowerId: any): Promise<any>;
|
|
48
|
-
getAllBorrowersShortened(userAccess: any): Promise<(Pick<IComplianceBorrowerDocument, "
|
|
48
|
+
getAllBorrowersShortened(userAccess: any): Promise<(Pick<IComplianceBorrowerDocument, "items" | "borrower" | "fundingStatus"> | {
|
|
49
49
|
items: {
|
|
50
50
|
instances: any[];
|
|
51
51
|
item: import("../models/ComplianceItem.model").IComplianceItemDocument;
|
|
@@ -148,5 +148,5 @@ export declare class ComplianceBorrowersService {
|
|
|
148
148
|
toggleComplianceBorrowerVisibility(borrowerId: string, isVisible: boolean): Promise<void>;
|
|
149
149
|
createComplianceBorrower(borrowerId: string, isVisible?: boolean): Promise<void>;
|
|
150
150
|
removeIncorrectBorrowers(): Promise<void>;
|
|
151
|
-
getBorrowerListReport(user:
|
|
151
|
+
getBorrowerListReport(user: IUser): Promise<any>;
|
|
152
152
|
}
|
|
@@ -536,7 +536,7 @@ class ComplianceBorrowersService {
|
|
|
536
536
|
async getBorrowerListReport(user) {
|
|
537
537
|
const userFilter = user.allBorrowers
|
|
538
538
|
? { isVisible: true }
|
|
539
|
-
: { 'borrower': { $in: user.borrowersAccess
|
|
539
|
+
: { 'borrower': { $in: user.borrowersAccess }, isVisible: true };
|
|
540
540
|
const borrowers = await BorrowerCompliance_model_1.BorrowerCompliance
|
|
541
541
|
.find(userFilter)
|
|
542
542
|
.populate('borrower')
|
|
@@ -11,8 +11,7 @@ import {
|
|
|
11
11
|
IComplianceBorrowerDocumentFull,
|
|
12
12
|
} from '../models/BorrowerCompliance.model';
|
|
13
13
|
import { BorrowerModel } from '../models/Borrower.model';
|
|
14
|
-
import {
|
|
15
|
-
|
|
14
|
+
import { IUser } from '../interfaces/auth-user.interface';
|
|
16
15
|
import FinancialComplianceBorrower from '../models/FinancialComplianceBorrower.model';
|
|
17
16
|
import { FileManagerService } from './file-manager.service';
|
|
18
17
|
import { UploadsService } from './uploads.service';
|
|
@@ -580,10 +579,10 @@ export class ComplianceBorrowersService {
|
|
|
580
579
|
}
|
|
581
580
|
}
|
|
582
581
|
|
|
583
|
-
async getBorrowerListReport(user:
|
|
582
|
+
async getBorrowerListReport(user: IUser) {
|
|
584
583
|
const userFilter = user.allBorrowers
|
|
585
584
|
? { isVisible: true }
|
|
586
|
-
: { 'borrower': { $in: user.borrowersAccess
|
|
585
|
+
: { 'borrower': { $in: user.borrowersAccess }, isVisible: true };
|
|
587
586
|
const borrowers = await BorrowerCompliance
|
|
588
587
|
.find(userFilter)
|
|
589
588
|
.populate('borrower')
|
|
@@ -24,7 +24,6 @@
|
|
|
24
24
|
/// <reference types="mongoose/types/inferschematype" />
|
|
25
25
|
import mongoose, { Document } from 'mongoose';
|
|
26
26
|
import { IResult } from '../interfaces/result.interface';
|
|
27
|
-
import { IUserLegacyDoc } from '../models/User.model';
|
|
28
27
|
import { IAvailabilitySignView } from '../models/AvailabilitySigns.model';
|
|
29
28
|
import { IBBCDateDoc } from '../models/BBCDate.model';
|
|
30
29
|
import { IBorrowerDocument } from '../models/Borrower.model';
|
|
@@ -49,12 +48,12 @@ export declare class SignsService {
|
|
|
49
48
|
private readonly loanStatementService;
|
|
50
49
|
private readonly usersService;
|
|
51
50
|
constructor(lockService: LockService, loanTransactionsService: LoanTransactionsService, loanStatementService: LoanStatementService, usersService: UsersService);
|
|
52
|
-
|
|
51
|
+
users: IUser[];
|
|
53
52
|
fulfillUserList(): Promise<void>;
|
|
54
53
|
clearUserList(): void;
|
|
55
54
|
getAvailabilitySigns(bbcDateId: string): Promise<IAvailabilitySignView>;
|
|
56
55
|
revokeAvailability(bbcDateId: string, userId: string, userIdRevoked: string): Promise<void>;
|
|
57
|
-
signAvailability(bbcDateId: string, user:
|
|
56
|
+
signAvailability(bbcDateId: string, user: IUser): Promise<IResult>;
|
|
58
57
|
isBBCLocked(bbcDateId: string): Promise<boolean>;
|
|
59
58
|
getLatestSignedBBCDate(borrowerId: string, date?: Date): Promise<IBBCDateDoc>;
|
|
60
59
|
getSavedData(bbcDateId: string): Promise<any>;
|
|
@@ -32,12 +32,12 @@ class SignsService {
|
|
|
32
32
|
this.loanStatementService = loanStatementService;
|
|
33
33
|
this.usersService = usersService;
|
|
34
34
|
}
|
|
35
|
-
|
|
35
|
+
users = null;
|
|
36
36
|
async fulfillUserList() {
|
|
37
|
-
this.
|
|
37
|
+
this.users = await this.usersService.getUserList();
|
|
38
38
|
}
|
|
39
39
|
clearUserList() {
|
|
40
|
-
this.
|
|
40
|
+
this.users = null;
|
|
41
41
|
}
|
|
42
42
|
async getAvailabilitySigns(bbcDateId) {
|
|
43
43
|
const availabilitiesSigns = await (0, availability_db_1.getAvailabilitySigns)([bbcDateId]);
|
|
@@ -50,7 +50,7 @@ class SignsService {
|
|
|
50
50
|
};
|
|
51
51
|
}
|
|
52
52
|
const availabilitySigns = availabilitiesSigns[0];
|
|
53
|
-
let keyCloakUsers = this.
|
|
53
|
+
let keyCloakUsers = this.users;
|
|
54
54
|
if (!keyCloakUsers) {
|
|
55
55
|
keyCloakUsers = await this.usersService.getUserList();
|
|
56
56
|
}
|
|
@@ -58,14 +58,14 @@ class SignsService {
|
|
|
58
58
|
if (!userSign.userSigned) {
|
|
59
59
|
return acc;
|
|
60
60
|
}
|
|
61
|
-
const foundUserSigned = keyCloakUsers.find((user) => user.id === userSign.userSigned.
|
|
61
|
+
const foundUserSigned = keyCloakUsers.find((user) => user.id === userSign.userSigned.id);
|
|
62
62
|
if (foundUserSigned) {
|
|
63
63
|
userSign.userSigned.firstName = foundUserSigned.firstName;
|
|
64
64
|
userSign.userSigned.lastName = foundUserSigned.lastName;
|
|
65
65
|
}
|
|
66
66
|
userSign.userSigned = (lodash_1.default.pick(userSign.userSigned, ['_id', 'firstName', 'lastName']));
|
|
67
67
|
if (userSign.userRevoked) {
|
|
68
|
-
const foundUserRevoked = keyCloakUsers.find((user) => user.id === userSign.userRevoked.
|
|
68
|
+
const foundUserRevoked = keyCloakUsers.find((user) => user.id === userSign.userRevoked.id);
|
|
69
69
|
if (foundUserRevoked) {
|
|
70
70
|
userSign.userRevoked.firstName = foundUserRevoked.firstName;
|
|
71
71
|
userSign.userRevoked.lastName = foundUserRevoked.lastName;
|
|
@@ -80,16 +80,15 @@ class SignsService {
|
|
|
80
80
|
const availability = await (0, availability_db_1.findAvailabilitySignsByBBCDateId)(bbcDateId);
|
|
81
81
|
const updatedSigns = availability.signs.map((sign) => {
|
|
82
82
|
if (sign.userSignedId.toString() === userId && !sign.revokedAt) {
|
|
83
|
-
sign.userRevokedId =
|
|
83
|
+
sign.userRevokedId = userIdRevoked;
|
|
84
84
|
sign.revokedAt = new Date();
|
|
85
|
-
sign.userRevokedId = new mongoose_1.default.Types.ObjectId(userIdRevoked);
|
|
86
85
|
}
|
|
87
86
|
return sign;
|
|
88
87
|
});
|
|
89
88
|
await (0, availability_db_1.updateAvailabilitySigns)(bbcDateId, updatedSigns);
|
|
90
89
|
}
|
|
91
90
|
async signAvailability(bbcDateId, user) {
|
|
92
|
-
const newSign = { userSignedId: user.
|
|
91
|
+
const newSign = { userSignedId: user.id, signedAt: new Date() };
|
|
93
92
|
return await (0, availability_db_1.addAvailabilitySign)(bbcDateId, newSign);
|
|
94
93
|
}
|
|
95
94
|
async isBBCLocked(bbcDateId) {
|
|
@@ -8,7 +8,6 @@ import {
|
|
|
8
8
|
getAvailabilitySigns,
|
|
9
9
|
updateAvailabilitySigns,
|
|
10
10
|
} from '../db/availability.db';
|
|
11
|
-
import { IUserLegacyDoc } from '../models/User.model';
|
|
12
11
|
import {
|
|
13
12
|
AvailabilitySignsModel,
|
|
14
13
|
IAvailabilitySignItem,
|
|
@@ -51,14 +50,14 @@ export class SignsService {
|
|
|
51
50
|
) {
|
|
52
51
|
}
|
|
53
52
|
|
|
54
|
-
|
|
53
|
+
users: IUser[] = null;
|
|
55
54
|
|
|
56
55
|
async fulfillUserList() {
|
|
57
|
-
this.
|
|
56
|
+
this.users = await this.usersService.getUserList();
|
|
58
57
|
}
|
|
59
58
|
|
|
60
59
|
clearUserList() {
|
|
61
|
-
this.
|
|
60
|
+
this.users = null;
|
|
62
61
|
}
|
|
63
62
|
|
|
64
63
|
async getAvailabilitySigns(bbcDateId: string): Promise<IAvailabilitySignView> {
|
|
@@ -72,7 +71,7 @@ export class SignsService {
|
|
|
72
71
|
};
|
|
73
72
|
}
|
|
74
73
|
const availabilitySigns = availabilitiesSigns[0];
|
|
75
|
-
let keyCloakUsers = this.
|
|
74
|
+
let keyCloakUsers = this.users;
|
|
76
75
|
if (!keyCloakUsers) {
|
|
77
76
|
keyCloakUsers = await this.usersService.getUserList();
|
|
78
77
|
}
|
|
@@ -80,19 +79,19 @@ export class SignsService {
|
|
|
80
79
|
if (!userSign.userSigned) {
|
|
81
80
|
return acc;
|
|
82
81
|
}
|
|
83
|
-
const foundUserSigned = keyCloakUsers.find((user) => user.id === userSign.userSigned.
|
|
82
|
+
const foundUserSigned = keyCloakUsers.find((user) => user.id === userSign.userSigned.id);
|
|
84
83
|
if (foundUserSigned) {
|
|
85
84
|
userSign.userSigned.firstName = foundUserSigned.firstName;
|
|
86
85
|
userSign.userSigned.lastName = foundUserSigned.lastName;
|
|
87
86
|
}
|
|
88
|
-
userSign.userSigned = (_.pick(userSign.userSigned, ['_id', 'firstName', 'lastName'])) as
|
|
87
|
+
userSign.userSigned = (_.pick(userSign.userSigned, ['_id', 'firstName', 'lastName'])) as IUser;
|
|
89
88
|
if (userSign.userRevoked) {
|
|
90
|
-
const foundUserRevoked = keyCloakUsers.find((user) => user.id === userSign.userRevoked.
|
|
89
|
+
const foundUserRevoked = keyCloakUsers.find((user) => user.id === userSign.userRevoked.id);
|
|
91
90
|
if (foundUserRevoked) {
|
|
92
91
|
userSign.userRevoked.firstName = foundUserRevoked.firstName;
|
|
93
92
|
userSign.userRevoked.lastName = foundUserRevoked.lastName;
|
|
94
93
|
}
|
|
95
|
-
userSign.userRevoked = (_.pick(userSign.userRevoked, ['_id', 'firstName', 'lastName'])) as
|
|
94
|
+
userSign.userRevoked = (_.pick(userSign.userRevoked, ['_id', 'firstName', 'lastName'])) as IUser;
|
|
96
95
|
}
|
|
97
96
|
return [...acc, _.pick(userSign, ['userSigned', 'signedAt', 'userRevoked', 'revokedAt'])];
|
|
98
97
|
}, []);
|
|
@@ -103,17 +102,16 @@ export class SignsService {
|
|
|
103
102
|
const availability = await findAvailabilitySignsByBBCDateId(bbcDateId);
|
|
104
103
|
const updatedSigns = availability.signs.map((sign) => {
|
|
105
104
|
if (sign.userSignedId.toString() === userId && !sign.revokedAt) {
|
|
106
|
-
sign.userRevokedId =
|
|
105
|
+
sign.userRevokedId = userIdRevoked;
|
|
107
106
|
sign.revokedAt = new Date();
|
|
108
|
-
sign.userRevokedId = new mongoose.Types.ObjectId(userIdRevoked);
|
|
109
107
|
}
|
|
110
108
|
return sign;
|
|
111
109
|
});
|
|
112
110
|
await updateAvailabilitySigns(bbcDateId, updatedSigns);
|
|
113
111
|
}
|
|
114
112
|
|
|
115
|
-
async signAvailability(bbcDateId: string, user:
|
|
116
|
-
const newSign = <IAvailabilitySignItem>{ userSignedId: user.
|
|
113
|
+
async signAvailability(bbcDateId: string, user: IUser): Promise<IResult> {
|
|
114
|
+
const newSign = <IAvailabilitySignItem>{ userSignedId: user.id, signedAt: new Date() };
|
|
117
115
|
return await addAvailabilitySign(bbcDateId, newSign);
|
|
118
116
|
}
|
|
119
117
|
|