creditu-common-library 1.16.2 → 2.1.0
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/debt/models/dto/balances-output.dto.d.ts +2 -2
- package/debt/models/dto/debt-inputs.dto.d.ts +5 -5
- package/debt/models/dto/debt-params.dto.d.ts +27 -0
- package/debt/models/dto/debt-params.dto.js +32 -1
- package/debt/models/dto/debt-response.dto.d.ts +7 -7
- package/debt/models/dto/inflation-by-dates.dto.d.ts +14 -0
- package/debt/models/dto/inflation-by-dates.dto.js +9 -0
- package/debt/models/lates-input.dto.d.ts +4 -0
- package/debt/services/amortization.service.d.ts +13 -19
- package/debt/services/amortization.service.js +40 -50
- package/debt/services/balance.service.d.ts +9 -7
- package/debt/services/balance.service.js +34 -24
- package/debt/services/index.d.ts +2 -2
- package/debt/services/index.js +3 -3
- package/debt/services/inflation.service.d.ts +30 -0
- package/debt/services/inflation.service.js +101 -0
- package/debt/services/installment.service.d.ts +1 -1
- package/debt/services/installment.service.js +30 -21
- package/debt/services/insurance.service.d.ts +13 -8
- package/debt/services/insurance.service.js +61 -18
- package/debt/services/interest.service.d.ts +12 -4
- package/debt/services/interest.service.js +43 -16
- package/debt/services/late.service.d.ts +14 -5
- package/debt/services/late.service.js +59 -31
- package/debt/services/monthly-payment.service.d.ts +5 -5
- package/debt/services/monthly-payment.service.js +15 -13
- package/package.json +4 -3
- package/shared/models/enum/insurances-strategy.enum.d.ts +4 -0
- package/shared/models/enum/insurances-strategy.enum.js +8 -0
- package/shared/models/enum/month-nominal-length.enum.d.ts +6 -0
- package/shared/models/enum/month-nominal-length.enum.js +10 -0
- package/shared/models/guarder.d.ts +2 -0
- package/shared/models/guarder.js +10 -0
- package/test/br/excel-translator.ts +171 -0
- package/test/br/installment.service.spec.ts +1218 -1218
- package/test/br/new-installment.service.specto.ts +727 -0
- package/debt/models/dto/daily-ipca-output.dto.d.ts +0 -14
- package/debt/models/dto/daily-ipca-output.dto.js +0 -9
- package/debt/services/ipca.service.d.ts +0 -28
- package/debt/services/ipca.service.js +0 -94
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
export declare class BalancesOutput {
|
|
2
2
|
/**
|
|
3
|
-
* Arreglo de saldos insolutos diarios aplicando
|
|
3
|
+
* Arreglo de saldos insolutos diarios aplicando inflación
|
|
4
4
|
*/
|
|
5
5
|
balances: number[];
|
|
6
6
|
/**
|
|
7
|
-
* Arreglo de montos darios de
|
|
7
|
+
* Arreglo de montos darios de corrección monetaria
|
|
8
8
|
*/
|
|
9
9
|
balanceMonetaryUpdateValues: number[];
|
|
10
10
|
}
|
|
@@ -28,7 +28,7 @@ export declare class DebtInputs {
|
|
|
28
28
|
*/
|
|
29
29
|
previousBalance: PreviousBalance;
|
|
30
30
|
/**
|
|
31
|
-
* Maximo de
|
|
31
|
+
* Maximo de inflación a pagar pactado con el cliente
|
|
32
32
|
*/
|
|
33
33
|
inflationaryUpperBound: number;
|
|
34
34
|
/**
|
|
@@ -36,15 +36,15 @@ export declare class DebtInputs {
|
|
|
36
36
|
*/
|
|
37
37
|
propertyAmount: number;
|
|
38
38
|
/**
|
|
39
|
-
* Mapa de
|
|
39
|
+
* Mapa de inflaciones en el rango de fechas de la deuda a calcular
|
|
40
40
|
* Key: Date YYYY/MM/DD format, Value: number format
|
|
41
41
|
*/
|
|
42
|
-
|
|
42
|
+
inflationMap: Record<string, number>;
|
|
43
43
|
/**
|
|
44
|
-
* Mapa de
|
|
44
|
+
* Mapa de inflaciones en el rango de fechas de la mora a calcular
|
|
45
45
|
* Key: Date YYYY/MM/DD format, Value: number format
|
|
46
46
|
*/
|
|
47
|
-
|
|
47
|
+
inflationMapLate: Record<string, number>;
|
|
48
48
|
/**
|
|
49
49
|
* Fecha a sobre la cuál se desea calcular la mora
|
|
50
50
|
*/
|
|
@@ -1,4 +1,7 @@
|
|
|
1
|
+
import { InterestType } from '../../../shared/models';
|
|
1
2
|
import { CreditInsuranceRate } from '../../../shared/models/credit-insurance-rate';
|
|
3
|
+
import { InsurancesStrategy } from '../../../shared/models/enum/insurances-strategy.enum';
|
|
4
|
+
import { MonthNominalLength } from '../../../shared/models/enum/month-nominal-length.enum';
|
|
2
5
|
/**
|
|
3
6
|
* Parametros para el calculo de la Deuda
|
|
4
7
|
*/
|
|
@@ -27,4 +30,28 @@ export declare class DebtParams {
|
|
|
27
30
|
* Tasa de multa mensual por atraso
|
|
28
31
|
*/
|
|
29
32
|
lateChargesInterestRate?: number;
|
|
33
|
+
/**
|
|
34
|
+
* Comportamiento del largo del mes, por defecto es REAL
|
|
35
|
+
*/
|
|
36
|
+
monthNominalLength?: number | MonthNominalLength;
|
|
37
|
+
/**
|
|
38
|
+
* Peridiocidad de los intereses, por defecto es Compuesta
|
|
39
|
+
*/
|
|
40
|
+
inflationExchangeMethodMonthlyToDaily?: InterestType;
|
|
41
|
+
/**
|
|
42
|
+
* Peridiocidad de los intereses, por defecto es Compuesta
|
|
43
|
+
*/
|
|
44
|
+
inflationExchangeMethodYearlyToMonthly?: InterestType;
|
|
45
|
+
/**
|
|
46
|
+
* Estrategia a usar para el calculo de los seguros.
|
|
47
|
+
* Por defecto es PERIODS, que es el cálculo que ya veníamos haciendo.
|
|
48
|
+
* La alternativa es BALANCES, que es el cálculo que se hace en el Excel "Producto_LowCode-Desarrollo"
|
|
49
|
+
*/
|
|
50
|
+
insurancesStrategy?: InsurancesStrategy;
|
|
51
|
+
/**
|
|
52
|
+
* Indica si se hace algún pago durante los meses de gracia
|
|
53
|
+
* Por defecto es true
|
|
54
|
+
*/
|
|
55
|
+
hasGracePeriodAnyPayment?: boolean;
|
|
56
|
+
constructor(params: DebtParams);
|
|
30
57
|
}
|
|
@@ -1,11 +1,42 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.DebtParams = void 0;
|
|
4
|
+
var models_1 = require("../../../shared/models");
|
|
5
|
+
var insurances_strategy_enum_1 = require("../../../shared/models/enum/insurances-strategy.enum");
|
|
6
|
+
var month_nominal_length_enum_1 = require("../../../shared/models/enum/month-nominal-length.enum");
|
|
4
7
|
/**
|
|
5
8
|
* Parametros para el calculo de la Deuda
|
|
6
9
|
*/
|
|
7
10
|
var DebtParams = /** @class */ (function () {
|
|
8
|
-
function DebtParams() {
|
|
11
|
+
function DebtParams(params) {
|
|
12
|
+
var _this = this;
|
|
13
|
+
/**
|
|
14
|
+
* Comportamiento del largo del mes, por defecto es REAL
|
|
15
|
+
*/
|
|
16
|
+
this.monthNominalLength = month_nominal_length_enum_1.MonthNominalLength.REAL;
|
|
17
|
+
/**
|
|
18
|
+
* Peridiocidad de los intereses, por defecto es Compuesta
|
|
19
|
+
*/
|
|
20
|
+
this.inflationExchangeMethodMonthlyToDaily = models_1.InterestType.COMPOUND;
|
|
21
|
+
/**
|
|
22
|
+
* Peridiocidad de los intereses, por defecto es Compuesta
|
|
23
|
+
*/
|
|
24
|
+
this.inflationExchangeMethodYearlyToMonthly = models_1.InterestType.COMPOUND;
|
|
25
|
+
/**
|
|
26
|
+
* Estrategia a usar para el calculo de los seguros.
|
|
27
|
+
* Por defecto es PERIODS, que es el cálculo que ya veníamos haciendo.
|
|
28
|
+
* La alternativa es BALANCES, que es el cálculo que se hace en el Excel "Producto_LowCode-Desarrollo"
|
|
29
|
+
*/
|
|
30
|
+
this.insurancesStrategy = insurances_strategy_enum_1.InsurancesStrategy.PERIODS;
|
|
31
|
+
/**
|
|
32
|
+
* Indica si se hace algún pago durante los meses de gracia
|
|
33
|
+
* Por defecto es true
|
|
34
|
+
*/
|
|
35
|
+
this.hasGracePeriodAnyPayment = true;
|
|
36
|
+
Object.entries(params).forEach(function (_a) {
|
|
37
|
+
var key = _a[0], value = _a[1];
|
|
38
|
+
_this[key] = value;
|
|
39
|
+
});
|
|
9
40
|
}
|
|
10
41
|
return DebtParams;
|
|
11
42
|
}());
|
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
import { BalancesOutput } from './balances-output.dto';
|
|
2
|
-
import {
|
|
2
|
+
import { InflationByDates } from './inflation-by-dates.dto';
|
|
3
3
|
/**
|
|
4
4
|
* Respuesta del calculo de la deuda
|
|
5
5
|
*/
|
|
6
6
|
export declare class DebtResponse {
|
|
7
|
-
/**
|
|
8
|
-
|
|
9
|
-
/** Saldos calculados
|
|
7
|
+
/** Inflación diaria para las fechas de calculo de deuda */
|
|
8
|
+
inflationByDates: InflationByDates[];
|
|
9
|
+
/** Saldos calculados aplicando inflación */
|
|
10
10
|
balanceValues: BalancesOutput;
|
|
11
11
|
/** Saldo insoluto corregido por inflación */
|
|
12
12
|
balanceInflationaryUpdated: number;
|
|
13
13
|
/** Saldo total despues del pago */
|
|
14
14
|
balanceAfter: number;
|
|
15
|
-
/** Monto total a pagar por concepto de
|
|
16
|
-
|
|
15
|
+
/** Monto total a pagar por concepto de inflación */
|
|
16
|
+
inflationaryUpdate: number;
|
|
17
17
|
/** Interés sin inflación */
|
|
18
18
|
interest: number;
|
|
19
19
|
/** Diferencia entre interés sin corrección monetaria y con */
|
|
@@ -37,7 +37,7 @@ export declare class DebtResponse {
|
|
|
37
37
|
/** amortización de capital que se aplicará finalmente */
|
|
38
38
|
amortization: number;
|
|
39
39
|
/** amortización teórica por concepto de inflación */
|
|
40
|
-
|
|
40
|
+
amortizationInflation: number;
|
|
41
41
|
/** Cuota de seguro de vida o desgravamen */
|
|
42
42
|
totalLifeInsuranceFee: number;
|
|
43
43
|
/** Cuota de seguro de vida o desgravamen aplicado al deudor */
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export declare class InflationByDates {
|
|
2
|
+
/**
|
|
3
|
+
* Fecha formato YYYY/MM/DD
|
|
4
|
+
*/
|
|
5
|
+
date: string;
|
|
6
|
+
/**
|
|
7
|
+
* Valor de la inflación para el mes de la fecha
|
|
8
|
+
*/
|
|
9
|
+
inflation: number;
|
|
10
|
+
/**
|
|
11
|
+
* Valor de la inflación para el dia
|
|
12
|
+
*/
|
|
13
|
+
dailyInflation: number;
|
|
14
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.InflationByDates = void 0;
|
|
4
|
+
var InflationByDates = /** @class */ (function () {
|
|
5
|
+
function InflationByDates() {
|
|
6
|
+
}
|
|
7
|
+
return InflationByDates;
|
|
8
|
+
}());
|
|
9
|
+
exports.InflationByDates = InflationByDates;
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { InterestType } from '../../shared/models';
|
|
2
|
+
import { MonthNominalLength } from '../../shared/models/enum/month-nominal-length.enum';
|
|
1
3
|
export declare class LatesInput {
|
|
2
4
|
dueDate: string;
|
|
3
5
|
today: string;
|
|
@@ -7,4 +9,6 @@ export declare class LatesInput {
|
|
|
7
9
|
annualCreditInterestRate: number;
|
|
8
10
|
inflationMap: Record<string, number>;
|
|
9
11
|
considerNegativeInflation: boolean;
|
|
12
|
+
monthNominalLength: number | MonthNominalLength;
|
|
13
|
+
inflationExchangeMethodYearlyToMonthly: InterestType;
|
|
10
14
|
}
|
|
@@ -1,51 +1,45 @@
|
|
|
1
1
|
import { MathService } from '../../math';
|
|
2
|
-
import { NumberOfMonths } from '../../shared/models/number-of-months';
|
|
3
|
-
import { PaymentNumber } from '../../shared/models/payment-number';
|
|
4
2
|
import { DebtInputs } from '../models/dto';
|
|
5
3
|
export declare class AmortizationService {
|
|
6
4
|
private readonly math;
|
|
7
5
|
constructor(math: MathService);
|
|
8
|
-
private readonly
|
|
6
|
+
private readonly inflationService;
|
|
9
7
|
private readonly interestService;
|
|
10
8
|
private getMonthlyPayment;
|
|
11
|
-
private getAmortizationDiffGerman;
|
|
12
9
|
/**
|
|
13
10
|
*
|
|
14
11
|
* @param monthlyRate Tasa mensual del crédito
|
|
15
|
-
* @param
|
|
16
|
-
* @param previusBalance Balance anterior
|
|
12
|
+
* @param periods Cantidad de cuotas restantes
|
|
17
13
|
* @param balance Balance actual
|
|
18
|
-
* @param paymentNumber Número de cuota
|
|
19
14
|
* @returns
|
|
20
15
|
*/
|
|
21
|
-
private
|
|
16
|
+
private getAmortizationFrench;
|
|
22
17
|
/**
|
|
23
18
|
*
|
|
24
19
|
* @param monthlyRate Tasa mensual del crédito
|
|
25
|
-
* @param
|
|
20
|
+
* @param previusBalance Balance anterior
|
|
26
21
|
* @param balance Balance actual
|
|
27
|
-
* @param paymentNumber Número de cuota
|
|
28
22
|
* @returns
|
|
29
23
|
*/
|
|
30
|
-
private
|
|
24
|
+
private getAmortizationDiffFrench;
|
|
31
25
|
/**
|
|
32
26
|
* Calcula la amortizacion
|
|
33
|
-
* @param
|
|
34
|
-
* @param numberOfMonths
|
|
27
|
+
* @param periods
|
|
35
28
|
* @param balance
|
|
36
29
|
*/
|
|
37
|
-
getAmortizationGerman(
|
|
30
|
+
getAmortizationGerman(periods: number, balance: number): number;
|
|
31
|
+
private getAmortizationDiffGerman;
|
|
38
32
|
getAmortizationIUB(inputs: any, balance: any, annualRate: any): {
|
|
39
33
|
amortizationIUB: any;
|
|
40
34
|
amortizationDiff: any;
|
|
41
35
|
};
|
|
42
|
-
getAmortization(amortizationIUB: number,
|
|
43
|
-
|
|
44
|
-
getAmortizations(inputs: DebtInputs, balance: number, annualRate: number,
|
|
45
|
-
|
|
36
|
+
getAmortization(amortizationIUB: number, amortizationDiff: number, postponedInflationaryUpdate: number): number;
|
|
37
|
+
getAmortizationInflation(upperBound: number, amortizationDiff: number, inflationaryUpdate: number): number;
|
|
38
|
+
getAmortizations(inputs: DebtInputs, balance: number, annualRate: number, inflationaryUpdate: number): {
|
|
39
|
+
inflationaryUpdate: number;
|
|
46
40
|
upperBound: number;
|
|
47
41
|
postponedInflationaryUpdate: number;
|
|
48
|
-
|
|
42
|
+
amortizationInflation: number;
|
|
49
43
|
amortization: number;
|
|
50
44
|
amortizationIUB: any;
|
|
51
45
|
amortizationDiff: any;
|
|
@@ -5,11 +5,11 @@ var math_1 = require("../../math");
|
|
|
5
5
|
var guarder_1 = require("../../shared/models/guarder");
|
|
6
6
|
var models_1 = require("../../shared/models");
|
|
7
7
|
var interest_service_1 = require("./interest.service");
|
|
8
|
-
var
|
|
8
|
+
var inflation_service_1 = require("./inflation.service");
|
|
9
9
|
var AmortizationService = /** @class */ (function () {
|
|
10
10
|
function AmortizationService(math) {
|
|
11
11
|
this.math = math;
|
|
12
|
-
this.
|
|
12
|
+
this.inflationService = new inflation_service_1.InflationService(this.math);
|
|
13
13
|
this.interestService = new interest_service_1.InterestService(this.math);
|
|
14
14
|
this.math = new math_1.MathService(true, 10);
|
|
15
15
|
}
|
|
@@ -19,96 +19,86 @@ var AmortizationService = /** @class */ (function () {
|
|
|
19
19
|
var periodRate = this.math.subtract(periodInterest, 1);
|
|
20
20
|
return this.math.multiply(this.math.divide(interest, periodRate), balance);
|
|
21
21
|
};
|
|
22
|
-
AmortizationService.prototype.getAmortizationDiffGerman = function (previousBalance, balance, numberOfMonths) {
|
|
23
|
-
return this.math.round(this.math.divide(this.math.subtract(balance, previousBalance), numberOfMonths), 10);
|
|
24
|
-
};
|
|
25
22
|
/**
|
|
26
23
|
*
|
|
27
24
|
* @param monthlyRate Tasa mensual del crédito
|
|
28
|
-
* @param
|
|
29
|
-
* @param previusBalance Balance anterior
|
|
25
|
+
* @param periods Cantidad de cuotas restantes
|
|
30
26
|
* @param balance Balance actual
|
|
31
|
-
* @param paymentNumber Número de cuota
|
|
32
27
|
* @returns
|
|
33
28
|
*/
|
|
34
|
-
AmortizationService.prototype.
|
|
35
|
-
|
|
36
|
-
var initialMonthlyPayment = this.getMonthlyPayment(monthlyRate, period, previusBalance);
|
|
37
|
-
var initialInterest = this.math.multiply(previusBalance, monthlyRate);
|
|
38
|
-
var initialMonthlyAmortization = this.math.subtract(initialMonthlyPayment, initialInterest);
|
|
39
|
-
var finalMonthlyPayment = this.getMonthlyPayment(monthlyRate, period, balance);
|
|
29
|
+
AmortizationService.prototype.getAmortizationFrench = function (monthlyRate, periods, balance) {
|
|
30
|
+
var monthlyPayment = this.getMonthlyPayment(monthlyRate, periods, balance);
|
|
40
31
|
var interest = this.math.multiply(balance, monthlyRate);
|
|
41
|
-
|
|
42
|
-
return this.math.subtract(finalMonthlyAmortization, initialMonthlyAmortization);
|
|
32
|
+
return this.math.subtract(monthlyPayment, interest);
|
|
43
33
|
};
|
|
44
34
|
/**
|
|
45
35
|
*
|
|
46
36
|
* @param monthlyRate Tasa mensual del crédito
|
|
47
|
-
* @param
|
|
37
|
+
* @param previusBalance Balance anterior
|
|
48
38
|
* @param balance Balance actual
|
|
49
|
-
* @param paymentNumber Número de cuota
|
|
50
39
|
* @returns
|
|
51
40
|
*/
|
|
52
|
-
AmortizationService.prototype.
|
|
53
|
-
|
|
54
|
-
var
|
|
55
|
-
|
|
56
|
-
return this.math.subtract(monthlyPayment, interest);
|
|
41
|
+
AmortizationService.prototype.getAmortizationDiffFrench = function (monthlyRate, periods, previusBalance, balance) {
|
|
42
|
+
var initialMonthlyAmortization = this.getAmortizationFrench(monthlyRate, periods, previusBalance);
|
|
43
|
+
var finalMonthlyAmortization = this.getAmortizationFrench(monthlyRate, periods, balance);
|
|
44
|
+
return this.math.subtract(finalMonthlyAmortization, initialMonthlyAmortization);
|
|
57
45
|
};
|
|
58
46
|
/**
|
|
59
47
|
* Calcula la amortizacion
|
|
60
|
-
* @param
|
|
61
|
-
* @param numberOfMonths
|
|
48
|
+
* @param periods
|
|
62
49
|
* @param balance
|
|
63
50
|
*/
|
|
64
|
-
AmortizationService.prototype.getAmortizationGerman = function (
|
|
65
|
-
guarder_1.Guarder.defined(
|
|
66
|
-
guarder_1.Guarder.
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
51
|
+
AmortizationService.prototype.getAmortizationGerman = function (periods, balance) {
|
|
52
|
+
guarder_1.Guarder.defined(periods, 'Periods');
|
|
53
|
+
guarder_1.Guarder.validNumber(periods, 'Periods');
|
|
54
|
+
guarder_1.Guarder.noNegativeNumber(periods, 'Periods');
|
|
55
|
+
guarder_1.Guarder.defined(balance, 'Balance');
|
|
56
|
+
guarder_1.Guarder.validNumber(balance, 'Balance');
|
|
57
|
+
guarder_1.Guarder.noNegativeNumber(balance, 'Balance');
|
|
58
|
+
var result = this.math.divide(balance, periods);
|
|
71
59
|
return result;
|
|
72
60
|
};
|
|
61
|
+
AmortizationService.prototype.getAmortizationDiffGerman = function (previousBalance, balance, periods) {
|
|
62
|
+
return this.math.round(this.math.divide(this.math.subtract(balance, previousBalance), periods), 10);
|
|
63
|
+
};
|
|
73
64
|
AmortizationService.prototype.getAmortizationIUB = function (inputs, balance, annualRate) {
|
|
74
65
|
if (inputs.isGraceMonth) {
|
|
75
66
|
return { amortizationIUB: 0, amortizationDiff: 0 };
|
|
76
67
|
}
|
|
77
68
|
var amortizationIUB;
|
|
78
69
|
var amortizationDiff;
|
|
79
|
-
var
|
|
70
|
+
var periods = this.math.subtract(this.math.add(inputs.numberOfMonths.value(), 1), inputs.paymentNumber.value());
|
|
80
71
|
if (inputs.amortizationMethod === models_1.AmortizationMethod.GERMAN) {
|
|
81
|
-
amortizationIUB = this.getAmortizationGerman(
|
|
82
|
-
amortizationDiff = this.getAmortizationDiffGerman(inputs.previousBalance.value(), balance,
|
|
72
|
+
amortizationIUB = this.getAmortizationGerman(periods, balance);
|
|
73
|
+
amortizationDiff = this.getAmortizationDiffGerman(inputs.previousBalance.value(), balance, periods);
|
|
83
74
|
}
|
|
84
75
|
else if (inputs.amortizationMethod === models_1.AmortizationMethod.FRENCH) {
|
|
85
76
|
var monthlyRate = this.interestService.getMonthlyInterestValue(annualRate);
|
|
86
|
-
amortizationIUB = this.getAmortizationFrench(monthlyRate,
|
|
87
|
-
amortizationDiff = this.getAmortizationDiffFrench(monthlyRate,
|
|
77
|
+
amortizationIUB = this.getAmortizationFrench(monthlyRate, periods, balance);
|
|
78
|
+
amortizationDiff = this.getAmortizationDiffFrench(monthlyRate, periods, inputs.previousBalance.value(), balance);
|
|
88
79
|
}
|
|
89
80
|
return { amortizationIUB: amortizationIUB, amortizationDiff: amortizationDiff };
|
|
90
81
|
};
|
|
91
|
-
AmortizationService.prototype.getAmortization = function (amortizationIUB,
|
|
92
|
-
return this.math.subtract(amortizationIUB,
|
|
82
|
+
AmortizationService.prototype.getAmortization = function (amortizationIUB, amortizationDiff, postponedInflationaryUpdate) {
|
|
83
|
+
return this.math.subtract(amortizationIUB, amortizationDiff, postponedInflationaryUpdate);
|
|
93
84
|
};
|
|
94
|
-
AmortizationService.prototype.
|
|
95
|
-
var
|
|
85
|
+
AmortizationService.prototype.getAmortizationInflation = function (upperBound, amortizationDiff, inflationaryUpdate) {
|
|
86
|
+
var amortizationInflation = this.math.round(upperBound < inflationaryUpdate
|
|
96
87
|
? this.math.subtract(upperBound, amortizationDiff)
|
|
97
|
-
: this.math.subtract(
|
|
98
|
-
return
|
|
88
|
+
: this.math.subtract(inflationaryUpdate, amortizationDiff), 10);
|
|
89
|
+
return amortizationInflation < 0 ? 0 : amortizationInflation;
|
|
99
90
|
};
|
|
100
|
-
AmortizationService.prototype.getAmortizations = function (inputs, balance, annualRate,
|
|
91
|
+
AmortizationService.prototype.getAmortizations = function (inputs, balance, annualRate, inflationaryUpdate) {
|
|
101
92
|
var _a = this.getAmortizationIUB(inputs, balance, annualRate), amortizationIUB = _a.amortizationIUB, amortizationDiff = _a.amortizationDiff;
|
|
102
|
-
var ipcaUpdate = this.ipcaService.getIPCAUpdate(balanceMonetaryUpdateValues);
|
|
103
93
|
var upperBound = this.math.multiply(inputs.previousBalance.value(), inputs.inflationaryUpperBound);
|
|
104
|
-
var
|
|
105
|
-
var postponedInflationaryUpdate = this.
|
|
106
|
-
var amortization = this.getAmortization(amortizationIUB,
|
|
94
|
+
var amortizationInflation = this.getAmortizationInflation(upperBound, amortizationDiff, inflationaryUpdate);
|
|
95
|
+
var postponedInflationaryUpdate = this.inflationService.getPosponedInflationaryUpdate(upperBound, inflationaryUpdate, inputs.upperBoundBehaviour);
|
|
96
|
+
var amortization = this.getAmortization(amortizationIUB, amortizationDiff, postponedInflationaryUpdate);
|
|
107
97
|
return {
|
|
108
|
-
|
|
98
|
+
inflationaryUpdate: inflationaryUpdate,
|
|
109
99
|
upperBound: upperBound,
|
|
110
100
|
postponedInflationaryUpdate: postponedInflationaryUpdate,
|
|
111
|
-
|
|
101
|
+
amortizationInflation: amortizationInflation,
|
|
112
102
|
amortization: amortization,
|
|
113
103
|
amortizationIUB: amortizationIUB,
|
|
114
104
|
amortizationDiff: amortizationDiff
|
|
@@ -1,25 +1,27 @@
|
|
|
1
1
|
import { MathService } from '../../math/math.service';
|
|
2
2
|
import { BalancesOutput } from '../models/dto/balances-output.dto';
|
|
3
3
|
import { PreviousBalance } from '../../shared/models/previous-balance';
|
|
4
|
+
import { InflationByDates } from '../models/dto/inflation-by-dates.dto';
|
|
5
|
+
import { InterestType } from '../../shared/models';
|
|
4
6
|
export declare class BalanceService {
|
|
5
7
|
private readonly math;
|
|
6
8
|
constructor(math: MathService);
|
|
7
9
|
/**
|
|
8
|
-
* Calcula los balances diarios aplicados con
|
|
9
|
-
* @param
|
|
10
|
+
* Calcula los balances diarios aplicados con inflación
|
|
11
|
+
* @param dailyInflationValues
|
|
10
12
|
* @param dailyInflationaryUpperBound
|
|
11
13
|
* @param previousBalance
|
|
12
14
|
*/
|
|
13
|
-
getBalances(
|
|
15
|
+
getBalances(inflationByDates: InflationByDates[], previousBalance: PreviousBalance, considerNegativeInflation: boolean, inflationExchangeMethodMonthlyToDaily?: InterestType): BalancesOutput;
|
|
14
16
|
/**
|
|
15
17
|
* Calcula el balance despues del pago
|
|
16
|
-
* previousBalance +
|
|
18
|
+
* previousBalance + inflationUpdate - amortizationInflation -amortization
|
|
17
19
|
* @param balance
|
|
18
|
-
* @param
|
|
20
|
+
* @param inflationaryUpdate
|
|
19
21
|
* @param amortization
|
|
20
|
-
* @param
|
|
22
|
+
* @param amortizationInflation
|
|
21
23
|
*/
|
|
22
|
-
getBalanceAfter(previousBalance: PreviousBalance,
|
|
24
|
+
getBalanceAfter(previousBalance: PreviousBalance, inflationaryUpdate: number, amortization: number, amortizationInflation: number): number;
|
|
23
25
|
/**
|
|
24
26
|
* Obtiene el balance de la cuota
|
|
25
27
|
* @param balanceValues
|
|
@@ -3,35 +3,42 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.BalanceService = void 0;
|
|
4
4
|
var math_service_1 = require("../../math/math.service");
|
|
5
5
|
var guarder_1 = require("../../shared/models/guarder");
|
|
6
|
+
var models_1 = require("../../shared/models");
|
|
6
7
|
var BalanceService = /** @class */ (function () {
|
|
7
8
|
function BalanceService(math) {
|
|
8
9
|
this.math = math;
|
|
9
10
|
this.math = new math_service_1.MathService(true, 10);
|
|
10
11
|
}
|
|
11
12
|
/**
|
|
12
|
-
* Calcula los balances diarios aplicados con
|
|
13
|
-
* @param
|
|
13
|
+
* Calcula los balances diarios aplicados con inflación
|
|
14
|
+
* @param dailyInflationValues
|
|
14
15
|
* @param dailyInflationaryUpperBound
|
|
15
16
|
* @param previousBalance
|
|
16
17
|
*/
|
|
17
|
-
BalanceService.prototype.getBalances = function (
|
|
18
|
+
BalanceService.prototype.getBalances = function (inflationByDates, previousBalance, considerNegativeInflation, inflationExchangeMethodMonthlyToDaily) {
|
|
18
19
|
var _this = this;
|
|
19
|
-
if (
|
|
20
|
-
|
|
20
|
+
if (inflationExchangeMethodMonthlyToDaily === void 0) { inflationExchangeMethodMonthlyToDaily = models_1.InterestType.COMPOUND; }
|
|
21
|
+
if (inflationByDates === undefined || inflationByDates.length === 0) {
|
|
22
|
+
throw new Error('invalid inflationByDates on Balances calculation');
|
|
23
|
+
}
|
|
21
24
|
guarder_1.Guarder.defined(previousBalance, 'PreviousBalance');
|
|
22
25
|
if (previousBalance.value() < 0)
|
|
23
26
|
throw new Error('invalid previousBalance on Balances calculation');
|
|
27
|
+
var dailyInflationvalues = inflationByDates
|
|
28
|
+
.map(function (obj) { return obj.dailyInflation; })
|
|
29
|
+
.slice(1);
|
|
24
30
|
var balances = [previousBalance.value()];
|
|
25
31
|
var balanceMonetaryUpdateValues = [];
|
|
26
|
-
|
|
27
|
-
var
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
32
|
+
dailyInflationvalues.forEach(function (dailyInflationValue) {
|
|
33
|
+
var dailyInflation = (dailyInflationValue < 0 && !considerNegativeInflation) ? 0 : dailyInflationValue;
|
|
34
|
+
var actualBalance = balances[balances.length - 1];
|
|
35
|
+
var balanceToUpdate = {
|
|
36
|
+
SIMPLE: previousBalance.value(),
|
|
37
|
+
COMPOUND: actualBalance
|
|
38
|
+
}[inflationExchangeMethodMonthlyToDaily];
|
|
39
|
+
var balanceMonetaryUpdate = _this.math.multiply(dailyInflation, balanceToUpdate);
|
|
33
40
|
balanceMonetaryUpdateValues.push(balanceMonetaryUpdate);
|
|
34
|
-
balances.push(_this.math.add(balanceMonetaryUpdate,
|
|
41
|
+
balances.push(_this.math.add(balanceMonetaryUpdate, actualBalance));
|
|
35
42
|
});
|
|
36
43
|
balances.splice(0, 1);
|
|
37
44
|
return {
|
|
@@ -41,23 +48,26 @@ var BalanceService = /** @class */ (function () {
|
|
|
41
48
|
};
|
|
42
49
|
/**
|
|
43
50
|
* Calcula el balance despues del pago
|
|
44
|
-
* previousBalance +
|
|
51
|
+
* previousBalance + inflationUpdate - amortizationInflation -amortization
|
|
45
52
|
* @param balance
|
|
46
|
-
* @param
|
|
53
|
+
* @param inflationaryUpdate
|
|
47
54
|
* @param amortization
|
|
48
|
-
* @param
|
|
55
|
+
* @param amortizationInflation
|
|
49
56
|
*/
|
|
50
|
-
BalanceService.prototype.getBalanceAfter = function (previousBalance,
|
|
57
|
+
BalanceService.prototype.getBalanceAfter = function (previousBalance, inflationaryUpdate, amortization, amortizationInflation) {
|
|
51
58
|
guarder_1.Guarder.defined(previousBalance, 'PreviousBalance');
|
|
52
|
-
if (
|
|
53
|
-
throw new Error('invalid
|
|
54
|
-
|
|
59
|
+
if (inflationaryUpdate === undefined || inflationaryUpdate === null) {
|
|
60
|
+
throw new Error('invalid inflationaryUpdate on BalanceAfter calculation');
|
|
61
|
+
}
|
|
62
|
+
if (amortization === undefined || amortization === null) {
|
|
55
63
|
throw new Error('invalid amortization on BalanceAfter calculation');
|
|
56
|
-
|
|
57
|
-
|
|
64
|
+
}
|
|
65
|
+
if (amortizationInflation === undefined || amortizationInflation === null) {
|
|
66
|
+
throw new Error('invalid amortizationInflation on BalanceAfter calculation');
|
|
67
|
+
}
|
|
58
68
|
var result = this.math.subtract(previousBalance.value(), amortization);
|
|
59
|
-
result = this.math.add(result,
|
|
60
|
-
result = this.math.subtract(result,
|
|
69
|
+
result = this.math.add(result, inflationaryUpdate);
|
|
70
|
+
result = this.math.subtract(result, amortizationInflation);
|
|
61
71
|
return result;
|
|
62
72
|
};
|
|
63
73
|
/**
|
package/debt/services/index.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { AmortizationService } from './amortization.service';
|
|
2
2
|
import { InsuranceService } from './insurance.service';
|
|
3
|
-
import {
|
|
3
|
+
import { InflationService } from './inflation.service';
|
|
4
4
|
import { MonthlyPaymentService } from './monthly-payment.service';
|
|
5
5
|
import { InterestService } from './interest.service';
|
|
6
6
|
import { InstallmentService } from './installment.service';
|
|
7
7
|
import { LateService } from './late.service';
|
|
8
|
-
export { AmortizationService, InsuranceService,
|
|
8
|
+
export { AmortizationService, InsuranceService, InflationService, MonthlyPaymentService, InterestService, InstallmentService, LateService };
|
package/debt/services/index.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.LateService = exports.InstallmentService = exports.InterestService = exports.MonthlyPaymentService = exports.
|
|
3
|
+
exports.LateService = exports.InstallmentService = exports.InterestService = exports.MonthlyPaymentService = exports.InflationService = exports.InsuranceService = exports.AmortizationService = void 0;
|
|
4
4
|
var amortization_service_1 = require("./amortization.service");
|
|
5
5
|
Object.defineProperty(exports, "AmortizationService", { enumerable: true, get: function () { return amortization_service_1.AmortizationService; } });
|
|
6
6
|
var insurance_service_1 = require("./insurance.service");
|
|
7
7
|
Object.defineProperty(exports, "InsuranceService", { enumerable: true, get: function () { return insurance_service_1.InsuranceService; } });
|
|
8
|
-
var
|
|
9
|
-
Object.defineProperty(exports, "
|
|
8
|
+
var inflation_service_1 = require("./inflation.service");
|
|
9
|
+
Object.defineProperty(exports, "InflationService", { enumerable: true, get: function () { return inflation_service_1.InflationService; } });
|
|
10
10
|
var monthly_payment_service_1 = require("./monthly-payment.service");
|
|
11
11
|
Object.defineProperty(exports, "MonthlyPaymentService", { enumerable: true, get: function () { return monthly_payment_service_1.MonthlyPaymentService; } });
|
|
12
12
|
var interest_service_1 = require("./interest.service");
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { MathService } from '../../math';
|
|
2
|
+
import { InflationByDates } from '../models/dto/inflation-by-dates.dto';
|
|
3
|
+
import { BehaviourCAP } from '../../shared/models/enum/behaviour-cap.enum';
|
|
4
|
+
import { InterestType } from '../../shared/models';
|
|
5
|
+
import { MonthNominalLength } from '../../shared/models/enum/month-nominal-length.enum';
|
|
6
|
+
export declare class InflationService {
|
|
7
|
+
private readonly math;
|
|
8
|
+
constructor(math: MathService);
|
|
9
|
+
private readonly interestService;
|
|
10
|
+
private calculateDaysOfMonth;
|
|
11
|
+
/**
|
|
12
|
+
* Permite obtener la inflación diaria desde la fecha inicio y fecha final del inflationMap
|
|
13
|
+
* @param inflationMap
|
|
14
|
+
*/
|
|
15
|
+
getInflationByDates(inflationMap: Record<string, number>, monthNominalLength?: number | MonthNominalLength, inflationExchangeMethodMonthlyToDaily?: InterestType): InflationByDates[];
|
|
16
|
+
getLastInflationaryBoundDifference(inflationaryBoundDifferenceValues: number[]): number;
|
|
17
|
+
/**
|
|
18
|
+
* Obtiene corrección monetaria
|
|
19
|
+
* @param inflationUpdateValues
|
|
20
|
+
*/
|
|
21
|
+
getInflationaryUpdate(inflationUpdateValues: number[]): number;
|
|
22
|
+
/**
|
|
23
|
+
* @param previusBalance Balance de la cuota anterior
|
|
24
|
+
* @param inflationaryUpperBound Tope máximo que el cliente está dispuesto a pagar
|
|
25
|
+
* @param inflationaryUpdate Correción monetaria del balance por inflación
|
|
26
|
+
* @param amortizationDiff ...
|
|
27
|
+
*/
|
|
28
|
+
getPosponedInflationaryUpdate(upperBound: number, inflationaryUpdate: number, upperBoundBehaviour: BehaviourCAP | undefined): number;
|
|
29
|
+
getDailyInflationValues(inflationByDates: InflationByDates[]): number[];
|
|
30
|
+
}
|