gemcap-be-common 1.5.134 → 1.5.136

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/brokers.db.js CHANGED
@@ -13,7 +13,9 @@ const LoanBroker_model_1 = require("../models/LoanBroker.model");
13
13
  const main_helper_1 = require("../helpers/main.helper");
14
14
  const handleBrokerInterestFee = (statementAmount, charges, interestShare, baseInterestTotal, primeRate) => {
15
15
  const interestCharge = charges.find((charge) => reports_db_1.EChargeType[charge.chargeType] === reports_db_1.EChargeType.INTEREST_FEE && charge.active && !charge.deletedAt);
16
- const interestBase = new decimal_js_1.default(primeRate).add(interestCharge?.percent || 0).div(baseInterestTotal).toDP(2).toNumber();
16
+ const interestBase = baseInterestTotal
17
+ ? new decimal_js_1.default(primeRate).add(interestCharge?.percent || 0).div(baseInterestTotal).toDP(2).toNumber()
18
+ : 0;
17
19
  const minBase = Math.min(1, interestBase);
18
20
  return new decimal_js_1.default(statementAmount).mul(interestShare).mul(minBase).toDP(2).toNumber();
19
21
  };
package/db/brokers.db.ts CHANGED
@@ -11,10 +11,12 @@ import { ILoanChargeDoc, ILoanChargeView } from '../models/LoanCharges.model';
11
11
 
12
12
  export const handleBrokerInterestFee = (statementAmount: number, charges: ILoanChargeView[], interestShare: number, baseInterestTotal: number, primeRate: number) => {
13
13
  const interestCharge = charges.find((charge) => EChargeType[charge.chargeType] === EChargeType.INTEREST_FEE && charge.active && !charge.deletedAt);
14
- const interestBase = new Decimal(primeRate).add(interestCharge?.percent || 0).div(baseInterestTotal).toDP(2).toNumber();
14
+ const interestBase = baseInterestTotal
15
+ ? new Decimal(primeRate).add(interestCharge?.percent || 0).div(baseInterestTotal).toDP(2).toNumber()
16
+ : 0;
15
17
  const minBase = Math.min(1, interestBase);
16
- return new Decimal(statementAmount).mul(interestShare).mul(minBase).toDP(2).toNumber();
17
- }
18
+ return new Decimal(statementAmount).mul(interestShare).mul(minBase).toDP(2).toNumber();
19
+ };
18
20
 
