creditu-common-library 1.3.0 → 1.3.3

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.
@@ -6,8 +6,7 @@ export declare class AmortizationService {
6
6
  constructor(math: MathService);
7
7
  private readonly interestService;
8
8
  private getMonthlyPayment;
9
- getAmortizationIPC(upperBound: number, amortizationDiff: number, IPCAupdate: number): number;
10
- getAmortizationDiffGerman(previousBalance: number, balance: number, numberOfMonths: number): number;
9
+ private getAmortizationDiffGerman;
11
10
  /**
12
11
  *
13
12
  * @param monthlyRate Tasa mensual del crédito
@@ -17,7 +16,7 @@ export declare class AmortizationService {
17
16
  * @param paymentNumber Número de cuota
18
17
  * @returns
19
18
  */
20
- getAmortizationDiffFrench(monthlyRate: number, numberOfMonths: number, previusBalance: number, balance: number, paymentNumber: number): number;
19
+ private getAmortizationDiffFrench;
21
20
  /**
22
21
  *
23
22
  * @param monthlyRate Tasa mensual del crédito
@@ -26,7 +25,7 @@ export declare class AmortizationService {
26
25
  * @param paymentNumber Número de cuota
27
26
  * @returns
28
27
  */
29
- getAmortizationFrench(monthlyRate: number, numberOfMonths: number, balance: number, paymentNumber: number): number;
28
+ private getAmortizationFrench;
30
29
  /**
31
30
  * Calcula la amortizacion
32
31
  * @param paymentNumber
@@ -39,4 +38,5 @@ export declare class AmortizationService {
39
38
  amortizationDiff: any;
40
39
  };
41
40
  getAmortization(amortizationIUB: number, postponedInflationaryUpdate: number, amortizationDiff: number): number;
41
+ getAmortizationIPC(upperBound: number, amortizationDiff: number, IPCAupdate: number): number;
42
42
  }
@@ -17,12 +17,6 @@ var AmortizationService = /** @class */ (function () {
17
17
  var periodRate = this.math.subtract(periodInterest, 1);
18
18
  return this.math.multiply(this.math.divide(interest, periodRate), balance);
19
19
  };
20
- AmortizationService.prototype.getAmortizationIPC = function (upperBound, amortizationDiff, IPCAupdate) {
21
- return this.math.round(upperBound < IPCAupdate
22
- ? this.math.subtract(upperBound, amortizationDiff)
23
- : this.math.subtract(IPCAupdate, amortizationDiff), 10);
24
- };
25
- // (balanceAfter - balance) / numberOfMonths
26
20
  AmortizationService.prototype.getAmortizationDiffGerman = function (previousBalance, balance, numberOfMonths) {
27
21
  return this.math.round(this.math.divide(this.math.subtract(balance, previousBalance), numberOfMonths), 10);
28
22
  };
@@ -35,8 +29,8 @@ var AmortizationService = /** @class */ (function () {
35
29
  * @param paymentNumber Número de cuota
36
30
  * @returns
37
31
  */
38
- AmortizationService.prototype.getAmortizationDiffFrench = function (monthlyRate, numberOfMonths, previusBalance, balance, paymentNumber) {
39
- var period = this.math.subtract(this.math.add(numberOfMonths, 1), paymentNumber);
32
+ AmortizationService.prototype.getAmortizationDiffFrench = function (monthlyRate, period, previusBalance, balance) {
33
+ // const period = this.math.subtract(this.math.add(numberOfMonths, 1), paymentNumber);
40
34
  var initialMonthlyPayment = this.getMonthlyPayment(monthlyRate, period, previusBalance);
41
35
  var initialInterest = this.math.multiply(previusBalance, monthlyRate);
42
36
  var initialMonthlyAmortization = this.math.subtract(initialMonthlyPayment, initialInterest);
@@ -53,8 +47,8 @@ var AmortizationService = /** @class */ (function () {
53
47
  * @param paymentNumber Número de cuota
54
48
  * @returns
55
49
  */
56
- AmortizationService.prototype.getAmortizationFrench = function (monthlyRate, numberOfMonths, balance, paymentNumber) {
57
- var period = this.math.subtract(this.math.add(numberOfMonths, 1), paymentNumber);
50
+ AmortizationService.prototype.getAmortizationFrench = function (monthlyRate, period, balance) {
51
+ // const period = this.math.subtract(this.math.add(numberOfMonths, 1), paymentNumber);
58
52
  var monthlyPayment = this.getMonthlyPayment(monthlyRate, period, balance);
59
53
  var interest = this.math.multiply(balance, monthlyRate);
60
54
  return this.math.subtract(monthlyPayment, interest);
@@ -80,20 +74,26 @@ var AmortizationService = /** @class */ (function () {
80
74
  }
81
75
  var amortizationIUB;
82
76
  var amortizationDiff;
77
+ var period = this.math.subtract(this.math.add(inputs.numberOfMonths.value(), 1), inputs.paymentNumber.value());
83
78
  if (inputs.amortizationMethod === models_1.AmortizationMethod.GERMAN) {
84
79
  amortizationIUB = this.getAmortizationGerman(inputs.paymentNumber, inputs.numberOfMonths, balance);
85
- amortizationDiff = this.getAmortizationDiffGerman(inputs.previousBalance.value(), balance, inputs.numberOfMonths.value());
80
+ amortizationDiff = this.getAmortizationDiffGerman(inputs.previousBalance.value(), balance, period);
86
81
  }
87
82
  else if (inputs.amortizationMethod === models_1.AmortizationMethod.FRENCH) {
88
83
  var monthlyRate = this.interestService.getMonthlyInterestValue(annualRate);
89
- amortizationIUB = this.getAmortizationFrench(monthlyRate, inputs.numberOfMonths.value(), balance, inputs.paymentNumber.value());
90
- amortizationDiff = this.getAmortizationDiffFrench(monthlyRate, inputs.numberOfMonths.value(), inputs.previousBalance.value(), balance, inputs.paymentNumber.value());
84
+ amortizationIUB = this.getAmortizationFrench(monthlyRate, period, balance);
85
+ amortizationDiff = this.getAmortizationDiffFrench(monthlyRate, period, inputs.previousBalance.value(), balance);
91
86
  }
92
87
  return { amortizationIUB: amortizationIUB, amortizationDiff: amortizationDiff };
93
88
  };
94
89
  AmortizationService.prototype.getAmortization = function (amortizationIUB, postponedInflationaryUpdate, amortizationDiff) {
95
90
  return this.math.subtract(amortizationIUB, postponedInflationaryUpdate, amortizationDiff);
96
91
  };
92
+ AmortizationService.prototype.getAmortizationIPC = function (upperBound, amortizationDiff, IPCAupdate) {
93
+ return this.math.round(upperBound < IPCAupdate
94
+ ? this.math.subtract(upperBound, amortizationDiff)
95
+ : this.math.subtract(IPCAupdate, amortizationDiff), 10);
96
+ };
97
97
  return AmortizationService;
98
98
  }());
99
99
  exports.AmortizationService = AmortizationService;
@@ -51,7 +51,7 @@ var InstallmentService = /** @class */ (function () {
51
51
  var insurancePeriods = this.insuranceService.getInsurancePeriods(inputs.IPCAmap, inputs.paymentNumber.value(), inputs.numberOfMonths.value());
52
52
  var lifeInsuranceBalance = this.insuranceService.getLifeInsuranceBalance(IPCAByDates, balanceValues.balances);
53
53
  var debtorLifeInsuranceFee = this.insuranceService.getInsuranceFee(lifeInsuranceBalance, params.debtorLifeInsuranceRate, insurancePeriods);
54
- var codebtorLifeInsuranceFee = params.codebtorLifeInsuranceRate ? this.insuranceService.getInsuranceFee(lifeInsuranceBalance, params.codebtorLifeInsuranceRate, insurancePeriods) : 0;
54
+ var codebtorLifeInsuranceFee = 0;
55
55
  var propertyInsuranceFee = this.insuranceService.getInsuranceFee(inputs.propertyAmount, params.propertyInsuranceRate, insurancePeriods);
56
56
  var monthlyPaymentWithInsurances = this.monthlyPaymentService.getMonthlyPaymentWithInsurances(interest, interestDiff, amortizationIUB, amortizationIPCA, debtorLifeInsuranceFee, codebtorLifeInsuranceFee, propertyInsuranceFee);
57
57
  var dailyRate = this.interestService.getDailyInterestValue(params.annualRate);
@@ -67,4 +67,18 @@ export declare class OfferInputs {
67
67
  * Se utiliza para aplicar o no lógico de doble cuota y setear los valores de: numberOfAnnualDoublePayments, indexOfFirstDoublePayment, indexOfSecondDoublePayment
68
68
  */
69
69
  useDoublePayments: boolean;
70
+ /**
71
+ * Estado de la propiedad
72
+ * true = Nueva
73
+ * false = Usada
74
+ */
75
+ isPropertyNew: boolean;
76
+ /**
77
+ * Distrito del cliente (Perú)
78
+ */
79
+ district: string;
80
+ /**
81
+ * Edad prospecto
82
+ */
83
+ prospectAge: number;
70
84
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "creditu-common-library",
3
- "version": "1.3.0",
3
+ "version": "1.3.3",
4
4
  "description": "",
5
5
  "main": "lib/index.js",
6
6
  "files": [
@@ -394,20 +394,20 @@ describe('installment-service for german method', () => {
394
394
  ]
395
395
  },
396
396
  balanceInflationaryUpdated: 130438.2727816632,
397
- balanceAfter: 128879.9907283133,
397
+ balanceAfter: 128880,
398
398
  ipcaUpdate: 1198.2727816632,
399
399
  dailyRate: 0.0002009109,
400
400
  interest: 781.24533156,
401
401
  interestDiff: 7.2434619051,
402
402
  interestIUB: 788.4887934651,
403
- monthlyPayment: 1141.2546032467,
404
- monthlyPaymentWithInsurances: 2373.4165708302,
405
- monthlyPaymentWithLate: 2373.4165708302,
406
- amortization: 360.0092716867,
407
- amortizationDiff: 3.3285355046,
403
+ monthlyPayment: 1141.24533156,
404
+ monthlyPaymentWithInsurances: 2373.4072991435,
405
+ monthlyPaymentWithLate: 2373.4072991435,
406
+ amortization: 360,
407
+ amortizationDiff: 3.3378071913,
408
408
  amortizationIUB: 363.3378071913,
409
409
  postponedInflationaryUpdate: 0,
410
- amortizationIPCA: 1194.9442461586,
410
+ amortizationIPCA: 1194.9349744719,
411
411
  debtorLifeInsuranceFee: 22.1457240152,
412
412
  codebtorLifeInsuranceFee: 0,
413
413
  propertyInsuranceFee: 4.5,
@@ -522,20 +522,20 @@ describe('installment-service for german method', () => {
522
522
  ]
523
523
  },
524
524
  balanceInflationaryUpdated: 130438.2727816632,
525
- balanceAfter: 129432.0635099765,
525
+ balanceAfter: 129432.0727816632,
526
526
  ipcaUpdate: 1198.2727816632,
527
527
  dailyRate: 0.0002009109,
528
528
  interest: 781.24533156,
529
529
  interestDiff: 7.2434619051,
530
530
  interestIUB: 788.4887934651,
531
- monthlyPayment: 589.1818215835,
532
- monthlyPaymentWithInsurances: 1821.343789167,
533
- monthlyPaymentWithLate: 1821.343789167,
534
- amortization: -192.0635099765,
535
- amortizationDiff: 3.3285355046,
531
+ monthlyPayment: 589.1725498968,
532
+ monthlyPaymentWithInsurances: 1821.3345174803,
533
+ monthlyPaymentWithLate: 1821.3345174803,
534
+ amortization: -192.0727816632,
535
+ amortizationDiff: 3.3378071913,
536
536
  amortizationIUB: 363.3378071913,
537
537
  postponedInflationaryUpdate: 552.0727816632,
538
- amortizationIPCA: 642.8714644954,
538
+ amortizationIPCA: 642.8621928087,
539
539
  debtorLifeInsuranceFee: 22.1457240152,
540
540
  codebtorLifeInsuranceFee: 0,
541
541
  propertyInsuranceFee: 4.5,
@@ -803,20 +803,20 @@ describe('installment-service for german method', () => {
803
803
  ]
804
804
  },
805
805
  balanceInflationaryUpdated: 130438.2727816632,
806
- balanceAfter: 128879.9907283133,
806
+ balanceAfter: 128880,
807
807
  ipcaUpdate: 1198.2727816632,
808
808
  dailyRate: 0.0002009109,
809
809
  interest: 781.24533156,
810
810
  interestDiff: 7.2434619051,
811
811
  interestIUB: 788.4887934651,
812
- monthlyPayment: 1141.2546032467,
813
- monthlyPaymentWithInsurances: 2373.4165708302,
814
- monthlyPaymentWithLate: 2373.4165708302,
815
- amortization: 360.0092716867,
816
- amortizationDiff: 3.3285355046,
812
+ monthlyPayment: 1141.24533156,
813
+ monthlyPaymentWithInsurances: 2373.4072991435,
814
+ monthlyPaymentWithLate: 2373.4072991435,
815
+ amortization: 360,
816
+ amortizationDiff: 3.3378071913,
817
817
  amortizationIUB: 363.3378071913,
818
818
  postponedInflationaryUpdate: 0,
819
- amortizationIPCA: 1194.9442461586,
819
+ amortizationIPCA: 1194.9349744719,
820
820
  debtorLifeInsuranceFee: 22.1457240152,
821
821
  codebtorLifeInsuranceFee: 0,
822
822
  propertyInsuranceFee: 4.5,
@@ -1510,14 +1510,14 @@ describe('installment-service for french method', () => {
1510
1510
  interestDiff: 8.1492915458,
1511
1511
  interestIUB: 1292.4276568637,
1512
1512
  monthlyPayment: 177.7754709601,
1513
- monthlyPaymentWithInsurances: 1655.2241060841,
1513
+ monthlyPaymentWithInsurances: 1584.4958814739,
1514
1514
  amortization: -1106.5028943578,
1515
1515
  amortizationDiff: 0,
1516
1516
  amortizationIUB: 0,
1517
1517
  postponedInflationaryUpdate: 1106.5028943578,
1518
1518
  amortizationIPCA: 207,
1519
1519
  debtorLifeInsuranceFee: 70.7282246102,
1520
- codebtorLifeInsuranceFee: 70.7282246102,
1520
+ codebtorLifeInsuranceFee: 0,
1521
1521
  propertyInsuranceFee: 14.34,
1522
1522
  lateDays: 0,
1523
1523
  lateCharges: 0,
@@ -1525,7 +1525,7 @@ describe('installment-service for french method', () => {
1525
1525
  lateAmortizationIPCA: 0,
1526
1526
  lateChargesInterest: 0,
1527
1527
  lateRate: 0.0003875435,
1528
- monthlyPaymentWithLate: 1655.2241060841
1528
+ monthlyPaymentWithLate: 1584.4958814739
1529
1529
  };
1530
1530
  const amortizationMethod = AmortizationMethod.FRENCH;
1531
1531
  const paymentNumber = new PaymentNumber(1);
@@ -1637,14 +1637,14 @@ describe('installment-service for french method', () => {
1637
1637
  interestDiff: 8.9681456397,
1638
1638
  interestIUB: 1347.9316492677,
1639
1639
  monthlyPayment: 153.2086940493,
1640
- monthlyPaymentWithInsurances: 1634.2476474001,
1640
+ monthlyPaymentWithInsurances: 1598.7278997811,
1641
1641
  amortization: -1185.7548095787,
1642
1642
  amortizationDiff: 0,
1643
1643
  amortizationIUB: 0,
1644
1644
  postponedInflationaryUpdate: 1185.7548095787,
1645
1645
  amortizationIPCA: 208.1065028944,
1646
1646
  debtorLifeInsuranceFee: 35.519747619,
1647
- codebtorLifeInsuranceFee: 35.519747619,
1647
+ codebtorLifeInsuranceFee: 0,
1648
1648
  propertyInsuranceFee: 7.17,
1649
1649
  lateDays: 0,
1650
1650
  lateCharges: 0,
@@ -1652,7 +1652,7 @@ describe('installment-service for french method', () => {
1652
1652
  lateAmortizationIPCA: 0,
1653
1653
  lateChargesInterest: 0,
1654
1654
  lateRate: 0.0005488375,
1655
- monthlyPaymentWithLate: 1634.2476474001
1655
+ monthlyPaymentWithLate: 1598.7278997811
1656
1656
  };
1657
1657
  const amortizationMethod = AmortizationMethod.FRENCH;
1658
1658
  const paymentNumber = new PaymentNumber(2);
@@ -1761,14 +1761,14 @@ describe('installment-service for french method', () => {
1761
1761
  interestDiff: 12.0642793752,
1762
1762
  interestIUB: 1861.5760642211,
1763
1763
  monthlyPayment: 1129.7984759794,
1764
- monthlyPaymentWithInsurances: 3315.4991476599,
1764
+ monthlyPaymentWithInsurances: 3214.1189294405,
1765
1765
  amortization: -719.7133088665,
1766
1766
  amortizationDiff: 0,
1767
1767
  amortizationIUB: 0,
1768
1768
  postponedInflationaryUpdate: 719.7133088665,
1769
1769
  amortizationIPCA: 1217.862647,
1770
1770
  debtorLifeInsuranceFee: 101.3802182194,
1771
- codebtorLifeInsuranceFee: 101.3802182194,
1771
+ codebtorLifeInsuranceFee: 0,
1772
1772
  propertyInsuranceFee: 33.3,
1773
1773
  lateDays: 0,
1774
1774
  lateCharges: 0,
@@ -1776,7 +1776,7 @@ describe('installment-service for french method', () => {
1776
1776
  lateAmortizationIPCA: 0,
1777
1777
  lateChargesInterest: 0,
1778
1778
  lateRate: 0.0005488375,
1779
- monthlyPaymentWithLate: 3315.4991476599
1779
+ monthlyPaymentWithLate: 3214.1189294405
1780
1780
  };
1781
1781
 
1782
1782
  const amortizationMethod = AmortizationMethod.FRENCH;
@@ -1811,4 +1811,146 @@ describe('installment-service for french method', () => {
1811
1811
  const result = service.getTotalMonthlyPayment(inputs, params);
1812
1812
  expect(result).toEqual(expectedResult);
1813
1813
  });
1814
+ it('Luciana (installment 1) should return the calculated installment', () => {
1815
+ const expectedResult = {
1816
+ IPCAByDates: [
1817
+ { date: '2022-04-18', ipca: 0.0101, dailyIPCA: 0.000335034 },
1818
+ { date: '2022-04-19', ipca: 0.0101, dailyIPCA: 0.000335034 },
1819
+ { date: '2022-04-20', ipca: 0.0101, dailyIPCA: 0.000335034 },
1820
+ { date: '2022-04-21', ipca: 0.0101, dailyIPCA: 0.000335034 },
1821
+ { date: '2022-04-22', ipca: 0.0101, dailyIPCA: 0.000335034 },
1822
+ { date: '2022-04-23', ipca: 0.0101, dailyIPCA: 0.000335034 },
1823
+ { date: '2022-04-24', ipca: 0.0101, dailyIPCA: 0.000335034 },
1824
+ { date: '2022-04-25', ipca: 0.0101, dailyIPCA: 0.000335034 },
1825
+ { date: '2022-04-26', ipca: 0.0101, dailyIPCA: 0.000335034 },
1826
+ { date: '2022-04-27', ipca: 0.0101, dailyIPCA: 0.000335034 },
1827
+ { date: '2022-04-28', ipca: 0.0101, dailyIPCA: 0.000335034 },
1828
+ { date: '2022-04-29', ipca: 0.0101, dailyIPCA: 0.000335034 },
1829
+ { date: '2022-04-30', ipca: 0.0101, dailyIPCA: 0.000335034 },
1830
+ { date: '2022-05-01', ipca: 0.0162, dailyIPCA: 0.0005185273 },
1831
+ { date: '2022-05-02', ipca: 0.0162, dailyIPCA: 0.0005185273 },
1832
+ { date: '2022-05-03', ipca: 0.0162, dailyIPCA: 0.0005185273 },
1833
+ { date: '2022-05-04', ipca: 0.0162, dailyIPCA: 0.0005185273 },
1834
+ { date: '2022-05-05', ipca: 0.0162, dailyIPCA: 0.0005185273 },
1835
+ { date: '2022-05-06', ipca: 0.0162, dailyIPCA: 0.0005185273 },
1836
+ { date: '2022-05-07', ipca: 0.0162, dailyIPCA: 0.0005185273 },
1837
+ { date: '2022-05-08', ipca: 0.0162, dailyIPCA: 0.0005185273 }
1838
+ ],
1839
+ balanceValues: {
1840
+ balances: [
1841
+ 242279.144564732, 242360.3163156521,
1842
+ 242441.5152618686, 242522.7414124928,
1843
+ 242603.9947766392, 242685.2753634252,
1844
+ 242766.5831819713, 242847.9182414011,
1845
+ 242929.2805508412, 243010.6701194213,
1846
+ 243092.0869562741, 243173.5310705354,
1847
+ 243299.6231850329, 243425.7806817341,
1848
+ 243552.0035945414, 243678.2919573749,
1849
+ 243804.6458041722, 243931.0651688885,
1850
+ 244057.5500854966, 244184.100587987
1851
+ ],
1852
+ balanceMonetaryUpdateValues: [
1853
+ 81.144564732, 81.1717509201,
1854
+ 81.1989462165, 81.2261506242,
1855
+ 81.2533641464, 81.280586786,
1856
+ 81.3078185461, 81.3350594298,
1857
+ 81.3623094401, 81.3895685801,
1858
+ 81.4168368528, 81.4441142613,
1859
+ 126.0921144975, 126.1574967012,
1860
+ 126.2229128073, 126.2883628335,
1861
+ 126.3538467973, 126.4193647163,
1862
+ 126.4849166081, 126.5505024904
1863
+ ]
1864
+ },
1865
+ balanceInflationaryUpdated: 244184.100587987,
1866
+ balanceAfter: 242048.7684186506,
1867
+ ipcaUpdate: 1986.100587987,
1868
+ dailyRate: 0.0002330313,
1869
+ interest: 1132.6166001979,
1870
+ interestDiff: 9.2878161488,
1871
+ interestIUB: 1141.9044163467,
1872
+ monthlyPayment: 1281.8481815473,
1873
+ monthlyPaymentWithInsurances: 3384.8755862471,
1874
+ amortization: 149.2315813494,
1875
+ amortizationDiff: 1.2237464036,
1876
+ amortizationIUB: 150.455327753,
1877
+ postponedInflationaryUpdate: 0,
1878
+ amortizationIPCA: 1984.8768415834,
1879
+ debtorLifeInsuranceFee: 82.679000564,
1880
+ codebtorLifeInsuranceFee: 0,
1881
+ propertyInsuranceFee: 24.96,
1882
+ lateDays: 0,
1883
+ lateCharges: 0,
1884
+ lateInterest: 0,
1885
+ lateAmortizationIPCA: 0,
1886
+ lateChargesInterest: 0,
1887
+ lateRate: 0.0007515586,
1888
+ monthlyPaymentWithLate: 3384.8755862471
1889
+ };
1890
+ const amortizationMethod = AmortizationMethod.FRENCH;
1891
+ const paymentNumber = new PaymentNumber(1);
1892
+ const isGraceMonth = false;
1893
+ const numberOfMonths = new NumberOfMonths(360);
1894
+ const previousBalance = new PreviousBalance(242198.00); //
1895
+ const annualRate = 0.0875;
1896
+ const debtorLifeInsuranceRate = new CreditInsuranceRate(0.00017);
1897
+ const inflationaryUpperBound = 1;
1898
+ const propertyAmount = 416000.0;
1899
+ const propertyInsuranceRate = new CreditInsuranceRate(0.00003);
1900
+ const IPCAmap = { '2022-04-18': 0.0101, '2022-05-08': 0.0162 };
1901
+ const inputs: DebtInputs = {
1902
+ amortizationMethod,
1903
+ isGraceMonth,
1904
+ paymentNumber,
1905
+ numberOfMonths,
1906
+ previousBalance,
1907
+ inflationaryUpperBound,
1908
+ propertyAmount,
1909
+ IPCAmap,
1910
+ IPCAmapLate: { '2022-03-08': 0.0054 },
1911
+ today: '2022-05-08'
1912
+ };
1913
+ const params: DebtParams = {
1914
+ annualRate,
1915
+ debtorLifeInsuranceRate,
1916
+ // codebtorLifeInsuranceRate: debtorLifeInsuranceRate,
1917
+ propertyInsuranceRate
1918
+ };
1919
+ const result = service.getTotalMonthlyPayment(inputs, params);
1920
+ expect(result).toEqual(expectedResult);
1921
+ });
1922
+ it('Tiago (installment 4) should return the calculated installment with correct amortizationDiff', () => {
1923
+ const amortizationMethod = AmortizationMethod.GERMAN;
1924
+ const paymentNumber = new PaymentNumber(3);
1925
+ const isGraceMonth = false;
1926
+ const numberOfMonths = new NumberOfMonths(360);
1927
+ const previousBalance = new PreviousBalance(164217.58); //
1928
+ const annualRate = 0.0800;
1929
+ const debtorLifeInsuranceRate = new CreditInsuranceRate(0.00017);
1930
+ const inflationaryUpperBound = 0.003;
1931
+ const propertyAmount = 208000;
1932
+ const propertyInsuranceRate = new CreditInsuranceRate(0.00003);
1933
+ const IPCAmap = { '2022-04-08': 0.0101, '2022-05-08': 0.0162 };
1934
+ const inputs: DebtInputs = {
1935
+ amortizationMethod,
1936
+ isGraceMonth,
1937
+ paymentNumber,
1938
+ numberOfMonths,
1939
+ previousBalance,
1940
+ inflationaryUpperBound,
1941
+ propertyAmount,
1942
+ IPCAmap,
1943
+ IPCAmapLate: { '2022-05-08': 0.0162 },
1944
+ today: '2022-05-08'
1945
+ };
1946
+ const params: DebtParams = {
1947
+ annualRate,
1948
+ debtorLifeInsuranceRate,
1949
+ // codebtorLifeInsuranceRate: debtorLifeInsuranceRate,
1950
+ propertyInsuranceRate
1951
+ };
1952
+ const result = service.getTotalMonthlyPayment(inputs, params);
1953
+ const { amortizationDiff } = result;
1954
+ expect(amortizationDiff).toBe(5.313323492);
1955
+ });
1814
1956
  });
@@ -72,7 +72,10 @@ describe('offerService', () => {
72
72
  numberOfGraceMonths: 0,
73
73
  operationalExpensesFinancing: OperationalExpensesFinancing.DEBTOR,
74
74
  useDoublePayments: true,
75
- clientAge: undefined
75
+ clientAge: undefined,
76
+ district: undefined,
77
+ isPropertyNew: undefined,
78
+ prospectAge: undefined
76
79
  };
77
80
  const offerParams: OfferParams = {
78
81
  purpose: Purpose.HOME,
@@ -218,7 +221,10 @@ describe('offerService', () => {
218
221
  numberOfGraceMonths: 0, // Meses de gracias(N)
219
222
  operationalExpensesFinancing: OperationalExpensesFinancing.DEBTOR,
220
223
  clientAge: 35,
221
- useDoublePayments: false
224
+ useDoublePayments: false,
225
+ district: undefined,
226
+ isPropertyNew: undefined,
227
+ prospectAge: undefined
222
228
  };
223
229
  const math = new MathService(true, 20);
224
230
  const offerService = new OfferService(math);
@@ -326,7 +332,10 @@ describe('offerService', () => {
326
332
  numberOfGraceMonths: 12, // Meses de gracias(N)
327
333
  operationalExpensesFinancing: OperationalExpensesFinancing.DEBTOR,
328
334
  clientAge: 35,
329
- useDoublePayments: false
335
+ useDoublePayments: false,
336
+ district: undefined,
337
+ isPropertyNew: undefined,
338
+ prospectAge: undefined
330
339
  };
331
340
  const math = new MathService(true, 20);
332
341
  const offerService = new OfferService(math);
@@ -436,7 +445,10 @@ describe('offerService', () => {
436
445
  numberOfGraceMonths: 0, // Meses de gracias(N)
437
446
  operationalExpensesFinancing: OperationalExpensesFinancing.DEBTOR,
438
447
  clientAge: 35,
439
- useDoublePayments: false
448
+ useDoublePayments: false,
449
+ district: undefined,
450
+ isPropertyNew: undefined,
451
+ prospectAge: undefined
440
452
  };
441
453
  const math = new MathService(true, 20);
442
454
  const offerService = new OfferService(math);
@@ -546,7 +558,10 @@ describe('offerService', () => {
546
558
  numberOfGraceMonths: 12, // Meses de gracias(N)
547
559
  operationalExpensesFinancing: OperationalExpensesFinancing.DEBTOR,
548
560
  clientAge: 35,
549
- useDoublePayments: false
561
+ useDoublePayments: false,
562
+ district: undefined,
563
+ isPropertyNew: undefined,
564
+ prospectAge: undefined
550
565
  };
551
566
  const math = new MathService(true, 20);
552
567
  const offerService = new OfferService(math);
@@ -656,7 +671,10 @@ describe('offerService', () => {
656
671
  numberOfGraceMonths: 0, // Meses de gracias(N)
657
672
  operationalExpensesFinancing: OperationalExpensesFinancing.DEBTOR,
658
673
  clientAge: 35,
659
- useDoublePayments: false
674
+ useDoublePayments: false,
675
+ district: undefined,
676
+ isPropertyNew: undefined,
677
+ prospectAge: undefined
660
678
  };
661
679
  const math = new MathService(true, 20);
662
680
  const offerService = new OfferService(math);
@@ -766,7 +784,10 @@ describe('offerService', () => {
766
784
  numberOfGraceMonths: 0, // Meses de gracias(N)
767
785
  operationalExpensesFinancing: OperationalExpensesFinancing.DEBTOR,
768
786
  clientAge: 35,
769
- useDoublePayments: false
787
+ useDoublePayments: false,
788
+ district: undefined,
789
+ isPropertyNew: undefined,
790
+ prospectAge: undefined
770
791
  };
771
792
  const math = new MathService(true, 20);
772
793
  const offerService = new OfferService(math);
@@ -876,7 +897,10 @@ describe('offerService', () => {
876
897
  numberOfGraceMonths: 12, // Meses de gracias(N)
877
898
  operationalExpensesFinancing: OperationalExpensesFinancing.DEBTOR,
878
899
  clientAge: 35,
879
- useDoublePayments: false
900
+ useDoublePayments: false,
901
+ district: undefined,
902
+ isPropertyNew: undefined,
903
+ prospectAge: undefined
880
904
  };
881
905
  const math = new MathService(true, 20);
882
906
  const offerService = new OfferService(math);
@@ -986,7 +1010,10 @@ describe('offerService', () => {
986
1010
  numberOfGraceMonths: 0, // Meses de gracias(N)
987
1011
  operationalExpensesFinancing: OperationalExpensesFinancing.DEBTOR,
988
1012
  clientAge: 35,
989
- useDoublePayments: false
1013
+ useDoublePayments: false,
1014
+ district: undefined,
1015
+ isPropertyNew: undefined,
1016
+ prospectAge: undefined
990
1017
  };
991
1018
  const math = new MathService(true, 20);
992
1019
  const offerService = new OfferService(math);
@@ -1095,7 +1122,10 @@ describe('offerService', () => {
1095
1122
  numberOfGraceMonths: 0, // Meses de gracias(N)
1096
1123
  operationalExpensesFinancing: OperationalExpensesFinancing.CREDITU,
1097
1124
  clientAge: 35,
1098
- useDoublePayments: false
1125
+ useDoublePayments: false,
1126
+ district: undefined,
1127
+ isPropertyNew: undefined,
1128
+ prospectAge: undefined
1099
1129
  };
1100
1130
  const math = new MathService(true, 20);
1101
1131
  const offerService = new OfferService(math);
@@ -1205,7 +1235,10 @@ describe('offerService', () => {
1205
1235
  numberOfGraceMonths: 0, // Meses de gracias(N)
1206
1236
  operationalExpensesFinancing: OperationalExpensesFinancing.DEBTOR,
1207
1237
  clientAge: 35,
1208
- useDoublePayments: false
1238
+ useDoublePayments: false,
1239
+ district: undefined,
1240
+ isPropertyNew: undefined,
1241
+ prospectAge: undefined
1209
1242
  };
1210
1243
  const math = new MathService(true, 20);
1211
1244
  const offerService = new OfferService(math);
@@ -1314,7 +1347,10 @@ describe('offerService', () => {
1314
1347
  numberOfGraceMonths: 0, // Meses de gracias(N)
1315
1348
  operationalExpensesFinancing: OperationalExpensesFinancing.DEBTOR,
1316
1349
  clientAge: 35,
1317
- useDoublePayments: false
1350
+ useDoublePayments: false,
1351
+ district: undefined,
1352
+ isPropertyNew: undefined,
1353
+ prospectAge: undefined
1318
1354
  };
1319
1355
  const math = new MathService(true, 20);
1320
1356
  const offerService = new OfferService(math);
@@ -1423,7 +1459,10 @@ describe('offerService', () => {
1423
1459
  numberOfGraceMonths: 0, // Meses de gracias(N)
1424
1460
  operationalExpensesFinancing: OperationalExpensesFinancing.DEBTOR,
1425
1461
  clientAge: 35,
1426
- useDoublePayments: false
1462
+ useDoublePayments: false,
1463
+ district: undefined,
1464
+ isPropertyNew: undefined,
1465
+ prospectAge: undefined
1427
1466
  };
1428
1467
  const math = new MathService(true, 20);
1429
1468
  const offerService = new OfferService(math);
@@ -1532,7 +1571,10 @@ describe('offerService', () => {
1532
1571
  numberOfGraceMonths: 0, // Meses de gracias(N)
1533
1572
  operationalExpensesFinancing: OperationalExpensesFinancing.DEBTOR,
1534
1573
  clientAge: 0,
1535
- useDoublePayments: false
1574
+ useDoublePayments: false,
1575
+ district: undefined,
1576
+ isPropertyNew: undefined,
1577
+ prospectAge: undefined
1536
1578
  };
1537
1579
  const math = new MathService(true, 20);
1538
1580
  const offerService = new OfferService(math);
@@ -1641,7 +1683,10 @@ describe('offerService', () => {
1641
1683
  numberOfGraceMonths: 0, // Meses de gracias(N)
1642
1684
  operationalExpensesFinancing: OperationalExpensesFinancing.DEBTOR,
1643
1685
  clientAge: null,
1644
- useDoublePayments: false
1686
+ useDoublePayments: false,
1687
+ district: undefined,
1688
+ isPropertyNew: undefined,
1689
+ prospectAge: undefined
1645
1690
  };
1646
1691
  const math = new MathService(true, 20);
1647
1692
  const offerService = new OfferService(math);
@@ -1750,7 +1795,10 @@ describe('offerService', () => {
1750
1795
  numberOfGraceMonths: 0, // Meses de gracias(N)
1751
1796
  operationalExpensesFinancing: OperationalExpensesFinancing.DEBTOR,
1752
1797
  clientAge: undefined,
1753
- useDoublePayments: false
1798
+ useDoublePayments: false,
1799
+ district: undefined,
1800
+ isPropertyNew: undefined,
1801
+ prospectAge: undefined
1754
1802
  };
1755
1803
  const math = new MathService(true, 20);
1756
1804
  const offerService = new OfferService(math);