gemcap-be-common 1.2.24 → 1.2.26
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/availability.db.d.ts +2 -2
- package/db/availability.db.js +7 -7
- package/db/availability.db.ts +3 -3
- package/db/bbcDates.db.d.ts +2 -2
- package/db/bbcDates.db.js +10 -9
- package/db/bbcDates.db.ts +3 -2
- package/db/bbcSheets.db.d.ts +2 -2
- package/db/bbcSheets.db.js +6 -6
- package/db/bbcSheets.db.ts +2 -2
- package/db/collaterals.db.d.ts +6 -6
- package/db/collaterals.db.js +18 -15
- package/db/collaterals.db.ts +8 -12
- package/db/inventory-availability.db.d.ts +2 -1
- package/db/inventory-availability.db.js +8 -7
- package/db/inventory-availability.db.ts +2 -3
- package/db/inventory-manual-entry.db.d.ts +1 -1
- package/db/inventory-manual-entry.db.js +2 -2
- package/db/inventory-manual-entry.db.ts +1 -1
- package/db/inventory-seasonal-rates.db.d.ts +1 -1
- package/db/inventory-seasonal-rates.db.js +5 -5
- package/db/inventory-seasonal-rates.db.ts +1 -1
- package/db/loan-products.db.d.ts +3 -2
- package/db/loan-products.db.js +18 -15
- package/db/loan-products.db.ts +9 -10
- package/db/loan-statement.db.js +4 -3
- package/db/loan-statement.db.ts +2 -1
- package/db/microservice-tasks.db.d.ts +2 -2
- package/db/microservice-tasks.db.js +9 -9
- package/db/microservice-tasks.db.ts +3 -2
- package/db/receivables.db.d.ts +1 -1
- package/db/receivables.db.js +24 -23
- package/db/receivables.db.ts +4 -3
- package/db/user-logs.db.d.ts +1 -1
- package/db/user-logs.db.js +2 -2
- package/db/user-logs.db.ts +1 -1
- package/helpers/column-desciptions.helper.d.ts +4 -4
- package/helpers/column-desciptions.helper.js +51 -49
- package/helpers/column-desciptions.helper.ts +7 -4
- package/helpers/numbers.helper.d.ts +1 -1
- package/helpers/numbers.helper.js +7 -6
- package/helpers/numbers.helper.ts +3 -2
- package/helpers/paginator.helper.d.ts +1 -1
- package/helpers/paginator.helper.js +2 -2
- package/helpers/paginator.helper.ts +1 -1
- package/helpers/users.helper.d.ts +2 -1
- package/helpers/users.helper.js +4 -4
- package/helpers/users.helper.ts +2 -1
- package/interfaces/collaterals.interface.d.ts +3 -1
- package/interfaces/collaterals.interface.ts +3 -1
- package/interfaces/custom-row.interface.d.ts +2 -1
- package/interfaces/custom-row.interface.ts +2 -1
- package/interfaces/email-addresses.interface.d.ts +1 -1
- package/interfaces/email-addresses.interface.ts +1 -1
- package/interfaces/query.interface.d.ts +1 -1
- package/interfaces/query.interface.ts +1 -1
- package/models/AccountPayableItem.model.d.ts +1 -1
- package/models/AccountPayableItem.model.ts +1 -1
- package/models/InventoryAvailability.model.d.ts +2 -2
- package/models/InventoryAvailability.model.js +1 -1
- package/models/InventoryAvailability.model.ts +2 -2
- package/models/InventoryItem.model.d.ts +1 -1
- package/models/InventoryItem.model.ts +1 -1
- package/models/LoanCharges.model.d.ts +2 -1
- package/models/LoanCharges.model.js +33 -32
- package/models/LoanCharges.model.ts +2 -2
- package/models/LoanProducts.model.d.ts +1 -1
- package/models/LoanProducts.model.ts +1 -1
- package/models/LoanTransaction.model.js +5 -5
- package/models/LoanTransaction.model.ts +1 -1
- package/models/MicroserviceTask.model.d.ts +2 -1
- package/models/MicroserviceTask.model.js +2 -1
- package/models/MicroserviceTask.model.ts +4 -3
- package/models/ReceivableItem.model.d.ts +1 -1
- package/models/ReceivableItem.model.ts +1 -1
- package/models/Yield.model.d.ts +1 -1
- package/models/Yield.model.ts +1 -1
- package/package.json +1 -1
- package/tsconfig.tsbuildinfo +1 -1
- package/db/index.d.ts +0 -12
- package/db/index.js +0 -28
- package/db/index.ts +0 -12
- package/enums/index.d.ts +0 -14
- package/enums/index.js +0 -30
- package/enums/index.ts +0 -14
- package/helpers/index.d.ts +0 -9
- package/helpers/index.js +0 -25
- package/helpers/index.ts +0 -9
- package/interfaces/index.d.ts +0 -14
- package/interfaces/index.js +0 -30
- package/interfaces/index.ts +0 -14
- package/models/index.d.ts +0 -29
- package/models/index.js +0 -45
- package/models/index.ts +0 -29
package/db/availability.db.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { IAvailabilitySignDoc, IAvailabilitySignItem, IAvailabilitySignView } from '../models';
|
|
2
|
-
import { IResult } from '../interfaces';
|
|
1
|
+
import { IAvailabilitySignDoc, IAvailabilitySignItem, IAvailabilitySignView } from '../models/AvailabilitySigns.model';
|
|
2
|
+
import { IResult } from '../interfaces/result.interface';
|
|
3
3
|
export declare const findAvailabilitySignsByBBCDateId: (bbcDateId: string) => Promise<IAvailabilitySignDoc>;
|
|
4
4
|
export declare const getAvailabilitySigns: (bbcDateId: string) => Promise<IAvailabilitySignView[]>;
|
|
5
5
|
export declare const addAvailabilitySign: (bbcDateId: string, sign: IAvailabilitySignItem) => Promise<IResult>;
|
package/db/availability.db.js
CHANGED
|
@@ -5,13 +5,13 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.updateAvailabilitySigns = exports.addAvailabilitySign = exports.getAvailabilitySigns = exports.findAvailabilitySignsByBBCDateId = void 0;
|
|
7
7
|
const mongoose_1 = __importDefault(require("mongoose"));
|
|
8
|
-
const
|
|
8
|
+
const AvailabilitySigns_model_1 = require("../models/AvailabilitySigns.model");
|
|
9
9
|
const findAvailabilitySignsByBBCDateId = async (bbcDateId) => {
|
|
10
|
-
return
|
|
10
|
+
return AvailabilitySigns_model_1.AvailabilitySignsModel.findOne({ bbcDateId: new mongoose_1.default.Types.ObjectId(bbcDateId) }).lean();
|
|
11
11
|
};
|
|
12
12
|
exports.findAvailabilitySignsByBBCDateId = findAvailabilitySignsByBBCDateId;
|
|
13
13
|
const getAvailabilitySigns = async (bbcDateId) => {
|
|
14
|
-
return
|
|
14
|
+
return AvailabilitySigns_model_1.AvailabilitySignsModel.aggregate([
|
|
15
15
|
{
|
|
16
16
|
$match: {
|
|
17
17
|
'bbcDateId': new mongoose_1.default.Types.ObjectId(bbcDateId)
|
|
@@ -73,9 +73,9 @@ const getAvailabilitySigns = async (bbcDateId) => {
|
|
|
73
73
|
};
|
|
74
74
|
exports.getAvailabilitySigns = getAvailabilitySigns;
|
|
75
75
|
const addAvailabilitySign = async (bbcDateId, sign) => {
|
|
76
|
-
const availabilitySigns = await
|
|
76
|
+
const availabilitySigns = await AvailabilitySigns_model_1.AvailabilitySignsModel.findOne({ bbcDateId: new mongoose_1.default.Types.ObjectId(bbcDateId) }).lean();
|
|
77
77
|
if (!availabilitySigns) {
|
|
78
|
-
await
|
|
78
|
+
await AvailabilitySigns_model_1.AvailabilitySignsModel.create({ bbcDateId, signs: [sign] });
|
|
79
79
|
return { message: 'Availability was signed', success: true };
|
|
80
80
|
}
|
|
81
81
|
const activeSigns = availabilitySigns.signs.filter((sign) => !sign.revokedAt);
|
|
@@ -87,11 +87,11 @@ const addAvailabilitySign = async (bbcDateId, sign) => {
|
|
|
87
87
|
return { message: `Availability required only ${availabilitySigns.requiredSigns} signs`, success: false };
|
|
88
88
|
}
|
|
89
89
|
const updatedSigns = availabilitySigns.signs.slice();
|
|
90
|
-
await
|
|
90
|
+
await AvailabilitySigns_model_1.AvailabilitySignsModel.findOneAndUpdate({ bbcDateId: new mongoose_1.default.Types.ObjectId(bbcDateId) }, { signs: [...updatedSigns, sign] });
|
|
91
91
|
return { message: 'Availability was signed', success: true };
|
|
92
92
|
};
|
|
93
93
|
exports.addAvailabilitySign = addAvailabilitySign;
|
|
94
94
|
const updateAvailabilitySigns = async (bbcDateId, signs) => {
|
|
95
|
-
await
|
|
95
|
+
await AvailabilitySigns_model_1.AvailabilitySignsModel.findOneAndUpdate({ bbcDateId: new mongoose_1.default.Types.ObjectId(bbcDateId) }, { signs: signs });
|
|
96
96
|
};
|
|
97
97
|
exports.updateAvailabilitySigns = updateAvailabilitySigns;
|
package/db/availability.db.ts
CHANGED
|
@@ -4,9 +4,9 @@ import {
|
|
|
4
4
|
AvailabilitySignsModel,
|
|
5
5
|
IAvailabilitySignDoc,
|
|
6
6
|
IAvailabilitySignItem,
|
|
7
|
-
IAvailabilitySignView
|
|
8
|
-
} from '../models';
|
|
9
|
-
import { IResult } from '../interfaces';
|
|
7
|
+
IAvailabilitySignView,
|
|
8
|
+
} from '../models/AvailabilitySigns.model';
|
|
9
|
+
import { IResult } from '../interfaces/result.interface';
|
|
10
10
|
|
|
11
11
|
export const findAvailabilitySignsByBBCDateId = async (bbcDateId: string): Promise<IAvailabilitySignDoc> => {
|
|
12
12
|
return AvailabilitySignsModel.findOne({ bbcDateId: new mongoose.Types.ObjectId(bbcDateId) }).lean();
|
package/db/bbcDates.db.d.ts
CHANGED
|
@@ -23,8 +23,8 @@
|
|
|
23
23
|
/// <reference types="mongoose/types/virtuals" />
|
|
24
24
|
/// <reference types="mongoose/types/inferschematype" />
|
|
25
25
|
import mongoose from 'mongoose';
|
|
26
|
-
import { IBBCDateDoc } from '../models';
|
|
27
|
-
import { ECollaterals } from '../enums';
|
|
26
|
+
import { IBBCDateDoc } from '../models/BBCDate.model';
|
|
27
|
+
import { ECollaterals } from '../enums/collaterals.enum';
|
|
28
28
|
export declare const getBBCDateDoc: (bbcDateId: string) => Promise<mongoose.FlattenMaps<IBBCDateDoc> & {
|
|
29
29
|
_id: mongoose.Types.ObjectId;
|
|
30
30
|
}>;
|
package/db/bbcDates.db.js
CHANGED
|
@@ -5,14 +5,15 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.createBBCDate = exports.getBBCDatesByType = exports.getBBCDatesForPeriod = exports.getBBCDates = exports.getOlderBBCDates = exports.getLatestSignedBBCDateDoc = exports.getBBCDatesByBorrower = exports.getBBCDateDoc = void 0;
|
|
7
7
|
const mongoose_1 = __importDefault(require("mongoose"));
|
|
8
|
-
const
|
|
8
|
+
const BBCDate_model_1 = require("../models/BBCDate.model");
|
|
9
|
+
const BBCSheet_model_1 = require("../models/BBCSheet.model");
|
|
9
10
|
const availability_db_1 = require("./availability.db");
|
|
10
11
|
const getBBCDateDoc = async (bbcDateId) => {
|
|
11
|
-
return
|
|
12
|
+
return BBCDate_model_1.BBCDateModel.findById(bbcDateId).lean();
|
|
12
13
|
};
|
|
13
14
|
exports.getBBCDateDoc = getBBCDateDoc;
|
|
14
15
|
const getBBCDatesByBorrower = async (borrowerId, sortOrder = 1) => {
|
|
15
|
-
return
|
|
16
|
+
return BBCDate_model_1.BBCDateModel.aggregate([
|
|
16
17
|
{
|
|
17
18
|
$match: {
|
|
18
19
|
borrowerId: new mongoose_1.default.Types.ObjectId(borrowerId),
|
|
@@ -25,7 +26,7 @@ const getBBCDatesByBorrower = async (borrowerId, sortOrder = 1) => {
|
|
|
25
26
|
};
|
|
26
27
|
exports.getBBCDatesByBorrower = getBBCDatesByBorrower;
|
|
27
28
|
const getLatestSignedBBCDateDoc = async (borrowerId) => {
|
|
28
|
-
const bbcDates = await
|
|
29
|
+
const bbcDates = await BBCDate_model_1.BBCDateModel.aggregate([
|
|
29
30
|
{
|
|
30
31
|
$match: {
|
|
31
32
|
borrowerId: new mongoose_1.default.Types.ObjectId(borrowerId),
|
|
@@ -55,7 +56,7 @@ const getLatestSignedBBCDateDoc = async (borrowerId) => {
|
|
|
55
56
|
};
|
|
56
57
|
exports.getLatestSignedBBCDateDoc = getLatestSignedBBCDateDoc;
|
|
57
58
|
const getOlderBBCDates = async (borrowerId, bbcDate) => {
|
|
58
|
-
return
|
|
59
|
+
return BBCDate_model_1.BBCDateModel.aggregate([
|
|
59
60
|
{
|
|
60
61
|
$match: {
|
|
61
62
|
borrowerId: new mongoose_1.default.Types.ObjectId(borrowerId),
|
|
@@ -69,7 +70,7 @@ const getOlderBBCDates = async (borrowerId, bbcDate) => {
|
|
|
69
70
|
};
|
|
70
71
|
exports.getOlderBBCDates = getOlderBBCDates;
|
|
71
72
|
const getBBCDates = async (borrowerId, bbcDate) => {
|
|
72
|
-
return
|
|
73
|
+
return BBCDate_model_1.BBCDateModel.aggregate([
|
|
73
74
|
{
|
|
74
75
|
$match: {
|
|
75
76
|
borrowerId: new mongoose_1.default.Types.ObjectId(borrowerId),
|
|
@@ -83,7 +84,7 @@ const getBBCDates = async (borrowerId, bbcDate) => {
|
|
|
83
84
|
};
|
|
84
85
|
exports.getBBCDates = getBBCDates;
|
|
85
86
|
const getBBCDatesForPeriod = async (borrowerId, bbcDateStart, bbcDateEnd) => {
|
|
86
|
-
return
|
|
87
|
+
return BBCDate_model_1.BBCDateModel.aggregate([
|
|
87
88
|
{
|
|
88
89
|
$match: {
|
|
89
90
|
$and: [
|
|
@@ -102,7 +103,7 @@ const getBBCDatesForPeriod = async (borrowerId, bbcDateStart, bbcDateEnd) => {
|
|
|
102
103
|
};
|
|
103
104
|
exports.getBBCDatesForPeriod = getBBCDatesForPeriod;
|
|
104
105
|
const getBBCDatesByType = (borrowerId, collateralType) => {
|
|
105
|
-
return
|
|
106
|
+
return BBCSheet_model_1.BBCSheetModel.aggregate([
|
|
106
107
|
{
|
|
107
108
|
$match: {
|
|
108
109
|
'dataType': collateralType,
|
|
@@ -155,7 +156,7 @@ const getBBCDatesByType = (borrowerId, collateralType) => {
|
|
|
155
156
|
};
|
|
156
157
|
exports.getBBCDatesByType = getBBCDatesByType;
|
|
157
158
|
const createBBCDate = async (borrowerId, bbcDate) => {
|
|
158
|
-
const newBBC = await
|
|
159
|
+
const newBBC = await BBCDate_model_1.BBCDateModel.create({ borrowerId: new mongoose_1.default.Types.ObjectId(borrowerId), bbcDate });
|
|
159
160
|
return newBBC.save();
|
|
160
161
|
};
|
|
161
162
|
exports.createBBCDate = createBBCDate;
|
package/db/bbcDates.db.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import mongoose from 'mongoose';
|
|
2
2
|
|
|
3
|
-
import { BBCDateModel,
|
|
3
|
+
import { BBCDateModel, IBBCDateDoc } from '../models/BBCDate.model';
|
|
4
|
+
import { BBCSheetModel } from '../models/BBCSheet.model';
|
|
4
5
|
import { getAvailabilitySigns } from './availability.db';
|
|
5
|
-
import { ECollaterals } from '../enums';
|
|
6
|
+
import { ECollaterals } from '../enums/collaterals.enum';
|
|
6
7
|
|
|
7
8
|
export const getBBCDateDoc = async (bbcDateId: string) => {
|
|
8
9
|
return BBCDateModel.findById(bbcDateId).lean();
|
package/db/bbcSheets.db.d.ts
CHANGED
|
@@ -23,8 +23,8 @@
|
|
|
23
23
|
/// <reference types="mongoose/types/virtuals" />
|
|
24
24
|
/// <reference types="mongoose/types/inferschematype" />
|
|
25
25
|
import mongoose from 'mongoose';
|
|
26
|
-
import { ECollaterals } from '../enums';
|
|
27
|
-
import { IBBCSheetDoc } from '../models';
|
|
26
|
+
import { ECollaterals } from '../enums/collaterals.enum';
|
|
27
|
+
import { IBBCSheetDoc } from '../models/BBCSheet.model';
|
|
28
28
|
export declare const getBBCSheetsByType: (bbcDateIds: string[], collateralType: ECollaterals) => Promise<IBBCSheetDoc[]>;
|
|
29
29
|
export declare const getBBCSheetsByTypeGroupedByBBC: (bbcDateIds: string[], collateralType: ECollaterals) => Promise<{
|
|
30
30
|
_id: mongoose.Types.ObjectId;
|
package/db/bbcSheets.db.js
CHANGED
|
@@ -5,9 +5,9 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.createBBCSheet = exports.getUniqueDatesForPeriod = exports.getUniqueDates = exports.getBBCSheetsByTypeGroupedByBBC = exports.getBBCSheetsByType = void 0;
|
|
7
7
|
const mongoose_1 = __importDefault(require("mongoose"));
|
|
8
|
-
const
|
|
8
|
+
const BBCSheet_model_1 = require("../models/BBCSheet.model");
|
|
9
9
|
const getBBCSheetsByType = async (bbcDateIds, collateralType) => {
|
|
10
|
-
return
|
|
10
|
+
return BBCSheet_model_1.BBCSheetModel.aggregate([
|
|
11
11
|
{
|
|
12
12
|
$match: {
|
|
13
13
|
bbcDateId: { $in: bbcDateIds.map((id) => new mongoose_1.default.Types.ObjectId(id)) },
|
|
@@ -21,7 +21,7 @@ const getBBCSheetsByType = async (bbcDateIds, collateralType) => {
|
|
|
21
21
|
};
|
|
22
22
|
exports.getBBCSheetsByType = getBBCSheetsByType;
|
|
23
23
|
const getBBCSheetsByTypeGroupedByBBC = async (bbcDateIds, collateralType) => {
|
|
24
|
-
return
|
|
24
|
+
return BBCSheet_model_1.BBCSheetModel.aggregate([
|
|
25
25
|
{
|
|
26
26
|
$match: {
|
|
27
27
|
bbcDateId: { $in: bbcDateIds.map((id) => new mongoose_1.default.Types.ObjectId(id)) },
|
|
@@ -52,7 +52,7 @@ const getBBCSheetsByTypeGroupedByBBC = async (bbcDateIds, collateralType) => {
|
|
|
52
52
|
};
|
|
53
53
|
exports.getBBCSheetsByTypeGroupedByBBC = getBBCSheetsByTypeGroupedByBBC;
|
|
54
54
|
const getUniqueDates = async (borrowerId, limit, collateral) => {
|
|
55
|
-
return
|
|
55
|
+
return BBCSheet_model_1.BBCSheetModel.aggregate([
|
|
56
56
|
{
|
|
57
57
|
$match: {
|
|
58
58
|
'dataType': collateral,
|
|
@@ -109,7 +109,7 @@ const getUniqueDates = async (borrowerId, limit, collateral) => {
|
|
|
109
109
|
};
|
|
110
110
|
exports.getUniqueDates = getUniqueDates;
|
|
111
111
|
const getUniqueDatesForPeriod = async (borrowerId, collateral, startDate, endDate) => {
|
|
112
|
-
return
|
|
112
|
+
return BBCSheet_model_1.BBCSheetModel.aggregate([
|
|
113
113
|
{
|
|
114
114
|
$match: {
|
|
115
115
|
'dataType': collateral,
|
|
@@ -169,7 +169,7 @@ const createBBCSheet = async (bbcDateId, dataType) => {
|
|
|
169
169
|
fileName: 'manual.xlsx',
|
|
170
170
|
sheetName: 'manual',
|
|
171
171
|
};
|
|
172
|
-
const newBBCSheet = new
|
|
172
|
+
const newBBCSheet = new BBCSheet_model_1.BBCSheetModel(newSheet);
|
|
173
173
|
return newBBCSheet.save();
|
|
174
174
|
};
|
|
175
175
|
exports.createBBCSheet = createBBCSheet;
|
package/db/bbcSheets.db.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import mongoose from 'mongoose';
|
|
2
2
|
|
|
3
|
-
import { ECollaterals } from '../enums';
|
|
4
|
-
import { BBCSheetModel, IBBCSheet, IBBCSheetDoc } from '../models';
|
|
3
|
+
import { ECollaterals } from '../enums/collaterals.enum';
|
|
4
|
+
import { BBCSheetModel, IBBCSheet, IBBCSheetDoc } from '../models/BBCSheet.model';
|
|
5
5
|
|
|
6
6
|
export const getBBCSheetsByType = async (bbcDateIds: string[], collateralType: ECollaterals) => {
|
|
7
7
|
return BBCSheetModel.aggregate<IBBCSheetDoc>([
|
package/db/collaterals.db.d.ts
CHANGED
|
@@ -23,8 +23,8 @@
|
|
|
23
23
|
/// <reference types="mongoose/types/virtuals" />
|
|
24
24
|
/// <reference types="mongoose/types/inferschematype" />
|
|
25
25
|
import mongoose from 'mongoose';
|
|
26
|
-
import { IPaginatorOptions } from '../interfaces';
|
|
27
|
-
import { ECollaterals } from '../enums';
|
|
26
|
+
import { IPaginatorOptions } from '../interfaces/collaterals.interface';
|
|
27
|
+
import { ECollaterals } from '../enums/collaterals.enum';
|
|
28
28
|
export interface IBbcDateWithSheets {
|
|
29
29
|
_id: mongoose.Types.ObjectId;
|
|
30
30
|
bbcDate: Date;
|
|
@@ -36,13 +36,13 @@ export interface IBbcDateWithSheets {
|
|
|
36
36
|
extraInfo?: string;
|
|
37
37
|
}
|
|
38
38
|
export declare const collateralMap: {
|
|
39
|
-
INVENTORY: mongoose.Model<import("../models").IInventoryItemDoc, {}, {}, {}, mongoose.Document<unknown, {}, import("../models").IInventoryItemDoc> & import("../models").IInventoryItemDoc & {
|
|
39
|
+
INVENTORY: mongoose.Model<import("../models/InventoryItem.model").IInventoryItemDoc, {}, {}, {}, mongoose.Document<unknown, {}, import("../models/InventoryItem.model").IInventoryItemDoc> & import("../models/InventoryItem.model").IInventoryItemDoc & {
|
|
40
40
|
_id: mongoose.Types.ObjectId;
|
|
41
41
|
}, any>;
|
|
42
|
-
RECEIVABLE: mongoose.Model<import("../models").IReceivableItemDoc, {}, {}, {}, mongoose.Document<unknown, {}, import("../models").IReceivableItemDoc> & import("../models").IReceivableItemDoc & {
|
|
42
|
+
RECEIVABLE: mongoose.Model<import("../models/ReceivableItem.model").IReceivableItemDoc, {}, {}, {}, mongoose.Document<unknown, {}, import("../models/ReceivableItem.model").IReceivableItemDoc> & import("../models/ReceivableItem.model").IReceivableItemDoc & {
|
|
43
43
|
_id: mongoose.Types.ObjectId;
|
|
44
44
|
}, any>;
|
|
45
|
-
ACCOUNT_PAYABLE: mongoose.Model<import("../models").IAccountPayableItemDoc, {}, {}, {}, mongoose.Document<unknown, {}, import("../models").IAccountPayableItemDoc> & import("../models").IAccountPayableItemDoc & {
|
|
45
|
+
ACCOUNT_PAYABLE: mongoose.Model<import("../models/AccountPayableItem.model").IAccountPayableItemDoc, {}, {}, {}, mongoose.Document<unknown, {}, import("../models/AccountPayableItem.model").IAccountPayableItemDoc> & import("../models/AccountPayableItem.model").IAccountPayableItemDoc & {
|
|
46
46
|
_id: mongoose.Types.ObjectId;
|
|
47
47
|
}, any>;
|
|
48
48
|
};
|
|
@@ -84,7 +84,7 @@ export declare const ITEMS_PAGINATION: (paginatorOptions: IPaginatorOptions) =>
|
|
|
84
84
|
$skip?: undefined;
|
|
85
85
|
})[];
|
|
86
86
|
export declare const findCollateralsWithSheets: (borrowerId: string, collateralTypes?: ECollaterals[]) => Promise<IBbcDateWithSheets[]>;
|
|
87
|
-
export declare const getBBCSheetsForBorrowerAndType: (borrowerId: string, collateralType: ECollaterals) => Promise<import("../models").IBBCSheetDoc[]>;
|
|
87
|
+
export declare const getBBCSheetsForBorrowerAndType: (borrowerId: string, collateralType: ECollaterals) => Promise<import("../models/BBCSheet.model").IBBCSheetDoc[]>;
|
|
88
88
|
export declare const getCollateralListBySheet: (sheetIds: string[], collateralType: ECollaterals) => Promise<any>;
|
|
89
89
|
export declare const getPreviousCollateralDocument: (borrowerId: string, date: Date, collateralType: ECollaterals, limit?: number) => Promise<{
|
|
90
90
|
_id: mongoose.Types.ObjectId;
|
package/db/collaterals.db.js
CHANGED
|
@@ -6,21 +6,24 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.getCollateralDocsByBBC = exports.getPreviousCollateralDocument = exports.getCollateralListBySheet = exports.getBBCSheetsForBorrowerAndType = exports.findCollateralsWithSheets = exports.ITEMS_PAGINATION = exports.createQuery = exports.COLLATERALS_LOOKUP = exports.collateralFields = exports.collateralMap = void 0;
|
|
7
7
|
const mongoose_1 = __importDefault(require("mongoose"));
|
|
8
8
|
const _models_1 = require("../models/_models");
|
|
9
|
-
const
|
|
10
|
-
const
|
|
11
|
-
const
|
|
12
|
-
const
|
|
9
|
+
const collaterals_enum_1 = require("../enums/collaterals.enum");
|
|
10
|
+
const AccountPayableItem_model_1 = require("../models/AccountPayableItem.model");
|
|
11
|
+
const BBCDate_model_1 = require("../models/BBCDate.model");
|
|
12
|
+
const BBCSheet_model_1 = require("../models/BBCSheet.model");
|
|
13
|
+
const InventoryItem_model_1 = require("../models/InventoryItem.model");
|
|
14
|
+
const ReceivableItem_model_1 = require("../models/ReceivableItem.model");
|
|
15
|
+
const enums_helper_1 = require("../helpers/enums.helper");
|
|
13
16
|
const bbcSheets_db_1 = require("./bbcSheets.db");
|
|
14
17
|
const bbcDates_db_1 = require("./bbcDates.db");
|
|
15
18
|
exports.collateralMap = {
|
|
16
|
-
[
|
|
17
|
-
[
|
|
18
|
-
[
|
|
19
|
+
[collaterals_enum_1.ECollaterals.INVENTORY]: InventoryItem_model_1.InventoryItemModel,
|
|
20
|
+
[collaterals_enum_1.ECollaterals.RECEIVABLE]: ReceivableItem_model_1.ReceivableItemModel,
|
|
21
|
+
[collaterals_enum_1.ECollaterals.ACCOUNT_PAYABLE]: AccountPayableItem_model_1.AccountPayableItemModel,
|
|
19
22
|
};
|
|
20
23
|
exports.collateralFields = {
|
|
21
|
-
[
|
|
22
|
-
[
|
|
23
|
-
[
|
|
24
|
+
[collaterals_enum_1.ECollaterals.INVENTORY]: InventoryItem_model_1.INVENTORY_FIELDS,
|
|
25
|
+
[collaterals_enum_1.ECollaterals.RECEIVABLE]: ReceivableItem_model_1.RECEIVABLE_FIELDS,
|
|
26
|
+
[collaterals_enum_1.ECollaterals.ACCOUNT_PAYABLE]: AccountPayableItem_model_1.ACCOUNT_PAYABLE_FIELDS,
|
|
24
27
|
};
|
|
25
28
|
exports.COLLATERALS_LOOKUP = [
|
|
26
29
|
{
|
|
@@ -51,7 +54,7 @@ exports.COLLATERALS_LOOKUP = [
|
|
|
51
54
|
},
|
|
52
55
|
];
|
|
53
56
|
const createQuery = (groupFields, collateralType) => {
|
|
54
|
-
const enumKey = (0,
|
|
57
|
+
const enumKey = (0, enums_helper_1.getEnumKeyByEnumValue)(collaterals_enum_1.ECollaterals, collateralType);
|
|
55
58
|
const itemFields = exports.collateralFields[enumKey];
|
|
56
59
|
if (!itemFields) {
|
|
57
60
|
console.error('Incorrect collateralType - ', collateralType);
|
|
@@ -90,7 +93,7 @@ const findCollateralsWithSheets = async (borrowerId, collateralTypes) => {
|
|
|
90
93
|
],
|
|
91
94
|
}
|
|
92
95
|
: bbcFilter;
|
|
93
|
-
return
|
|
96
|
+
return BBCSheet_model_1.BBCSheetModel.aggregate([
|
|
94
97
|
{
|
|
95
98
|
$match: collateralFilter,
|
|
96
99
|
},
|
|
@@ -151,7 +154,7 @@ const getBBCSheetsForBorrowerAndType = async (borrowerId, collateralType) => {
|
|
|
151
154
|
};
|
|
152
155
|
exports.getBBCSheetsForBorrowerAndType = getBBCSheetsForBorrowerAndType;
|
|
153
156
|
const getCollateralListBySheet = async (sheetIds, collateralType) => {
|
|
154
|
-
const enumKey = (0,
|
|
157
|
+
const enumKey = (0, enums_helper_1.getEnumKeyByEnumValue)(collaterals_enum_1.ECollaterals, collateralType);
|
|
155
158
|
const sheetIdsMapped = sheetIds.map((sheetId) => new mongoose_1.default.Types.ObjectId(sheetId));
|
|
156
159
|
return exports.collateralMap[enumKey].aggregate([
|
|
157
160
|
{
|
|
@@ -195,7 +198,7 @@ const getCollateralListBySheet = async (sheetIds, collateralType) => {
|
|
|
195
198
|
};
|
|
196
199
|
exports.getCollateralListBySheet = getCollateralListBySheet;
|
|
197
200
|
const getPreviousCollateralDocument = async (borrowerId, date, collateralType, limit = 1) => {
|
|
198
|
-
return
|
|
201
|
+
return BBCSheet_model_1.BBCSheetModel.aggregate([
|
|
199
202
|
{
|
|
200
203
|
$match: {
|
|
201
204
|
'dataType': collateralType,
|
|
@@ -273,7 +276,7 @@ const getCollateralDocsByBBC = async (bbcIds, collateralType) => {
|
|
|
273
276
|
},
|
|
274
277
|
]);
|
|
275
278
|
if (!aggregationResult.length) {
|
|
276
|
-
const BBCs = await
|
|
279
|
+
const BBCs = await BBCDate_model_1.BBCDateModel.find({ _id: { $in: bbcIds } }).lean();
|
|
277
280
|
return BBCs.map((BBC) => ({ ...BBC, items: [] }));
|
|
278
281
|
}
|
|
279
282
|
return aggregationResult;
|
package/db/collaterals.db.ts
CHANGED
|
@@ -1,18 +1,14 @@
|
|
|
1
1
|
import mongoose from 'mongoose';
|
|
2
2
|
|
|
3
3
|
import { MODEL_NAMES } from '../models/_models';
|
|
4
|
-
import { IPaginatorOptions } from '../interfaces';
|
|
5
|
-
import { ECollaterals } from '../enums';
|
|
6
|
-
import {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
InventoryItemModel,
|
|
13
|
-
} from '../models';
|
|
14
|
-
import { RECEIVABLE_FIELDS, ReceivableItemModel } from '../models';
|
|
15
|
-
import { getEnumKeyByEnumValue } from '../helpers';
|
|
4
|
+
import { IPaginatorOptions } from '../interfaces/collaterals.interface';
|
|
5
|
+
import { ECollaterals } from '../enums/collaterals.enum';
|
|
6
|
+
import { ACCOUNT_PAYABLE_FIELDS, AccountPayableItemModel } from '../models/AccountPayableItem.model';
|
|
7
|
+
import { BBCDateModel } from '../models/BBCDate.model';
|
|
8
|
+
import { BBCSheetModel } from '../models/BBCSheet.model';
|
|
9
|
+
import { INVENTORY_FIELDS, InventoryItemModel } from '../models/InventoryItem.model';
|
|
10
|
+
import { RECEIVABLE_FIELDS, ReceivableItemModel } from '../models/ReceivableItem.model';
|
|
11
|
+
import { getEnumKeyByEnumValue } from '../helpers/enums.helper';
|
|
16
12
|
import { getBBCSheetsByType } from './bbcSheets.db';
|
|
17
13
|
import { getBBCDatesByBorrower } from './bbcDates.db';
|
|
18
14
|
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { IInventoryAvailabilityDocument,
|
|
1
|
+
import { IInventoryAvailabilityDocument, IInventoryAvailabilitySummary } from '../models/InventoryAvailability.model';
|
|
2
|
+
import { IInventoryAvailabilityItem } from '../models/InventoryAvailabilityItem.model';
|
|
2
3
|
export declare const getInventoryAvailabilityByBBCDateId: (bbcDateId: string) => Promise<IInventoryAvailabilityDocument>;
|
|
3
4
|
export declare const saveInventoryAvailabilityItems: (inventoryAvailabilityId: string, items: IInventoryAvailabilityItem[]) => Promise<void>;
|
|
4
5
|
export declare const saveInventoryAvailabilitySummary: (inventoryAvailabilityId: string, summary: IInventoryAvailabilitySummary[]) => Promise<void>;
|
|
@@ -1,27 +1,28 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.setManualInputsToggle = exports.updateAvailabilityStatus = exports.saveInventoryAvailabilitySummary = exports.saveInventoryAvailabilityItems = exports.getInventoryAvailabilityByBBCDateId = void 0;
|
|
4
|
-
const
|
|
4
|
+
const InventoryAvailability_model_1 = require("../models/InventoryAvailability.model");
|
|
5
|
+
const InventoryAvailabilityItem_model_1 = require("../models/InventoryAvailabilityItem.model");
|
|
5
6
|
const getInventoryAvailabilityByBBCDateId = async (bbcDateId) => {
|
|
6
|
-
return
|
|
7
|
+
return InventoryAvailability_model_1.InventoryAvailabilityModel
|
|
7
8
|
.findOne({ bbcDateId })
|
|
8
9
|
.lean();
|
|
9
10
|
};
|
|
10
11
|
exports.getInventoryAvailabilityByBBCDateId = getInventoryAvailabilityByBBCDateId;
|
|
11
12
|
const saveInventoryAvailabilityItems = async (inventoryAvailabilityId, items) => {
|
|
12
|
-
await
|
|
13
|
-
await
|
|
13
|
+
await InventoryAvailabilityItem_model_1.InventoryAvailabilityItemModel.deleteMany({ inventoryAvailabilityId });
|
|
14
|
+
await InventoryAvailabilityItem_model_1.InventoryAvailabilityItemModel.insertMany(items);
|
|
14
15
|
};
|
|
15
16
|
exports.saveInventoryAvailabilityItems = saveInventoryAvailabilityItems;
|
|
16
17
|
const saveInventoryAvailabilitySummary = async (inventoryAvailabilityId, summary) => {
|
|
17
|
-
await
|
|
18
|
+
await InventoryAvailability_model_1.InventoryAvailabilityModel.findByIdAndUpdate(inventoryAvailabilityId, { summary }, { upsert: true, new: true });
|
|
18
19
|
};
|
|
19
20
|
exports.saveInventoryAvailabilitySummary = saveInventoryAvailabilitySummary;
|
|
20
21
|
const updateAvailabilityStatus = async (bbcDateId, status) => {
|
|
21
|
-
await
|
|
22
|
+
await InventoryAvailability_model_1.InventoryAvailabilityModel.updateOne({ bbcDateId }, { status });
|
|
22
23
|
};
|
|
23
24
|
exports.updateAvailabilityStatus = updateAvailabilityStatus;
|
|
24
25
|
const setManualInputsToggle = async (bbcDateId, useManualInputs) => {
|
|
25
|
-
await
|
|
26
|
+
await InventoryAvailability_model_1.InventoryAvailabilityModel.updateOne({ bbcDateId }, { useManualInputs });
|
|
26
27
|
};
|
|
27
28
|
exports.setManualInputsToggle = setManualInputsToggle;
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import {
|
|
2
2
|
IInventoryAvailabilityDocument,
|
|
3
|
-
IInventoryAvailabilityItem,
|
|
4
3
|
IInventoryAvailabilitySummary,
|
|
5
|
-
InventoryAvailabilityItemModel,
|
|
6
4
|
InventoryAvailabilityModel,
|
|
7
|
-
} from '../models';
|
|
5
|
+
} from '../models/InventoryAvailability.model';
|
|
6
|
+
import { IInventoryAvailabilityItem, InventoryAvailabilityItemModel } from '../models/InventoryAvailabilityItem.model';
|
|
8
7
|
|
|
9
8
|
export const getInventoryAvailabilityByBBCDateId = async (bbcDateId: string): Promise<IInventoryAvailabilityDocument> => {
|
|
10
9
|
return InventoryAvailabilityModel
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { IInventoryManualEntry } from '../models';
|
|
1
|
+
import { IInventoryManualEntry } from '../models/InventoryManualEntry.model';
|
|
2
2
|
export declare const getInventoryManualEntryData: (bbcDateId: string) => Promise<IInventoryManualEntry>;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getInventoryManualEntryData = void 0;
|
|
4
|
-
const
|
|
4
|
+
const InventoryManualEntry_model_1 = require("../models/InventoryManualEntry.model");
|
|
5
5
|
const getInventoryManualEntryData = async (bbcDateId) => {
|
|
6
|
-
const manualEntry = await
|
|
6
|
+
const manualEntry = await InventoryManualEntry_model_1.InventoryManualEntryModel.findOne({ bbcDateId }).lean();
|
|
7
7
|
if (!manualEntry) {
|
|
8
8
|
return {
|
|
9
9
|
bbcDateId: bbcDateId,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { IInventoryManualEntry, InventoryManualEntryModel } from '../models';
|
|
1
|
+
import { IInventoryManualEntry, InventoryManualEntryModel } from '../models/InventoryManualEntry.model';
|
|
2
2
|
|
|
3
3
|
export const getInventoryManualEntryData = async (bbcDateId: string) => {
|
|
4
4
|
const manualEntry = await InventoryManualEntryModel.findOne({ bbcDateId }).lean();
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { IInventorySeasonalRatesDoc, IInventorySeasonalRatesItemDoc } from '../models';
|
|
1
|
+
import { IInventorySeasonalRatesDoc, IInventorySeasonalRatesItemDoc } from '../models/InventorySeasonalRates.model';
|
|
2
2
|
export declare const getNewSeasonalRates: (borrowerId: string) => Promise<IInventorySeasonalRatesDoc>;
|
|
3
3
|
export declare const getSeasonalRates: (borrowerId: string) => Promise<IInventorySeasonalRatesDoc>;
|
|
4
4
|
export declare const saveSeasonalRates: (borrowerId: string, rates: IInventorySeasonalRatesItemDoc[]) => Promise<void>;
|
|
@@ -5,7 +5,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.saveSeasonalRates = exports.getSeasonalRates = exports.getNewSeasonalRates = void 0;
|
|
7
7
|
const mongoose_1 = __importDefault(require("mongoose"));
|
|
8
|
-
const
|
|
8
|
+
const InventorySeasonalRates_model_1 = require("../models/InventorySeasonalRates.model");
|
|
9
9
|
const getNewSeasonalRates = async (borrowerId) => {
|
|
10
10
|
return {
|
|
11
11
|
borrowerId: new mongoose_1.default.Types.ObjectId(borrowerId),
|
|
@@ -14,7 +14,7 @@ const getNewSeasonalRates = async (borrowerId) => {
|
|
|
14
14
|
};
|
|
15
15
|
exports.getNewSeasonalRates = getNewSeasonalRates;
|
|
16
16
|
const getSeasonalRates = async (borrowerId) => {
|
|
17
|
-
const foundRates = await
|
|
17
|
+
const foundRates = await InventorySeasonalRates_model_1.InventorySeasonalEntryModel.findOne({ borrowerId });
|
|
18
18
|
if (foundRates) {
|
|
19
19
|
return foundRates;
|
|
20
20
|
}
|
|
@@ -22,20 +22,20 @@ const getSeasonalRates = async (borrowerId) => {
|
|
|
22
22
|
};
|
|
23
23
|
exports.getSeasonalRates = getSeasonalRates;
|
|
24
24
|
const saveSeasonalRates = async (borrowerId, rates) => {
|
|
25
|
-
const foundRates = await
|
|
25
|
+
const foundRates = await InventorySeasonalRates_model_1.InventorySeasonalEntryModel.findOne({ borrowerId });
|
|
26
26
|
if (foundRates) {
|
|
27
27
|
const mappedRates = rates.map((rate) => {
|
|
28
28
|
const { _id, ...restRate } = rate;
|
|
29
29
|
return restRate;
|
|
30
30
|
});
|
|
31
|
-
await
|
|
31
|
+
await InventorySeasonalRates_model_1.InventorySeasonalEntryModel.findByIdAndUpdate(foundRates._id, { items: mappedRates });
|
|
32
32
|
}
|
|
33
33
|
else {
|
|
34
34
|
const mappedRates = rates.map((rate) => {
|
|
35
35
|
const { _id, ...restRate } = rate;
|
|
36
36
|
return restRate;
|
|
37
37
|
});
|
|
38
|
-
const newRates = await
|
|
38
|
+
const newRates = await InventorySeasonalRates_model_1.InventorySeasonalEntryModel.create({ borrowerId, items: mappedRates });
|
|
39
39
|
await newRates.save();
|
|
40
40
|
}
|
|
41
41
|
};
|
|
@@ -4,7 +4,7 @@ import {
|
|
|
4
4
|
IInventorySeasonalRatesDoc,
|
|
5
5
|
IInventorySeasonalRatesItemDoc,
|
|
6
6
|
InventorySeasonalEntryModel,
|
|
7
|
-
} from '../models';
|
|
7
|
+
} from '../models/InventorySeasonalRates.model';
|
|
8
8
|
|
|
9
9
|
export const getNewSeasonalRates = async (borrowerId: string) => {
|
|
10
10
|
return <IInventorySeasonalRatesDoc>{
|
package/db/loan-products.db.d.ts
CHANGED
|
@@ -23,8 +23,9 @@
|
|
|
23
23
|
/// <reference types="mongoose/types/virtuals" />
|
|
24
24
|
/// <reference types="mongoose/types/inferschematype" />
|
|
25
25
|
import mongoose from 'mongoose';
|
|
26
|
-
import { ILoanChargeView
|
|
27
|
-
|
|
26
|
+
import { ILoanChargeView } from '../models/LoanCharges.model';
|
|
27
|
+
import { IStatementPeriod } from '../models/LoanStatementTransaction.model';
|
|
28
|
+
export declare const getLoanProductById: (productId: string) => Promise<mongoose.FlattenMaps<import("../models/LoanProducts.model").ILoanProductDoc> & {
|
|
28
29
|
_id: mongoose.Types.ObjectId;
|
|
29
30
|
}>;
|
|
30
31
|
export declare const getLoanProductBalance: (productId: string, forDate?: Date) => Promise<{
|