creditu-common-library 1.0.21 → 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/debt/models/dto/balances-output.dto.d.ts +18 -0
- package/debt/models/dto/balances-output.dto.js +9 -0
- package/debt/models/dto/daily-ipca-output.dto.d.ts +14 -0
- package/debt/models/dto/daily-ipca-output.dto.js +9 -0
- package/debt/models/dto/debt-inputs.dto.d.ts +38 -0
- package/debt/models/dto/debt-inputs.dto.js +12 -0
- package/debt/models/dto/debt-params.dto.d.ts +18 -0
- package/debt/models/dto/debt-params.dto.js +12 -0
- package/debt/models/dto/debt-response.dto.d.ts +59 -0
- package/debt/models/dto/debt-response.dto.js +12 -0
- package/debt/models/dto/index.d.ts +4 -0
- package/debt/models/dto/index.js +9 -0
- package/debt/services/amortization-service.d.ts +20 -0
- package/debt/services/amortization-service.js +42 -0
- package/debt/services/balance-service.d.ts +27 -0
- package/debt/services/balance-service.js +81 -0
- package/debt/services/index.d.ts +7 -0
- package/debt/services/index.js +15 -0
- package/debt/services/installment-service.d.ts +20 -0
- package/debt/services/installment-service.js +65 -0
- package/debt/services/insurance-service.d.ts +18 -0
- package/debt/services/insurance-service.js +52 -0
- package/{finance → debt}/services/interest.service.d.ts +8 -3
- package/{finance → debt}/services/interest.service.js +25 -11
- package/debt/services/ipca.service.d.ts +26 -0
- package/debt/services/ipca.service.js +99 -0
- package/debt/services/late.service.d.ts +29 -0
- package/debt/services/late.service.js +116 -0
- package/debt/services/payment-service.d.ts +12 -0
- package/debt/services/payment-service.js +27 -0
- package/math/math.service.d.ts +1 -1
- package/offer/models/dto/index.d.ts +4 -0
- package/offer/models/dto/index.js +9 -0
- package/{finance → offer}/models/dto/offer-inputs.dto.d.ts +1 -1
- package/{finance → offer}/models/dto/offer-inputs.dto.js +0 -0
- package/{finance → offer}/models/dto/offer-params.dto.d.ts +6 -6
- package/{finance → offer}/models/dto/offer-params.dto.js +0 -0
- package/{finance → offer}/models/dto/offer-response.dto.d.ts +0 -0
- package/{finance → offer}/models/dto/offer-response.dto.js +0 -0
- package/{finance → offer}/services/constants.service.d.ts +9 -9
- package/{finance → offer}/services/constants.service.js +1 -1
- package/{finance → offer}/services/credit-insurance.service.d.ts +3 -3
- package/{finance → offer}/services/credit-insurance.service.js +0 -0
- package/{finance → offer}/services/finance.service.d.ts +1 -1
- package/{finance → offer}/services/finance.service.js +1 -1
- package/offer/services/index.d.ts +9 -0
- package/{finance → offer}/services/index.js +1 -11
- package/{finance → offer}/services/installment.service.d.ts +1 -1
- package/{finance → offer}/services/installment.service.js +1 -1
- package/{finance → offer}/services/loan-to-value.service.d.ts +2 -2
- package/{finance → offer}/services/loan-to-value.service.js +1 -1
- package/{finance → offer}/services/maximum-local.service.d.ts +3 -3
- package/{finance → offer}/services/maximum-local.service.js +1 -1
- package/{finance → offer}/services/offer.service.d.ts +9 -6
- package/{finance → offer}/services/offer.service.js +8 -8
- package/{finance → offer}/services/operational-expenses.d.ts +2 -2
- package/{finance → offer}/services/operational-expenses.js +0 -0
- package/package.json +1 -1
- package/{finance → shared}/models/appraisal-expenses-percentage.d.ts +0 -0
- package/{finance → shared}/models/appraisal-expenses-percentage.js +0 -0
- package/{finance → shared}/models/credit-amount.d.ts +0 -0
- package/{finance → shared}/models/credit-amount.js +0 -0
- package/{finance → shared}/models/credit-insurance-financing.d.ts +0 -0
- package/{finance → shared}/models/credit-insurance-financing.js +0 -0
- package/{finance → shared}/models/credit-insurance-rate.d.ts +0 -0
- package/{finance → shared}/models/credit-insurance-rate.js +0 -0
- package/{finance → shared}/models/credit-tax-rate-percentage.d.ts +0 -0
- package/{finance → shared}/models/credit-tax-rate-percentage.js +0 -0
- package/{finance → shared}/models/credit-tax-rate.d.ts +0 -0
- package/{finance → shared}/models/credit-tax-rate.js +0 -0
- package/{finance → shared}/models/deed-expenses-percentage.d.ts +0 -0
- package/{finance → shared}/models/deed-expenses-percentage.js +0 -0
- package/{finance → shared}/models/dto/life-insurance-monthly-rate-range.dto.d.ts +0 -0
- package/{finance → shared}/models/dto/life-insurance-monthly-rate-range.dto.js +0 -0
- package/{finance → shared}/models/enum/amortization-method.enum.d.ts +0 -0
- package/{finance → shared}/models/enum/amortization-method.enum.js +0 -0
- package/{finance → shared}/models/enum/grace-months-interest-method.enum.d.ts +0 -0
- package/{finance → shared}/models/enum/grace-months-interest-method.enum.js +0 -0
- package/{finance → shared}/models/enum/interest-type.enum.d.ts +0 -0
- package/{finance → shared}/models/enum/interest-type.enum.js +0 -0
- package/{finance → shared}/models/enum/operational-expenses-interest.enum.d.ts +0 -0
- package/{finance → shared}/models/enum/operational-expenses-interest.enum.js +0 -0
- package/{finance → shared}/models/enum/operational-expenses.financing.d.ts +0 -0
- package/{finance → shared}/models/enum/operational-expenses.financing.js +0 -0
- package/{finance → shared}/models/enum/purpose.enum.d.ts +0 -0
- package/{finance → shared}/models/enum/purpose.enum.js +0 -0
- package/{finance → shared}/models/greater-than.vo.d.ts +0 -0
- package/{finance → shared}/models/greater-than.vo.js +0 -0
- package/{finance → shared}/models/guarder.d.ts +0 -0
- package/{finance → shared}/models/guarder.js +0 -0
- package/{finance → shared}/models/index.d.ts +1 -4
- package/{finance → shared}/models/index.js +1 -7
- package/{finance → shared}/models/investment-weight.d.ts +0 -0
- package/{finance → shared}/models/investment-weight.js +0 -0
- package/{finance → shared}/models/maximum-backend-ratio.d.ts +0 -0
- package/{finance → shared}/models/maximum-backend-ratio.js +0 -0
- package/{finance → shared}/models/maximum-credit-ltv.d.ts +0 -0
- package/{finance → shared}/models/maximum-credit-ltv.js +0 -0
- package/{finance → shared}/models/maximum-frontend-ratio.d.ts +0 -0
- package/{finance → shared}/models/maximum-frontend-ratio.js +0 -0
- package/{finance → shared}/models/maximum-loan-to-value.d.ts +0 -0
- package/{finance → shared}/models/maximum-loan-to-value.js +0 -0
- package/{finance → shared}/models/maximum-local-params.interface.d.ts +0 -0
- package/{finance → shared}/models/maximum-local-params.interface.js +0 -0
- package/{finance → shared}/models/maximum-property-ltv.d.ts +0 -0
- package/{finance → shared}/models/maximum-property-ltv.js +0 -0
- package/{finance → shared}/models/notary-expenses-percentage.d.ts +0 -0
- package/{finance → shared}/models/notary-expenses-percentage.js +0 -0
- package/{finance → shared}/models/number-of-months.d.ts +0 -0
- package/{finance → shared}/models/number-of-months.js +0 -0
- package/{finance → shared}/models/number.vo.d.ts +0 -0
- package/{finance → shared}/models/number.vo.js +0 -0
- package/{finance → shared}/models/operational-expenses-number-of-months.d.ts +0 -0
- package/{finance → shared}/models/operational-expenses-number-of-months.js +0 -0
- package/shared/models/payment-number.d.ts +4 -0
- package/shared/models/payment-number.js +27 -0
- package/{finance/models/new-balance-before.d.ts → shared/models/previous-balance.d.ts} +1 -1
- package/{finance/models/new-balance-before.js → shared/models/previous-balance.js} +7 -7
- package/{finance → shared}/models/range-vo-config.d.ts +0 -0
- package/{finance → shared}/models/range-vo-config.js +0 -0
- package/{finance → shared}/models/range.vo.d.ts +0 -0
- package/{finance → shared}/models/range.vo.js +0 -0
- package/{finance → shared}/models/real-estate-expenses-percentage.d.ts +0 -0
- package/{finance → shared}/models/real-estate-expenses-percentage.js +0 -0
- package/{finance → shared}/models/tax-rate.d.ts +0 -0
- package/{finance → shared}/models/tax-rate.js +0 -0
- package/{finance → shared}/models/title-study-expenses-percentage.d.ts +0 -0
- package/{finance → shared}/models/title-study-expenses-percentage.js +0 -0
- package/test/installment.service.spec.ts +644 -0
- package/test/offer.service.spec.ts +6 -6
- package/finance/services/amortization-service.d.ts +0 -27
- package/finance/services/amortization-service.js +0 -65
- package/finance/services/balance.service.d.ts +0 -6
- package/finance/services/balance.service.js +0 -15
- package/finance/services/index.d.ts +0 -14
- package/finance/services/insurance-service.d.ts +0 -7
- package/finance/services/insurance-service.js +0 -23
- package/finance/services/ipca.service.d.ts +0 -14
- package/finance/services/ipca.service.js +0 -46
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export declare class BalancesOutput {
|
|
2
|
+
/**
|
|
3
|
+
* Arreglo de saldos insolutos diarios aplicando IPCA
|
|
4
|
+
*/
|
|
5
|
+
balances: number[];
|
|
6
|
+
/**
|
|
7
|
+
* Arreglo de montos darios de IPCA
|
|
8
|
+
*/
|
|
9
|
+
balanceMonetaryUpdateValues: number[];
|
|
10
|
+
/**
|
|
11
|
+
* Arreglo de montos darios aplicando IPCA considerando el tope maximo de pago de IPCA pactado con el cliente
|
|
12
|
+
*/
|
|
13
|
+
balanceUpperBoundMonetaryUpdateValues: number[];
|
|
14
|
+
/**
|
|
15
|
+
* Arreglo de montos diarios de IPCA que exceden el tope maximo de pago de IPCA pactado con el cliente
|
|
16
|
+
*/
|
|
17
|
+
inflationaryBoundDifferenceValues: number[];
|
|
18
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.BalancesOutput = void 0;
|
|
4
|
+
var BalancesOutput = /** @class */ (function () {
|
|
5
|
+
function BalancesOutput() {
|
|
6
|
+
}
|
|
7
|
+
return BalancesOutput;
|
|
8
|
+
}());
|
|
9
|
+
exports.BalancesOutput = BalancesOutput;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DailyIPCAOutput = void 0;
|
|
4
|
+
var DailyIPCAOutput = /** @class */ (function () {
|
|
5
|
+
function DailyIPCAOutput() {
|
|
6
|
+
}
|
|
7
|
+
return DailyIPCAOutput;
|
|
8
|
+
}());
|
|
9
|
+
exports.DailyIPCAOutput = DailyIPCAOutput;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { AmortizationMethod } from '../../../shared/models/enum/amortization-method.enum';
|
|
2
|
+
import { NumberOfMonths } from '../../../shared/models/number-of-months';
|
|
3
|
+
import { PreviousBalance } from '../../../shared/models/previous-balance';
|
|
4
|
+
import { PaymentNumber } from '../../../shared/models/payment-number';
|
|
5
|
+
/**
|
|
6
|
+
* Inputs para el calculo de la deuda
|
|
7
|
+
*/
|
|
8
|
+
export declare class DebtInputs {
|
|
9
|
+
/**
|
|
10
|
+
* Tipo de Amortizacion pactada con el cliente
|
|
11
|
+
*/
|
|
12
|
+
amortizationMethod: AmortizationMethod;
|
|
13
|
+
/**
|
|
14
|
+
* Numero de cuota al que se le calcula la deuda
|
|
15
|
+
*/
|
|
16
|
+
paymentNumber: PaymentNumber;
|
|
17
|
+
/**
|
|
18
|
+
* Numero de meses (cuotas) totales del credito
|
|
19
|
+
*/
|
|
20
|
+
numberOfMonths: NumberOfMonths;
|
|
21
|
+
/**
|
|
22
|
+
* Saldo insoluto de la cuota anterior
|
|
23
|
+
*/
|
|
24
|
+
previousBalance: PreviousBalance;
|
|
25
|
+
/**
|
|
26
|
+
* Maximo de IPCA a pagar pactado con el cliente
|
|
27
|
+
*/
|
|
28
|
+
inflationaryUpperBound: number;
|
|
29
|
+
/**
|
|
30
|
+
* Valor de la propiedad
|
|
31
|
+
*/
|
|
32
|
+
propertyAmount: number;
|
|
33
|
+
/**
|
|
34
|
+
* Mapa de IPCAs en el rango de fechas de la deuda a calcular
|
|
35
|
+
* Key: Date YYYY/MM/DD format, Value: number format
|
|
36
|
+
*/
|
|
37
|
+
IPCAmap: Record<string, number>;
|
|
38
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DebtInputs = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Inputs para el calculo de la deuda
|
|
6
|
+
*/
|
|
7
|
+
var DebtInputs = /** @class */ (function () {
|
|
8
|
+
function DebtInputs() {
|
|
9
|
+
}
|
|
10
|
+
return DebtInputs;
|
|
11
|
+
}());
|
|
12
|
+
exports.DebtInputs = DebtInputs;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { CreditInsuranceRate } from '../../../shared/models/credit-insurance-rate';
|
|
2
|
+
/**
|
|
3
|
+
* Parametros para el calculo de la Deuda
|
|
4
|
+
*/
|
|
5
|
+
export declare class DebtParams {
|
|
6
|
+
/**
|
|
7
|
+
* Tasa de interes anual
|
|
8
|
+
*/
|
|
9
|
+
annualRate: number;
|
|
10
|
+
/**
|
|
11
|
+
* Tasa de seguro de vida o desgravamen
|
|
12
|
+
*/
|
|
13
|
+
lifeInsuranceRates: CreditInsuranceRate[];
|
|
14
|
+
/**
|
|
15
|
+
* Tasa de seguro de incendio o propiedad
|
|
16
|
+
*/
|
|
17
|
+
propertyInsuranceRate: CreditInsuranceRate;
|
|
18
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DebtParams = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Parametros para el calculo de la Deuda
|
|
6
|
+
*/
|
|
7
|
+
var DebtParams = /** @class */ (function () {
|
|
8
|
+
function DebtParams() {
|
|
9
|
+
}
|
|
10
|
+
return DebtParams;
|
|
11
|
+
}());
|
|
12
|
+
exports.DebtParams = DebtParams;
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { BalancesOutput } from './balances-output.dto';
|
|
2
|
+
import { DailyIPCAOutput } from './daily-ipca-output.dto';
|
|
3
|
+
/**
|
|
4
|
+
* Respuesta del calculo de la deuda
|
|
5
|
+
*/
|
|
6
|
+
export declare class DebtResponse {
|
|
7
|
+
/**
|
|
8
|
+
* Deuda calculada para la cuota
|
|
9
|
+
*/
|
|
10
|
+
totalMonthlyPayment: number;
|
|
11
|
+
/**
|
|
12
|
+
* IPCA diarios para las fechas de calculo de deuda
|
|
13
|
+
*/
|
|
14
|
+
IPCAByDates: DailyIPCAOutput[];
|
|
15
|
+
/**
|
|
16
|
+
* Saldos calculados en base al IPCA
|
|
17
|
+
*/
|
|
18
|
+
balanceValues: BalancesOutput;
|
|
19
|
+
/**
|
|
20
|
+
* Saldo total del pago
|
|
21
|
+
*/
|
|
22
|
+
balance: number;
|
|
23
|
+
/**
|
|
24
|
+
* Saldo total despues del pago
|
|
25
|
+
*/
|
|
26
|
+
balanceAfter: number;
|
|
27
|
+
/**
|
|
28
|
+
* Monto total a pagar por concepto de IPCA
|
|
29
|
+
*/
|
|
30
|
+
ipcaUpdate: number;
|
|
31
|
+
/**
|
|
32
|
+
* Tasa diaria usada para los calculos
|
|
33
|
+
*/
|
|
34
|
+
dailyRate: number;
|
|
35
|
+
/**
|
|
36
|
+
* Interes
|
|
37
|
+
*/
|
|
38
|
+
interest: number;
|
|
39
|
+
/**
|
|
40
|
+
* Valor de la cuota
|
|
41
|
+
*/
|
|
42
|
+
monthlyPayment: number;
|
|
43
|
+
/**
|
|
44
|
+
* Amortizacion
|
|
45
|
+
*/
|
|
46
|
+
amortization: number;
|
|
47
|
+
/**
|
|
48
|
+
* Amortizacion ajustado al IPCA
|
|
49
|
+
*/
|
|
50
|
+
amortizationIPCA: number;
|
|
51
|
+
/**
|
|
52
|
+
* Cuota de seguro de vida o desgravamen
|
|
53
|
+
*/
|
|
54
|
+
lifeInsuranceFee: number;
|
|
55
|
+
/**
|
|
56
|
+
* Cuota de seguro de incendio o propiedad
|
|
57
|
+
*/
|
|
58
|
+
propertyInsuranceFee: number;
|
|
59
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DebtResponse = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Respuesta del calculo de la deuda
|
|
6
|
+
*/
|
|
7
|
+
var DebtResponse = /** @class */ (function () {
|
|
8
|
+
function DebtResponse() {
|
|
9
|
+
}
|
|
10
|
+
return DebtResponse;
|
|
11
|
+
}());
|
|
12
|
+
exports.DebtResponse = DebtResponse;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DebtResponse = exports.DebtParams = exports.DebtInputs = void 0;
|
|
4
|
+
var debt_inputs_dto_1 = require("./debt-inputs.dto");
|
|
5
|
+
Object.defineProperty(exports, "DebtInputs", { enumerable: true, get: function () { return debt_inputs_dto_1.DebtInputs; } });
|
|
6
|
+
var debt_params_dto_1 = require("./debt-params.dto");
|
|
7
|
+
Object.defineProperty(exports, "DebtParams", { enumerable: true, get: function () { return debt_params_dto_1.DebtParams; } });
|
|
8
|
+
var debt_response_dto_1 = require("./debt-response.dto");
|
|
9
|
+
Object.defineProperty(exports, "DebtResponse", { enumerable: true, get: function () { return debt_response_dto_1.DebtResponse; } });
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { MathService } from '../../math';
|
|
2
|
+
import { NumberOfMonths } from '../../shared/models/number-of-months';
|
|
3
|
+
import { PaymentNumber } from '../../shared/models/payment-number';
|
|
4
|
+
export declare class AmortizationService {
|
|
5
|
+
private readonly math;
|
|
6
|
+
constructor(math: MathService);
|
|
7
|
+
/**
|
|
8
|
+
* Calcula la amortizacion aplicando IPCA
|
|
9
|
+
* @param balanceMonetaryUpdateValues
|
|
10
|
+
* @param inflationaryBoundDifferenceValues
|
|
11
|
+
*/
|
|
12
|
+
getAmortizationIPCA(balanceMonetaryUpdateValues: number[], inflationaryBoundDifferenceValues: number[]): number;
|
|
13
|
+
/**
|
|
14
|
+
* Calcula la amortizacion
|
|
15
|
+
* @param paymentNumber
|
|
16
|
+
* @param numberOfMonths
|
|
17
|
+
* @param balance
|
|
18
|
+
*/
|
|
19
|
+
getAmortization(paymentNumber: PaymentNumber, numberOfMonths: NumberOfMonths, balance: number): number;
|
|
20
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.AmortizationService = void 0;
|
|
4
|
+
var math_1 = require("../../math");
|
|
5
|
+
var guarder_1 = require("../../shared/models/guarder");
|
|
6
|
+
var AmortizationService = /** @class */ (function () {
|
|
7
|
+
function AmortizationService(math) {
|
|
8
|
+
this.math = math;
|
|
9
|
+
this.math = new math_1.MathService(true, 10);
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Calcula la amortizacion aplicando IPCA
|
|
13
|
+
* @param balanceMonetaryUpdateValues
|
|
14
|
+
* @param inflationaryBoundDifferenceValues
|
|
15
|
+
*/
|
|
16
|
+
AmortizationService.prototype.getAmortizationIPCA = function (balanceMonetaryUpdateValues, inflationaryBoundDifferenceValues) {
|
|
17
|
+
if (balanceMonetaryUpdateValues === undefined || balanceMonetaryUpdateValues.length === 0)
|
|
18
|
+
throw new Error('invalid balanceMonetaryUpdateValues on AmortizationIPCA calculation');
|
|
19
|
+
if (inflationaryBoundDifferenceValues === undefined || inflationaryBoundDifferenceValues.length === 0)
|
|
20
|
+
throw new Error('invalid inflationaryBoundDifferenceValues on AmortizationIPCA calculation');
|
|
21
|
+
var balanceMonetaryUpdateTotal = balanceMonetaryUpdateValues.reduce(function (sum, x) { return sum + x; }, 0);
|
|
22
|
+
var inflationaryBoundDifferenceTotal = inflationaryBoundDifferenceValues.reduce(function (sum2, x2) { return sum2 + x2; }, 0);
|
|
23
|
+
return this.math.round(this.math.subtract(balanceMonetaryUpdateTotal, inflationaryBoundDifferenceTotal), 2);
|
|
24
|
+
};
|
|
25
|
+
/**
|
|
26
|
+
* Calcula la amortizacion
|
|
27
|
+
* @param paymentNumber
|
|
28
|
+
* @param numberOfMonths
|
|
29
|
+
* @param balance
|
|
30
|
+
*/
|
|
31
|
+
AmortizationService.prototype.getAmortization = function (paymentNumber, numberOfMonths, balance) {
|
|
32
|
+
guarder_1.Guarder.defined(paymentNumber, 'PaymentNumber');
|
|
33
|
+
guarder_1.Guarder.defined(numberOfMonths, 'NumberOfMonths');
|
|
34
|
+
if (balance === undefined || balance < 0 || balance === null)
|
|
35
|
+
throw new Error('invalid balance on Amortization calculation');
|
|
36
|
+
var divisor = numberOfMonths.value() - paymentNumber.value() + 1;
|
|
37
|
+
var result = this.math.divide(balance, divisor);
|
|
38
|
+
return result;
|
|
39
|
+
};
|
|
40
|
+
return AmortizationService;
|
|
41
|
+
}());
|
|
42
|
+
exports.AmortizationService = AmortizationService;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { MathService } from '../../math/math.service';
|
|
2
|
+
import { BalancesOutput } from '../models/dto/balances-output.dto';
|
|
3
|
+
import { PreviousBalance } from '../../shared/models/previous-balance';
|
|
4
|
+
export declare class BalanceService {
|
|
5
|
+
private readonly math;
|
|
6
|
+
constructor(math: MathService);
|
|
7
|
+
/**
|
|
8
|
+
* Calcula los balances diarios aplicados con IPCA
|
|
9
|
+
* @param dailyIPCAvalues
|
|
10
|
+
* @param dailyInflationaryUpperBound
|
|
11
|
+
* @param previousBalance
|
|
12
|
+
*/
|
|
13
|
+
getBalances(dailyIPCAvalues: number[], dailyInflationaryUpperBound: number[], previousBalance: PreviousBalance): BalancesOutput;
|
|
14
|
+
/**
|
|
15
|
+
* Calcula el balance despues del pago
|
|
16
|
+
* @param balance
|
|
17
|
+
* @param ipcaUpdate
|
|
18
|
+
* @param amortization
|
|
19
|
+
* @param amortizationIPCA
|
|
20
|
+
*/
|
|
21
|
+
getBalanceAfter(previousBalance: PreviousBalance, ipcaUpdate: number, amortization: number, amortizationIPCA: number): number;
|
|
22
|
+
/**
|
|
23
|
+
* Obtiene el balance de la cuota
|
|
24
|
+
* @param balanceValues
|
|
25
|
+
*/
|
|
26
|
+
getBalance(balanceValues: number[]): number;
|
|
27
|
+
}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.BalanceService = void 0;
|
|
4
|
+
var math_service_1 = require("../../math/math.service");
|
|
5
|
+
var guarder_1 = require("../../shared/models/guarder");
|
|
6
|
+
var BalanceService = /** @class */ (function () {
|
|
7
|
+
function BalanceService(math) {
|
|
8
|
+
this.math = math;
|
|
9
|
+
this.math = new math_service_1.MathService(true, 10);
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Calcula los balances diarios aplicados con IPCA
|
|
13
|
+
* @param dailyIPCAvalues
|
|
14
|
+
* @param dailyInflationaryUpperBound
|
|
15
|
+
* @param previousBalance
|
|
16
|
+
*/
|
|
17
|
+
BalanceService.prototype.getBalances = function (dailyIPCAvalues, dailyInflationaryUpperBound, previousBalance) {
|
|
18
|
+
var _this = this;
|
|
19
|
+
if (dailyIPCAvalues === undefined || dailyIPCAvalues.length === 0)
|
|
20
|
+
throw new Error('invalid dailyIPCAvalues on Balances calculation');
|
|
21
|
+
if (dailyInflationaryUpperBound === undefined || dailyInflationaryUpperBound.length === 0)
|
|
22
|
+
throw new Error('invalid dailyInflationaryUpperBound on Balances calculation');
|
|
23
|
+
guarder_1.Guarder.defined(previousBalance, 'PreviousBalance');
|
|
24
|
+
if (previousBalance.value() < 0)
|
|
25
|
+
throw new Error('invalid previousBalance on Balances calculation');
|
|
26
|
+
var balances = [previousBalance.value()];
|
|
27
|
+
var balanceMonetaryUpdateValues = [];
|
|
28
|
+
var balanceUpperBoundMonetaryUpdateValues = [];
|
|
29
|
+
var inflationaryBoundDifferenceValues = [];
|
|
30
|
+
dailyIPCAvalues.forEach(function (dailyIPCA, index) {
|
|
31
|
+
var previusBalanceUsed = balances[balances.length - 1];
|
|
32
|
+
var balanceMonetaryUpdate = _this.math.multiply(dailyIPCA, previusBalanceUsed);
|
|
33
|
+
balanceMonetaryUpdateValues.push(balanceMonetaryUpdate);
|
|
34
|
+
balances.push(_this.math.add(balanceMonetaryUpdate, previusBalanceUsed));
|
|
35
|
+
var balanceUpperBoundMonetaryUpdate = dailyInflationaryUpperBound[index] < dailyIPCA ? _this.math.multiply(previusBalanceUsed, dailyInflationaryUpperBound[index]) : 0;
|
|
36
|
+
balanceUpperBoundMonetaryUpdateValues.push(balanceUpperBoundMonetaryUpdate);
|
|
37
|
+
var inflationaryBoundDifference = balanceUpperBoundMonetaryUpdate ? _this.math.subtract(balanceMonetaryUpdate, balanceUpperBoundMonetaryUpdate) : 0;
|
|
38
|
+
inflationaryBoundDifferenceValues.push(inflationaryBoundDifference);
|
|
39
|
+
});
|
|
40
|
+
balances.splice(0, 1);
|
|
41
|
+
return {
|
|
42
|
+
balances: balances,
|
|
43
|
+
balanceMonetaryUpdateValues: balanceMonetaryUpdateValues,
|
|
44
|
+
balanceUpperBoundMonetaryUpdateValues: balanceUpperBoundMonetaryUpdateValues,
|
|
45
|
+
inflationaryBoundDifferenceValues: inflationaryBoundDifferenceValues
|
|
46
|
+
};
|
|
47
|
+
};
|
|
48
|
+
/**
|
|
49
|
+
* Calcula el balance despues del pago
|
|
50
|
+
* @param balance
|
|
51
|
+
* @param ipcaUpdate
|
|
52
|
+
* @param amortization
|
|
53
|
+
* @param amortizationIPCA
|
|
54
|
+
*/
|
|
55
|
+
BalanceService.prototype.getBalanceAfter = function (previousBalance, ipcaUpdate, amortization, amortizationIPCA) {
|
|
56
|
+
guarder_1.Guarder.defined(previousBalance, 'PreviousBalance');
|
|
57
|
+
if (ipcaUpdate === undefined || ipcaUpdate === null)
|
|
58
|
+
throw new Error('invalid ipcaUpdate on BalanceAfter calculation');
|
|
59
|
+
if (amortization === undefined || amortization === null)
|
|
60
|
+
throw new Error('invalid amortization on BalanceAfter calculation');
|
|
61
|
+
if (amortizationIPCA === undefined || amortizationIPCA === null)
|
|
62
|
+
throw new Error('invalid amortizationIPCA on BalanceAfter calculation');
|
|
63
|
+
var result = this.math.subtract(previousBalance.value(), amortization);
|
|
64
|
+
result = this.math.add(result, ipcaUpdate);
|
|
65
|
+
result = this.math.subtract(result, amortizationIPCA);
|
|
66
|
+
return result;
|
|
67
|
+
};
|
|
68
|
+
/**
|
|
69
|
+
* Obtiene el balance de la cuota
|
|
70
|
+
* @param balanceValues
|
|
71
|
+
*/
|
|
72
|
+
// eslint-disable-next-line class-methods-use-this
|
|
73
|
+
BalanceService.prototype.getBalance = function (balanceValues) {
|
|
74
|
+
if (balanceValues === undefined || balanceValues.length === 0) {
|
|
75
|
+
throw new Error('invalid balanceValues on balance calculation');
|
|
76
|
+
}
|
|
77
|
+
return balanceValues[balanceValues.length - 1];
|
|
78
|
+
};
|
|
79
|
+
return BalanceService;
|
|
80
|
+
}());
|
|
81
|
+
exports.BalanceService = BalanceService;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { AmortizationService } from './amortization-service';
|
|
2
|
+
import { InsuranceService } from './insurance-service';
|
|
3
|
+
import { IPCAService } from './ipca.service';
|
|
4
|
+
import { PaymentService } from './payment-service';
|
|
5
|
+
import { InterestService } from './interest.service';
|
|
6
|
+
import { InstallmentService } from './installment-service';
|
|
7
|
+
export { AmortizationService, InsuranceService, IPCAService, PaymentService, InterestService, InstallmentService };
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.InstallmentService = exports.InterestService = exports.PaymentService = exports.IPCAService = exports.InsuranceService = exports.AmortizationService = void 0;
|
|
4
|
+
var amortization_service_1 = require("./amortization-service");
|
|
5
|
+
Object.defineProperty(exports, "AmortizationService", { enumerable: true, get: function () { return amortization_service_1.AmortizationService; } });
|
|
6
|
+
var insurance_service_1 = require("./insurance-service");
|
|
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; } });
|
|
10
|
+
var payment_service_1 = require("./payment-service");
|
|
11
|
+
Object.defineProperty(exports, "PaymentService", { enumerable: true, get: function () { return payment_service_1.PaymentService; } });
|
|
12
|
+
var interest_service_1 = require("./interest.service");
|
|
13
|
+
Object.defineProperty(exports, "InterestService", { enumerable: true, get: function () { return interest_service_1.InterestService; } });
|
|
14
|
+
var installment_service_1 = require("./installment-service");
|
|
15
|
+
Object.defineProperty(exports, "InstallmentService", { enumerable: true, get: function () { return installment_service_1.InstallmentService; } });
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { MathService } from '../../math';
|
|
2
|
+
import { DebtInputs } from '../models/dto/debt-inputs.dto';
|
|
3
|
+
import { DebtParams } from '../models/dto/debt-params.dto';
|
|
4
|
+
import { DebtResponse } from '../models/dto/debt-response.dto';
|
|
5
|
+
export declare class InstallmentService {
|
|
6
|
+
private readonly math;
|
|
7
|
+
constructor(math: MathService);
|
|
8
|
+
private readonly insuranceService;
|
|
9
|
+
private readonly ipcaService;
|
|
10
|
+
private readonly amortizationService;
|
|
11
|
+
private readonly paymentService;
|
|
12
|
+
private readonly interestService;
|
|
13
|
+
private readonly balanceService;
|
|
14
|
+
/**
|
|
15
|
+
* Calcula el total del pago mensual para una cuota
|
|
16
|
+
* @param inputs
|
|
17
|
+
* @param params
|
|
18
|
+
*/
|
|
19
|
+
getTotalMonthlyPayment(inputs: DebtInputs, params: DebtParams): DebtResponse;
|
|
20
|
+
}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.InstallmentService = void 0;
|
|
4
|
+
var math_1 = require("../../math");
|
|
5
|
+
var insurance_service_1 = require("./insurance-service");
|
|
6
|
+
var ipca_service_1 = require("./ipca.service");
|
|
7
|
+
var amortization_service_1 = require("./amortization-service");
|
|
8
|
+
var payment_service_1 = require("./payment-service");
|
|
9
|
+
var interest_service_1 = require("./interest.service");
|
|
10
|
+
var balance_service_1 = require("./balance-service");
|
|
11
|
+
var InstallmentService = /** @class */ (function () {
|
|
12
|
+
function InstallmentService(math) {
|
|
13
|
+
this.math = math;
|
|
14
|
+
this.insuranceService = new insurance_service_1.InsuranceService(this.math);
|
|
15
|
+
this.ipcaService = new ipca_service_1.IPCAService(this.math);
|
|
16
|
+
this.amortizationService = new amortization_service_1.AmortizationService(this.math);
|
|
17
|
+
this.paymentService = new payment_service_1.PaymentService(this.math);
|
|
18
|
+
this.interestService = new interest_service_1.InterestService(this.math);
|
|
19
|
+
this.balanceService = new balance_service_1.BalanceService(this.math);
|
|
20
|
+
this.math = new math_1.MathService(true, 10);
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Calcula el total del pago mensual para una cuota
|
|
24
|
+
* @param inputs
|
|
25
|
+
* @param params
|
|
26
|
+
*/
|
|
27
|
+
InstallmentService.prototype.getTotalMonthlyPayment = function (inputs, params) {
|
|
28
|
+
var IPCAByDates = this.ipcaService.getIPCAsByDates(inputs.IPCAmap);
|
|
29
|
+
var dates = IPCAByDates.map(function (obj) { return obj.date; });
|
|
30
|
+
var dailyIPCAvalues = IPCAByDates.map(function (obj) { return obj.dailyIPCA; });
|
|
31
|
+
var dailyInflationaryUpperBound = this.ipcaService.getDailyInflationaryUpperBound(dates, inputs.inflationaryUpperBound);
|
|
32
|
+
var balanceValues = this.balanceService.getBalances(dailyIPCAvalues, dailyInflationaryUpperBound, inputs.previousBalance);
|
|
33
|
+
var dailyRate = this.interestService.getDailyInterestValue(params.annualRate);
|
|
34
|
+
var balance = this.balanceService.getBalance(balanceValues.balances);
|
|
35
|
+
var interest = this.interestService.getInterest(balanceValues.balances, dailyRate);
|
|
36
|
+
var amortization = this.amortizationService.getAmortization(inputs.paymentNumber, inputs.numberOfMonths, balance);
|
|
37
|
+
var balanceWithInflationaryDebt = this.math.add(inputs.previousBalance.value(), balanceValues.inflationaryBoundDifferenceValues.reduce(function (sum2, x2) { return sum2 + x2; }, 0));
|
|
38
|
+
var amortizationDiff = this.math.subtract(amortization, this.amortizationService.getAmortization(inputs.paymentNumber, inputs.numberOfMonths, balanceWithInflationaryDebt));
|
|
39
|
+
var amortizationIPCA = this.amortizationService.getAmortizationIPCA(balanceValues.balanceMonetaryUpdateValues, balanceValues.inflationaryBoundDifferenceValues);
|
|
40
|
+
amortizationIPCA = this.math.subtract(amortizationIPCA, amortizationDiff);
|
|
41
|
+
var monthlyPayment = this.paymentService.getMonthlyPayment(interest, amortization, amortizationIPCA);
|
|
42
|
+
var ipcaUpdate = this.ipcaService.getIPCAUpdate(balanceValues.balanceMonetaryUpdateValues);
|
|
43
|
+
var balanceAfter = this.balanceService.getBalanceAfter(inputs.previousBalance, ipcaUpdate, amortization, amortizationIPCA);
|
|
44
|
+
var lifeInsuranceFee = this.insuranceService.getLifeInsurance(params.lifeInsuranceRates, balance);
|
|
45
|
+
var propertyInsuranceFee = this.insuranceService.getPropertyInsurance(inputs.propertyAmount, params.propertyInsuranceRate, inputs.IPCAmap);
|
|
46
|
+
var totalMonthlyPayment = this.math.add(monthlyPayment, lifeInsuranceFee, propertyInsuranceFee);
|
|
47
|
+
return {
|
|
48
|
+
totalMonthlyPayment: totalMonthlyPayment,
|
|
49
|
+
IPCAByDates: IPCAByDates,
|
|
50
|
+
balanceValues: balanceValues,
|
|
51
|
+
balance: balance,
|
|
52
|
+
balanceAfter: balanceAfter,
|
|
53
|
+
ipcaUpdate: ipcaUpdate,
|
|
54
|
+
dailyRate: dailyRate,
|
|
55
|
+
interest: interest,
|
|
56
|
+
monthlyPayment: monthlyPayment,
|
|
57
|
+
amortization: amortization,
|
|
58
|
+
amortizationIPCA: amortizationIPCA,
|
|
59
|
+
lifeInsuranceFee: lifeInsuranceFee,
|
|
60
|
+
propertyInsuranceFee: propertyInsuranceFee
|
|
61
|
+
};
|
|
62
|
+
};
|
|
63
|
+
return InstallmentService;
|
|
64
|
+
}());
|
|
65
|
+
exports.InstallmentService = InstallmentService;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { MathService } from '../../math';
|
|
2
|
+
import { CreditInsuranceRate } from '../../shared/models/credit-insurance-rate';
|
|
3
|
+
export declare class InsuranceService {
|
|
4
|
+
private readonly math;
|
|
5
|
+
constructor(math: MathService);
|
|
6
|
+
/**
|
|
7
|
+
* Calcula el seguro de propiedad
|
|
8
|
+
* @param propertyAmount
|
|
9
|
+
* @param propertyInsuranceRate
|
|
10
|
+
*/
|
|
11
|
+
getPropertyInsurance(propertyAmount: number, propertyInsuranceRate: CreditInsuranceRate, IPCAmap: Record<string, number>): number;
|
|
12
|
+
/**
|
|
13
|
+
* Calcula el seguro de vida
|
|
14
|
+
* @param lifeInsuranceRateValues // Array con una sola posición ya que la tasa es fija en la operacion de un cliente
|
|
15
|
+
* @param balance // Balance actualizado por corrección monetaria
|
|
16
|
+
*/
|
|
17
|
+
getLifeInsurance(lifeInsuranceRateValues: CreditInsuranceRate[], balance: number): number;
|
|
18
|
+
}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.InsuranceService = void 0;
|
|
4
|
+
var math_1 = require("../../math");
|
|
5
|
+
var guarder_1 = require("../../shared/models/guarder");
|
|
6
|
+
var InsuranceService = /** @class */ (function () {
|
|
7
|
+
function InsuranceService(math) {
|
|
8
|
+
this.math = math;
|
|
9
|
+
this.math = new math_1.MathService(true, 10);
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Calcula el seguro de propiedad
|
|
13
|
+
* @param propertyAmount
|
|
14
|
+
* @param propertyInsuranceRate
|
|
15
|
+
*/
|
|
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);
|
|
33
|
+
};
|
|
34
|
+
/**
|
|
35
|
+
* Calcula el seguro de vida
|
|
36
|
+
* @param lifeInsuranceRateValues // Array con una sola posición ya que la tasa es fija en la operacion de un cliente
|
|
37
|
+
* @param balance // Balance actualizado por corrección monetaria
|
|
38
|
+
*/
|
|
39
|
+
InsuranceService.prototype.getLifeInsurance = function (lifeInsuranceRateValues, balance) {
|
|
40
|
+
var _this = this;
|
|
41
|
+
guarder_1.Guarder.defined(lifeInsuranceRateValues, 'CreditInsuranceRate');
|
|
42
|
+
if (lifeInsuranceRateValues.filter(function (lifeInsuranceRate) { return lifeInsuranceRate.value() === 0; }).length > 0)
|
|
43
|
+
throw new Error('Invalid life insurance rate');
|
|
44
|
+
var lifeInsurance = lifeInsuranceRateValues
|
|
45
|
+
.reduce(function (acc, lifeInsuranceRate) { return _this.math.multiply(balance, _this.math.divide(lifeInsuranceRate.value(), 100)); }, 0);
|
|
46
|
+
// const lifeInsurance = this.math.multiply(this.math.subtract(balance, inflationaryBoundDifference), this.math.divide(lifeInsuranceRate.value(), 100));
|
|
47
|
+
var result = this.math.round(lifeInsurance, 2);
|
|
48
|
+
return result;
|
|
49
|
+
};
|
|
50
|
+
return InsuranceService;
|
|
51
|
+
}());
|
|
52
|
+
exports.InsuranceService = InsuranceService;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { MathService } from '../../math';
|
|
2
2
|
export declare class InterestService {
|
|
3
3
|
private readonly math;
|
|
4
|
-
constructor(math
|
|
4
|
+
constructor(math: MathService);
|
|
5
5
|
/**
|
|
6
6
|
* Método que calcula el interés de la cuota para un período de tiempo determinado
|
|
7
7
|
* Más info en {@link https://docs.google.com/spreadsheets/d/1m43MNX-8b5GKZjyfZyxBqpu88pYI9CWICGwrFswajhQ/edit#gid=493241946}
|
|
@@ -12,7 +12,6 @@ export declare class InterestService {
|
|
|
12
12
|
* @param numberDays Cantidad de días sobre la cual se desea calcular el interés
|
|
13
13
|
* @returns
|
|
14
14
|
*/
|
|
15
|
-
getInterestValue(newBalanceBefore: number, ipcaUpdate: number, negativeAmortization: number, dailyRate: number, numberDays: number): number;
|
|
16
15
|
/**
|
|
17
16
|
* Método que calcula el interés diario a partir del interés anual.
|
|
18
17
|
* @param annyalRate Tasa de interés anual.
|
|
@@ -24,7 +23,6 @@ export declare class InterestService {
|
|
|
24
23
|
* @param annyalRate Tasa de interés anual.
|
|
25
24
|
* @returns
|
|
26
25
|
*/
|
|
27
|
-
getMonthlyInterestValue(annyalRate: number): number;
|
|
28
26
|
/**
|
|
29
27
|
* Método que calcula el interés de un periodo de tiempo a partir del interés anual.
|
|
30
28
|
* @param annyalRate Tasa de interés anual.
|
|
@@ -32,4 +30,11 @@ export declare class InterestService {
|
|
|
32
30
|
* @returns
|
|
33
31
|
*/
|
|
34
32
|
private getPeriodInterestValue;
|
|
33
|
+
/**
|
|
34
|
+
* Calcula el interes a partir del interes diario
|
|
35
|
+
* @param balanceValues
|
|
36
|
+
* @param inflationaryBoundDifference
|
|
37
|
+
* @param dailyRate
|
|
38
|
+
*/
|
|
39
|
+
getInterest(balanceValues: number[], dailyRate: number): number;
|
|
35
40
|
}
|