gemcap-be-common 1.3.187 → 1.4.2
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/interfaces/auth-user.interface.d.ts +21 -0
- package/interfaces/auth-user.interface.ts +22 -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 +2 -2
- package/models/ReceivableAvailability.model.ts +2 -2
- package/models/User.model.d.ts +3 -3
- package/models/User.model.ts +3 -3
- package/models/_index.d.ts +3 -3
- 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/borrowers.db.d.ts +1 -1
- package/services/borrowers.db.js +1 -1
- package/services/borrowers.db.ts +2 -2
- package/services/borrowers.service.d.ts +5 -4
- package/services/borrowers.service.js +8 -5
- package/services/borrowers.service.ts +9 -5
- package/services/compliance-borrowers.service.d.ts +1 -1
- package/services/compliance-borrowers.service.js +1 -1
- package/services/compliance-borrowers.service.ts +2 -3
- package/services/loan-payments.service.d.ts +3 -1
- package/services/loan-payments.service.js +5 -4
- package/services/loan-payments.service.ts +4 -3
- package/services/nodemailer.service.d.ts +0 -2
- package/services/nodemailer.service.js +0 -28
- package/services/nodemailer.service.ts +0 -35
- package/services/signs.service.d.ts +3 -4
- package/services/signs.service.js +9 -12
- package/services/signs.service.ts +13 -18
- package/services/uploads.service.d.ts +3 -1
- package/services/uploads.service.js +4 -3
- package/services/uploads.service.ts +3 -2
- package/services/users.service.d.ts +15 -137
- package/services/users.service.js +81 -349
- package/services/users.service.ts +88 -380
- package/tsconfig.tsbuildinfo +1 -1
- package/interfaces/keycloak-role.interface.d.ts +0 -14
- package/interfaces/keycloak-role.interface.ts +0 -16
- package/interfaces/keycloak-user.interface.d.ts +0 -31
- package/interfaces/keycloak-user.interface.js +0 -2
- package/interfaces/keycloak-user.interface.ts +0 -30
- /package/interfaces/{keycloak-role.interface.js → auth-user.interface.js} +0 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export interface IUserBasic {
|
|
2
|
+
id: string;
|
|
3
|
+
username: string;
|
|
4
|
+
email: string | null;
|
|
5
|
+
firstName: string | null;
|
|
6
|
+
lastName: string | null;
|
|
7
|
+
}
|
|
8
|
+
export interface IUser extends IUserBasic {
|
|
9
|
+
createdAt?: Date;
|
|
10
|
+
updatedAt?: Date;
|
|
11
|
+
passwordResetTokenHash?: string | null;
|
|
12
|
+
passwordResetExpires?: Date | null;
|
|
13
|
+
refreshTokenHash?: string | null;
|
|
14
|
+
refreshTokenExpires?: Date | null;
|
|
15
|
+
roles?: Record<string, string[]>;
|
|
16
|
+
deletedAt?: Date | null;
|
|
17
|
+
isEnabled?: boolean;
|
|
18
|
+
allBorrowers?: boolean;
|
|
19
|
+
borrowersAccess?: string[];
|
|
20
|
+
lastLogin?: Date | null;
|
|
21
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
export interface IUserBasic {
|
|
2
|
+
id: string;
|
|
3
|
+
username: string;
|
|
4
|
+
email: string | null;
|
|
5
|
+
firstName: string | null;
|
|
6
|
+
lastName: string | null;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export interface IUser extends IUserBasic {
|
|
10
|
+
createdAt?: Date;
|
|
11
|
+
updatedAt?: Date;
|
|
12
|
+
passwordResetTokenHash?: string | null;
|
|
13
|
+
passwordResetExpires?: Date | null;
|
|
14
|
+
refreshTokenHash?: string | null;
|
|
15
|
+
refreshTokenExpires?: Date | null;
|
|
16
|
+
roles?: Record<string, string[]>;
|
|
17
|
+
deletedAt?: Date | null;
|
|
18
|
+
isEnabled?: boolean;
|
|
19
|
+
allBorrowers?: boolean;
|
|
20
|
+
borrowersAccess?: string[];
|
|
21
|
+
lastLogin?: Date | null;
|
|
22
|
+
}
|
|
@@ -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: {
|
|
@@ -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/User.model.d.ts
CHANGED
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
/// <reference types="mongoose/types/virtuals" />
|
|
24
24
|
/// <reference types="mongoose/types/inferschematype" />
|
|
25
25
|
import mongoose, { Document } from 'mongoose';
|
|
26
|
-
export interface
|
|
26
|
+
export interface IUserLegacy {
|
|
27
27
|
isDeleted?: boolean;
|
|
28
28
|
firstName?: string;
|
|
29
29
|
lastName?: string;
|
|
@@ -34,7 +34,7 @@ export interface IUser {
|
|
|
34
34
|
borrower: string;
|
|
35
35
|
}[];
|
|
36
36
|
}
|
|
37
|
-
export interface
|
|
37
|
+
export interface IUserLegacyDoc extends IUserLegacy, Document {
|
|
38
38
|
}
|
|
39
39
|
export declare const UserSchema: mongoose.Schema<any, mongoose.Model<any, any, any, any, any, any>, {}, {}, {}, {}, {
|
|
40
40
|
timestamps: true;
|
|
@@ -83,4 +83,4 @@ export declare const UserSchema: mongoose.Schema<any, mongoose.Model<any, any, a
|
|
|
83
83
|
}> & {
|
|
84
84
|
_id: mongoose.Types.ObjectId;
|
|
85
85
|
}>;
|
|
86
|
-
export declare const UserModel: mongoose.Model<
|
|
86
|
+
export declare const UserModel: mongoose.Model<IUserLegacyDoc>;
|
package/models/User.model.ts
CHANGED
|
@@ -4,7 +4,7 @@ import { MODEL_NAMES } from './_models';
|
|
|
4
4
|
|
|
5
5
|
const mongooseLeanId = require('../plugins/id.plugin');
|
|
6
6
|
|
|
7
|
-
export interface
|
|
7
|
+
export interface IUserLegacy {
|
|
8
8
|
isDeleted?: boolean;
|
|
9
9
|
firstName?: string;
|
|
10
10
|
lastName?: string;
|
|
@@ -16,7 +16,7 @@ export interface IUser {
|
|
|
16
16
|
}[];
|
|
17
17
|
}
|
|
18
18
|
|
|
19
|
-
export interface
|
|
19
|
+
export interface IUserLegacyDoc extends IUserLegacy, Document {
|
|
20
20
|
}
|
|
21
21
|
|
|
22
22
|
export const UserSchema = new mongoose.Schema(
|
|
@@ -63,4 +63,4 @@ export const UserSchema = new mongoose.Schema(
|
|
|
63
63
|
|
|
64
64
|
UserSchema.plugin(mongooseLeanId);
|
|
65
65
|
|
|
66
|
-
export const UserModel: mongoose.Model<
|
|
66
|
+
export const UserModel: mongoose.Model<IUserLegacyDoc> = mongoose.model<IUserLegacyDoc>(MODEL_NAMES.users, UserSchema);
|
package/models/_index.d.ts
CHANGED
|
@@ -31,8 +31,8 @@ export declare const allSchemas: {
|
|
|
31
31
|
createdAt: NativeDate;
|
|
32
32
|
updatedAt: NativeDate;
|
|
33
33
|
} & {
|
|
34
|
-
order: number;
|
|
35
34
|
bbcSheetId: import("mongoose").Types.ObjectId;
|
|
35
|
+
order: number;
|
|
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
|
-
order: number;
|
|
49
48
|
bbcSheetId: import("mongoose").Types.ObjectId;
|
|
49
|
+
order: number;
|
|
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
|
-
order: number;
|
|
63
62
|
bbcSheetId: import("mongoose").Types.ObjectId;
|
|
63
|
+
order: number;
|
|
64
64
|
apDate: Date;
|
|
65
65
|
amount: number;
|
|
66
66
|
__v?: number;
|
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);
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
/// <reference types="mongoose/types/virtuals" />
|
|
24
24
|
/// <reference types="mongoose" />
|
|
25
25
|
/// <reference types="mongoose/types/inferschematype" />
|
|
26
|
-
import { IUser } from '../
|
|
26
|
+
import { IUser } from '../interfaces/auth-user.interface';
|
|
27
27
|
export declare class BorrowersDB {
|
|
28
28
|
getAllBorrowers(): Promise<(import("mongoose").FlattenMaps<import("../models/Borrower.model").IBorrowerDocument> & {
|
|
29
29
|
_id: import("mongoose").Types.ObjectId;
|
package/services/borrowers.db.js
CHANGED
|
@@ -11,7 +11,7 @@ class BorrowersDB {
|
|
|
11
11
|
}
|
|
12
12
|
async getAllowedBorrowers(user) {
|
|
13
13
|
return Borrower_model_1.BorrowerModel
|
|
14
|
-
.find(user.allBorrowers ? {} : { '_id': { $in: user.borrowersAccess
|
|
14
|
+
.find(user.allBorrowers ? {} : { '_id': { $in: user.borrowersAccess } })
|
|
15
15
|
.collation({ locale: 'en' })
|
|
16
16
|
.sort({ code: 1 })
|
|
17
17
|
.lean();
|
package/services/borrowers.db.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { BorrowerModel } from '../models/Borrower.model';
|
|
2
|
-
import { IUser } from '../
|
|
2
|
+
import { IUser } from '../interfaces/auth-user.interface';
|
|
3
3
|
|
|
4
4
|
export class BorrowersDB {
|
|
5
5
|
async getAllBorrowers() {
|
|
@@ -12,7 +12,7 @@ export class BorrowersDB {
|
|
|
12
12
|
|
|
13
13
|
async getAllowedBorrowers(user: IUser) {
|
|
14
14
|
return BorrowerModel
|
|
15
|
-
.find(user.allBorrowers ? {} : { '_id': { $in: user.borrowersAccess
|
|
15
|
+
.find(user.allBorrowers ? {} : { '_id': { $in: user.borrowersAccess } })
|
|
16
16
|
.collation({ locale: 'en' })
|
|
17
17
|
.sort({ code: 1 })
|
|
18
18
|
.lean();
|
|
@@ -30,6 +30,7 @@ import { CollateralsService } from './collaterals.service';
|
|
|
30
30
|
import { LoanStatementStatusService } from './loan-statement-status.service';
|
|
31
31
|
import { LoanTransactionsService } from './loan-transactions.service';
|
|
32
32
|
import { SignsService } from './signs.service';
|
|
33
|
+
import { IUser } from '../interfaces/auth-user.interface';
|
|
33
34
|
export declare const borrowerDataModels: {
|
|
34
35
|
[modelName: string]: mongoose.Model<any>;
|
|
35
36
|
};
|
|
@@ -39,8 +40,8 @@ export declare class BorrowerService {
|
|
|
39
40
|
private readonly getLoanTransactionsService;
|
|
40
41
|
private readonly getSignsService;
|
|
41
42
|
constructor(getCollateralsService: () => CollateralsService, getLoanStatementStatusService: () => LoanStatementStatusService, getLoanTransactionsService: () => LoanTransactionsService, getSignsService: () => SignsService);
|
|
42
|
-
isBorrowerAllowed(
|
|
43
|
-
checkBorrower(
|
|
43
|
+
isBorrowerAllowed(user: IUser, requestedBorrowerId: string): boolean;
|
|
44
|
+
checkBorrower(user: IUser, requestedBorrowerId: string): boolean;
|
|
44
45
|
getBorrowerById(borrowerId: string): Promise<mongoose.FlattenMaps<IBorrowerDocument> & {
|
|
45
46
|
_id: mongoose.Types.ObjectId;
|
|
46
47
|
}>;
|
|
@@ -83,10 +84,10 @@ export declare class BorrowerService {
|
|
|
83
84
|
getBorrowerCodesMap(): Promise<Map<string, string>>;
|
|
84
85
|
getBorrowerStatementDetails(borrowers: IBorrowerDocument[]): Promise<{
|
|
85
86
|
[x: number]: {
|
|
86
|
-
SELECTED_PERIOD?: boolean;
|
|
87
|
-
ENTIRE_LOAN?: boolean;
|
|
88
87
|
LAST_MONTH?: boolean;
|
|
89
88
|
CURRENT_MONTH?: boolean;
|
|
89
|
+
ENTIRE_LOAN?: boolean;
|
|
90
|
+
SELECTED_PERIOD?: boolean;
|
|
90
91
|
TERM_LOAN?: boolean;
|
|
91
92
|
};
|
|
92
93
|
}>;
|
|
@@ -39,14 +39,17 @@ class BorrowerService {
|
|
|
39
39
|
this.getLoanTransactionsService = getLoanTransactionsService;
|
|
40
40
|
this.getSignsService = getSignsService;
|
|
41
41
|
}
|
|
42
|
-
isBorrowerAllowed(
|
|
43
|
-
if (
|
|
42
|
+
isBorrowerAllowed(user, requestedBorrowerId) {
|
|
43
|
+
if (!user) {
|
|
44
|
+
return false;
|
|
45
|
+
}
|
|
46
|
+
if (user.allBorrowers) {
|
|
44
47
|
return true;
|
|
45
48
|
}
|
|
46
|
-
return
|
|
49
|
+
return user.borrowersAccess?.includes(requestedBorrowerId);
|
|
47
50
|
}
|
|
48
|
-
checkBorrower(
|
|
49
|
-
const allowedBorrower = this.isBorrowerAllowed(
|
|
51
|
+
checkBorrower(user, requestedBorrowerId) {
|
|
52
|
+
const allowedBorrower = this.isBorrowerAllowed(user, requestedBorrowerId);
|
|
50
53
|
if (!allowedBorrower) {
|
|
51
54
|
throw new Error('Non allowed borrower');
|
|
52
55
|
}
|
|
@@ -24,6 +24,7 @@ import { CollateralsService } from './collaterals.service';
|
|
|
24
24
|
import { LoanStatementStatusService } from './loan-statement-status.service';
|
|
25
25
|
import { LoanTransactionsService } from './loan-transactions.service';
|
|
26
26
|
import { SignsService } from './signs.service';
|
|
27
|
+
import { IUser } from '../interfaces/auth-user.interface';
|
|
27
28
|
|
|
28
29
|
export const borrowerDataModels: {
|
|
29
30
|
[modelName: string]: mongoose.Model<any>
|
|
@@ -50,15 +51,18 @@ export class BorrowerService {
|
|
|
50
51
|
}
|
|
51
52
|
|
|
52
53
|
|
|
53
|
-
isBorrowerAllowed(
|
|
54
|
-
if (
|
|
54
|
+
isBorrowerAllowed(user: IUser, requestedBorrowerId: string): boolean {
|
|
55
|
+
if (!user) {
|
|
56
|
+
return false;
|
|
57
|
+
}
|
|
58
|
+
if (user.allBorrowers) {
|
|
55
59
|
return true;
|
|
56
60
|
}
|
|
57
|
-
return
|
|
61
|
+
return user.borrowersAccess?.includes(requestedBorrowerId);
|
|
58
62
|
}
|
|
59
63
|
|
|
60
|
-
checkBorrower(
|
|
61
|
-
const allowedBorrower = this.isBorrowerAllowed(
|
|
64
|
+
checkBorrower(user: IUser, requestedBorrowerId: string): boolean {
|
|
65
|
+
const allowedBorrower = this.isBorrowerAllowed(user, requestedBorrowerId);
|
|
62
66
|
if (!allowedBorrower) {
|
|
63
67
|
throw new Error('Non allowed borrower');
|
|
64
68
|
}
|
|
@@ -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 { IUser } from '../
|
|
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 {
|
|
@@ -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 { IUser } from '../
|
|
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';
|
|
@@ -583,7 +582,7 @@ export class ComplianceBorrowersService {
|
|
|
583
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')
|
|
@@ -37,6 +37,7 @@ import { LoanStatementStatusService } from './loan-statement-status.service';
|
|
|
37
37
|
import { LoanTransactionsService } from './loan-transactions.service';
|
|
38
38
|
import { TermLoanService } from './term-loan.service';
|
|
39
39
|
import { LockService } from './lock.service';
|
|
40
|
+
import { UsersService } from './users.service';
|
|
40
41
|
export declare const paymentOrder: ELoanChargeType[];
|
|
41
42
|
export declare class LoanPaymentsService {
|
|
42
43
|
private readonly redisClient;
|
|
@@ -50,7 +51,8 @@ export declare class LoanPaymentsService {
|
|
|
50
51
|
private readonly loanTransactionsService;
|
|
51
52
|
private readonly lockService;
|
|
52
53
|
private readonly termLoanService;
|
|
53
|
-
|
|
54
|
+
private readonly usersService;
|
|
55
|
+
constructor(redisClient: RedisClientType, borrowersDB: BorrowersDB, financialComplianceService: FinancialComplianceService, loanChargesService: LoanChargesService, loanProductsService: LoanProductsService, loanStatementBalanceService: LoanStatementBalanceService, getLoanStatementService: () => LoanStatementService, loanStatementStatusService: LoanStatementStatusService, loanTransactionsService: LoanTransactionsService, lockService: LockService, termLoanService: TermLoanService, usersService: UsersService);
|
|
54
56
|
getLoanPayment(paymentId: string): Promise<mongoose.FlattenMaps<ILoanPaymentDoc> & {
|
|
55
57
|
_id: mongoose.Types.ObjectId;
|
|
56
58
|
}>;
|
|
@@ -16,7 +16,6 @@ const collaterals_db_1 = require("../db/collaterals.db");
|
|
|
16
16
|
const LoanTransaction_model_1 = require("../models/LoanTransaction.model");
|
|
17
17
|
const LoanProducts_model_1 = require("../models/LoanProducts.model");
|
|
18
18
|
const Borrower_model_1 = require("../models/Borrower.model");
|
|
19
|
-
const User_model_1 = require("../models/User.model");
|
|
20
19
|
const LoanPayment_model_1 = require("../models/LoanPayment.model");
|
|
21
20
|
exports.paymentOrder = [
|
|
22
21
|
loan_charge_type_enum_1.ELoanChargeType.RECOVERABLE,
|
|
@@ -40,7 +39,8 @@ class LoanPaymentsService {
|
|
|
40
39
|
loanTransactionsService;
|
|
41
40
|
lockService;
|
|
42
41
|
termLoanService;
|
|
43
|
-
|
|
42
|
+
usersService;
|
|
43
|
+
constructor(redisClient, borrowersDB, financialComplianceService, loanChargesService, loanProductsService, loanStatementBalanceService, getLoanStatementService, loanStatementStatusService, loanTransactionsService, lockService, termLoanService, usersService) {
|
|
44
44
|
this.redisClient = redisClient;
|
|
45
45
|
this.borrowersDB = borrowersDB;
|
|
46
46
|
this.financialComplianceService = financialComplianceService;
|
|
@@ -52,6 +52,7 @@ class LoanPaymentsService {
|
|
|
52
52
|
this.loanTransactionsService = loanTransactionsService;
|
|
53
53
|
this.lockService = lockService;
|
|
54
54
|
this.termLoanService = termLoanService;
|
|
55
|
+
this.usersService = usersService;
|
|
55
56
|
}
|
|
56
57
|
async getLoanPayment(paymentId) {
|
|
57
58
|
return LoanPayment_model_1.LoanPaymentModel.findById(paymentId).lean();
|
|
@@ -399,7 +400,7 @@ class LoanPaymentsService {
|
|
|
399
400
|
}
|
|
400
401
|
}
|
|
401
402
|
async getExpectedPayments(userId) {
|
|
402
|
-
const user = await
|
|
403
|
+
const user = await this.usersService.getUserById(userId);
|
|
403
404
|
if (!user) {
|
|
404
405
|
return [];
|
|
405
406
|
}
|
|
@@ -429,7 +430,7 @@ class LoanPaymentsService {
|
|
|
429
430
|
return { message: 'Incorrect list of borrowers IDs' };
|
|
430
431
|
}
|
|
431
432
|
await this.redisClient.set(CALCULATION_VAR, 1);
|
|
432
|
-
const user = await
|
|
433
|
+
const user = await this.usersService.getUserById(userId);
|
|
433
434
|
if (!user) {
|
|
434
435
|
return { message: 'Cannot find user with this id' };
|
|
435
436
|
}
|