creditu-common-library 2.2.0 → 2.3.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/lates-input.dto.d.ts +1 -0
- package/debt/services/amortization.service.d.ts +1 -1
- package/debt/services/amortization.service.js +24 -6
- package/debt/services/installment.service.js +6 -7
- package/debt/services/insurance.service.js +2 -1
- package/debt/services/late.service.d.ts +1 -1
- package/debt/services/late.service.js +4 -1
- package/debt/services/monthly-payment.service.d.ts +3 -3
- package/debt/services/monthly-payment.service.js +9 -3
- package/package.json +1 -1
- package/test/br/{new-installment.service.specto.ts → new-installment.service.spec.ts} +1110 -65
|
@@ -35,7 +35,7 @@ export declare class AmortizationService {
|
|
|
35
35
|
};
|
|
36
36
|
getAmortization(amortizationIUB: number, amortizationDiff: number, postponedInflationaryUpdate: number): number;
|
|
37
37
|
getAmortizationInflation(upperBound: number, amortizationDiff: number, inflationaryUpdate: number): number;
|
|
38
|
-
getAmortizations(inputs: DebtInputs, balance: number, annualRate: number, inflationaryUpdate: number): {
|
|
38
|
+
getAmortizations(inputs: DebtInputs, balance: number, annualRate: number, inflationaryUpdate: number, interestIUB: number, interestDiff: number): {
|
|
39
39
|
inflationaryUpdate: number;
|
|
40
40
|
upperBound: number;
|
|
41
41
|
postponedInflationaryUpdate: number;
|
|
@@ -88,12 +88,30 @@ var AmortizationService = /** @class */ (function () {
|
|
|
88
88
|
: this.math.subtract(inflationaryUpdate, amortizationDiff), 10);
|
|
89
89
|
return amortizationInflation < 0 ? 0 : amortizationInflation;
|
|
90
90
|
};
|
|
91
|
-
AmortizationService.prototype.getAmortizations = function (inputs, balance, annualRate, inflationaryUpdate) {
|
|
92
|
-
var
|
|
93
|
-
var
|
|
94
|
-
var
|
|
95
|
-
var
|
|
96
|
-
var amortization
|
|
91
|
+
AmortizationService.prototype.getAmortizations = function (inputs, balance, annualRate, inflationaryUpdate, interestIUB, interestDiff) {
|
|
92
|
+
var upperBound;
|
|
93
|
+
var postponedInflationaryUpdate;
|
|
94
|
+
var amortizationIUB;
|
|
95
|
+
var amortizationDiff;
|
|
96
|
+
var amortization;
|
|
97
|
+
var amortizationInflation;
|
|
98
|
+
if (inputs.isGraceMonth) {
|
|
99
|
+
upperBound = 0; // no se usa en este caso
|
|
100
|
+
postponedInflationaryUpdate = inflationaryUpdate + interestDiff;
|
|
101
|
+
amortizationIUB = -interestIUB;
|
|
102
|
+
amortizationDiff = -interestDiff;
|
|
103
|
+
amortization = -(interestIUB + inflationaryUpdate); // ajustado para que balanceAfter dé lo que queremos
|
|
104
|
+
amortizationInflation = 0; // no se usa en este caso
|
|
105
|
+
}
|
|
106
|
+
else {
|
|
107
|
+
upperBound = this.math.multiply(inputs.previousBalance.value(), inputs.inflationaryUpperBound);
|
|
108
|
+
postponedInflationaryUpdate = this.inflationService.getPosponedInflationaryUpdate(upperBound, inflationaryUpdate, inputs.upperBoundBehaviour);
|
|
109
|
+
var amortizations = this.getAmortizationIUB(inputs, balance, annualRate);
|
|
110
|
+
amortizationIUB = amortizations.amortizationIUB;
|
|
111
|
+
amortizationDiff = amortizations.amortizationDiff;
|
|
112
|
+
amortization = this.getAmortization(amortizationIUB, amortizationDiff, postponedInflationaryUpdate);
|
|
113
|
+
amortizationInflation = this.getAmortizationInflation(upperBound, amortizationDiff, inflationaryUpdate);
|
|
114
|
+
}
|
|
97
115
|
return {
|
|
98
116
|
inflationaryUpdate: inflationaryUpdate,
|
|
99
117
|
upperBound: upperBound,
|
|
@@ -36,7 +36,7 @@ var InstallmentService = /** @class */ (function () {
|
|
|
36
36
|
var dueDate = Object.keys(inputs.inflationMap).pop();
|
|
37
37
|
var _a = this.interestService.getInterests(inputs, balanceValues, params, dueDate), interest = _a.interest, interestIUB = _a.interestIUB, interestDiff = _a.interestDiff;
|
|
38
38
|
var inflationaryUpdate = this.inflationService.getInflationaryUpdate(balanceValues.balanceMonetaryUpdateValues);
|
|
39
|
-
var _b = this.amortizationService.getAmortizations(inputs, balanceInflationaryUpdated, params.annualRate, inflationaryUpdate), upperBound = _b.upperBound, postponedInflationaryUpdate = _b.postponedInflationaryUpdate, amortizationInflation = _b.amortizationInflation, amortization = _b.amortization, amortizationIUB = _b.amortizationIUB, amortizationDiff = _b.amortizationDiff;
|
|
39
|
+
var _b = this.amortizationService.getAmortizations(inputs, balanceInflationaryUpdated, params.annualRate, inflationaryUpdate, interestIUB, interestDiff), upperBound = _b.upperBound, postponedInflationaryUpdate = _b.postponedInflationaryUpdate, amortizationInflation = _b.amortizationInflation, amortization = _b.amortization, amortizationIUB = _b.amortizationIUB, amortizationDiff = _b.amortizationDiff;
|
|
40
40
|
var monthlyPayment = this.monthlyPaymentService.getMonthlyPayment({
|
|
41
41
|
interestIUB: interestIUB,
|
|
42
42
|
amortizationIUB: amortizationIUB,
|
|
@@ -44,15 +44,13 @@ var InstallmentService = /** @class */ (function () {
|
|
|
44
44
|
inflationaryUpdate: inflationaryUpdate,
|
|
45
45
|
postponedInflationaryUpdate: postponedInflationaryUpdate
|
|
46
46
|
});
|
|
47
|
-
// TODO: Cambiar monthlyPayment para que use valores IUB
|
|
48
|
-
// Antes debemos verificar que monthlyPayment no lo estamos usando en el backend o en otro lugar.
|
|
49
47
|
var balanceAfter = this.math.subtract(inputs.previousBalance.value(), amortization);
|
|
50
48
|
var _c = this.insuranceService.getInsurances(inputs, params, inflationByDates, balanceValues, balanceAfter), totalLifeInsuranceFee = _c.totalLifeInsuranceFee, debtorLifeInsuranceFee = _c.debtorLifeInsuranceFee, codebtorLifeInsuranceFee = _c.codebtorLifeInsuranceFee, propertyInsuranceFee = _c.propertyInsuranceFee, monthlyCreditInsurance = _c.monthlyCreditInsurance, monthlyCreditInsuranceExpenses = _c.monthlyCreditInsuranceExpenses, monthlyCreditInsurancePrize = _c.monthlyCreditInsurancePrize;
|
|
51
|
-
var monthlyPaymentWithInsurances = this.monthlyPaymentService.getMonthlyPaymentWithInsurances(monthlyPayment, debtorLifeInsuranceFee, codebtorLifeInsuranceFee, propertyInsuranceFee, monthlyCreditInsurance || 0);
|
|
49
|
+
var monthlyPaymentWithInsurances = this.monthlyPaymentService.getMonthlyPaymentWithInsurances(monthlyPayment, debtorLifeInsuranceFee, codebtorLifeInsuranceFee, propertyInsuranceFee, monthlyCreditInsurance || 0, inputs.isGraceMonth);
|
|
52
50
|
var TACValue = inputs.considerTAC === true ? inputs.TACValue : 0;
|
|
53
|
-
var monthlyPaymentWithTAC = this.monthlyPaymentService.getMonthlyPaymentWithTAC(monthlyPaymentWithInsurances, TACValue);
|
|
51
|
+
var monthlyPaymentWithTAC = this.monthlyPaymentService.getMonthlyPaymentWithTAC(monthlyPaymentWithInsurances, TACValue, inputs.isGraceMonth);
|
|
54
52
|
var walletBalance = inputs.considerWallet === true ? inputs.walletBalance : 0;
|
|
55
|
-
monthlyPaymentWithTAC = this.monthlyPaymentService.getMonthlyPaymentWithWallet(monthlyPaymentWithTAC, walletBalance);
|
|
53
|
+
monthlyPaymentWithTAC = this.monthlyPaymentService.getMonthlyPaymentWithWallet(monthlyPaymentWithTAC, walletBalance, inputs.isGraceMonth);
|
|
56
54
|
var inflationMapLate = inputs.inflationMapLate, todayIn = inputs.today;
|
|
57
55
|
var today = todayIn || new creditu_date_model_1.DateModel().toString();
|
|
58
56
|
var _d = this.lateService.getLates({
|
|
@@ -65,7 +63,8 @@ var InstallmentService = /** @class */ (function () {
|
|
|
65
63
|
inflationMap: inflationMapLate,
|
|
66
64
|
considerNegativeInflation: inputs.considerNegativeInflation,
|
|
67
65
|
monthNominalLength: params.monthNominalLength,
|
|
68
|
-
inflationExchangeMethodYearlyToMonthly: params.inflationExchangeMethodYearlyToMonthly
|
|
66
|
+
inflationExchangeMethodYearlyToMonthly: params.inflationExchangeMethodYearlyToMonthly,
|
|
67
|
+
isGraceMonth: inputs.isGraceMonth
|
|
69
68
|
}), lateDays = _d.lateDays, lateChargesFine = _d.lateChargesFine, lateInflation = _d.lateInflation, lateInflationaryCorrection = _d.lateInflationaryCorrection, lateChargesInterestRate = _d.lateChargesInterestRate, lateChargesInterest = _d.lateChargesInterest, lateInterestRate = _d.lateInterestRate, lateInterest = _d.lateInterest, lastMonthLateInflation = _d.lastMonthLateInflation, lastMonthLateChargesInterestRate = _d.lastMonthLateChargesInterestRate, lastMonthLateInterestRate = _d.lastMonthLateInterestRate, lastMonthTotalLateRate = _d.lastMonthTotalLateRate, totalLateRate = _d.totalLateRate, totalLateInterest = _d.totalLateInterest, totalLate = _d.totalLate, monthlyPaymentWithLate = _d.monthlyPaymentWithLate;
|
|
70
69
|
var totalMonthlyPayment = monthlyPaymentWithLate;
|
|
71
70
|
var response = {
|
|
@@ -113,7 +113,8 @@ var InsuranceService = /** @class */ (function () {
|
|
|
113
113
|
var dueDate = dates[dates.length - 1];
|
|
114
114
|
var daysPerMonth = params.monthNominalLength; // En BRASIL actualmente siempre viene un número
|
|
115
115
|
var numberOfExtraMonths = creditu_date_model_1.DateModel.days360(signatureDate, dueDate) > daysPerMonth ? 2 : 1;
|
|
116
|
-
|
|
116
|
+
// Los meses extra son ADICIONALES al que ya pagamos ese mes
|
|
117
|
+
return normalMonthAmount * (1 + numberOfExtraMonths);
|
|
117
118
|
};
|
|
118
119
|
InsuranceService.prototype.getInsurances = function (inputs, params, inflationByDates, balanceValues, balanceAfter) {
|
|
119
120
|
var totalLifeInsuranceFee;
|
|
@@ -26,5 +26,5 @@ export declare class LateService {
|
|
|
26
26
|
monthlyPaymentWithLate: number;
|
|
27
27
|
};
|
|
28
28
|
getTotalMonthlyPayment(dueDate: string, today: string, monthlyPaymentWithTAC: number, lateChargesFineRate: number, lateChargesInterestRate: number, interestRate: number, inflationMapLate: Record<string, number>, dailyinflationvalues: number[]): Record<string, number>;
|
|
29
|
-
getLates({ dueDate, today, totalMonthlyPaymentBeforeLate, lateChargesFineRate, lateChargesInterestRate, annualCreditInterestRate, inflationMap, considerNegativeInflation, monthNominalLength, inflationExchangeMethodYearlyToMonthly }: LatesInput): LatesOutput;
|
|
29
|
+
getLates({ dueDate, today, totalMonthlyPaymentBeforeLate, lateChargesFineRate, lateChargesInterestRate, annualCreditInterestRate, inflationMap, considerNegativeInflation, monthNominalLength, inflationExchangeMethodYearlyToMonthly, isGraceMonth }: LatesInput): LatesOutput;
|
|
30
30
|
}
|
|
@@ -125,7 +125,7 @@ var LateService = /** @class */ (function () {
|
|
|
125
125
|
};
|
|
126
126
|
LateService.prototype.getLates = function (_a) {
|
|
127
127
|
var _this = this;
|
|
128
|
-
var dueDate = _a.dueDate, today = _a.today, totalMonthlyPaymentBeforeLate = _a.totalMonthlyPaymentBeforeLate, lateChargesFineRate = _a.lateChargesFineRate, lateChargesInterestRate = _a.lateChargesInterestRate, annualCreditInterestRate = _a.annualCreditInterestRate, inflationMap = _a.inflationMap, considerNegativeInflation = _a.considerNegativeInflation, monthNominalLength = _a.monthNominalLength, inflationExchangeMethodYearlyToMonthly = _a.inflationExchangeMethodYearlyToMonthly;
|
|
128
|
+
var dueDate = _a.dueDate, today = _a.today, totalMonthlyPaymentBeforeLate = _a.totalMonthlyPaymentBeforeLate, lateChargesFineRate = _a.lateChargesFineRate, lateChargesInterestRate = _a.lateChargesInterestRate, annualCreditInterestRate = _a.annualCreditInterestRate, inflationMap = _a.inflationMap, considerNegativeInflation = _a.considerNegativeInflation, monthNominalLength = _a.monthNominalLength, inflationExchangeMethodYearlyToMonthly = _a.inflationExchangeMethodYearlyToMonthly, isGraceMonth = _a.isGraceMonth;
|
|
129
129
|
var lates = {
|
|
130
130
|
lateDays: 0,
|
|
131
131
|
lateChargesFine: 0,
|
|
@@ -144,6 +144,9 @@ var LateService = /** @class */ (function () {
|
|
|
144
144
|
totalLate: 0,
|
|
145
145
|
monthlyPaymentWithLate: totalMonthlyPaymentBeforeLate
|
|
146
146
|
};
|
|
147
|
+
if (isGraceMonth) {
|
|
148
|
+
return lates;
|
|
149
|
+
}
|
|
147
150
|
var todayDateModel = new creditu_date_model_1.DateModel(today);
|
|
148
151
|
var dueDateDateModel = new creditu_date_model_1.DateModel(dueDate);
|
|
149
152
|
var lateDays = todayDateModel.daysDiff(dueDateDateModel);
|
|
@@ -15,14 +15,14 @@ export declare class MonthlyPaymentService {
|
|
|
15
15
|
* @param monthlyPaymentWithInsurances
|
|
16
16
|
* @param TACvalue
|
|
17
17
|
*/
|
|
18
|
-
getMonthlyPaymentWithTAC(monthlyPaymentWithInsurances: number, TACvalue: number): number;
|
|
18
|
+
getMonthlyPaymentWithTAC(monthlyPaymentWithInsurances: number, TACvalue: number, isGraceMonth?: boolean): number;
|
|
19
19
|
/**
|
|
20
20
|
* Calcula el pago de la cuota mensual considerando todo menos los cargos de atraso
|
|
21
21
|
* @param interest
|
|
22
22
|
* @param amortization
|
|
23
23
|
* @param amortizationIinflation
|
|
24
24
|
*/
|
|
25
|
-
getMonthlyPaymentWithInsurances(monthlyPayment: number, debtorLifeInsuranceFee: number, codebtorLifeInsuranceFee: number, propertyInsuranceFee: number, monthlyCreditInsurance: number): number;
|
|
25
|
+
getMonthlyPaymentWithInsurances(monthlyPayment: number, debtorLifeInsuranceFee: number, codebtorLifeInsuranceFee: number, propertyInsuranceFee: number, monthlyCreditInsurance: number, isGraceMonth?: boolean): number;
|
|
26
26
|
/**
|
|
27
27
|
* Calcula el monto de la cuota considerando el saldo en wallet
|
|
28
28
|
*
|
|
@@ -31,5 +31,5 @@ export declare class MonthlyPaymentService {
|
|
|
31
31
|
* @param monthlyPaymentWithTAC
|
|
32
32
|
* @param walletBallance
|
|
33
33
|
*/
|
|
34
|
-
getMonthlyPaymentWithWallet(monthlyPaymentWithTAC: number, walletBallance: number): number;
|
|
34
|
+
getMonthlyPaymentWithWallet(monthlyPaymentWithTAC: number, walletBallance: number, isGraceMonth?: boolean): number;
|
|
35
35
|
}
|
|
@@ -41,11 +41,13 @@ var MonthlyPaymentService = /** @class */ (function () {
|
|
|
41
41
|
* @param monthlyPaymentWithInsurances
|
|
42
42
|
* @param TACvalue
|
|
43
43
|
*/
|
|
44
|
-
MonthlyPaymentService.prototype.getMonthlyPaymentWithTAC = function (monthlyPaymentWithInsurances, TACvalue) {
|
|
44
|
+
MonthlyPaymentService.prototype.getMonthlyPaymentWithTAC = function (monthlyPaymentWithInsurances, TACvalue, isGraceMonth) {
|
|
45
45
|
this.paramsValidator({
|
|
46
46
|
monthlyPaymentWithInsurances: monthlyPaymentWithInsurances,
|
|
47
47
|
TACvalue: TACvalue
|
|
48
48
|
});
|
|
49
|
+
if (isGraceMonth)
|
|
50
|
+
return monthlyPaymentWithInsurances;
|
|
49
51
|
return this.math.add(monthlyPaymentWithInsurances, TACvalue);
|
|
50
52
|
};
|
|
51
53
|
/**
|
|
@@ -54,7 +56,7 @@ var MonthlyPaymentService = /** @class */ (function () {
|
|
|
54
56
|
* @param amortization
|
|
55
57
|
* @param amortizationIinflation
|
|
56
58
|
*/
|
|
57
|
-
MonthlyPaymentService.prototype.getMonthlyPaymentWithInsurances = function (monthlyPayment, debtorLifeInsuranceFee, codebtorLifeInsuranceFee, propertyInsuranceFee, monthlyCreditInsurance) {
|
|
59
|
+
MonthlyPaymentService.prototype.getMonthlyPaymentWithInsurances = function (monthlyPayment, debtorLifeInsuranceFee, codebtorLifeInsuranceFee, propertyInsuranceFee, monthlyCreditInsurance, isGraceMonth) {
|
|
58
60
|
this.paramsValidator({
|
|
59
61
|
monthlyPayment: monthlyPayment,
|
|
60
62
|
debtorLifeInsuranceFee: debtorLifeInsuranceFee,
|
|
@@ -62,6 +64,8 @@ var MonthlyPaymentService = /** @class */ (function () {
|
|
|
62
64
|
propertyInsuranceFee: propertyInsuranceFee,
|
|
63
65
|
monthlyCreditInsurance: monthlyCreditInsurance
|
|
64
66
|
});
|
|
67
|
+
if (isGraceMonth)
|
|
68
|
+
return monthlyPayment;
|
|
65
69
|
return this.math.add(monthlyPayment, debtorLifeInsuranceFee, codebtorLifeInsuranceFee, propertyInsuranceFee, monthlyCreditInsurance);
|
|
66
70
|
};
|
|
67
71
|
/**
|
|
@@ -72,11 +76,13 @@ var MonthlyPaymentService = /** @class */ (function () {
|
|
|
72
76
|
* @param monthlyPaymentWithTAC
|
|
73
77
|
* @param walletBallance
|
|
74
78
|
*/
|
|
75
|
-
MonthlyPaymentService.prototype.getMonthlyPaymentWithWallet = function (monthlyPaymentWithTAC, walletBallance) {
|
|
79
|
+
MonthlyPaymentService.prototype.getMonthlyPaymentWithWallet = function (monthlyPaymentWithTAC, walletBallance, isGraceMonth) {
|
|
76
80
|
this.paramsValidator({
|
|
77
81
|
monthlyPaymentWithTAC: monthlyPaymentWithTAC,
|
|
78
82
|
walletBallance: walletBallance
|
|
79
83
|
});
|
|
84
|
+
if (isGraceMonth)
|
|
85
|
+
return monthlyPaymentWithTAC;
|
|
80
86
|
return walletBallance > monthlyPaymentWithTAC ? monthlyPaymentWithTAC : this.math.subtract(monthlyPaymentWithTAC, walletBallance);
|
|
81
87
|
};
|
|
82
88
|
return MonthlyPaymentService;
|