creditu-common-library 2.3.11 → 2.3.12

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.
@@ -211,4 +211,19 @@ export declare class OfferParams {
211
211
  * Nombre del producto / servicio financiero
212
212
  */
213
213
  product?: string;
214
+ /**
215
+ * Umbral de LTV para cambiar el DR
216
+ * Threshold value for determining which frontend ratio to apply
217
+ */
218
+ ltvThresholdForFrontendRatio?: number;
219
+ /**
220
+ * DR 40% para LTV > 75%
221
+ * Maximum frontend ratio to apply when LTV is above the threshold
222
+ */
223
+ maximumFrontendRatioHighLTV?: number;
224
+ /**
225
+ * DR 50% para LTV ≤ 75%
226
+ * Maximum frontend ratio to apply when LTV is below or equal to the threshold
227
+ */
228
+ maximumFrontendRatioLowLTV?: number;
214
229
  }
@@ -16,7 +16,7 @@ export declare class MaximumLocalService {
16
16
  /**
17
17
  * Función que calcula el Máximo Local Dividendo Renta (M_a^DR)
18
18
  * Más info en {@link https://creditu-team.gitlab.io/wiki/content/journeys/acquisition/Offer.html#maximo-local-dividendo-renta}
19
- * @param params Parámetros definidos por el negocio para el calculo máximo local
19
+ * @param params Parámetros definidos por el negocio para el cálculo máximo local
20
20
  * @param longTermMonthlyFee Cuota largo plazo (Clp)
21
21
  */
22
22
  incomeDividend(params: MaximumLocalParams, longTermMonthlyFee: number): number;
@@ -36,17 +36,32 @@ var MaximumLocalService = /** @class */ (function () {
36
36
  /**
37
37
  * Función que calcula el Máximo Local Dividendo Renta (M_a^DR)
38
38
  * Más info en {@link https://creditu-team.gitlab.io/wiki/content/journeys/acquisition/Offer.html#maximo-local-dividendo-renta}
39
- * @param params Parámetros definidos por el negocio para el calculo máximo local
39
+ * @param params Parámetros definidos por el negocio para el cálculo máximo local
40
40
  * @param longTermMonthlyFee Cuota largo plazo (Clp)
41
41
  */
42
42
  MaximumLocalService.prototype.incomeDividend = function (params, longTermMonthlyFee) {
43
- var numerator = this.calculateIncomeDividendNumerator(longTermMonthlyFee, params);
43
+ var maximumFrontendRatio = params.maximumFrontendRatio.value();
44
+ // Apply LTV-dependent frontend ratio if the parameters exist
45
+ if (params.ltvThresholdForFrontendRatio !== undefined
46
+ && params.maximumFrontendRatioHighLTV !== undefined
47
+ && params.maximumFrontendRatioLowLTV !== undefined
48
+ && params.loanToValueHome !== undefined) {
49
+ // If LTV > threshold, use the high LTV ratio, otherwise use the low LTV ratio
50
+ if (params.loanToValueHome > params.ltvThresholdForFrontendRatio) {
51
+ maximumFrontendRatio = params.maximumFrontendRatioHighLTV;
52
+ }
53
+ else {
54
+ maximumFrontendRatio = params.maximumFrontendRatioLowLTV;
55
+ }
56
+ }
57
+ var numerator = this.calculateIncomeDividendNumerator(longTermMonthlyFee, params, maximumFrontendRatio);
44
58
  var denominator = this.calculateIncomeDividendDenominator(params);
45
59
  return this.math.divide(numerator, denominator);
46
60
  };
47
- MaximumLocalService.prototype.calculateIncomeDividendNumerator = function (longTermMonthlyFee, params) {
61
+ MaximumLocalService.prototype.calculateIncomeDividendNumerator = function (longTermMonthlyFee, params, maximumFrontendRatio) {
48
62
  var _a;
49
- var paymentCapacity = this.math.subtract(this.math.multiply(params.disposableIncome, params.maximumFrontendRatio.value()), longTermMonthlyFee);
63
+ var frontendRatio = maximumFrontendRatio || params.maximumFrontendRatio.value();
64
+ var paymentCapacity = this.math.subtract(this.math.multiply(params.disposableIncome, frontendRatio), longTermMonthlyFee);
50
65
  var creditInsuranceResidual = params.creditInsuranceFeeTermDefinition === credit_insurance_fee_term_definition_enum_1.CreditInsuranceFeeTermDefinition.LONG
51
66
  ? this.math.multiply(params.k2Fin, params.kScr)
52
67
  : 0;
@@ -121,6 +121,7 @@ var OfferService = /** @class */ (function () {
121
121
  // creditInsuranceFactor,
122
122
  creditInsurancePercentageFinanced);
123
123
  var amountRequestedByClient = this.amountRequestedByClient(downPayment, subsidy, propertyValue);
124
+ var estimatedLoanToValueHome = this.math.divide(amountRequestedByClient, propertyValue);
124
125
  var kScr = this.constantService.calculateKScr();
125
126
  // creditInsuranceFactor,
126
127
  // creditInsurancePercentageFinanced,
@@ -148,7 +149,11 @@ var OfferService = /** @class */ (function () {
148
149
  maximumBackendRatio: maximumBackendRatio,
149
150
  maximumFrontendRatio: maximumFrontendRatio,
150
151
  numberOfGraceMonths: numberOfGraceMonths,
151
- creditInsuranceNumberOfMonths: creditInsuranceNumberOfMonths
152
+ creditInsuranceNumberOfMonths: creditInsuranceNumberOfMonths,
153
+ ltvThresholdForFrontendRatio: params.ltvThresholdForFrontendRatio,
154
+ maximumFrontendRatioHighLTV: params.maximumFrontendRatioHighLTV,
155
+ maximumFrontendRatioLowLTV: params.maximumFrontendRatioLowLTV,
156
+ loanToValueHome: estimatedLoanToValueHome
152
157
  };
153
158
  var approvedAmountFinanceCharge = this.maximumLocal.financeCharge(maximumLocalParams, shortTermMonthlyFee, longTermMonthlyFee);
154
159
  var maximumLocalIncomeDividend = this.maximumLocal.incomeDividend(maximumLocalParams, longTermMonthlyFee);
@@ -166,6 +171,7 @@ var OfferService = /** @class */ (function () {
166
171
  ? 0
167
172
  : operationalExpensesFinanceable;
168
173
  var loanToValueCredit = this.ltv.credit(financingAmount, creditInsurancePremium, propertyValue, creditInsurancePercentageFinanced, operationalExpensesFinanced, operationalExpensesFinancing);
174
+ var financingRatio = this.math.divide(financingAmount, amountRequestedByClient);
169
175
  var loanToValueHome = this.ltv.home(financingAmount, propertyValue);
170
176
  var creditInsuranceInstallment = this.insurance.creditInsurance(financingAmount, creditInsuranceFactor, creditInsurancePercentageFinanced.value(), creditInsuranceNumberOfMonths, isCreditInsuranceAccelerated, creditInsurancePremium, numberOfGraceMonths, installment);
171
177
  var lifeInsuranceFee = this.insurance.lifeInsurance(creditAmount, totalLifeInsuranceMonthlyRate);
@@ -232,7 +238,7 @@ var OfferService = /** @class */ (function () {
232
238
  operationalExpensesFinanced: operationalExpensesFinanced,
233
239
  operationalExpenses: operationalExpenses,
234
240
  creditInsuranceFactor: creditInsuranceFactor,
235
- financingRatio: this.math.divide(financingAmount, amountRequestedByClient)
241
+ financingRatio: financingRatio
236
242
  };
237
243
  };
238
244
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "creditu-common-library",
3
- "version": "2.3.11",
3
+ "version": "2.3.12",
4
4
  "description": "Common library for Creditu applications",
5
5
  "main": "lib/index.js",
6
6
  "files": [
@@ -25,4 +25,8 @@ export interface MaximumLocalParams {
25
25
  isCreditInsuranceAccelerated: boolean;
26
26
  numberOfGraceMonths: number;
27
27
  creditInsuranceNumberOfMonths: number;
28
+ ltvThresholdForFrontendRatio?: number;
29
+ maximumFrontendRatioHighLTV?: number;
30
+ maximumFrontendRatioLowLTV?: number;
31
+ loanToValueHome?: number;
28
32
  }
@@ -49,26 +49,6 @@ describe('offer service functional tests common', () => {
49
49
  expect(result).toBe(70);
50
50
  });
51
51
  });
52
- describe('getPropertyValue', () => {
53
- it('getPropertyValue should return commercialValue when appraisal is 0', () => {
54
- // ACT
55
- const result = offerService.getPropertyValue(0, 70);
56
- // ASSERT
57
- expect(result).toBe(70);
58
- });
59
- it('getPropertyValue should return appraisal when appraisal is less than commercialValue', () => {
60
- // ACT
61
- const result = offerService.getPropertyValue(10, 70);
62
- // ASSERT
63
- expect(result).toBe(10);
64
- });
65
- it('getPropertyValue should return appraicommercialValuesal when commercialValue is less than appraisalValue', () => {
66
- // ACT
67
- const result = offerService.getPropertyValue(60, 30);
68
- // ASSERT
69
- expect(result).toBe(30);
70
- });
71
- });
72
52
  describe('getApprovedAmount', () => {
73
53
  it('getApprovedAmount should return maximumLocalFinanceCharge when is the minimum value', () => {
74
54
  // ACT