gemcap-be-common 1.4.28 → 1.4.30

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.
@@ -22,13 +22,15 @@
22
22
  /// <reference types="mongoose/types/validation" />
23
23
  /// <reference types="mongoose/types/virtuals" />
24
24
  /// <reference types="mongoose/types/inferschematype" />
25
- import mongoose, { Model } from 'mongoose';
26
- import { IAvailabilitySignDoc, IAvailabilitySignItem } from '../models/AvailabilitySigns.model';
25
+ import mongoose from 'mongoose';
26
+ import { IAvailabilitySignItem } from '../models/AvailabilitySigns.model';
27
27
  import { IResult } from '../interfaces/result.interface';
28
- export declare const findAvailabilitySignsByBBCDateId: (bbcDateId: string) => Promise<mongoose.FlattenMaps<IAvailabilitySignDoc> & {
28
+ export declare const findAvailabilitySignsByBBCDateId: (bbcDateId: string) => Promise<mongoose.FlattenMaps<import("../models/AvailabilitySigns.model").IAvailabilitySignDoc> & {
29
29
  _id: mongoose.Types.ObjectId;
30
30
  }>;
31
- export declare const getAvailabilitySigns: (bbcDateIds: string[], repo?: Model<IAvailabilitySignDoc>) => Promise<(mongoose.FlattenMaps<IAvailabilitySignDoc> & {
31
+ export declare const getAvailabilitySigns: (bbcDateIds: string[], repo?: mongoose.Model<import("../models/AvailabilitySigns.model").IAvailabilitySignDoc, {}, {}, {}, mongoose.Document<unknown, {}, import("../models/AvailabilitySigns.model").IAvailabilitySignDoc> & import("../models/AvailabilitySigns.model").IAvailabilitySignDoc & {
32
+ _id: mongoose.Types.ObjectId;
33
+ }, any>) => Promise<(mongoose.FlattenMaps<import("../models/AvailabilitySigns.model").IAvailabilitySignDoc> & {
32
34
  _id: mongoose.Types.ObjectId;
33
35
  })[]>;
34
36
  export declare const addAvailabilitySign: (bbcDateId: string, sign: IAvailabilitySignItem) => Promise<IResult>;
@@ -1,8 +1,7 @@
1
- import mongoose, { Model } from 'mongoose';
1
+ import mongoose from 'mongoose';
2
2
 
3
3
  import {
4
4
  AvailabilitySignsModel,
5
- IAvailabilitySignDoc,
6
5
  IAvailabilitySignItem,
7
6
  } from '../models/AvailabilitySigns.model';
8
7
  import { IResult } from '../interfaces/result.interface';
@@ -11,7 +10,7 @@ export const findAvailabilitySignsByBBCDateId = async (bbcDateId: string) => {
11
10
  return AvailabilitySignsModel.findOne({ bbcDateId: new mongoose.Types.ObjectId(bbcDateId) }).lean();
12
11
  };
13
12
 
14
- export const getAvailabilitySigns = async (bbcDateIds: string[], repo: Model<IAvailabilitySignDoc> = AvailabilitySignsModel) => {
13
+ export const getAvailabilitySigns = async (bbcDateIds: string[], repo = AvailabilitySignsModel) => {
15
14
  return repo.find({ bbcDateId: { $in: bbcDateIds } }).lean();
16
15
  };
17
16
 
@@ -22,14 +22,17 @@
22
22
  /// <reference types="mongoose/types/validation" />
23
23
  /// <reference types="mongoose/types/virtuals" />
24
24
  /// <reference types="mongoose/types/inferschematype" />
25
- import mongoose, { Model } from 'mongoose';
25
+ import mongoose from 'mongoose';
26
26
  import { IBBCDateDoc } from '../models/BBCDate.model';
27
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
  }>;
31
31
  export declare const getBBCDatesByBorrower: (borrowerId: string, sortOrder?: 1 | -1) => Promise<IBBCDateDoc[]>;
32
- export declare const getLatestSignedBBCDateDoc: (borrowerId: string, date?: Date, repo?: Model<IBBCDateDoc>) => Promise<IBBCDateDoc | null>;
32
+ export declare const getLatestBBCDates: (borrowerId: string, date?: Date, repo?: mongoose.Model<IBBCDateDoc, {}, {}, {}, mongoose.Document<unknown, {}, IBBCDateDoc> & IBBCDateDoc & {
33
+ _id: mongoose.Types.ObjectId;
34
+ }, any>) => Promise<IBBCDateDoc[]>;
35
+ export declare const getLatestSignedBBCDateDoc: (borrowerId: string, date?: Date) => Promise<IBBCDateDoc | null>;
33
36
  export declare const getOlderBBCDates: (borrowerId: string, bbcDate: Date) => Promise<IBBCDateDoc[]>;
34
37
  export declare const getBBCDates: (borrowerId: string, bbcDate: Date) => Promise<IBBCDateDoc[]>;
35
38
  export declare const getBBCDatesForPeriod: (borrowerId: string, bbcDateStart: Date, bbcDateEnd: Date) => Promise<IBBCDateDoc[]>;
package/db/bbcDates.db.js CHANGED
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.createBBCDate = exports.getBBCDatesByType = exports.getBBCDatesForPeriod = exports.getBBCDates = exports.getOlderBBCDates = exports.getLatestSignedBBCDateDoc = exports.getBBCDatesByBorrower = exports.getBBCDateDoc = void 0;
6
+ exports.createBBCDate = exports.getBBCDatesByType = exports.getBBCDatesForPeriod = exports.getBBCDates = exports.getOlderBBCDates = exports.getLatestSignedBBCDateDoc = exports.getLatestBBCDates = exports.getBBCDatesByBorrower = exports.getBBCDateDoc = void 0;
7
7
  const mongoose_1 = __importDefault(require("mongoose"));
8
8
  const BBCDate_model_1 = require("../models/BBCDate.model");
9
9
  const BBCSheet_model_1 = require("../models/BBCSheet.model");
@@ -26,17 +26,24 @@ const getBBCDatesByBorrower = async (borrowerId, sortOrder = 1) => {
26
26
  ]);
27
27
  };
28
28
  exports.getBBCDatesByBorrower = getBBCDatesByBorrower;
29
- const getLatestSignedBBCDateDoc = async (borrowerId, date, repo = BBCDate_model_1.BBCDateModel) => {
29
+ const getLatestBBCDates = async (borrowerId, date, repo = BBCDate_model_1.BBCDateModel) => {
30
30
  const match = {
31
31
  borrowerId: new mongoose_1.default.Types.ObjectId(borrowerId),
32
32
  };
33
33
  if (date) {
34
34
  match.bbcDate = { $lte: date };
35
35
  }
36
- const bbcDates = await repo.aggregate([
37
- { $match: match },
38
- { $sort: { bbcDate: -1 } },
39
- ]);
36
+ return repo.aggregate([{ $match: match }, { $sort: { bbcDate: -1 } }]);
37
+ };
38
+ exports.getLatestBBCDates = getLatestBBCDates;
39
+ const getLatestSignedBBCDateDoc = async (borrowerId, date) => {
40
+ const match = {
41
+ borrowerId: new mongoose_1.default.Types.ObjectId(borrowerId),
42
+ };
43
+ if (date) {
44
+ match.bbcDate = { $lte: date };
45
+ }
46
+ const bbcDates = await (0, exports.getLatestBBCDates)(borrowerId, date);
40
47
  if (!bbcDates.length) {
41
48
  return null;
42
49
  }
package/db/bbcDates.db.ts CHANGED
@@ -1,4 +1,4 @@
1
- import mongoose, { Model } from 'mongoose';
1
+ import mongoose from 'mongoose';
2
2
 
3
3
  import { BBCDateModel, IBBCDateDoc } from '../models/BBCDate.model';
4
4
  import { BBCSheetModel } from '../models/BBCSheet.model';
@@ -23,7 +23,7 @@ export const getBBCDatesByBorrower = async (borrowerId: string, sortOrder: 1 | -
23
23
  ]);
24
24
  };
25
25
 
26
- export const getLatestSignedBBCDateDoc = async (borrowerId: string, date?: Date, repo: Model<IBBCDateDoc> = BBCDateModel): Promise<IBBCDateDoc | null> => {
26
+ export const getLatestBBCDates = async (borrowerId: string, date?: Date, repo = BBCDateModel) => {
27
27
  const match: {
28
28
  borrowerId: mongoose.Types.ObjectId;
29
29
  bbcDate?: { $lte: Date };
@@ -34,10 +34,21 @@ export const getLatestSignedBBCDateDoc = async (borrowerId: string, date?: Date,
34
34
  match.bbcDate = { $lte: date };
35
35
  }
36
36
 
37
- const bbcDates = await repo.aggregate<IBBCDateDoc>([
38
- { $match: match },
39
- { $sort: { bbcDate: -1 } },
40
- ]);
37
+ return repo.aggregate<IBBCDateDoc>([{ $match: match }, { $sort: { bbcDate: -1 } }]);
38
+ };
39
+
40
+ export const getLatestSignedBBCDateDoc = async (borrowerId: string, date?: Date,): Promise<IBBCDateDoc | null> => {
41
+ const match: {
42
+ borrowerId: mongoose.Types.ObjectId;
43
+ bbcDate?: { $lte: Date };
44
+ } = {
45
+ borrowerId: new mongoose.Types.ObjectId(borrowerId),
46
+ };
47
+ if (date) {
48
+ match.bbcDate = { $lte: date };
49
+ }
50
+
51
+ const bbcDates = await getLatestBBCDates(borrowerId, date);
41
52
  if (!bbcDates.length) {
42
53
  return null;
43
54
  }
@@ -64,7 +64,7 @@ export interface IAvailabilitySignView {
64
64
  }
65
65
  export interface IAvailabilitySignDoc extends IAvailabilitySign, mongoose.Document {
66
66
  }
67
- export declare const IAvailabilitySignSchema: mongoose.Schema<any, mongoose.Model<any, any, any, any, any, any>, {}, {}, {}, {}, {
67
+ export declare const AvailabilitySignSchema: mongoose.Schema<any, mongoose.Model<any, any, any, any, any, any>, {}, {}, {}, {}, {
68
68
  timestamps: true;
69
69
  }, {
70
70
  createdAt: NativeDate;
@@ -3,12 +3,11 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.AvailabilitySignsModel = exports.IAvailabilitySignSchema = exports.REQUIRED_SIGNS = void 0;
6
+ exports.AvailabilitySignsModel = exports.AvailabilitySignSchema = exports.REQUIRED_SIGNS = void 0;
7
7
  const mongoose_1 = __importDefault(require("mongoose"));
8
8
  const _models_1 = require("./_models");
9
- const mongooseLeanId = require('../plugins/id.plugin');
10
9
  exports.REQUIRED_SIGNS = 2;
11
- exports.IAvailabilitySignSchema = new mongoose_1.default.Schema({
10
+ exports.AvailabilitySignSchema = new mongoose_1.default.Schema({
12
11
  bbcDateId: {
13
12
  type: mongoose_1.default.Schema.Types.ObjectId,
14
13
  ref: _models_1.MODEL_NAMES.BBCDates,
@@ -41,5 +40,4 @@ exports.IAvailabilitySignSchema = new mongoose_1.default.Schema({
41
40
  ],
42
41
  __v: { type: Number, select: false },
43
42
  }, { timestamps: true });
44
- exports.IAvailabilitySignSchema.plugin(mongooseLeanId);
45
- exports.AvailabilitySignsModel = mongoose_1.default.model(_models_1.MODEL_NAMES.availabilitySign, exports.IAvailabilitySignSchema);
43
+ exports.AvailabilitySignsModel = mongoose_1.default.model(_models_1.MODEL_NAMES.availabilitySign, exports.AvailabilitySignSchema);
@@ -3,8 +3,6 @@ import mongoose from 'mongoose';
3
3
  import { IUser } from '../interfaces/auth-user.interface';
4
4
  import { MODEL_NAMES } from './_models';
5
5
 
6
- const mongooseLeanId = require('../plugins/id.plugin');
7
-
8
6
  export const REQUIRED_SIGNS = 2;
9
7
 
10
8
  export interface IAvailabilitySignItem {
@@ -53,7 +51,7 @@ export interface IAvailabilitySignView {
53
51
  export interface IAvailabilitySignDoc extends IAvailabilitySign, mongoose.Document {
54
52
  }
55
53
 
56
- export const IAvailabilitySignSchema = new mongoose.Schema(
54
+ export const AvailabilitySignSchema = new mongoose.Schema(
57
55
  {
58
56
  bbcDateId: {
59
57
  type: mongoose.Schema.Types.ObjectId,
@@ -90,6 +88,4 @@ export const IAvailabilitySignSchema = new mongoose.Schema(
90
88
  { timestamps: true },
91
89
  );
92
90
 
93
- IAvailabilitySignSchema.plugin(mongooseLeanId);
94
-
95
- export const AvailabilitySignsModel = mongoose.model<IAvailabilitySignDoc>(MODEL_NAMES.availabilitySign, IAvailabilitySignSchema);
91
+ export const AvailabilitySignsModel = mongoose.model<IAvailabilitySignDoc>(MODEL_NAMES.availabilitySign, AvailabilitySignSchema);
@@ -23,7 +23,7 @@
23
23
  /// <reference types="mongoose/types/virtuals" />
24
24
  /// <reference types="mongoose/types/inferschematype" />
25
25
  import Joi from 'joi';
26
- import mongoose, { Connection, Document, Model } from 'mongoose';
26
+ import mongoose, { Document } from 'mongoose';
27
27
  export interface ICreateBBCDate {
28
28
  date: Date;
29
29
  inventory: boolean;
@@ -64,4 +64,3 @@ export declare const BBCDateSchema: mongoose.Schema<any, mongoose.Model<any, any
64
64
  _id: mongoose.Types.ObjectId;
65
65
  }>;
66
66
  export declare const BBCDateModel: mongoose.Model<IBBCDateDoc>;
67
- export declare const createBBCDateModel: (conn: Connection) => Model<IBBCDateDoc>;
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.createBBCDateModel = exports.BBCDateModel = exports.BBCDateSchema = exports.ICreateBBCDateSchema = void 0;
6
+ exports.BBCDateModel = exports.BBCDateSchema = exports.ICreateBBCDateSchema = void 0;
7
7
  const joi_1 = __importDefault(require("joi"));
8
8
  const mongoose_1 = __importDefault(require("mongoose"));
9
9
  const _models_1 = require("./_models");
@@ -28,5 +28,3 @@ exports.BBCDateSchema = new mongoose_1.default.Schema({
28
28
  }, { timestamps: true });
29
29
  exports.BBCDateSchema.plugin(mongooseLeanId);
30
30
  exports.BBCDateModel = mongoose_1.default.model(_models_1.MODEL_NAMES.BBCDates, exports.BBCDateSchema);
31
- const createBBCDateModel = (conn) => conn.model(_models_1.MODEL_NAMES.BBCDates, exports.BBCDateSchema);
32
- exports.createBBCDateModel = createBBCDateModel;
@@ -1,5 +1,5 @@
1
1
  import Joi from 'joi';
2
- import mongoose, { Connection, Document, Model } from 'mongoose';
2
+ import mongoose, { Document } from 'mongoose';
3
3
 
4
4
  import { MODEL_NAMES } from './_models';
5
5
 
@@ -46,5 +46,3 @@ export const BBCDateSchema = new mongoose.Schema(
46
46
  BBCDateSchema.plugin(mongooseLeanId);
47
47
 
48
48
  export const BBCDateModel: mongoose.Model<IBBCDateDoc> = mongoose.model<IBBCDateDoc>(MODEL_NAMES.BBCDates, BBCDateSchema);
49
-
50
- export const createBBCDateModel = (conn: Connection): Model<IBBCDateDoc> => conn.model<IBBCDateDoc>(MODEL_NAMES.BBCDates, BBCDateSchema);
package/models/_index.js CHANGED
@@ -86,7 +86,7 @@ exports.allSchemas = [
86
86
  { name: _models_1.MODEL_NAMES.accountPayableItem, schema: AccountPayableItem_model_1.AccountPayableItemSchema },
87
87
  { name: _models_1.MODEL_NAMES.allocatedBankTransactions, schema: AllocatedBankTransaction_model_1.AllocatedBankTransactionSchema },
88
88
  { name: _models_1.MODEL_NAMES.allocatedData, schema: AllocatedData_model_1.AllocatedDataSchema },
89
- { name: _models_1.MODEL_NAMES.availabilitySign, schema: AvailabilitySigns_model_1.IAvailabilitySignSchema },
89
+ { name: _models_1.MODEL_NAMES.availabilitySign, schema: AvailabilitySigns_model_1.AvailabilitySignSchema },
90
90
  { name: _models_1.MODEL_NAMES.availabilitySignedData, schema: AvilabilitySignedData_model_1.AvailabilitySignedDataSchema },
91
91
  { name: _models_1.MODEL_NAMES.banks, schema: Banks_model_1.BankSchema },
92
92
  { name: _models_1.MODEL_NAMES.BBCDates, schema: BBCDate_model_1.BBCDateSchema },
package/models/_index.ts CHANGED
@@ -2,7 +2,7 @@ import { MODEL_NAMES } from './_models';
2
2
  import { AccountPayableItemSchema } from './AccountPayableItem.model';
3
3
  import { AllocatedBankTransactionSchema } from './AllocatedBankTransaction.model';
4
4
  import { AllocatedDataSchema } from './AllocatedData.model';
5
- import { IAvailabilitySignSchema } from './AvailabilitySigns.model';
5
+ import { AvailabilitySignSchema } from './AvailabilitySigns.model';
6
6
  import { AvailabilitySignedDataSchema } from './AvilabilitySignedData.model';
7
7
  import { BankSchema } from './Banks.model';
8
8
  import { BBCDateSchema } from './BBCDate.model';
@@ -84,7 +84,7 @@ export const allSchemas = [
84
84
  { name: MODEL_NAMES.accountPayableItem, schema: AccountPayableItemSchema },
85
85
  { name: MODEL_NAMES.allocatedBankTransactions, schema: AllocatedBankTransactionSchema },
86
86
  { name: MODEL_NAMES.allocatedData, schema: AllocatedDataSchema },
87
- { name: MODEL_NAMES.availabilitySign, schema: IAvailabilitySignSchema },
87
+ { name: MODEL_NAMES.availabilitySign, schema: AvailabilitySignSchema },
88
88
  { name: MODEL_NAMES.availabilitySignedData, schema: AvailabilitySignedDataSchema },
89
89
  { name: MODEL_NAMES.banks, schema: BankSchema },
90
90
  { name: MODEL_NAMES.BBCDates, schema: BBCDateSchema },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gemcap-be-common",
3
- "version": "1.4.28",
3
+ "version": "1.4.30",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -84,10 +84,10 @@ export declare class BorrowerService {
84
84
  getBorrowerCodesMap(): Promise<Map<string, string>>;
85
85
  getBorrowerStatementDetails(borrowers: IBorrowerDocument[]): Promise<{
86
86
  [x: number]: {
87
- SELECTED_PERIOD?: boolean;
88
- ENTIRE_LOAN?: boolean;
89
87
  LAST_MONTH?: boolean;
90
88
  CURRENT_MONTH?: boolean;
89
+ ENTIRE_LOAN?: boolean;
90
+ SELECTED_PERIOD?: boolean;
91
91
  TERM_LOAN?: boolean;
92
92
  };
93
93
  }>;