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.
Files changed (40) hide show
  1. package/debt/models/dto/balances-output.dto.d.ts +2 -2
  2. package/debt/models/dto/debt-inputs.dto.d.ts +5 -5
  3. package/debt/models/dto/debt-params.dto.d.ts +27 -0
  4. package/debt/models/dto/debt-params.dto.js +32 -1
  5. package/debt/models/dto/debt-response.dto.d.ts +7 -7
  6. package/debt/models/dto/inflation-by-dates.dto.d.ts +14 -0
  7. package/debt/models/dto/inflation-by-dates.dto.js +9 -0
  8. package/debt/models/lates-input.dto.d.ts +4 -0
  9. package/debt/services/amortization.service.d.ts +13 -19
  10. package/debt/services/amortization.service.js +40 -50
  11. package/debt/services/balance.service.d.ts +9 -7
  12. package/debt/services/balance.service.js +34 -24
  13. package/debt/services/index.d.ts +2 -2
  14. package/debt/services/index.js +3 -3
  15. package/debt/services/inflation.service.d.ts +30 -0
  16. package/debt/services/inflation.service.js +101 -0
  17. package/debt/services/installment.service.d.ts +1 -1
  18. package/debt/services/installment.service.js +30 -21
  19. package/debt/services/insurance.service.d.ts +13 -8
  20. package/debt/services/insurance.service.js +61 -18
  21. package/debt/services/interest.service.d.ts +12 -4
  22. package/debt/services/interest.service.js +43 -16
  23. package/debt/services/late.service.d.ts +14 -5
  24. package/debt/services/late.service.js +59 -31
  25. package/debt/services/monthly-payment.service.d.ts +5 -5
  26. package/debt/services/monthly-payment.service.js +15 -13
  27. package/package.json +4 -3
  28. package/shared/models/enum/insurances-strategy.enum.d.ts +4 -0
  29. package/shared/models/enum/insurances-strategy.enum.js +8 -0
  30. package/shared/models/enum/month-nominal-length.enum.d.ts +6 -0
  31. package/shared/models/enum/month-nominal-length.enum.js +10 -0
  32. package/shared/models/guarder.d.ts +2 -0
  33. package/shared/models/guarder.js +10 -0
  34. package/test/br/excel-translator.ts +171 -0
  35. package/test/br/installment.service.spec.ts +1218 -1218
  36. package/test/br/new-installment.service.specto.ts +727 -0
  37. package/debt/models/dto/daily-ipca-output.dto.d.ts +0 -14
  38. package/debt/models/dto/daily-ipca-output.dto.js +0 -9
  39. package/debt/services/ipca.service.d.ts +0 -28
  40. 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 IPCA
3
+ * Arreglo de saldos insolutos diarios aplicando inflación
4
4
  */
5
5
  balances: number[];
6
6
  /**
7
- * Arreglo de montos darios de IPCA
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 IPCA a pagar pactado con el cliente
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 IPCAs en el rango de fechas de la deuda a calcular
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
- IPCAmap: Record<string, number>;
42
+ inflationMap: Record<string, number>;
43
43
  /**
44
- * Mapa de IPCAs en el rango de fechas de la mora a calcular
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
- IPCAmapLate: Record<string, number>;
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 { DailyIPCAOutput } from './daily-ipca-output.dto';
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
- /** IPCA diarios para las fechas de calculo de deuda */
8
- IPCAByDates: DailyIPCAOutput[];
9
- /** Saldos calculados en base al IPCA */
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 IPCA */
16
- ipcaUpdate: number;
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
- amortizationIPCA: number;
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 ipcaService;
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 numberOfMonths Número de meses del crédito
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 getAmortizationDiffFrench;
16
+ private getAmortizationFrench;
22
17
  /**
23
18
  *
24
19
  * @param monthlyRate Tasa mensual del crédito
25
- * @param numberOfMonths Número de meses del crédito
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 getAmortizationFrench;
24
+ private getAmortizationDiffFrench;
31
25
  /**
32
26
  * Calcula la amortizacion
33
- * @param paymentNumber
34
- * @param numberOfMonths
27
+ * @param periods
35
28
  * @param balance
36
29
  */
