gemcap-be-common 1.1.91 → 1.1.92

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.
@@ -0,0 +1,6 @@
1
+ import { IAvailabilitySignDoc, IAvailabilitySignItem, IAvailabilitySignView } from '../models';
2
+ import { IResult } from '../interfaces';
3
+ export declare const findAvailabilitySignsByBBCDateId: (bbcDateId: string) => Promise<IAvailabilitySignDoc>;
4
+ export declare const getAvailabilitySigns: (bbcDateId: string) => Promise<IAvailabilitySignView[]>;
5
+ export declare const addAvailabilitySign: (bbcDateId: string, sign: IAvailabilitySignItem) => Promise<IResult>;
6
+ export declare const updateAvailabilitySigns: (bbcDateId: string, signs: IAvailabilitySignItem[]) => Promise<void>;
@@ -0,0 +1,97 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.updateAvailabilitySigns = exports.addAvailabilitySign = exports.getAvailabilitySigns = exports.findAvailabilitySignsByBBCDateId = void 0;
7
+ const mongoose_1 = __importDefault(require("mongoose"));
8
+ const models_1 = require("../models");
9
+ const findAvailabilitySignsByBBCDateId = async (bbcDateId) => {
10
+ return models_1.AvailabilitySign.findOne({ bbcDateId: new mongoose_1.default.Types.ObjectId(bbcDateId) }).lean();
11
+ };
12
+ exports.findAvailabilitySignsByBBCDateId = findAvailabilitySignsByBBCDateId;
13
+ const getAvailabilitySigns = async (bbcDateId) => {
14
+ return models_1.AvailabilitySign.aggregate([
15
+ {
16
+ $match: {
17
+ 'bbcDateId': new mongoose_1.default.Types.ObjectId(bbcDateId)
18
+ }
19
+ }, {
20
+ $unwind: {
21
+ path: '$signs',
22
+ preserveNullAndEmptyArrays: true
23
+ }
24
+ }, {
25
+ $lookup: {
26
+ from: 'users',
27
+ localField: 'signs.userSignedId',
28
+ foreignField: '_id',
29
+ as: 'signs.userSigned'
30
+ }
31
+ }, {
32
+ $lookup: {
33
+ from: 'users',
34
+ localField: 'signs.userRevokedId',
35
+ foreignField: '_id',
36
+ as: 'signs.userRevoked',
37
+ },
38
+ }, {
39
+ $unwind: {
40
+ path: '$signs.userSigned',
41
+ preserveNullAndEmptyArrays: true
42
+ }
43
+ }, {
44
+ $unwind: {
45
+ path: '$signs.userRevoked',
46
+ preserveNullAndEmptyArrays: true,
47
+ },
48
+ }, {
49
+ $unset: [
50
+ 'signs.userSignedId',
51
+ 'signs.userRevokedId',
52
+ ],
53
+ },
54
+ {
55
+ $sort: {
56
+ 'signs.signedAt': 1,
57
+ },
58
+ }, {
59
+ $group: {
60
+ '_id': '$_id',
61
+ 'bbcDateId': {
62
+ $first: '$bbcDateId'
63
+ },
64
+ 'requiredSigns': {
65
+ $first: '$requiredSigns'
66
+ },
67
+ 'signs': {
68
+ $push: '$signs'
69
+ }
70
+ }
71
+ }
72
+ ]);
73
+ };
74
+ exports.getAvailabilitySigns = getAvailabilitySigns;
75
+ const addAvailabilitySign = async (bbcDateId, sign) => {
76
+ const availabilitySigns = await models_1.AvailabilitySign.findOne({ bbcDateId: new mongoose_1.default.Types.ObjectId(bbcDateId) }).lean();
77
+ if (!availabilitySigns) {
78
+ await models_1.AvailabilitySign.create({ bbcDateId, signs: [sign] });
79
+ return { message: 'Availability was signed', success: true };
80
+ }
81
+ const activeSigns = availabilitySigns.signs.filter((sign) => !sign.revokedAt);
82
+ const foundUserSign = activeSigns.find((s) => s.userSignedId.toString() === sign.userSignedId.toString());
83
+ if (foundUserSign) {
84
+ return { message: `You already signed this availability`, success: false };
85
+ }
86
+ if (activeSigns.length >= availabilitySigns.requiredSigns) {
87
+ return { message: `Availability required only ${availabilitySigns.requiredSigns} signs`, success: false };
88
+ }
89
+ const updatedSigns = availabilitySigns.signs.slice();
90
+ await models_1.AvailabilitySign.findOneAndUpdate({ bbcDateId: new mongoose_1.default.Types.ObjectId(bbcDateId) }, { signs: [...updatedSigns, sign] });
91
+ return { message: 'Availability was signed', success: true };
92
+ };
93
+ exports.addAvailabilitySign = addAvailabilitySign;
94
+ const updateAvailabilitySigns = async (bbcDateId, signs) => {
95
+ await models_1.AvailabilitySign.findOneAndUpdate({ bbcDateId: new mongoose_1.default.Types.ObjectId(bbcDateId) }, { signs: signs });
96
+ };
97
+ exports.updateAvailabilitySigns = updateAvailabilitySigns;
@@ -0,0 +1,100 @@
1
+ import mongoose from 'mongoose';
2
+
3
+ import {
4
+ AvailabilitySign,
5
+ IAvailabilitySignDoc,
6
+ IAvailabilitySignItem,
7
+ IAvailabilitySignView
8
+ } from '../models';
9
+ import { IResult } from '../interfaces';
10
+
11
+ export const findAvailabilitySignsByBBCDateId = async (bbcDateId: string): Promise<IAvailabilitySignDoc> => {
12
+ return AvailabilitySign.findOne({ bbcDateId: new mongoose.Types.ObjectId(bbcDateId) }).lean();
13
+ }
14
+
15
+ export const getAvailabilitySigns = async (bbcDateId: string) => {
16
+ return AvailabilitySign.aggregate<IAvailabilitySignView>([
17
+ {
18
+ $match: {
19
+ 'bbcDateId': new mongoose.Types.ObjectId(bbcDateId)
20
+ }
21
+ }, {
22
+ $unwind: {
23
+ path: '$signs',
24
+ preserveNullAndEmptyArrays: true
25
+ }
26
+ }, {
27
+ $lookup: {
28
+ from: 'users',
29
+ localField: 'signs.userSignedId',
30
+ foreignField: '_id',
31
+ as: 'signs.userSigned'
32
+ }
33
+ }, {
34
+ $lookup:
35
+ {
36
+ from: 'users',
37
+ localField: 'signs.userRevokedId',
38
+ foreignField: '_id',
39
+ as: 'signs.userRevoked',
40
+ },
41
+ }, {
42
+ $unwind: {
43
+ path: '$signs.userSigned',
44
+ preserveNullAndEmptyArrays: true
45
+ }
46
+ }, {
47
+ $unwind: {
48
+ path: '$signs.userRevoked',
49
+ preserveNullAndEmptyArrays: true,
50
+ },
51
+ }, {
52
+ $unset: [
53
+ 'signs.userSignedId',
54
+ 'signs.userRevokedId',
55
+ ],
56
+ },
57
+ {
58
+ $sort:
59
+ {
60
+ 'signs.signedAt': 1,
61
+ },
62
+ }, {
63
+ $group: {
64
+ '_id': '$_id',
65
+ 'bbcDateId': {
66
+ $first: '$bbcDateId'
67
+ },
68
+ 'requiredSigns': {
69
+ $first: '$requiredSigns'
70
+ },
71
+ 'signs': {
72
+ $push: '$signs'
73
+ }
74
+ }
75
+ }
76
+ ]);
77
+ }
78
+
79
+ export const addAvailabilitySign = async (bbcDateId: string, sign: IAvailabilitySignItem): Promise<IResult> => {
80
+ const availabilitySigns: IAvailabilitySignDoc = await AvailabilitySign.findOne({ bbcDateId: new mongoose.Types.ObjectId(bbcDateId) }).lean();
81
+ if (!availabilitySigns) {
82
+ await AvailabilitySign.create({ bbcDateId, signs: [sign] });
83
+ return { message: 'Availability was signed', success: true };
84
+ }
85
+ const activeSigns = availabilitySigns.signs.filter((sign) => !sign.revokedAt);
86
+ const foundUserSign = activeSigns.find((s) => s.userSignedId.toString() === sign.userSignedId.toString());
87
+ if (foundUserSign) {
88
+ return { message: `You already signed this availability`, success: false };
89
+ }
90
+ if (activeSigns.length >= availabilitySigns.requiredSigns) {
91
+ return { message: `Availability required only ${availabilitySigns.requiredSigns} signs`, success: false };
92
+ }
93
+ const updatedSigns = availabilitySigns.signs.slice();
94
+ await AvailabilitySign.findOneAndUpdate({ bbcDateId: new mongoose.Types.ObjectId(bbcDateId) }, {signs: [...updatedSigns, sign] });
95
+ return { message: 'Availability was signed', success: true };
96
+ }
97
+
98
+ export const updateAvailabilitySigns = async (bbcDateId: string, signs: IAvailabilitySignItem[]): Promise<void> => {
99
+ await AvailabilitySign.findOneAndUpdate({ bbcDateId: new mongoose.Types.ObjectId(bbcDateId) }, { signs: signs });
100
+ }
@@ -0,0 +1,39 @@
1
+ /// <reference types="mongoose/types/aggregate" />
2
+ /// <reference types="mongoose/types/callback" />
3
+ /// <reference types="mongoose/types/collection" />
4
+ /// <reference types="mongoose/types/connection" />
5
+ /// <reference types="mongoose/types/cursor" />
6
+ /// <reference types="mongoose/types/document" />
7
+ /// <reference types="mongoose/types/error" />
8
+ /// <reference types="mongoose/types/expressions" />
9
+ /// <reference types="mongoose/types/helpers" />
10
+ /// <reference types="mongoose/types/middlewares" />
11
+ /// <reference types="mongoose/types/indexes" />
12
+ /// <reference types="mongoose/types/models" />
13
+ /// <reference types="mongoose/types/mongooseoptions" />
14
+ /// <reference types="mongoose/types/pipelinestage" />
15
+ /// <reference types="mongoose/types/populate" />
16
+ /// <reference types="mongoose/types/query" />
17
+ /// <reference types="mongoose/types/schemaoptions" />
18
+ /// <reference types="mongoose/types/schematypes" />
19
+ /// <reference types="mongoose/types/session" />
20
+ /// <reference types="mongoose/types/types" />
21
+ /// <reference types="mongoose/types/utility" />
22
+ /// <reference types="mongoose/types/validation" />
23
+ /// <reference types="mongoose/types/virtuals" />
24
+ /// <reference types="mongoose/types/inferschematype" />
25
+ import mongoose from 'mongoose';
26
+ import { IBBCDateDoc } from '../models';
27
+ import { ECollaterals } from '../enums';
28
+ export declare const getBBCDateDoc: (bbcDateId: string) => Promise<mongoose.FlattenMaps<IBBCDateDoc> & {
29
+ _id: mongoose.Types.ObjectId;
30
+ }>;
31
+ export declare const getBBCDatesByBorrower: (borrowerId: string, sortOrder?: 1 | -1) => Promise<IBBCDateDoc[]>;
32
+ export declare const getLatestSignedBBCDateDoc: (borrowerId: string) => Promise<any>;
33
+ export declare const getOlderBBCDates: (borrowerId: string, bbcDate: Date) => Promise<IBBCDateDoc[]>;
34
+ export declare const getBBCDates: (borrowerId: string, bbcDate: Date) => Promise<IBBCDateDoc[]>;
35
+ export declare const getBBCDatesForPeriod: (borrowerId: string, bbcDateStart: Date, bbcDateEnd: Date) => Promise<IBBCDateDoc[]>;
36
+ export declare const getBBCDatesByType: (borrowerId: string, collateralType: ECollaterals) => mongoose.Aggregate<IBBCDateDoc[]>;
37
+ export declare const createBBCDate: (borrowerId: string, bbcDate: Date) => Promise<mongoose.Document<unknown, {}, IBBCDateDoc> & IBBCDateDoc & {
38
+ _id: mongoose.Types.ObjectId;
39
+ }>;
@@ -0,0 +1,161 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.createBBCDate = exports.getBBCDatesByType = exports.getBBCDatesForPeriod = exports.getBBCDates = exports.getOlderBBCDates = exports.getLatestSignedBBCDateDoc = exports.getBBCDatesByBorrower = exports.getBBCDateDoc = void 0;
7
+ const mongoose_1 = __importDefault(require("mongoose"));
8
+ const models_1 = require("../models");
9
+ const availability_db_1 = require("./availability.db");
10
+ const getBBCDateDoc = async (bbcDateId) => {
11
+ return models_1.BBCDateModel.findById(bbcDateId).lean();
12
+ };
13
+ exports.getBBCDateDoc = getBBCDateDoc;
14
+ const getBBCDatesByBorrower = async (borrowerId, sortOrder = 1) => {
15
+ return models_1.BBCDateModel.aggregate([
16
+ {
17
+ $match: {
18
+ borrowerId: new mongoose_1.default.Types.ObjectId(borrowerId),
19
+ },
20
+ },
21
+ {
22
+ $sort: { bbcDate: sortOrder },
23
+ },
24
+ ]);
25
+ };
26
+ exports.getBBCDatesByBorrower = getBBCDatesByBorrower;
27
+ const getLatestSignedBBCDateDoc = async (borrowerId) => {
28
+ const bbcDates = await models_1.BBCDateModel.aggregate([
29
+ {
30
+ $match: {
31
+ borrowerId: new mongoose_1.default.Types.ObjectId(borrowerId),
32
+ },
33
+ },
34
+ {
35
+ $sort: { bbcDate: -1 },
36
+ },
37
+ ]);
38
+ if (!bbcDates) {
39
+ return null;
40
+ }
41
+ let foundSignedBBC = null;
42
+ let i = 0;
43
+ while (!foundSignedBBC) {
44
+ if (i === bbcDates.length) {
45
+ break;
46
+ }
47
+ const availabilitySigns = (await (0, availability_db_1.getAvailabilitySigns)(bbcDates[i]._id.toString())).pop();
48
+ if (availabilitySigns) {
49
+ const totalSigns = availabilitySigns.signs.filter((sign) => !sign.revokedAt);
50
+ foundSignedBBC = totalSigns.length === availabilitySigns.requiredSigns ? bbcDates[i] : null;
51
+ }
52
+ i = i + 1;
53
+ }
54
+ return foundSignedBBC;
55
+ };
56
+ exports.getLatestSignedBBCDateDoc = getLatestSignedBBCDateDoc;
57
+ const getOlderBBCDates = async (borrowerId, bbcDate) => {
58
+ return models_1.BBCDateModel.aggregate([
59
+ {
60
+ $match: {
61
+ borrowerId: new mongoose_1.default.Types.ObjectId(borrowerId),
62
+ bbcDate: { $lt: bbcDate },
63
+ },
64
+ },
65
+ {
66
+ $sort: { bbcDate: 1 },
67
+ },
68
+ ]);
69
+ };
70
+ exports.getOlderBBCDates = getOlderBBCDates;
71
+ const getBBCDates = async (borrowerId, bbcDate) => {
72
+ return models_1.BBCDateModel.aggregate([
73
+ {
74
+ $match: {
75
+ borrowerId: new mongoose_1.default.Types.ObjectId(borrowerId),
76
+ bbcDate: new Date(bbcDate),
77
+ },
78
+ },
79
+ {
80
+ $sort: { updatedAt: 1 },
81
+ },
82
+ ]);
83
+ };
84
+ exports.getBBCDates = getBBCDates;
85
+ const getBBCDatesForPeriod = async (borrowerId, bbcDateStart, bbcDateEnd) => {
86
+ return models_1.BBCDateModel.aggregate([
87
+ {
88
+ $match: {
89
+ $and: [
90
+ { 'borrowerId': new mongoose_1.default.Types.ObjectId(borrowerId) },
91
+ { 'bbcDate': { $gte: bbcDateStart } },
92
+ { 'bbcDate': { $lte: bbcDateEnd } },
93
+ ],
94
+ },
95
+ },
96
+ {
97
+ $sort: {
98
+ 'bbcDate': 1,
99
+ },
100
+ },
101
+ ]);
102
+ };
103
+ exports.getBBCDatesForPeriod = getBBCDatesForPeriod;
104
+ const getBBCDatesByType = (borrowerId, collateralType) => {
105
+ return models_1.BBCSheetModel.aggregate([
106
+ {
107
+ $match: {
108
+ 'dataType': collateralType,
109
+ },
110
+ },
111
+ {
112
+ $lookup: {
113
+ from: 'bbcdates',
114
+ localField: 'bbcDateId',
115
+ foreignField: '_id',
116
+ as: 'bbc',
117
+ },
118
+ },
119
+ {
120
+ $unwind: {
121
+ path: '$bbc',
122
+ },
123
+ },
124
+ {
125
+ $match: {
126
+ 'bbc.borrowerId': new mongoose_1.default.Types.ObjectId(borrowerId),
127
+ },
128
+ },
129
+ {
130
+ $group: {
131
+ '_id': '$bbc._id',
132
+ 'borrowerId': {
133
+ $first: '$bbc.borrowerId',
134
+ },
135
+ 'bbcDate': {
136
+ $first: '$bbc.bbcDate',
137
+ },
138
+ 'createdAt': {
139
+ $first: '$bbc.createdAt',
140
+ },
141
+ 'updatedAt': {
142
+ $first: '$bbc.updatedAt',
143
+ },
144
+ '__v': {
145
+ $first: '$bbc.__v',
146
+ },
147
+ },
148
+ },
149
+ {
150
+ $sort: {
151
+ 'bbcDate': -1,
152
+ },
153
+ },
154
+ ]);
155
+ };
156
+ exports.getBBCDatesByType = getBBCDatesByType;
157
+ const createBBCDate = async (borrowerId, bbcDate) => {
158
+ const newBBC = await models_1.BBCDateModel.create({ borrowerId: new mongoose_1.default.Types.ObjectId(borrowerId), bbcDate });
159
+ return newBBC.save();
160
+ };
161
+ exports.createBBCDate = createBBCDate;
@@ -0,0 +1,157 @@
1
+ import mongoose from 'mongoose';
2
+
3
+ import { BBCDateModel, BBCSheetModel, IBBCDateDoc } from '../models';
4
+ import { getAvailabilitySigns } from './availability.db';
5
+ import { ECollaterals } from '../enums';
6
+
7
+ export const getBBCDateDoc = async (bbcDateId: string) => {
8
+ return BBCDateModel.findById(bbcDateId).lean();
9
+ };
10
+
11
+ export const getBBCDatesByBorrower = async (borrowerId: string, sortOrder: 1 | -1 = 1) => {
12
+ return BBCDateModel.aggregate<IBBCDateDoc>([
13
+ {
14
+ $match: {
15
+ borrowerId: new mongoose.Types.ObjectId(borrowerId),
16
+ },
17
+ },
18
+ {
19
+ $sort: { bbcDate: sortOrder },
20
+ },
21
+ ]);
22
+ };
23
+
24
+ export const getLatestSignedBBCDateDoc = async (borrowerId: string) => {
25
+ const bbcDates = await BBCDateModel.aggregate<IBBCDateDoc>([
26
+ {
27
+ $match: {
28
+ borrowerId: new mongoose.Types.ObjectId(borrowerId),
29
+ },
30
+ },
31
+ {
32
+ $sort: { bbcDate: -1 },
33
+ },
34
+ ]);
35
+ if (!bbcDates) {
36
+ return null;
37
+ }
38
+ let foundSignedBBC = null;
39
+ let i = 0;
40
+ while (!foundSignedBBC) {
41
+ if (i === bbcDates.length) {
42
+ break;
43
+ }
44
+ const availabilitySigns = (await getAvailabilitySigns(bbcDates[i]._id.toString())).pop();
45
+ if (availabilitySigns) {
46
+ const totalSigns = availabilitySigns.signs.filter((sign) => !sign.revokedAt);
47
+ foundSignedBBC = totalSigns.length === availabilitySigns.requiredSigns ? bbcDates[i] : null;
48
+ }
49
+ i = i + 1;
50
+ }
51
+ return foundSignedBBC;
52
+ };
53
+
54
+ export const getOlderBBCDates = async (borrowerId: string, bbcDate: Date) => {
55
+ return BBCDateModel.aggregate<IBBCDateDoc>([
56
+ {
57
+ $match: {
58
+ borrowerId: new mongoose.Types.ObjectId(borrowerId),
59
+ bbcDate: { $lt: bbcDate },
60
+ },
61
+ },
62
+ {
63
+ $sort: { bbcDate: 1 },
64
+ },
65
+ ]);
66
+ };
67
+
68
+ export const getBBCDates = async (borrowerId: string, bbcDate: Date) => {
69
+ return BBCDateModel.aggregate<IBBCDateDoc>([
70
+ {
71
+ $match: {
72
+ borrowerId: new mongoose.Types.ObjectId(borrowerId),
73
+ bbcDate: new Date(bbcDate),
74
+ },
75
+ },
76
+ {
77
+ $sort: { updatedAt: 1 },
78
+ },
79
+ ]);
80
+ };
81
+
82
+ export const getBBCDatesForPeriod = async (borrowerId: string, bbcDateStart: Date, bbcDateEnd: Date) => {
83
+ return BBCDateModel.aggregate<IBBCDateDoc>([
84
+ {
85
+ $match: {
86
+ $and: [
87
+ { 'borrowerId': new mongoose.Types.ObjectId(borrowerId) },
88
+ { 'bbcDate': { $gte: bbcDateStart } },
89
+ { 'bbcDate': { $lte: bbcDateEnd } },
90
+ ],
91
+ },
92
+ },
93
+ {
94
+ $sort: {
95
+ 'bbcDate': 1,
96
+ },
97
+ },
98
+ ]);
99
+ };
100
+
101
+ export const getBBCDatesByType = (borrowerId: string, collateralType: ECollaterals) => {
102
+ return BBCSheetModel.aggregate<IBBCDateDoc>([
103
+ {
104
+ $match: {
105
+ 'dataType': collateralType,
106
+ },
107
+ },
108
+ {
109
+ $lookup: {
110
+ from: 'bbcdates',
111
+ localField: 'bbcDateId',
112
+ foreignField: '_id',
113
+ as: 'bbc',
114
+ },
115
+ },
116
+ {
117
+ $unwind: {
118
+ path: '$bbc',
119
+ },
120
+ },
121
+ {
122
+ $match: {
123
+ 'bbc.borrowerId': new mongoose.Types.ObjectId(borrowerId),
124
+ },
125
+ },
126
+ {
127
+ $group: {
128
+ '_id': '$bbc._id',
129
+ 'borrowerId': {
130
+ $first: '$bbc.borrowerId',
131
+ },
132
+ 'bbcDate': {
133
+ $first: '$bbc.bbcDate',
134
+ },
135
+ 'createdAt': {
136
+ $first: '$bbc.createdAt',
137
+ },
138
+ 'updatedAt': {
139
+ $first: '$bbc.updatedAt',
140
+ },
141
+ '__v': {
142
+ $first: '$bbc.__v',
143
+ },
144
+ },
145
+ },
146
+ {
147
+ $sort: {
148
+ 'bbcDate': -1,
149
+ },
150
+ },
151
+ ]);
152
+ };
153
+
154
+ export const createBBCDate = async (borrowerId: string, bbcDate: Date) => {
155
+ const newBBC = await BBCDateModel.create({ borrowerId: new mongoose.Types.ObjectId(borrowerId), bbcDate });
156
+ return newBBC.save();
157
+ };
@@ -0,0 +1,44 @@
1
+ /// <reference types="mongoose/types/aggregate" />
2
+ /// <reference types="mongoose/types/callback" />
3
+ /// <reference types="mongoose/types/collection" />
4
+ /// <reference types="mongoose/types/connection" />
5
+ /// <reference types="mongoose/types/cursor" />
6
+ /// <reference types="mongoose/types/document" />
7
+ /// <reference types="mongoose/types/error" />
8
+ /// <reference types="mongoose/types/expressions" />
9
+ /// <reference types="mongoose/types/helpers" />
10
+ /// <reference types="mongoose/types/middlewares" />
11
+ /// <reference types="mongoose/types/indexes" />
12
+ /// <reference types="mongoose/types/models" />
13
+ /// <reference types="mongoose/types/mongooseoptions" />
14
+ /// <reference types="mongoose/types/pipelinestage" />
15
+ /// <reference types="mongoose/types/populate" />
16
+ /// <reference types="mongoose/types/query" />
17
+ /// <reference types="mongoose/types/schemaoptions" />
18
+ /// <reference types="mongoose/types/schematypes" />
19
+ /// <reference types="mongoose/types/session" />
20
+ /// <reference types="mongoose/types/types" />
21
+ /// <reference types="mongoose/types/utility" />
22
+ /// <reference types="mongoose/types/validation" />
23
+ /// <reference types="mongoose/types/virtuals" />
24
+ /// <reference types="mongoose/types/inferschematype" />
25
+ import mongoose from 'mongoose';
26
+ import { ECollaterals } from '../enums';
27
+ import { IBBCSheetDoc } from '../models';
28
+ export declare const getBBCSheetsByType: (bbcDateIds: string[], collateralType: ECollaterals) => Promise<IBBCSheetDoc[]>;
29
+ export declare const getBBCSheetsByTypeGroupedByBBC: (bbcDateIds: string[], collateralType: ECollaterals) => Promise<{
30
+ _id: mongoose.Types.ObjectId;
31
+ sheets: IBBCSheetDoc[];
32
+ }[]>;
33
+ export declare const getUniqueDates: (borrowerId: string, limit: number, collateral: ECollaterals) => Promise<{
34
+ bbcDate: Date;
35
+ ids: mongoose.Types.ObjectId[];
36
+ }[]>;
37
+ export declare const getUniqueDatesForPeriod: (borrowerId: string, collateral: ECollaterals, startDate: Date, endDate: Date) => Promise<{
38
+ _id: mongoose.Types.ObjectId;
39
+ bbcDate: Date;
40
+ ids: mongoose.Types.ObjectId[];
41
+ }[]>;
42
+ export declare const createBBCSheet: (bbcDateId: string, dataType: 'INVENTORY' | 'RECEIVABLE') => Promise<mongoose.Document<unknown, {}, IBBCSheetDoc> & IBBCSheetDoc & {
43
+ _id: mongoose.Types.ObjectId;
44
+ }>;