creditu-common-library 1.2.8 → 1.2.11

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.
@@ -55,7 +55,8 @@ var InstallmentService = /** @class */ (function () {
55
55
  var balance = this.balanceService.getBalance(balanceValues.balances);
56
56
  var startDate = Object.keys(inputs.IPCAmap)[0];
57
57
  var endDate = Object.keys(inputs.IPCAmap).pop();
58
- var interest = this.interestService.getInterest(balanceValues.balances, params.annualRate, startDate, endDate, inputs.paymentNumber.value());
58
+ var proportionalDays = inputs.paymentNumber.value() === 1 ? this.interestService.getProportionalDays(startDate, endDate) : 1;
59
+ var interest = this.interestService.getInterest(balanceValues.balances, params.annualRate, proportionalDays);
59
60
  var amortization;
60
61
  var amortizationDiff;
61
62
  if (inputs.amortizationMethod === amortization_method_enum_1.AmortizationMethod.GERMAN) {
@@ -71,9 +72,10 @@ var InstallmentService = /** @class */ (function () {
71
72
  var amortizationIPCA = this.amortizationService.getAmortizationIPC(inputs.previousBalance.value(), inputs.inflationaryUpperBound, amortizationDiff, ipcaUpdate);
72
73
  var monthlyPayment = this.paymentService.getMonthlyPayment(interest, amortization, amortizationIPCA);
73
74
  var balanceAfter = this.balanceService.getBalanceAfter(inputs.previousBalance, ipcaUpdate, amortization, amortizationIPCA);
74
- var debtorLifeInsuranceFee = this.insuranceService.getLifeInsurance(params.debtorLifeInsuranceRate, balance);
75
- var codebtorLifeInsuranceFee = params.codebtorLifeInsuranceRate ? this.insuranceService.getLifeInsurance(params.codebtorLifeInsuranceRate, balance) : 0;
76
- var propertyInsuranceFee = this.insuranceService.getPropertyInsurance(inputs.propertyAmount, params.propertyInsuranceRate, inputs.IPCAmap);
75
+ var insurancePeriods = this.insuranceService.getInsurancePeriods(inputs.IPCAmap, inputs.paymentNumber.value(), inputs.numberOfMonths.value());
76
+ var debtorLifeInsuranceFee = this.insuranceService.getInsuranceFee(balance, params.debtorLifeInsuranceRate, insurancePeriods);
77
+ var codebtorLifeInsuranceFee = params.codebtorLifeInsuranceRate ? this.insuranceService.getInsuranceFee(balance, params.codebtorLifeInsuranceRate, insurancePeriods) : 0;
78
+ var propertyInsuranceFee = this.insuranceService.getInsuranceFee(inputs.propertyAmount, params.propertyInsuranceRate, insurancePeriods);
77
79
  var monthlyPaymentWithInsurances = this.math.add(monthlyPayment, debtorLifeInsuranceFee, codebtorLifeInsuranceFee, propertyInsuranceFee);
78
80
  return {
79
81
  IPCAByDates: IPCAByDates,
@@ -4,15 +4,16 @@ export declare class InsuranceService {
4
4
  private readonly math;
5
5
  constructor(math: MathService);
6
6
  /**
7
- * Calcula el seguro de propiedad
8
- * @param propertyAmount
9
- * @param propertyInsuranceRate
7
+ * Gives apropiate qty of months to apply insurances
8
+ * @param IPCAmap dates keyed object to know start and end dates
9
+ * @param paymentNumber to validate if it is first or last payment
10
+ * @param numberOfMonths to validate if it is last payment
10
11
  */
11
- getPropertyInsurance(propertyAmount: number, propertyInsuranceRate: CreditInsuranceRate, IPCAmap: Record<string, number>): number;
12
+ getInsurancePeriods(IPCAmap: any, paymentNumber: number, numberOfMonths: number): number;
12
13
  /**
13
- * Calcula el seguro de vida
14
- * @param lifeInsuranceRate // tasa sobre la que se calcula el valor de un seguro
15
- * @param balance // Balance actualizado por corrección monetaria
14
+ * Calcula el cobro de un seguro
15
+ * @param propertyAmount
16
+ * @param propertyInsuranceRate
16
17
  */
17
- getLifeInsurance(lifeInsuranceRate: CreditInsuranceRate, balance: number): number;
18
+ getInsuranceFee(baseAmount: number, insuranceRate: CreditInsuranceRate, insurancePeriods: number): number;
18
19
  }
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.InsuranceService = void 0;
4
+ var creditu_date_model_1 = require("creditu-date-model");
4
5
  var math_1 = require("../../math");
5
6
  var guarder_1 = require("../../shared/models/guarder");
6
7
  var InsuranceService = /** @class */ (function () {
@@ -9,40 +10,35 @@ var InsuranceService = /** @class */ (function () {
9
10
  this.math = new math_1.MathService(true, 10);
10
11
  }
11
12
  /**
12
- * Calcula el seguro de propiedad
13
- * @param propertyAmount
14
- * @param propertyInsuranceRate
13
+ * Gives apropiate qty of months to apply insurances
14
+ * @param IPCAmap dates keyed object to know start and end dates
15
+ * @param paymentNumber to validate if it is first or last payment
16
+ * @param numberOfMonths to validate if it is last payment
15
17
  */
16
- InsuranceService.prototype.getPropertyInsurance = function (propertyAmount, propertyInsuranceRate, IPCAmap) {
17
- var _this = this;
18
- guarder_1.Guarder.defined(propertyInsuranceRate, 'CreditInsuranceRate');
19
- var getLifeInsurancePeriods = function (IPCAmap) {
20
- var result = Object.keys(IPCAmap)
21
- .map(function (date) {
22
- var days = date.split(',').map(function (strNum) { return parseInt(strNum, 10); }).pop();
23
- return days > 5 ? 1 : 2;
24
- })
25
- .reduce(function (a, b) { return _this.math.add(a, b); }, 0);
26
- return result - 1;
27
- };
28
- var lifeInsurancePeriods = getLifeInsurancePeriods(IPCAmap);
29
- if (propertyInsuranceRate.value() === 0)
30
- throw new Error('Invalid property insurance rate');
31
- var propertyInsurance = this.math.multiply(propertyAmount, this.math.divide(propertyInsuranceRate.value(), 100));
32
- return this.math.round(this.math.multiply(propertyInsurance, lifeInsurancePeriods), 2);
18
+ // eslint-disable-next-line class-methods-use-this
19
+ InsuranceService.prototype.getInsurancePeriods = function (IPCAmap, paymentNumber, numberOfMonths) {
20
+ if (paymentNumber === numberOfMonths) {
21
+ return 0;
22
+ }
23
+ if (paymentNumber !== 1) {
24
+ return 1;
25
+ }
26
+ var datesMap = Object.keys(IPCAmap);
27
+ var firstDate = new creditu_date_model_1.DateModel(datesMap[0]);
28
+ var lastDate = new creditu_date_model_1.DateModel(datesMap[datesMap.length - 1]);
29
+ return lastDate.monthsDiff(firstDate) + 2;
33
30
  };
34
31
  /**
35
- * Calcula el seguro de vida
36
- * @param lifeInsuranceRate // tasa sobre la que se calcula el valor de un seguro
37
- * @param balance // Balance actualizado por corrección monetaria
32
+ * Calcula el cobro de un seguro
33
+ * @param propertyAmount
34
+ * @param propertyInsuranceRate
38
35
  */
39
- InsuranceService.prototype.getLifeInsurance = function (lifeInsuranceRate, balance) {
40
- guarder_1.Guarder.defined(lifeInsuranceRate, 'CreditInsuranceRate');
41
- if (lifeInsuranceRate.value() === 0)
42
- throw new Error('Invalid life insurance rate');
43
- var lifeInsurance = this.math.multiply(balance, this.math.divide(lifeInsuranceRate.value(), 100));
44
- var result = this.math.round(lifeInsurance, 2);
45
- return result;
36
+ InsuranceService.prototype.getInsuranceFee = function (baseAmount, insuranceRate, insurancePeriods) {
37
+ guarder_1.Guarder.defined(insuranceRate, 'CreditInsuranceRate');
38
+ if (insuranceRate.value() === 0)
39
+ throw new Error('Invalid insurance rate');
40
+ var propertyInsurance = this.math.multiply(baseAmount, insuranceRate.value());
41
+ return this.math.round(this.math.multiply(propertyInsurance, insurancePeriods), 2);
46
42
  };
47
43
  return InsuranceService;
48
44
  }());
@@ -2,7 +2,6 @@ import { MathService } from '../../math';
2
2
  export declare class InterestService {
3
3
  private readonly math;
4
4
  constructor(math: MathService);
5
- private calculateDaysOfMonth;
6
5
  /**
7
6
  * Método que calcula el interés diario a partir del interés anual.
8
7
  * @param annyalRate Tasa de interés anual.
@@ -22,13 +21,17 @@ export declare class InterestService {
22
21
  * @returns
23
22
  */
24
23
  private getPeriodInterestValue;
25
- private findPeriodIndex;
24
+ /**
25
+ * Taking past month as base, returns days between start and end date over past month's total days
26
+ * @param startDate
27
+ * @param endDate
28
+ */
29
+ getProportionalDays(startDate: string, endDate: string): number;
26
30
  /**
27
31
  * Calcula el interes a partir del interes diario
28
32
  * @param balanceValues
29
33
  * @param annualRate
30
- * @param startDate
31
- * @param endDate
34
+ * @param proportion
32
35
  */
33
- getInterest(balanceValues: number[], annualRate: number, startDate: string, endDate: string, paymentNumber: number): number;
36
+ getInterest(balanceValues: number[], annualRate: number, proportion: number): number;
34
37
  }
@@ -1,6 +1,4 @@
1
1
  "use strict";
2
- // import { MathService } from '../../math';
3
- // import { PreviousBalance } from '../../shared/models/previous-balance';
4
2
  Object.defineProperty(exports, "__esModule", { value: true });
5
3
  exports.InterestService = void 0;
6
4
  var creditu_date_model_1 = require("creditu-date-model");
@@ -8,24 +6,8 @@ var math_1 = require("../../math");
8
6
  var InterestService = /** @class */ (function () {
9
7
  function InterestService(math) {
10
8
  this.math = math;
11
- this.findPeriodIndex = function (periodArray, period) {
12
- var periodIndex;
13
- // eslint-disable-next-line no-loop-func
14
- periodArray.find(function (element, index) {
15
- if (element.period === period) {
16
- periodIndex = index;
17
- return true;
18
- }
19
- return false;
20
- });
21
- return periodIndex;
22
- };
23
9
  this.math = new math_1.MathService(true, 10);
24
10
  }
25
- // eslint-disable-next-line class-methods-use-this
26
- InterestService.prototype.calculateDaysOfMonth = function (year, month) {
27
- return new Date(year, month, 0).getDate();
28
- };
29
11
  /**
30
12
  * Método que calcula el interés diario a partir del interés anual.
31
13
  * @param annyalRate Tasa de interés anual.
@@ -57,44 +39,46 @@ var InterestService = /** @class */ (function () {
57
39
  return this.math.round(this.math.subtract(preResult, 1), 10);
58
40
  };
59
41
  /**
60
- * Calcula el interes a partir del interes diario
61
- * @param balanceValues
62
- * @param annualRate
42
+ * Taking past month as base, returns days between start and end date over past month's total days
63
43
  * @param startDate
64
44
  * @param endDate
65
45
  */
66
- InterestService.prototype.getInterest = function (balanceValues, annualRate, startDate, endDate, paymentNumber) {
46
+ InterestService.prototype.getProportionalDays = function (startDate, endDate) {
67
47
  var _this = this;
68
- var periodArray = [];
69
- var startDateModel = new creditu_date_model_1.DateModel(startDate);
70
- if (paymentNumber === 1) {
71
- startDateModel = startDateModel.addDays(1);
72
- }
48
+ var startDateModel = new creditu_date_model_1.DateModel(startDate).addDays(1);
73
49
  var endDateModel = new creditu_date_model_1.DateModel(endDate);
74
- while (startDateModel <= endDateModel) {
75
- var _a = startDateModel.toString().split('-'), year = _a[0], month = _a[1];
76
- var period = "".concat(year, "-").concat(month);
77
- var periodIndex = this.findPeriodIndex(periodArray, period);
78
- if (periodIndex === undefined) {
79
- periodArray.push({ period: period, days: 1 });
50
+ var periodArray = [];
51
+ var _loop_1 = function () {
52
+ var _b = startDateModel.toString().split('-'), year_1 = _b[0], month_1 = _b[1];
53
+ var currentPeriod = "".concat(year_1, "-").concat(month_1);
54
+ var periodIndex = periodArray.findIndex(function (periodObject) { return periodObject.period === currentPeriod; });
55
+ if (periodIndex === -1) {
56
+ periodArray.push({ currentPeriod: currentPeriod, days: 1 });
80
57
  }
81
58
  else {
82
59
  periodArray[periodIndex].days += 1;
83
60
  }
84
61
  startDateModel = startDateModel.addDays(1);
62
+ };
63
+ while (startDateModel <= endDateModel) {
64
+ _loop_1();
85
65
  }
66
+ // Se utiliza el primer mes antes del vencimiento de la cuota para el total de días a considerar en la proporción para el interés.
67
+ var monthBeforeEndDate = endDateModel.substractMonths(1);
68
+ var _a = monthBeforeEndDate.toString().split('-'), year = _a[0], month = _a[1];
69
+ var daysOfMonth = new Date(Number(year), Number(month), 0).getDate();
70
+ var proportion = periodArray.reduce(function (proportion, element) { return proportion + _this.math.multiply(_this.math.divide(1, daysOfMonth), element.days); }, 0);
71
+ // return this.math.round(proportion, 2);
72
+ return proportion;
73
+ };
74
+ /**
75
+ * Calcula el interes a partir del interes diario
76
+ * @param balanceValues
77
+ * @param annualRate
78
+ * @param proportion
79
+ */
80
+ InterestService.prototype.getInterest = function (balanceValues, annualRate, proportion) {
86
81
  var interest = this.math.multiply(balanceValues[balanceValues.length - 1], this.getMonthlyInterestValue(annualRate));
87
- var proportion = 1;
88
- if (paymentNumber === 1) {
89
- // Se utiliza el primer mes antes del vencimiento de la cuota para el total de días a considerar en la proporción para el interés.
90
- var yearMonth = periodArray[periodArray.length - 2].period.split('-');
91
- var daysOfMonth_1 = this.calculateDaysOfMonth(yearMonth[0], yearMonth[1]);
92
- proportion = periodArray.reduce(function (proportion, element) {
93
- // eslint-disable-next-line no-param-reassign
94
- proportion += _this.math.multiply(_this.math.divide(1, daysOfMonth_1), element.days);
95
- return proportion;
96
- }, 0);
97
- }
98
82
  return this.math.round(this.math.multiply(interest, proportion), 2);
99
83
  };
100
84
  return InterestService;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "creditu-common-library",
3
- "version": "1.2.8",
3
+ "version": "1.2.11",
4
4
  "description": "",
5
5
  "main": "lib/index.js",
6
6
  "files": [
@@ -79,12 +79,12 @@ describe('installment-service for german method', () => {
79
79
  dailyRate: 0.0002009109,
80
80
  interest: 330.09,
81
81
  monthlyPayment: 819.68713637,
82
- monthlyPaymentWithInsurances: 846.62713637,
82
+ monthlyPaymentWithInsurances: 873.55713637,
83
83
  amortization: 361.70713637,
84
84
  amortizationIPCA: 127.89,
85
- debtorLifeInsuranceFee: 22.14,
85
+ debtorLifeInsuranceFee: 44.27,
86
86
  codebtorLifeInsuranceFee: 0,
87
- propertyInsuranceFee: 4.8
87
+ propertyInsuranceFee: 9.6
88
88
  };
89
89
 
90
90
  const amortizationMethod = AmortizationMethod.GERMAN;
@@ -92,10 +92,10 @@ describe('installment-service for german method', () => {
92
92
  const numberOfMonths = new NumberOfMonths(360);
93
93
  const previousBalance = new PreviousBalance(129600);
94
94
  const annualRate = 0.075;
95
- const debtorLifeInsuranceRate = new CreditInsuranceRate(0.017);
95
+ const debtorLifeInsuranceRate = new CreditInsuranceRate(0.00017);
96
96
  const inflationaryUpperBound = 0.001;
97
97
  const propertyAmount = 160000;
98
- const propertyInsuranceRate = new CreditInsuranceRate(0.003);
98
+ const propertyInsuranceRate = new CreditInsuranceRate(0.00003);
99
99
  const IPCAmap = {
100
100
  '2021-12-23': 0.0125,
101
101
  '2022-01-05': 0.0095
@@ -177,22 +177,22 @@ describe('installment-service for german method', () => {
177
177
  dailyRate: 0.0002009109,
178
178
  interest: 330.09,
179
179
  monthlyPayment: 1304.656229564,
180
- monthlyPaymentWithInsurances: 1331.596229564,
180
+ monthlyPaymentWithInsurances: 1358.526229564,
181
181
  amortization: 361.70713637,
182
182
  amortizationIPCA: 612.859093194,
183
- debtorLifeInsuranceFee: 22.14,
184
- propertyInsuranceFee: 4.8,
185
- codebtorLifeInsuranceFee: 0
183
+ debtorLifeInsuranceFee: 44.27,
184
+ codebtorLifeInsuranceFee: 0,
185
+ propertyInsuranceFee: 9.6
186
186
  };
187
187
  const amortizationMethod = AmortizationMethod.GERMAN;
188
188
  const paymentNumber = new PaymentNumber(1);
189
189
  const numberOfMonths = new NumberOfMonths(360);
190
190
  const previousBalance = new PreviousBalance(129600);
191
191
  const annualRate = 0.075;
192
- const debtorLifeInsuranceRate = new CreditInsuranceRate(0.017);
192
+ const debtorLifeInsuranceRate = new CreditInsuranceRate(0.00017);
193
193
  const inflationaryUpperBound = 1;
194
194
  const propertyAmount = 160000;
195
- const propertyInsuranceRate = new CreditInsuranceRate(0.003);
195
+ const propertyInsuranceRate = new CreditInsuranceRate(0.00003);
196
196
  const IPCAmap = {
197
197
  '2021-12-23': 0.0125,
198
198
  '2022-01-05': 0.0095
@@ -212,7 +212,6 @@ describe('installment-service for german method', () => {
212
212
  propertyInsuranceRate
213
213
  };
214
214
  const result = service.getTotalMonthlyPayment(inputs, params);
215
- // console.log('file: installment.service.spec.ts ~ line 216 ~ result', result);
216
215
  expect(result).toEqual(expectedResult);
217
216
  });
218
217
  it('(WEDSON (Case 1 inflationaryUpperBound) should return the calculated installment with 1 day late', () => {
@@ -275,20 +274,20 @@ describe('installment-service for german method', () => {
275
274
  dailyRate: 0.0002009109,
276
275
  interest: 330.09,
277
276
  monthlyPayment: 1304.656229564,
278
- monthlyPaymentWithInsurances: 1331.596229564,
277
+ monthlyPaymentWithInsurances: 1358.526229564,
279
278
  amortization: 361.70713637,
280
279
  amortizationIPCA: 612.859093194,
281
- debtorLifeInsuranceFee: 22.14,
282
- propertyInsuranceFee: 4.8,
283
- codebtorLifeInsuranceFee: 0
280
+ debtorLifeInsuranceFee: 44.27,
281
+ codebtorLifeInsuranceFee: 0,
282
+ propertyInsuranceFee: 9.6
284
283
  };
285
284
 
286
285
  const expectedLateResult = {
287
- lateInterest: 0.2675321969,
288
- lateAmotizationIPCA: 0.4062055604,
289
- lateChargesInterest: 0.4274822044,
290
- lateDays: 1,
291
- totalMonthlyPayment: 1359.329374117
286
+ totalMonthlyPayment: 1386.8202450224,
287
+ lateInterest: 0.2729427275,
288
+ lateAmotizationIPCA: 0.4144206,
289
+ lateChargesInterest: 0.4361275396,
290
+ lateDays: 1
292
291
  };
293
292
 
294
293
  const amortizationMethod = AmortizationMethod.GERMAN;
@@ -296,10 +295,10 @@ describe('installment-service for german method', () => {
296
295
  const numberOfMonths = new NumberOfMonths(360);
297
296
  const previousBalance = new PreviousBalance(129600);
298
297
  const annualRate = 0.075;
299
- const debtorLifeInsuranceRate = new CreditInsuranceRate(0.017);
298
+ const debtorLifeInsuranceRate = new CreditInsuranceRate(0.00017);
300
299
  const inflationaryUpperBound = 1;
301
300
  const propertyAmount = 160000;
302
- const propertyInsuranceRate = new CreditInsuranceRate(0.003);
301
+ const propertyInsuranceRate = new CreditInsuranceRate(0.00003);
303
302
  const IPCAmap = {
304
303
  '2021-12-23': 0.0125,
305
304
  '2022-01-05': 0.0095
@@ -319,7 +318,6 @@ describe('installment-service for german method', () => {
319
318
  propertyInsuranceRate
320
319
  };
321
320
  const result = service.getTotalMonthlyPayment(inputs, params);
322
- // console.log('file: installment.service.spec.ts ~ line 216 ~ result', result);
323
321
  expect(result).toEqual(expectedResult);
324
322
 
325
323
  const totalMonthlyPayment = result.monthlyPaymentWithInsurances;
@@ -432,10 +430,10 @@ describe('installment-service for german method', () => {
432
430
  const numberOfMonths = new NumberOfMonths(360);
433
431
  const previousBalance = new PreviousBalance(129240.00);
434
432
  const annualRate = 0.075;
435
- const debtorLifeInsuranceRate = new CreditInsuranceRate(0.017);
433
+ const debtorLifeInsuranceRate = new CreditInsuranceRate(0.00017);
436
434
  const inflationaryUpperBound = 1;
437
435
  const propertyAmount = 160000;
438
- const propertyInsuranceRate = new CreditInsuranceRate(0.003);
436
+ const propertyInsuranceRate = new CreditInsuranceRate(0.00003);
439
437
  const IPCAmap = {
440
438
  '2021-01-05': 0.0095,
441
439
  '2022-02-05': 0.0073
@@ -569,10 +567,10 @@ describe('installment-service for german method', () => {
569
567
  const numberOfMonths = new NumberOfMonths(360);
570
568
  const previousBalance = new PreviousBalance(129240);
571
569
  const annualRate = 0.075;
572
- const debtorLifeInsuranceRate = new CreditInsuranceRate(0.017);
570
+ const debtorLifeInsuranceRate = new CreditInsuranceRate(0.00017);
573
571
  const inflationaryUpperBound = 0.005;
574
572
  const propertyAmount = 160000;
575
- const propertyInsuranceRate = new CreditInsuranceRate(0.003);
573
+ const propertyInsuranceRate = new CreditInsuranceRate(0.00003);
576
574
  const IPCAmap = {
577
575
  '2021-01-05': 0.0095,
578
576
  '2022-02-05': 0.0073
@@ -879,10 +877,10 @@ describe('installment-service for german method', () => {
879
877
  const numberOfMonths = new NumberOfMonths(360);
880
878
  const previousBalance = new PreviousBalance(129240.00);
881
879
  const annualRate = 0.075;
882
- const debtorLifeInsuranceRate = new CreditInsuranceRate(0.017);
880
+ const debtorLifeInsuranceRate = new CreditInsuranceRate(0.00017);
883
881
  const inflationaryUpperBound = 0.005;
884
882
  const propertyAmount = 160000;
885
- const propertyInsuranceRate = new CreditInsuranceRate(0.003);
883
+ const propertyInsuranceRate = new CreditInsuranceRate(0.00003);
886
884
  const IPCAmap = { '2022-01-05': 0.0095, '2022-02-05': 0.0073 };
887
885
  const inputs: DebtInputs = {
888
886
  amortizationMethod,
@@ -901,7 +899,105 @@ describe('installment-service for german method', () => {
901
899
  const result = service.getTotalMonthlyPayment(inputs, params);
902
900
  expect(result).toEqual(expectedResult);
903
901
  });
902
+ it('WEDSON caso productivo 1ra cuota', () => {
903
+ const expectedResult = {
904
+ IPCAByDates: [
905
+ { date: '2021-12-23', ipca: 0.0125, dailyIPCA: 0.0004008068 },
906
+ { date: '2021-12-24', ipca: 0.0125, dailyIPCA: 0.0004008068 },
907
+ { date: '2021-12-25', ipca: 0.0125, dailyIPCA: 0.0004008068 },
908
+ { date: '2021-12-26', ipca: 0.0125, dailyIPCA: 0.0004008068 },
909
+ { date: '2021-12-27', ipca: 0.0125, dailyIPCA: 0.0004008068 },
910
+ { date: '2021-12-28', ipca: 0.0125, dailyIPCA: 0.0004008068 },
911
+ { date: '2021-12-29', ipca: 0.0125, dailyIPCA: 0.0004008068 },
912
+ { date: '2021-12-30', ipca: 0.0125, dailyIPCA: 0.0004008068 },
913
+ { date: '2021-12-31', ipca: 0.0125, dailyIPCA: 0.0004008068 },
914
+ { date: '2022-01-01', ipca: 0.0095, dailyIPCA: 0.0003050516 },
915
+ { date: '2022-01-02', ipca: 0.0095, dailyIPCA: 0.0003050516 },
916
+ { date: '2022-01-03', ipca: 0.0095, dailyIPCA: 0.0003050516 },
917
+ { date: '2022-01-04', ipca: 0.0095, dailyIPCA: 0.0003050516 },
918
+ { date: '2022-01-05', ipca: 0.0095, dailyIPCA: 0.0003050516 }
919
+ ],
920
+ balanceValues: {
921
+ balances: [
922
+ 129651.94456128,
923
+ 129703.9099422934,
924
+ 129755.8961513849,
925
+ 129807.9031969025,
926
+ 129859.9310871976,
927
+ 129911.9798306249,
928
+ 129964.0494355425,
929
+ 130016.1399103118,
930
+ 130055.8015418173,
931
+ 130095.4752721669,
932
+ 130135.1611050514,
933
+ 130174.8590441628,
934
+ 130214.569093194
935
+ ],
936
+ balanceMonetaryUpdateValues: [
937
+ 51.94456128, 51.9653810134,
938
+ 51.9862090915, 52.0070455176,
939
+ 52.0278902951, 52.0487434273,
940
+ 52.0696049176, 52.0904747693,
941
+ 39.6616315055, 39.6737303496,
942
+ 39.6858328845, 39.6979391114,
943
+ 39.7100490312
944
+ ],
945
+ balanceUpperBoundMonetaryUpdateValues: [
946
+ 0, 0, 0, 0, 0, 0,
947
+ 0, 0, 0, 0, 0, 0,
948
+ 0
949
+ ],
950
+ inflationaryBoundDifferenceValues: [
951
+ 0, 0, 0, 0, 0, 0,
952
+ 0, 0, 0, 0, 0, 0,
953
+ 0
954
+ ]
955
+ },
956
+ balance: 130214.569093194,
957
+ balanceAfter: 129240.00286363,
958
+ ipcaUpdate: 614.569093194,
959
+ dailyRate: 0.0002009109,
960
+ interest: 330.09,
961
+ monthlyPayment: 1304.656229564,
962
+ monthlyPaymentWithInsurances: 1358.526229564,
963
+ amortization: 361.70713637,
964
+ amortizationIPCA: 612.859093194,
965
+ debtorLifeInsuranceFee: 44.27,
966
+ codebtorLifeInsuranceFee: 0,
967
+ propertyInsuranceFee: 9.6
968
+ };
969
+ const amortizationMethod = AmortizationMethod.GERMAN;
970
+ const paymentNumber = new PaymentNumber(1);
971
+ const numberOfMonths = new NumberOfMonths(360);
972
+ const previousBalance = new PreviousBalance(129600);
973
+ const annualRate = 0.075;
974
+ const debtorLifeInsuranceRate = new CreditInsuranceRate(0.00017);
975
+ const inflationaryUpperBound = 1;
976
+ const propertyAmount = 160000;
977
+ const propertyInsuranceRate = new CreditInsuranceRate(0.00003);
978
+ const IPCAmap = {
979
+ '2021-12-23': 0.0125,
980
+ '2022-01-05': 0.0095
981
+ };
982
+ const inputs: DebtInputs = {
983
+ amortizationMethod,
984
+ paymentNumber,
985
+ numberOfMonths,
986
+ previousBalance,
987
+ inflationaryUpperBound,
988
+ propertyAmount,
989
+ IPCAmap
990
+ };
991
+ const params: DebtParams = {
992
+ annualRate,
993
+ debtorLifeInsuranceRate,
994
+ propertyInsuranceRate
995
+ };
996
+ const result = service.getTotalMonthlyPayment(inputs, params);
997
+ expect(expectedResult).toEqual(result);
998
+ });
904
999
  });
1000
+
905
1001
  describe('installment-service for french method', () => {
906
1002
  const service = new InstallmentService(new MathService(true, 10));
907
1003
  it('Alitio (inflationaryUpperBound 1) should return the calculated installment', () => {
@@ -966,12 +1062,12 @@ describe('installment-service for french method', () => {
966
1062
  dailyRate: 0.0002266368,
967
1063
  interest: 1804.52,
968
1064
  monthlyPayment: 5821.2051403922,
969
- monthlyPaymentWithInsurances: 5928.5651403922,
1065
+ monthlyPaymentWithInsurances: 6035.9151403922,
970
1066
  amortization: 1638.6085052585,
971
1067
  amortizationIPCA: 2378.0766351337,
972
- debtorLifeInsuranceFee: 82.01,
973
- propertyInsuranceFee: 25.35,
974
- codebtorLifeInsuranceFee: 0
1068
+ debtorLifeInsuranceFee: 164.01,
1069
+ codebtorLifeInsuranceFee: 0,
1070
+ propertyInsuranceFee: 50.7
975
1071
  };
976
1072
 
977
1073
  const amortizationMethod = AmortizationMethod.FRENCH;
@@ -979,10 +1075,10 @@ describe('installment-service for french method', () => {
979
1075
  const numberOfMonths = new NumberOfMonths(162);
980
1076
  const previousBalance = new PreviousBalance(480000.00); //
981
1077
  const annualRate = 0.085;
982
- const debtorLifeInsuranceRate = new CreditInsuranceRate(0.017);
1078
+ const debtorLifeInsuranceRate = new CreditInsuranceRate(0.00017);
983
1079
  const inflationaryUpperBound = 1;
984
1080
  const propertyAmount = 845000;
985
- const propertyInsuranceRate = new CreditInsuranceRate(0.003);
1081
+ const propertyInsuranceRate = new CreditInsuranceRate(0.00003);
986
1082
  const IPCAmap = { '2022-01-19': 0.0095, '2022-02-05': 0.0073 };
987
1083
  const inputs: DebtInputs = {
988
1084
  amortizationMethod,
@@ -999,7 +1095,6 @@ describe('installment-service for french method', () => {
999
1095
  propertyInsuranceRate
1000
1096
  };
1001
1097
  const result = service.getTotalMonthlyPayment(inputs, params);
1002
- // console.log('file: installment.service.spec.ts ~ line 883 ~ result', result);
1003
1098
  expect(result).toEqual(expectedResult);
1004
1099
  });
1005
1100
  // Falla en el cálculo de la amortizationIPC