37
- getAmortizationGerman(paymentNumber: PaymentNumber, numberOfMonths: NumberOfMonths, balance: number): number;
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, postponedInflationaryUpdate: number, amortizationDiff: number): number;
43
- getAmortizationIPC(upperBound: number, amortizationDiff: number, IPCAupdate: number): number;
44
- getAmortizations(inputs: DebtInputs, balance: number, annualRate: number, balanceMonetaryUpdateValues: number[]): {
45
- ipcaUpdate: number;
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
- amortizationIPCA: number;
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 ipca_service_1 = require("./ipca.service");
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.ipcaService = new ipca_service_1.IPCAService(this.math);
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 numberOfMonths Número de meses del crédito
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.getAmortizationDiffFrench = function (monthlyRate, period, previusBalance, balance) {
35
- // const period = this.math.subtract(this.math.add(numberOfMonths, 1), paymentNumber);
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
- var finalMonthlyAmortization = this.math.subtract(finalMonthlyPayment, interest);
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 numberOfMonths Número de meses del crédito
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.getAmortizationFrench = function (monthlyRate, period, balance) {
53
- // const period = this.math.subtract(this.math.add(numberOfMonths, 1), paymentNumber);
54
- var monthlyPayment = this.getMonthlyPayment(monthlyRate, period, balance);
55
- var interest = this.math.multiply(balance, monthlyRate);
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 paymentNumber
61
- * @param numberOfMonths
48
+ * @param periods
62
49
  * @param balance
63
50
  */
64
- AmortizationService.prototype.getAmortizationGerman = function (paymentNumber, numberOfMonths, balance) {
65
- guarder_1.Guarder.defined(paymentNumber, 'PaymentNumber');
66
- guarder_1.Guarder.defined(numberOfMonths, 'NumberOfMonths');
67
- if (balance === undefined || balance < 0 || balance === null)
68
- throw new Error('invalid balance on Amortization calculation');
69
- var divisor = numberOfMonths.value() - paymentNumber.value() + 1;
70
- var result = this.math.divide(balance, divisor);
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 period = this.math.subtract(this.math.add(inputs.numberOfMonths.value(), 1), inputs.paymentNumber.value());
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(inputs.paymentNumber, inputs.numberOfMonths, balance);
82
- amortizationDiff = this.getAmortizationDiffGerman(inputs.previousBalance.value(), balance, period);
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, period, balance);
87
- amortizationDiff = this.getAmortizationDiffFrench(monthlyRate, period, inputs.previousBalance.value(), balance);
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, postponedInflationaryUpdate, amortizationDiff) {
92
- return this.math.subtract(amortizationIUB, postponedInflationaryUpdate, amortizationDiff);
82
+ AmortizationService.prototype.getAmortization = function (amortizationIUB, amortizationDiff, postponedInflationaryUpdate) {
83
+ return this.math.subtract(amortizationIUB, amortizationDiff, postponedInflationaryUpdate);
93
84
  };
94
- AmortizationService.prototype.getAmortizationIPC = function (upperBound, amortizationDiff, IPCAupdate) {
95
- var amortizationIPCA = this.math.round(upperBound < IPCAupdate
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(IPCAupdate, amortizationDiff), 10);
98
- return amortizationIPCA < 0 ? 0 : amortizationIPCA;
88
+ : this.math.subtract(inflationaryUpdate, amortizationDiff), 10);
89
+ return amortizationInflation < 0 ? 0 : amortizationInflation;
99
90
  };
100
- AmortizationService.prototype.getAmortizations = function (inputs, balance, annualRate, balanceMonetaryUpdateValues) {
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 amortizationIPCA = this.getAmortizationIPC(upperBound, amortizationDiff, ipcaUpdate);
105
- var postponedInflationaryUpdate = this.ipcaService.getPosponedInflationaryUpdate(upperBound, ipcaUpdate, inputs.upperBoundBehaviour);
106
- var amortization = this.getAmortization(amortizationIUB, postponedInflationaryUpdate, amortizationDiff);
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
- ipcaUpdate: ipcaUpdate,
98
+ inflationaryUpdate: inflationaryUpdate,
109
99
  upperBound: upperBound,
110
100
  postponedInflationaryUpdate: postponedInflationaryUpdate,
111
- amortizationIPCA: amortizationIPCA,
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 IPCA
9
- * @param dailyIPCAvalues
10
+ * Calcula los balances diarios aplicados con inflación
11
+ * @param dailyInflationValues
10
12
  * @param dailyInflationaryUpperBound
11
13
  * @param previousBalance
12
14
  */
13
- getBalances(dailyIPCAvalues: number[], previousBalance: PreviousBalance, considerNegativeInflation: boolean): BalancesOutput;
15
+ getBalances(inflationByDates: InflationByDates[], previousBalance: PreviousBalance, considerNegativeInflation: boolean, inflationExchangeMethodMonthlyToDaily?: InterestType): BalancesOutput;
14
16
  /**
15
17
  * Calcula el balance despues del pago
16
- * previousBalance + IPCAupdate - amortizationIPC -amortization
18
+ * previousBalance + inflationUpdate - amortizationInflation -amortization
17
19
  * @param balance
18
- * @param ipcaUpdate
20
+ * @param inflationaryUpdate
19
21
  * @param amortization
20
- * @param amortizationIPCA
22
+ * @param amortizationInflation
21
23
  */
22
- getBalanceAfter(previousBalance: PreviousBalance, ipcaUpdate: number, amortization: number, amortizationIPCA: number): number;
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 IPCA
13
- * @param dailyIPCAvalues
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 (dailyIPCAvalues, previousBalance, considerNegativeInflation) {
18
+ BalanceService.prototype.getBalances = function (inflationByDates, previousBalance, considerNegativeInflation, inflationExchangeMethodMonthlyToDaily) {
18
19
  var _this = this;
19
- if (dailyIPCAvalues === undefined || dailyIPCAvalues.length === 0)
20
- throw new Error('invalid dailyIPCAvalues on Balances calculation');
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
- dailyIPCAvalues.forEach(function (dailyIPCA) {
27
- var previusBalanceUsed = balances[balances.length - 1];
28
- if (dailyIPCA < 0 && considerNegativeInflation === false) {
29
- // eslint-disable-next-line no-param-reassign
30
- dailyIPCA = 0;
31
- }
32
- var balanceMonetaryUpdate = _this.math.multiply(dailyIPCA, previusBalanceUsed);
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, previusBalanceUsed));
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 + IPCAupdate - amortizationIPC -amortization
51
+ * previousBalance + inflationUpdate - amortizationInflation -amortization
45
52
  * @param balance
46
- * @param ipcaUpdate
53
+ * @param inflationaryUpdate
47
54
  * @param amortization
48
- * @param amortizationIPCA
55
+ * @param amortizationInflation
49
56
  */
50
- BalanceService.prototype.getBalanceAfter = function (previousBalance, ipcaUpdate, amortization, amortizationIPCA) {
57
+ BalanceService.prototype.getBalanceAfter = function (previousBalance, inflationaryUpdate, amortization, amortizationInflation) {
51
58
  guarder_1.Guarder.defined(previousBalance, 'PreviousBalance');
52
- if (ipcaUpdate === undefined || ipcaUpdate === null)
53
- throw new Error('invalid ipcaUpdate on BalanceAfter calculation');
54
- if (amortization === undefined || amortization === null)
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
- if (amortizationIPCA === undefined || amortizationIPCA === null)
57
- throw new Error('invalid amortizationIPCA on BalanceAfter calculation');
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, ipcaUpdate);
60
- result = this.math.subtract(result, amortizationIPCA);
69
+ result = this.math.add(result, inflationaryUpdate);
70
+ result = this.math.subtract(result, amortizationInflation);
61
71
  return result;
62
72
  };
63
73
  /**
@@ -1,8 +1,8 @@
1
1
  import { AmortizationService } from './amortization.service';
2
2
  import { InsuranceService } from './insurance.service';
3
- import { IPCAService } from './ipca.service';
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, IPCAService, MonthlyPaymentService, InterestService, InstallmentService, LateService };
8
+ export { AmortizationService, InsuranceService, InflationService, MonthlyPaymentService, InterestService, InstallmentService, LateService };
@@ -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.IPCAService = exports.InsuranceService = exports.AmortizationService = void 0;
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 ipca_service_1 = require("./ipca.service");
9
- Object.defineProperty(exports, "IPCAService", { enumerable: true, get: function () { return ipca_service_1.IPCAService; } });
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
+ }