gemcap-be-common 1.5.180 → 1.5.182

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,29 @@
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
+ export type TToPlainValue<T> = T extends mongoose.Types.ObjectId | null ? string | null : T extends Date | null ? string | null : T;
27
+ export type TUpdatePayload<T, TReadonly extends keyof T = never> = {
28
+ [K in keyof Omit<T, TReadonly>]?: TToPlainValue<T[K]>;
29
+ };
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,12 @@
1
+ import mongoose from 'mongoose';
2
+
3
+ export type TToPlainValue<T> =
4
+ T extends mongoose.Types.ObjectId | null
5
+ ? string | null
6
+ : T extends Date | null
7
+ ? string | null
8
+ : T;
9
+
10
+ export type TUpdatePayload<T, TReadonly extends keyof T = never> = {
11
+ [K in keyof Omit<T, TReadonly>]?: TToPlainValue<T[K]>;
12
+ };
@@ -23,6 +23,7 @@
23
23
  /// <reference types="mongoose/types/virtuals" />
24
24
  /// <reference types="mongoose/types/inferschematype" />
25
25
  import mongoose from 'mongoose';
26
+ import { TUpdatePayload } from '../interfaces/db.interface';
26
27
  export interface IBorrowerFinanceSettings {
27
28
  borrowerId: mongoose.Types.ObjectId;
28
29
  companyId: mongoose.Types.ObjectId | null;
@@ -42,13 +43,14 @@ export interface IBorrowerFinanceSettingsLean extends IBorrowerFinanceSettings {
42
43
  export interface IBorrowerFinanceSettingsPlain extends Omit<IBorrowerFinanceSettings, 'borrowerId' | 'companyId' | 'reserveCodeCompanyId' | 'reserveCodeId'> {
43
44
  _id: string;
44
45
  borrowerId: string;
45
- companyId: string;
46
- reserveCodeCompanyId: string;
47
- reserveCodeId: string;
46
+ companyId: string | null;
47
+ reserveCodeCompanyId: string | null;
48
+ reserveCodeId: string | null;
48
49
  createdAt: Date;
49
50
  updatedAt: Date;
50
51
  }
51
52
  export type TBorrowerFinanceSettingsModel = mongoose.Model<TBorrowerFinanceSettingsDoc>;
53
+ export type TUpdateBorrowerFinanceSettings = TUpdatePayload<IBorrowerFinanceSettings, 'borrowerId'>;
52
54
  export declare const BorrowerFinanceSettingsSchema: mongoose.Schema<any, mongoose.Model<any, any, any, any, any, any>, {}, {}, {}, {}, {
53
55
  timestamps: true;
54
56
  }, {
@@ -1,6 +1,7 @@
1
1
  import mongoose from 'mongoose';
2
2
 
3
3
  import { MODEL_NAMES } from './_models';
4
+ import { TToPlainValue, TUpdatePayload } from '../interfaces/db.interface';
4
5
 
5
6
  export interface IBorrowerFinanceSettings {
6
7
  borrowerId: mongoose.Types.ObjectId;
@@ -27,15 +28,17 @@ export interface IBorrowerFinanceSettingsLean extends IBorrowerFinanceSettings {
27
28
  export interface IBorrowerFinanceSettingsPlain extends Omit<IBorrowerFinanceSettings, 'borrowerId' | 'companyId' | 'reserveCodeCompanyId' | 'reserveCodeId'> {
28
29
  _id: string;
29
30
  borrowerId: string;
30
- companyId: string;
31
- reserveCodeCompanyId: string;
32
- reserveCodeId: string;
31
+ companyId: string | null;
32
+ reserveCodeCompanyId: string | null;
33
+ reserveCodeId: string | null;
33
34
  createdAt: Date;
34
35
  updatedAt: Date;
35
36
  }
36
37
 
37
38
  export type TBorrowerFinanceSettingsModel = mongoose.Model<TBorrowerFinanceSettingsDoc>;
38
39
 
40
+ export type TUpdateBorrowerFinanceSettings = TUpdatePayload<IBorrowerFinanceSettings, 'borrowerId'>;
41
+
39
42
  export const BorrowerFinanceSettingsSchema = new mongoose.Schema(
40
43
  {
41
44
  borrowerId: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gemcap-be-common",
3
- "version": "1.5.180",
3
+ "version": "1.5.182",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -22,6 +22,7 @@ const TermLoan_model_1 = require("../models/TermLoan.model");
22
22
  const loan_statement_db_1 = require("../db/loan-statement.db");
23
23
  const BBCDate_model_1 = require("../models/BBCDate.model");
24
24
  const financial_indexes_service_1 = require("./financial-indexes.service");
25
+ const BorrowerFinanceSettings_model_1 = require("../models/BorrowerFinanceSettings.model");
25
26
  dayjs_1.default.extend(utc_1.default);
26
27
  dayjs_1.default.extend(timezone_1.default);
27
28
  class LoanStatementService {
@@ -179,6 +180,11 @@ class LoanStatementService {
179
180
  await loanStatementEffectsService.saveMonthData(productId, statementDate);
180
181
  const charges = await this.loanChargesService.getLoanChargeForProduct(productId);
181
182
  const product = await this.loanChargesService.getLoanProductById(productId);
183
+ const borrowerFinanceSettings = await BorrowerFinanceSettings_model_1.BorrowerFinanceSettings.findOne({ borrowerId: product.borrowerId }).lean().exec();
184
+ // If borrower accrual is enabled, skip everything early
185
+ if (borrowerFinanceSettings && borrowerFinanceSettings.accrualEnabled && (0, dayjs_1.default)(statementDate).isSameOrAfter((0, dayjs_1.default)(borrowerFinanceSettings.accrualAppliedFrom))) {
186
+ return;
187
+ }
182
188
  // If product is already deactivated for this statement date (inclusive) — skip everything early
183
189
  if (product.deactivationDate && (0, dayjs_1.default)(statementDate).isSameOrAfter((0, dayjs_1.default)(product.deactivationDate))) {
184
190
  return;
@@ -38,6 +38,7 @@ import { LoanStatementBalanceService } from './loan-statement-balance.service';
38
38
  import { TermLoanService } from './term-loan.service';
39
39
  import { UploadsService } from './uploads.service';
40
40
  import { LoanStatementEffectsService } from './loan-statement-effects.service';
41
+ import { BorrowerFinanceSettings } from '../models/BorrowerFinanceSettings.model';
41
42
 
42
43
  dayjs.extend(utc);
43
44
  dayjs.extend(timezone);
@@ -218,6 +219,12 @@ export class LoanStatementService {
218
219
 
219
220
  const charges = await this.loanChargesService.getLoanChargeForProduct(productId);
220
221
  const product = await this.loanChargesService.getLoanProductById(productId);
222
+ const borrowerFinanceSettings = await BorrowerFinanceSettings.findOne({ borrowerId: product.borrowerId }).lean().exec();
223
+
224
+ // If borrower accrual is enabled, skip everything early
225
+ if (borrowerFinanceSettings && borrowerFinanceSettings.accrualEnabled && dayjs(statementDate).isSameOrAfter(dayjs(borrowerFinanceSettings.accrualAppliedFrom))) {
226
+ return;
227
+ }
221
228
 
222
229
  // If product is already deactivated for this statement date (inclusive) — skip everything early
223
230
  if (product.deactivationDate && dayjs(statementDate).isSameOrAfter(dayjs(product.deactivationDate))) {