creditu-common-library 1.3.3 → 1.4.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.
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { NestMiddleware, Logger } from '@nestjs/common';
|
|
2
|
+
import { Request, Response, NextFunction } from 'express';
|
|
3
|
+
export declare class AppLoggerMiddleware implements NestMiddleware {
|
|
4
|
+
private logger;
|
|
5
|
+
constructor(logger?: Logger);
|
|
6
|
+
private logObject;
|
|
7
|
+
use(request: Request, response: Response, next: NextFunction): void;
|
|
8
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.AppLoggerMiddleware = void 0;
|
|
10
|
+
var common_1 = require("@nestjs/common");
|
|
11
|
+
var util_1 = require("util");
|
|
12
|
+
var AppLoggerMiddleware = /** @class */ (function () {
|
|
13
|
+
function AppLoggerMiddleware(logger) {
|
|
14
|
+
if (logger === void 0) { logger = new common_1.Logger('HTTP'); }
|
|
15
|
+
this.logger = logger;
|
|
16
|
+
this.logObject = function (obj) { return (0, util_1.inspect)(obj, { showHidden: false, depth: null, colors: true }); };
|
|
17
|
+
}
|
|
18
|
+
AppLoggerMiddleware.prototype.use = function (request, response, next) {
|
|
19
|
+
var _this = this;
|
|
20
|
+
response.on('finish', function () {
|
|
21
|
+
var method = request.method, originalUrl = request.originalUrl, body = request.body;
|
|
22
|
+
var statusCode = response.statusCode, statusMessage = response.statusMessage;
|
|
23
|
+
var message = "".concat(method, " ").concat(originalUrl, " ").concat(statusCode, " ").concat(statusMessage, "\nRequest body: ").concat(_this.logObject(body));
|
|
24
|
+
if (statusCode >= 500) {
|
|
25
|
+
return _this.logger.error(message);
|
|
26
|
+
}
|
|
27
|
+
if (statusCode >= 400) {
|
|
28
|
+
return _this.logger.warn(message);
|
|
29
|
+
}
|
|
30
|
+
return _this.logger.log(message);
|
|
31
|
+
});
|
|
32
|
+
next();
|
|
33
|
+
};
|
|
34
|
+
AppLoggerMiddleware = __decorate([
|
|
35
|
+
(0, common_1.Injectable)()
|
|
36
|
+
], AppLoggerMiddleware);
|
|
37
|
+
return AppLoggerMiddleware;
|
|
38
|
+
}());
|
|
39
|
+
exports.AppLoggerMiddleware = AppLoggerMiddleware;
|
|
@@ -150,7 +150,7 @@ var OfferService = /** @class */ (function () {
|
|
|
150
150
|
var debtGuaranteeViv = this.maximumLocal.debtGuaranteeViv(propertyValue, maximumPropertyLTV, k1Fin, k2Fin);
|
|
151
151
|
var approvedAmountLoanToValue = this.maximumLocal.debtGuarantee(debtGuaranteeViv, debtGuaranteeCr);
|
|
152
152
|
var approvedAmount = this.getApprovedAmount(approvedAmountFinanceCharge, maximumLocalIncomeDividend, approvedAmountLoanToValue);
|
|
153
|
-
var credituAmount = this.credituAmount(downPayment, subsidy, propertyValue, creditInsuranceFactor, creditInsuranceFinancing, operationalExpensesWeightedSum, operationalExpensesFinancing, creditTaxRate, creditTaxRatePercentage, amountRequestedByClient);
|
|
153
|
+
var credituAmount = this.math.round(this.credituAmount(downPayment, subsidy, propertyValue, creditInsuranceFactor, creditInsuranceFinancing, operationalExpensesWeightedSum, operationalExpensesFinancing, creditTaxRate, creditTaxRatePercentage, amountRequestedByClient), 0);
|
|
154
154
|
var creditAmount = this.getCreditAmountToOffer(approvedAmount, credituAmount, creditMinAmount, creditMaxAmount);
|
|
155
155
|
var financingAmount = this.financingAmount(creditAmount, k1Fin, k2Fin);
|
|
156
156
|
var installment = this.installment.getMonthlyPayment(baseMonthlyPayment, creditAmount);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "creditu-common-library",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.4.0",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"files": [
|
|
@@ -40,9 +40,13 @@
|
|
|
40
40
|
"typescript": "^4.2.3"
|
|
41
41
|
},
|
|
42
42
|
"dependencies": {
|
|
43
|
+
"@nestjs/common": "^9.0.11",
|
|
44
|
+
"creditu-date-model": "^2.6.0",
|
|
43
45
|
"dayjs": "^1.10.4",
|
|
44
46
|
"dinero.js": "^1.9.0",
|
|
45
|
-
"
|
|
47
|
+
"express": "^4.18.1",
|
|
48
|
+
"reflect-metadata": "^0.1.13",
|
|
49
|
+
"rxjs": "^7.5.6"
|
|
46
50
|
},
|
|
47
51
|
"jest": {
|
|
48
52
|
"rootDir": "src",
|
|
@@ -473,7 +473,7 @@ describe('offerService', () => {
|
|
|
473
473
|
propertyInsuranceFee: 19.5,
|
|
474
474
|
unemploymentInsuranceFee: 0,
|
|
475
475
|
creditAmount: 558848.1417156955,
|
|
476
|
-
credituAmount:
|
|
476
|
+
credituAmount: 585000,
|
|
477
477
|
approvedAmount: 558848.1417156955,
|
|
478
478
|
approvedAmountFinanceCharge: 718918.0631221518,
|
|
479
479
|
creditInsurancePremium: 42776.0179277166,
|
|
@@ -582,25 +582,25 @@ describe('offerService', () => {
|
|
|
582
582
|
creditInsuranceFee: 0,
|
|
583
583
|
gf: 0,
|
|
584
584
|
gp: 32499.999999999996,
|
|
585
|
-
lifeInsuranceFee: 88.
|
|
585
|
+
lifeInsuranceFee: 88.39983,
|
|
586
586
|
propertyInsuranceFee: 19.5,
|
|
587
587
|
unemploymentInsuranceFee: 0,
|
|
588
|
-
creditAmount: 519999
|
|
589
|
-
credituAmount: 519999
|
|
588
|
+
creditAmount: 519999,
|
|
589
|
+
credituAmount: 519999,
|
|
590
590
|
approvedAmount: 519999.99999999994,
|
|
591
591
|
approvedAmountFinanceCharge: 880329.7165416365,
|
|
592
|
-
creditInsurancePremium: 38518.
|
|
593
|
-
installment: 5840.
|
|
592
|
+
creditInsurancePremium: 38518.4444433659,
|
|
593
|
+
installment: 5840.9126354541,
|
|
594
594
|
unitInstallment: 0.0112325459,
|
|
595
595
|
approvedAmountIncomeDividend: 684320.8585549303,
|
|
596
|
-
backEndRatio: 0.
|
|
596
|
+
backEndRatio: 0.2661661058,
|
|
597
597
|
approvedAmountLoanToValue: 519999.99999999994,
|
|
598
|
-
financingAmount: 481480.
|
|
599
|
-
frontEndRatio: 0.
|
|
600
|
-
loanToValueCredit: 0.
|
|
601
|
-
loanToValueHome: 0.
|
|
602
|
-
totalFee: 5948.
|
|
603
|
-
creditFee: 5948.
|
|
598
|
+
financingAmount: 481480.5555420741,
|
|
599
|
+
frontEndRatio: 0.2661661058,
|
|
600
|
+
loanToValueCredit: 0.7999984615,
|
|
601
|
+
loanToValueHome: 0.7407393162000001,
|
|
602
|
+
totalFee: 5948.812465454101,
|
|
603
|
+
creditFee: 5948.812465454101,
|
|
604
604
|
propertyValue: 650000,
|
|
605
605
|
monthlyInterestRate: 0.0110148959202348,
|
|
606
606
|
amountRequestedByClient: 481481,
|
|
@@ -608,7 +608,7 @@ describe('offerService', () => {
|
|
|
608
608
|
percentageOperationalExpensesFinanced: 0,
|
|
609
609
|
operationalExpenses: 34435.539999999986,
|
|
610
610
|
creditInsuranceFactor: 0.08,
|
|
611
|
-
financingRatio:
|
|
611
|
+
financingRatio: 0.9999990769000001
|
|
612
612
|
};
|
|
613
613
|
|
|
614
614
|
const params: OfferParams = {
|
|
@@ -695,25 +695,25 @@ describe('offerService', () => {
|
|
|
695
695
|
creditInsuranceFee: 0,
|
|
696
696
|
gf: 0,
|
|
697
697
|
gp: 22500,
|
|
698
|
-
lifeInsuranceFee: 61.
|
|
698
|
+
lifeInsuranceFee: 61.2,
|
|
699
699
|
propertyInsuranceFee: 13.5,
|
|
700
700
|
unemploymentInsuranceFee: 0,
|
|
701
|
-
creditAmount:
|
|
702
|
-
credituAmount:
|
|
701
|
+
creditAmount: 360000,
|
|
702
|
+
credituAmount: 360000,
|
|
703
703
|
approvedAmount: 360000,
|
|
704
704
|
approvedAmountFinanceCharge: 717899.3819035813,
|
|
705
|
-
creditInsurancePremium: 26666.
|
|
706
|
-
installment: 4670.
|
|
705
|
+
creditInsurancePremium: 26666.666665920002,
|
|
706
|
+
installment: 4670.8558920000005,
|
|
707
707
|
unitInstallment: 0.0129745997,
|
|
708
708
|
approvedAmountIncomeDividend: 615195.607668448,
|
|
709
|
-
backEndRatio: 0.
|
|
709
|
+
backEndRatio: 0.1757613293,
|
|
710
710
|
approvedAmountLoanToValue: 360000,
|
|
711
|
-
financingAmount:
|
|
712
|
-
frontEndRatio: 0.
|
|
713
|
-
loanToValueCredit: 0.
|
|
714
|
-
loanToValueHome: 0.
|
|
715
|
-
totalFee: 4745.
|
|
716
|
-
creditFee: 4745.
|
|
711
|
+
financingAmount: 333333.333324,
|
|
712
|
+
frontEndRatio: 0.1757613293,
|
|
713
|
+
loanToValueCredit: 0.8,
|
|
714
|
+
loanToValueHome: 0.7407407407,
|
|
715
|
+
totalFee: 4745.555892,
|
|
716
|
+
creditFee: 4745.555892,
|
|
717
717
|
propertyValue: 450000,
|
|
718
718
|
monthlyInterestRate: 0.0128434215415128,
|
|
719
719
|
amountRequestedByClient: 333333,
|
|
@@ -721,7 +721,7 @@ describe('offerService', () => {
|
|
|
721
721
|
percentageOperationalExpensesFinanced: 0,
|
|
722
722
|
operationalExpenses: 24435.54,
|
|
723
723
|
creditInsuranceFactor: 0.08,
|
|
724
|
-
financingRatio: 1
|
|
724
|
+
financingRatio: 1.000001
|
|
725
725
|
};
|
|
726
726
|
|
|
727
727
|
const params: OfferParams = {
|
|
@@ -925,7 +925,7 @@ describe('offerService', () => {
|
|
|
925
925
|
propertyInsuranceFee: 0,
|
|
926
926
|
unemploymentInsuranceFee: 0,
|
|
927
927
|
creditAmount: 421822.0545259302,
|
|
928
|
-
credituAmount:
|
|
928
|
+
credituAmount: 520000,
|
|
929
929
|
approvedAmount: 421822.0545259302,
|
|
930
930
|
approvedAmountFinanceCharge: 421822.0545259302,
|
|
931
931
|
creditInsurancePremium: 0,
|
|
@@ -1034,33 +1034,33 @@ describe('offerService', () => {
|
|
|
1034
1034
|
creditInsuranceFee: 0,
|
|
1035
1035
|
gf: 19.8,
|
|
1036
1036
|
gp: 11,
|
|
1037
|
-
lifeInsuranceFee: 0.
|
|
1037
|
+
lifeInsuranceFee: 0.69147,
|
|
1038
1038
|
propertyInsuranceFee: 0.4004,
|
|
1039
1039
|
unemploymentInsuranceFee: 0,
|
|
1040
|
-
creditAmount: 1773
|
|
1041
|
-
credituAmount: 1773
|
|
1040
|
+
creditAmount: 1773,
|
|
1041
|
+
credituAmount: 1773,
|
|
1042
1042
|
approvedAmount: 1980,
|
|
1043
1043
|
approvedAmountFinanceCharge: 4207.7629943957,
|
|
1044
|
-
creditInsurancePremium: 116.
|
|
1045
|
-
installment: 9.
|
|
1044
|
+
creditInsurancePremium: 116.8363636381,
|
|
1045
|
+
installment: 9.2541410541,
|
|
1046
1046
|
unitInstallment: 0.0052194817,
|
|
1047
1047
|
approvedAmountIncomeDividend: 3734.7943267201,
|
|
1048
|
-
backEndRatio: 0.
|
|
1048
|
+
backEndRatio: 0.326109246,
|
|
1049
1049
|
approvedAmountLoanToValue: 1980,
|
|
1050
|
-
financingAmount: 1636.
|
|
1051
|
-
frontEndRatio: 0.
|
|
1052
|
-
loanToValueCredit: 0.
|
|
1053
|
-
loanToValueHome: 0.
|
|
1054
|
-
totalFee: 19.
|
|
1055
|
-
creditFee: 10.
|
|
1050
|
+
financingAmount: 1636.3636363886,
|
|
1051
|
+
frontEndRatio: 0.1696014922,
|
|
1052
|
+
loanToValueCredit: 0.8059090909,
|
|
1053
|
+
loanToValueHome: 0.7438016529000001,
|
|
1054
|
+
totalFee: 19.8932793561,
|
|
1055
|
+
creditFee: 10.3460110541,
|
|
1056
1056
|
propertyValue: 2200,
|
|
1057
1057
|
monthlyInterestRate: 0.003962491754522,
|
|
1058
1058
|
amountRequestedByClient: 1636.5700000000002,
|
|
1059
1059
|
operationalExpensesFee: 0,
|
|
1060
1060
|
percentageOperationalExpensesFinanced: 19.8,
|
|
1061
|
-
operationalExpenses: 26.
|
|
1061
|
+
operationalExpenses: 26.348,
|
|
1062
1062
|
creditInsuranceFactor: 0.0714,
|
|
1063
|
-
financingRatio:
|
|
1063
|
+
financingRatio: 0.9998739047999999
|
|
1064
1064
|
};
|
|
1065
1065
|
const params: OfferParams = {
|
|
1066
1066
|
maximumBackendRatio: 0.55, // Máximo de CF (L alpha)
|
|
@@ -1150,7 +1150,7 @@ describe('offerService', () => {
|
|
|
1150
1150
|
propertyInsuranceFee: 0.3458,
|
|
1151
1151
|
unemploymentInsuranceFee: 0,
|
|
1152
1152
|
creditAmount: 0,
|
|
1153
|
-
credituAmount:
|
|
1153
|
+
credituAmount: 1527,
|
|
1154
1154
|
approvedAmount: -1083.2554644041,
|
|
1155
1155
|
approvedAmountFinanceCharge: -1083.2554644041,
|
|
1156
1156
|
creditInsurancePremium: 0,
|
|
@@ -1259,33 +1259,33 @@ describe('offerService', () => {
|
|
|
1259
1259
|
creditInsuranceFee: 0,
|
|
1260
1260
|
gf: 20.8,
|
|
1261
1261
|
gp: 12,
|
|
1262
|
-
lifeInsuranceFee: 0.
|
|
1262
|
+
lifeInsuranceFee: 0.391365,
|
|
1263
1263
|
propertyInsuranceFee: 0.4368,
|
|
1264
1264
|
unemploymentInsuranceFee: 0,
|
|
1265
|
-
creditAmount:
|
|
1266
|
-
credituAmount:
|
|
1265
|
+
creditAmount: 2007,
|
|
1266
|
+
credituAmount: 2007,
|
|
1267
1267
|
approvedAmount: 2070.5411139114003,
|
|
1268
1268
|
approvedAmountFinanceCharge: 3302.1569962424,
|
|
1269
|
-
creditInsurancePremium: 133.
|
|
1270
|
-
installment: 9.
|
|
1269
|
+
creditInsurancePremium: 133.7500466699,
|
|
1270
|
+
installment: 9.9482024682,
|
|
1271
1271
|
unitInstallment: 0.0049567526,
|
|
1272
1272
|
approvedAmountIncomeDividend: 2070.5411139114003,
|
|
1273
|
-
backEndRatio: 0.
|
|
1273
|
+
backEndRatio: 0.339681667,
|
|
1274
1274
|
approvedAmountLoanToValue: 2160,
|
|
1275
|
-
financingAmount: 1873.
|
|
1276
|
-
frontEndRatio: 0.
|
|
1277
|
-
loanToValueCredit: 0.
|
|
1278
|
-
loanToValueHome: 0.
|
|
1279
|
-
totalFee: 10.
|
|
1280
|
-
creditFee: 10.
|
|
1275
|
+
financingAmount: 1873.2499533603,
|
|
1276
|
+
frontEndRatio: 0.339681667,
|
|
1277
|
+
loanToValueCredit: 0.83625,
|
|
1278
|
+
loanToValueHome: 0.7805208138999999,
|
|
1279
|
+
totalFee: 10.7763674682,
|
|
1280
|
+
creditFee: 10.7763674682,
|
|
1281
1281
|
propertyValue: 2400,
|
|
1282
1282
|
monthlyInterestRate: 0.0035947364096048,
|
|
1283
1283
|
amountRequestedByClient: 1873,
|
|
1284
1284
|
operationalExpensesFee: 0,
|
|
1285
1285
|
percentageOperationalExpensesFinanced: 20.8,
|
|
1286
|
-
operationalExpenses: 27.
|
|
1286
|
+
operationalExpenses: 27.815999999999995,
|
|
1287
1287
|
creditInsuranceFactor: 0.0714,
|
|
1288
|
-
financingRatio: 1
|
|
1288
|
+
financingRatio: 1.0001334508
|
|
1289
1289
|
};
|
|
1290
1290
|
const params: OfferParams = {
|
|
1291
1291
|
maximumBackendRatio: 0.55, // Máximo de CF (L alpha)
|
|
@@ -1371,33 +1371,33 @@ describe('offerService', () => {
|
|
|
1371
1371
|
creditInsuranceFee: 0,
|
|
1372
1372
|
gf: 19.8,
|
|
1373
1373
|
gp: 11,
|
|
1374
|
-
lifeInsuranceFee: 0.
|
|
1374
|
+
lifeInsuranceFee: 0.77103,
|
|
1375
1375
|
propertyInsuranceFee: 0.4004,
|
|
1376
1376
|
unemploymentInsuranceFee: 0,
|
|
1377
|
-
creditAmount:
|
|
1378
|
-
credituAmount:
|
|
1377
|
+
creditAmount: 1977,
|
|
1378
|
+
credituAmount: 1977,
|
|
1379
1379
|
approvedAmount: 1980,
|
|
1380
1380
|
approvedAmountFinanceCharge: 2733.0574039923,
|
|
1381
|
-
creditInsurancePremium: 131.
|
|
1382
|
-
installment: 10.
|
|
1381
|
+
creditInsurancePremium: 131.7507933565,
|
|
1382
|
+
installment: 10.1452081929,
|
|
1383
1383
|
unitInstallment: 0.0051316177,
|
|
1384
1384
|
approvedAmountIncomeDividend: 2003.5069485162,
|
|
1385
|
-
backEndRatio: 0.
|
|
1385
|
+
backEndRatio: 0.42253502109999996,
|
|
1386
1386
|
approvedAmountLoanToValue: 1980,
|
|
1387
|
-
financingAmount: 1845.
|
|
1388
|
-
frontEndRatio: 0.
|
|
1389
|
-
loanToValueCredit: 0.
|
|
1390
|
-
loanToValueHome: 0.
|
|
1391
|
-
totalFee: 13.
|
|
1392
|
-
creditFee: 11.
|
|
1387
|
+
financingAmount: 1845.2492066732998,
|
|
1388
|
+
frontEndRatio: 0.3455311493,
|
|
1389
|
+
loanToValueCredit: 0.8986363636,
|
|
1390
|
+
loanToValueHome: 0.8387496394,
|
|
1391
|
+
totalFee: 13.838624872899999,
|
|
1392
|
+
creditFee: 11.3166381929,
|
|
1393
1393
|
propertyValue: 2200,
|
|
1394
1394
|
monthlyInterestRate: 0.0035947364096048,
|
|
1395
1395
|
amountRequestedByClient: 1845,
|
|
1396
1396
|
operationalExpensesFee: 0,
|
|
1397
1397
|
percentageOperationalExpensesFinanced: 19.8,
|
|
1398
|
-
operationalExpenses: 26.
|
|
1398
|
+
operationalExpenses: 26.756,
|
|
1399
1399
|
creditInsuranceFactor: 0.0714,
|
|
1400
|
-
financingRatio: 1
|
|
1400
|
+
financingRatio: 1.0001350714000001
|
|
1401
1401
|
};
|
|
1402
1402
|
const params: OfferParams = {
|
|
1403
1403
|
maximumBackendRatio: 0.55, // Máximo de CF (L alpha)
|
|
@@ -1487,7 +1487,7 @@ describe('offerService', () => {
|
|
|
1487
1487
|
propertyInsuranceFee: 0.4004,
|
|
1488
1488
|
unemploymentInsuranceFee: 0,
|
|
1489
1489
|
creditAmount: 1767.8099999734,
|
|
1490
|
-
credituAmount:
|
|
1490
|
+
credituAmount: 1977,
|
|
1491
1491
|
approvedAmount: 1767.8099999734,
|
|
1492
1492
|
approvedAmountFinanceCharge: 2611.0147948526,
|
|
1493
1493
|
creditInsurancePremium: 117.81,
|
|
@@ -1599,7 +1599,7 @@ describe('offerService', () => {
|
|
|
1599
1599
|
propertyInsuranceFee: 0.364,
|
|
1600
1600
|
unemploymentInsuranceFee: 0,
|
|
1601
1601
|
creditAmount: 1607.0999999758,
|
|
1602
|
-
credituAmount: 1762
|
|
1602
|
+
credituAmount: 1762,
|
|
1603
1603
|
approvedAmount: 1607.0999999758,
|
|
1604
1604
|
approvedAmountFinanceCharge: 1608.3313023417,
|
|
1605
1605
|
creditInsurancePremium: 107.10000000000001,
|