creditu-common-library 2.3.14 → 2.3.15
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/README.md
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
# Creditú CommonLibrary
|
|
2
2
|
|
|
3
3
|
## Descripción
|
|
4
|
-
Esta librería
|
|
4
|
+
Esta librería contiene los módulos y funciones matemáticas y financieras para el manejo de cálculos en el producto digital.
|
|
5
5
|
|
|
6
6
|
## Instalar en tu repositorio
|
|
7
7
|
|
|
@@ -21,7 +21,7 @@ La librería tiene dos módulos:
|
|
|
21
21
|
|
|
22
22
|
- `Finance`: expone varios servicios orientados a un dominio específico, y cuyas funciones resuelven diversas fórmulas financieras en su ámbito.
|
|
23
23
|
Los services expuestos son:
|
|
24
|
-
- `ConstantsService`: es un servicio auxiliar, que contiene funciones que calculan constantes que, a su vez, agrupan
|
|
24
|
+
- `ConstantsService`: es un servicio auxiliar, que contiene funciones que calculan constantes que, a su vez, agrupan parámetros conocidos para diversos propósitos en cálculos financieros.
|
|
25
25
|
- `CreditInsuranceService`: este servicio tiene funciones de cálculo para el dominio `Seguros`.
|
|
26
26
|
- `FinanceService`: este servicio auxiliar tiene funciones genéricas de funciones financieras, como interés anual, mensual, etc.
|
|
27
27
|
- `PaymentService`: este servicio tiene funciones de cálculo para el dominio `Dividendo`.
|
|
@@ -366,12 +366,16 @@ var OfferService = /** @class */ (function () {
|
|
|
366
366
|
*/
|
|
367
367
|
// eslint-disable-next-line class-methods-use-this
|
|
368
368
|
OfferService.prototype.getCreditAmountToOffer = function (approvedAmount, credituAmount, creditMinAmount, creditMaxAmount) {
|
|
369
|
+
if (creditMinAmount.value() > creditMaxAmount.value()) {
|
|
370
|
+
throw new Error('Credit minimum amount cannot be greater than maximum amount');
|
|
371
|
+
}
|
|
369
372
|
models_1.Guarder.defined(creditMinAmount, 'CreditMinAmount');
|
|
373
|
+
models_1.Guarder.defined(creditMaxAmount, 'CreditMaxAmount');
|
|
370
374
|
var minApprovedAmount = Math.min(approvedAmount, credituAmount);
|
|
371
375
|
if (minApprovedAmount > creditMaxAmount.value())
|
|
372
376
|
return creditMaxAmount.value();
|
|
373
377
|
if (minApprovedAmount < creditMinAmount.value())
|
|
374
|
-
return
|
|
378
|
+
return 0;
|
|
375
379
|
return minApprovedAmount;
|
|
376
380
|
};
|
|
377
381
|
/**
|
package/package.json
CHANGED
|
@@ -226,7 +226,7 @@ describe('offerService CL', () => {
|
|
|
226
226
|
const math = new MathService(true, 20);
|
|
227
227
|
const offerService = new OfferService(math);
|
|
228
228
|
const result = offerService.calculateCreditAmountToOffer(inputs, params);
|
|
229
|
-
expect(result).toMatchObject(expectedResult);
|
|
229
|
+
expect(result).toMatchObject({ ...expectedResult, approvedAmount: 0 });
|
|
230
230
|
});
|
|
231
231
|
|
|
232
232
|
it('CHILE, SUBSIDY, SUBSIDY_1_2 A', () => {
|
|
@@ -7,28 +7,27 @@ describe('offer service functional tests common', () => {
|
|
|
7
7
|
const math = new MathService(true, 20);
|
|
8
8
|
const offerService = new OfferService(math);
|
|
9
9
|
describe('getCreditAmountToOffer', () => {
|
|
10
|
-
it('getCreditAmountToOffer should return 0 when minApprovedAmount < creditMinAmount', () => {
|
|
10
|
+
it('getCreditAmountToOffer should return 0 when minApprovedAmount < creditMinAmount', async () => {
|
|
11
11
|
// ARRANGE
|
|
12
12
|
const creditMinAmount = new CreditAmount(10);
|
|
13
13
|
const creditMaxAmount = new CreditAmount(0);
|
|
14
14
|
// ACT
|
|
15
|
-
|
|
15
|
+
expect(() => offerService.getCreditAmountToOffer(
|
|
16
16
|
0,
|
|
17
17
|
9,
|
|
18
18
|
creditMinAmount,
|
|
19
19
|
creditMaxAmount
|
|
20
|
-
)
|
|
20
|
+
))
|
|
21
|
+
.toThrow('Credit minimum amount cannot be greater than maximum amount');
|
|
21
22
|
// ASSERT
|
|
22
|
-
expect(result).toBe(0);
|
|
23
23
|
});
|
|
24
|
-
it('
|
|
25
|
-
|
|
26
|
-
const
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
expect(result).toBe(10);
|
|
24
|
+
it('should throw error when creditMinAmount > creditMaxAmount', () => {
|
|
25
|
+
const creditMinAmount = new CreditAmount(10);
|
|
26
|
+
const creditMaxAmount = new CreditAmount(0);
|
|
27
|
+
|
|
28
|
+
expect(() => {
|
|
29
|
+
offerService.getCreditAmountToOffer(0, 9, creditMinAmount, creditMaxAmount);
|
|
30
|
+
}).toThrow('Credit minimum amount cannot be greater than maximum amount');
|
|
32
31
|
});
|
|
33
32
|
it('getCreditAmountToOffer should return approvedAmount when ir more than credituAmount and is in range', () => {
|
|
34
33
|
// ARRANGE
|