19
21
  export const getProductBrokers = async (productId: string) => {
20
22
  return ProductBroker.aggregate<IProductBrokerDocWithLoanBroker>([
@@ -51,7 +53,6 @@ export const enrichWithBrokers = async (transactions: ILedgerDataRow[], product:
51
53
  let statementAmount: number;
52
54
 
53
55
 
54
-
55
56
  if (shareName === 'interestShare') {
56
57
  statementAmount = handleBrokerInterestFee(-t.statementAmount, charges, broker.interestShare, broker.baseInterestTotal, primeRate);
57
58
  } else {
@@ -31,7 +31,7 @@ import mongoose from 'mongoose';
31
31
  import { TModelName } from './_models';
32
32
  import { TTaskStatus } from '../interfaces/task.interface';
33
33
  export declare const AI_JOBS_FOLDER = "AI_jobs";
34
- export declare const AI_JOB_TYPES: readonly ["loan-memo-excel", "approval-memo", "email-summary"];
34
+ export declare const AI_JOB_TYPES: readonly ["loan-memo-excel", "approval-memo", "email-summary", "borrower-assumption"];
35
35
  export type TAIJobType = (typeof AI_JOB_TYPES)[number];
36
36
  export interface IAIJobResponseChunk {
37
37
  type: 'text' | 'thinking' | 'tool' | 'status';
@@ -11,6 +11,7 @@ exports.AI_JOB_TYPES = [
11
11
  'loan-memo-excel',
12
12
  'approval-memo',
13
13
  'email-summary',
14
+ 'borrower-assumption',
14
15
  ];
15
16
  exports.AIJobSchema = new mongoose_1.default.Schema({
16
17
  taskId: {
@@ -9,6 +9,7 @@ export const AI_JOB_TYPES = [
9
9
  'loan-memo-excel',
10
10
  'approval-memo',
11
11
  'email-summary',
12
+ 'borrower-assumption',
12
13
  ] as const;
13
14
 
14
15
  export type TAIJobType = (typeof AI_JOB_TYPES)[number];
@@ -0,0 +1,51 @@
1
+ /// <reference types="mongoose/types/schematypes" />
2
+ /// <reference types="mongoose/types/types" />
3
+ /// <reference types="mongoose/types/models" />
4
+ /// <reference types="mongoose/types/schemaoptions" />
5
+ /// <reference types="mongoose/types/utility" />
6
+ /// <reference types="mongoose/types/document" />
7
+ /// <reference types="mongoose/types/aggregate" />
8
+ /// <reference types="mongoose/types/callback" />
9
+ /// <reference types="mongoose/types/collection" />
10
+ /// <reference types="mongoose/types/connection" />
11
+ /// <reference types="mongoose/types/cursor" />
12
+ /// <reference types="mongoose/types/document" />
13
+ /// <reference types="mongoose/types/error" />
14
+ /// <reference types="mongoose/types/expressions" />
15
+ /// <reference types="mongoose/types/helpers" />
16
+ /// <reference types="mongoose/types/middlewares" />
17
+ /// <reference types="mongoose/types/indexes" />
18
+ /// <reference types="mongoose/types/models" />
19
+ /// <reference types="mongoose/types/mongooseoptions" />
20
+ /// <reference types="mongoose/types/pipelinestage" />
21
+ /// <reference types="mongoose/types/populate" />
22
+ /// <reference types="mongoose/types/query" />
23
+ /// <reference types="mongoose/types/schemaoptions" />
24
+ /// <reference types="mongoose/types/schematypes" />
25
+ /// <reference types="mongoose/types/session" />
26
+ /// <reference types="mongoose/types/types" />
27
+ /// <reference types="mongoose/types/utility" />
28
+ /// <reference types="mongoose/types/validation" />
29
+ /// <reference types="mongoose/types/virtuals" />
30
+ /// <reference types="mongoose/types/inferschematype" />
31
+ import mongoose from 'mongoose';
32
+ export interface IBorrowerAssumption {
33
+ borrowerId: mongoose.Schema.Types.ObjectId;
34
+ assumptionFileId: string;
35
+ version: number;
36
+ uploadedAt: Date;
37
+ uploadedBy: string;
38
+ }
39
+ export interface IBorrowerAssumptionLean extends IBorrowerAssumption {
40
+ _id: mongoose.Types.ObjectId;
41
+ }
42
+ export interface IBorrowerAssumptionPlain extends Omit<IBorrowerAssumption, 'borrowerId'> {
43
+ _id: string;
44
+ borrowerId: string;
45
+ }
46
+ export type TBorrowerAssumptionDoc = mongoose.HydratedDocument<IBorrowerAssumption>;
47
+ export type TBorrowerAssumptionModel = mongoose.Model<IBorrowerAssumption>;
48
+ export declare const LoanBrokerSchema: mongoose.Schema<IBorrowerAssumption, TBorrowerAssumptionModel, {}, {}, {}, {}, mongoose.DefaultSchemaOptions, IBorrowerAssumption, mongoose.Document<unknown, {}, mongoose.FlatRecord<IBorrowerAssumption>> & mongoose.FlatRecord<IBorrowerAssumption> & {
49
+ _id: mongoose.Types.ObjectId;
50
+ }>;
51
+ export declare const LoanBroker: TBorrowerAssumptionModel;
@@ -0,0 +1,35 @@
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.LoanBroker = exports.LoanBrokerSchema = void 0;
7
+ const mongoose_1 = __importDefault(require("mongoose"));
8
+ const _models_1 = require("./_models");
9
+ exports.LoanBrokerSchema = new mongoose_1.default.Schema({
10
+ borrowerId: {
11
+ type: mongoose_1.default.Schema.Types.ObjectId,
12
+ ref: _models_1.MODEL_NAMES.borrowers,
13
+ required: true,
14
+ },
15
+ assumptionFileId: {
16
+ type: String,
17
+ required: true,
18
+ },
19
+ version: {
20
+ type: Number,
21
+ required: true,
22
+ },
23
+ uploadedAt: {
24
+ type: Date,
25
+ required: true,
26
+ },
27
+ uploadedBy: {
28
+ type: String,
29
+ required: true,
30
+ },
31
+ }, {
32
+ timestamps: { createdAt: true, updatedAt: true },
33
+ versionKey: false,
34
+ });
35
+ exports.LoanBroker = mongoose_1.default.model(_models_1.MODEL_NAMES.loanBrokers, exports.LoanBrokerSchema);
@@ -0,0 +1,56 @@
1
+ import mongoose from 'mongoose';
2
+
3
+ import { MODEL_NAMES } from './_models';
4
+
5
+ export interface IBorrowerAssumption {
6
+ borrowerId: mongoose.Schema.Types.ObjectId;
7
+ assumptionFileId: string;
8
+ version: number;
9
+ uploadedAt: Date;
10
+ uploadedBy: string;
11
+ }
12
+
13
+ export interface IBorrowerAssumptionLean extends IBorrowerAssumption {
14
+ _id: mongoose.Types.ObjectId;
15
+ }
16
+
17
+ export interface IBorrowerAssumptionPlain extends Omit<IBorrowerAssumption, 'borrowerId'> {
18
+ _id: string;
19
+ borrowerId: string;
20
+ }
21
+
22
+ export type TBorrowerAssumptionDoc = mongoose.HydratedDocument<IBorrowerAssumption>
23
+
24
+ export type TBorrowerAssumptionModel = mongoose.Model<IBorrowerAssumption>;
25
+
26
+ export const LoanBrokerSchema = new mongoose.Schema<IBorrowerAssumption, TBorrowerAssumptionModel>(
27
+ {
28
+ borrowerId: {
29
+ type: mongoose.Schema.Types.ObjectId,
30
+ ref: MODEL_NAMES.borrowers,
31
+ required: true,
32
+ },
33
+ assumptionFileId: {
34
+ type: String,
35
+ required: true,
36
+ },
37
+ version: {
38
+ type: Number,
39
+ required: true,
40
+ },
41
+ uploadedAt: {
42
+ type: Date,
43
+ required: true,
44
+ },
45
+ uploadedBy: {
46
+ type: String,
47
+ required: true,
48
+ },
49
+ },
50
+ {
51
+ timestamps: { createdAt: true, updatedAt: true },
52
+ versionKey: false,
53
+ },
54
+ );
55
+
56
+ export const LoanBroker = mongoose.model<IBorrowerAssumption, TBorrowerAssumptionModel>(MODEL_NAMES.loanBrokers, LoanBrokerSchema);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gemcap-be-common",
3
- "version": "1.5.134",
3
+ "version": "1.5.136",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {