@credithub/harlan-components 1.20.0 → 1.20.2
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/lib/cjs/index.js +51 -13
- package/lib/esm/components/chart/chartSystem.js +12 -2
- package/lib/esm/components/chart/types/iChart.d.ts +1 -0
- package/lib/esm/components/chart/utils/dataProcessing.js +36 -11
- package/lib/esm/components/consultaSimplesSection/consultaSimplesSection.js +1 -1
- package/lib/esm/utils/string.d.ts +1 -0
- package/lib/esm/utils/string.js +4 -0
- package/package.json +1 -1
package/lib/cjs/index.js
CHANGED
|
@@ -13683,6 +13683,10 @@ var isDocumentoPF = function (documento) {
|
|
|
13683
13683
|
var cleanDocument = documento.replace(/\D/g, '');
|
|
13684
13684
|
return cleanDocument.length === 11;
|
|
13685
13685
|
};
|
|
13686
|
+
var converterParaFormatoValido = function (data) {
|
|
13687
|
+
var _a = data.split('/'), dia = _a[0], mes = _a[1], ano = _a[2];
|
|
13688
|
+
return "".concat(mes, "/").concat(dia, "/").concat(ano);
|
|
13689
|
+
};
|
|
13686
13690
|
function formatDatePtBrToDate(date) {
|
|
13687
13691
|
var _a, _b;
|
|
13688
13692
|
return new Date((_b = (_a = date === null || date === void 0 ? void 0 : date.split('/')) === null || _a === void 0 ? void 0 : _a.reverse()) === null || _b === void 0 ? void 0 : _b.join('-'));
|
|
@@ -64697,29 +64701,54 @@ var processData = function (data, quantidadeProcessosJuridicos) {
|
|
|
64697
64701
|
.filter(function (info) { return info.data; });
|
|
64698
64702
|
return __assign$6(__assign$6({}, data), { protestos: data.protestos, ccfs: data.ccfs, boaVista: data.boaVista, serasa: data.serasa, dividasPublicasGrafico: data.dividasPublicasGrafico, pieChartTotalConfig: __assign$6(__assign$6({}, data.pieChartTotalConfig), { processosJuridicos: quantidadeProcessosJuridicos }) });
|
|
64699
64703
|
};
|
|
64704
|
+
var obterUltimaData = function (protestos) {
|
|
64705
|
+
if (!protestos.length)
|
|
64706
|
+
return null;
|
|
64707
|
+
var datas = protestos
|
|
64708
|
+
.map(function (p) { return new Date(converterParaFormatoValido(p.dataProtesto)).getTime(); })
|
|
64709
|
+
.filter(function (d) { return !isNaN(d); });
|
|
64710
|
+
return datas.length
|
|
64711
|
+
? new Date(Math.max.apply(Math, datas)).toLocaleDateString()
|
|
64712
|
+
: null;
|
|
64713
|
+
};
|
|
64700
64714
|
function processProtestData(document) {
|
|
64701
|
-
var _a, _b;
|
|
64702
64715
|
var filterProtestos = function (regex, data) {
|
|
64703
|
-
return XPathUtils.selectArray('//body//protesto', data)
|
|
64716
|
+
return XPathUtils.selectArray('//body//protesto', data)
|
|
64717
|
+
.filter(function (protesto) {
|
|
64704
64718
|
return regex.test(XPathUtils.select('string(./nomeCedente)', protesto));
|
|
64705
|
-
})
|
|
64719
|
+
})
|
|
64720
|
+
.map(function (protesto) { return ({
|
|
64721
|
+
dataProtesto: XPathUtils.select('string(./dataProtesto)', protesto),
|
|
64722
|
+
valor: parseFloat(XPathUtils.select('string(./valor)', protesto))
|
|
64723
|
+
}); });
|
|
64706
64724
|
};
|
|
64725
|
+
var protestosDeCredito = filterProtestos(REGEX_PROTESTOS_DE_CREDITO, document);
|
|
64726
|
+
var protestosDeImpostos = filterProtestos(REGEX_PROTESTOS_DE_IMPOSTO, document);
|
|
64727
|
+
var protestosGerais = XPathUtils.selectArray('//body//protesto', document)
|
|
64728
|
+
.filter(function (protesto) {
|
|
64729
|
+
var nomeCedente = XPathUtils.select('string(./nomeCedente)', protesto);
|
|
64730
|
+
return (!REGEX_PROTESTOS_DE_IMPOSTO.test(nomeCedente) &&
|
|
64731
|
+
!REGEX_PROTESTOS_DE_CREDITO.test(nomeCedente));
|
|
64732
|
+
})
|
|
64733
|
+
.map(function (protesto) { return ({
|
|
64734
|
+
dataProtesto: XPathUtils.select('string(./dataProtesto)', protesto),
|
|
64735
|
+
valor: parseFloat(XPathUtils.select('string(./valor)', protesto))
|
|
64736
|
+
}); });
|
|
64707
64737
|
return [
|
|
64708
64738
|
{
|
|
64709
64739
|
categoria: 'Protestos de Crédito',
|
|
64710
|
-
quantidade:
|
|
64740
|
+
quantidade: protestosDeCredito.length,
|
|
64741
|
+
ultimaOcorrencia: obterUltimaData(protestosDeCredito)
|
|
64711
64742
|
},
|
|
64712
64743
|
{
|
|
64713
64744
|
categoria: 'Protestos de Impostos',
|
|
64714
|
-
quantidade:
|
|
64745
|
+
quantidade: protestosDeImpostos.length,
|
|
64746
|
+
ultimaOcorrencia: obterUltimaData(protestosDeImpostos)
|
|
64715
64747
|
},
|
|
64716
64748
|
{
|
|
64717
64749
|
categoria: 'Protestos Gerais',
|
|
64718
|
-
quantidade:
|
|
64719
|
-
|
|
64720
|
-
return (!REGEX_PROTESTOS_DE_IMPOSTO.test(nomeCedente) &&
|
|
64721
|
-
!REGEX_PROTESTOS_DE_CREDITO.test(nomeCedente));
|
|
64722
|
-
}).length
|
|
64750
|
+
quantidade: protestosGerais.length,
|
|
64751
|
+
ultimaOcorrencia: obterUltimaData(protestosGerais)
|
|
64723
64752
|
}
|
|
64724
64753
|
];
|
|
64725
64754
|
}
|
|
@@ -64814,8 +64843,17 @@ var ChartSystem = function (_a) {
|
|
|
64814
64843
|
var _q = useCalculation((data === null || data === void 0 ? void 0 : data.boaVista) || []), quantidadeBoaVista = _q.quantidade, valorTotalBoaVista = _q.valorTotal;
|
|
64815
64844
|
var quantidadeCCFs = useCalculation((data === null || data === void 0 ? void 0 : data.ccfs) || []).quantidade;
|
|
64816
64845
|
var ultimaOcorrenciaProtestos = '';
|
|
64817
|
-
if ((data === null || data === void 0 ? void 0 : data.
|
|
64818
|
-
|
|
64846
|
+
if ((data === null || data === void 0 ? void 0 : data.protestosCategory) && data.protestosCategory.length > 0) {
|
|
64847
|
+
var datasOcorrencias = data.protestosCategory
|
|
64848
|
+
.map(function (categoria) { return categoria.ultimaOcorrencia; })
|
|
64849
|
+
.filter(Boolean)
|
|
64850
|
+
.map(function (data) {
|
|
64851
|
+
return new Date(converterParaFormatoValido(data)).getTime();
|
|
64852
|
+
})
|
|
64853
|
+
.filter(function (timestamp) { return !isNaN(timestamp); });
|
|
64854
|
+
if (datasOcorrencias.length > 0) {
|
|
64855
|
+
ultimaOcorrenciaProtestos = new Date(Math.max.apply(Math, datasOcorrencias)).toLocaleDateString();
|
|
64856
|
+
}
|
|
64819
64857
|
}
|
|
64820
64858
|
var consultaPefinBoaVista = (_g = (_f = ctxConsultasComplementares === null || ctxConsultasComplementares === void 0 ? void 0 : ctxConsultasComplementares.consultasComplementares) === null || _f === void 0 ? void 0 : _f.refinBoaVista) === null || _g === void 0 ? void 0 : _g.data;
|
|
64821
64859
|
var consultaPefinSerasa = (_j = (_h = ctxConsultasComplementares === null || ctxConsultasComplementares === void 0 ? void 0 : ctxConsultasComplementares.consultasComplementares) === null || _h === void 0 ? void 0 : _h.refinSerasa) === null || _j === void 0 ? void 0 : _j.data;
|
|
@@ -65396,7 +65434,7 @@ var getPossuiPendenciaText = function (_a) {
|
|
|
65396
65434
|
protestos
|
|
65397
65435
|
? protestos === 1
|
|
65398
65436
|
? 'Protesto Encontrado'
|
|
65399
|
-
: "
|
|
65437
|
+
: "".concat(protestos, " Protestos")
|
|
65400
65438
|
: '',
|
|
65401
65439
|
processosJuridicos
|
|
65402
65440
|
? processosJuridicos === 1
|
|
@@ -16,6 +16,7 @@ import ChevronDown from '../../assets/btn/chevronDown';
|
|
|
16
16
|
import useChartData from './hooks/useChartData';
|
|
17
17
|
import ResumoDeNegativacoesIcon from '../../assets/icones/resumoNegativacoes';
|
|
18
18
|
import { ConsultasComplementaresContext } from '../consultasComplementares';
|
|
19
|
+
import { converterParaFormatoValido } from '../../utils/string';
|
|
19
20
|
var Content = styled.div(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n display: ", ";\n padding: 0px 30px;\n\n @media print {\n display: block;\n }\n"], ["\n display: ", ";\n padding: 0px 30px;\n\n @media print {\n display: block;\n }\n"])), function (props) { return (props.isOpen ? 'block' : 'none'); });
|
|
20
21
|
var ChartSystem = function (_a) {
|
|
21
22
|
var _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
@@ -32,8 +33,17 @@ var ChartSystem = function (_a) {
|
|
|
32
33
|
var _q = useCalculation((data === null || data === void 0 ? void 0 : data.boaVista) || []), quantidadeBoaVista = _q.quantidade, valorTotalBoaVista = _q.valorTotal;
|
|
33
34
|
var quantidadeCCFs = useCalculation((data === null || data === void 0 ? void 0 : data.ccfs) || []).quantidade;
|
|
34
35
|
var ultimaOcorrenciaProtestos = '';
|
|
35
|
-
if ((data === null || data === void 0 ? void 0 : data.
|
|
36
|
-
|
|
36
|
+
if ((data === null || data === void 0 ? void 0 : data.protestosCategory) && data.protestosCategory.length > 0) {
|
|
37
|
+
var datasOcorrencias = data.protestosCategory
|
|
38
|
+
.map(function (categoria) { return categoria.ultimaOcorrencia; })
|
|
39
|
+
.filter(Boolean)
|
|
40
|
+
.map(function (data) {
|
|
41
|
+
return new Date(converterParaFormatoValido(data)).getTime();
|
|
42
|
+
})
|
|
43
|
+
.filter(function (timestamp) { return !isNaN(timestamp); });
|
|
44
|
+
if (datasOcorrencias.length > 0) {
|
|
45
|
+
ultimaOcorrenciaProtestos = new Date(Math.max.apply(Math, datasOcorrencias)).toLocaleDateString();
|
|
46
|
+
}
|
|
37
47
|
}
|
|
38
48
|
var consultaPefinBoaVista = (_g = (_f = ctxConsultasComplementares === null || ctxConsultasComplementares === void 0 ? void 0 : ctxConsultasComplementares.consultasComplementares) === null || _f === void 0 ? void 0 : _f.refinBoaVista) === null || _g === void 0 ? void 0 : _g.data;
|
|
39
49
|
var consultaPefinSerasa = (_j = (_h = ctxConsultasComplementares === null || ctxConsultasComplementares === void 0 ? void 0 : ctxConsultasComplementares.consultasComplementares) === null || _h === void 0 ? void 0 : _h.refinSerasa) === null || _j === void 0 ? void 0 : _j.data;
|
|
@@ -9,7 +9,7 @@ var __assign = (this && this.__assign) || function () {
|
|
|
9
9
|
};
|
|
10
10
|
return __assign.apply(this, arguments);
|
|
11
11
|
};
|
|
12
|
-
import { formatDatePtBrToDate } from '../../../utils/string';
|
|
12
|
+
import { converterParaFormatoValido, formatDatePtBrToDate } from '../../../utils/string';
|
|
13
13
|
import { groupBy, sortBy, unique } from 'underscore';
|
|
14
14
|
import XPathUtils from '../../../utils/xpath';
|
|
15
15
|
import { REGEX_PROTESTOS_DE_CREDITO, REGEX_PROTESTOS_DE_IMPOSTO } from '../../../constants/regex';
|
|
@@ -58,29 +58,54 @@ export var processData = function (data, quantidadeProcessosJuridicos) {
|
|
|
58
58
|
.filter(function (info) { return info.data; });
|
|
59
59
|
return __assign(__assign({}, data), { protestos: data.protestos, ccfs: data.ccfs, boaVista: data.boaVista, serasa: data.serasa, dividasPublicasGrafico: data.dividasPublicasGrafico, pieChartTotalConfig: __assign(__assign({}, data.pieChartTotalConfig), { processosJuridicos: quantidadeProcessosJuridicos }) });
|
|
60
60
|
};
|
|
61
|
+
var obterUltimaData = function (protestos) {
|
|
62
|
+
if (!protestos.length)
|
|
63
|
+
return null;
|
|
64
|
+
var datas = protestos
|
|
65
|
+
.map(function (p) { return new Date(converterParaFormatoValido(p.dataProtesto)).getTime(); })
|
|
66
|
+
.filter(function (d) { return !isNaN(d); });
|
|
67
|
+
return datas.length
|
|
68
|
+
? new Date(Math.max.apply(Math, datas)).toLocaleDateString()
|
|
69
|
+
: null;
|
|
70
|
+
};
|
|
61
71
|
export function processProtestData(document) {
|
|
62
|
-
var _a, _b;
|
|
63
72
|
var filterProtestos = function (regex, data) {
|
|
64
|
-
return XPathUtils.selectArray('//body//protesto', data)
|
|
73
|
+
return XPathUtils.selectArray('//body//protesto', data)
|
|
74
|
+
.filter(function (protesto) {
|
|
65
75
|
return regex.test(XPathUtils.select('string(./nomeCedente)', protesto));
|
|
66
|
-
})
|
|
76
|
+
})
|
|
77
|
+
.map(function (protesto) { return ({
|
|
78
|
+
dataProtesto: XPathUtils.select('string(./dataProtesto)', protesto),
|
|
79
|
+
valor: parseFloat(XPathUtils.select('string(./valor)', protesto))
|
|
80
|
+
}); });
|
|
67
81
|
};
|
|
82
|
+
var protestosDeCredito = filterProtestos(REGEX_PROTESTOS_DE_CREDITO, document);
|
|
83
|
+
var protestosDeImpostos = filterProtestos(REGEX_PROTESTOS_DE_IMPOSTO, document);
|
|
84
|
+
var protestosGerais = XPathUtils.selectArray('//body//protesto', document)
|
|
85
|
+
.filter(function (protesto) {
|
|
86
|
+
var nomeCedente = XPathUtils.select('string(./nomeCedente)', protesto);
|
|
87
|
+
return (!REGEX_PROTESTOS_DE_IMPOSTO.test(nomeCedente) &&
|
|
88
|
+
!REGEX_PROTESTOS_DE_CREDITO.test(nomeCedente));
|
|
89
|
+
})
|
|
90
|
+
.map(function (protesto) { return ({
|
|
91
|
+
dataProtesto: XPathUtils.select('string(./dataProtesto)', protesto),
|
|
92
|
+
valor: parseFloat(XPathUtils.select('string(./valor)', protesto))
|
|
93
|
+
}); });
|
|
68
94
|
return [
|
|
69
95
|
{
|
|
70
96
|
categoria: 'Protestos de Crédito',
|
|
71
|
-
quantidade:
|
|
97
|
+
quantidade: protestosDeCredito.length,
|
|
98
|
+
ultimaOcorrencia: obterUltimaData(protestosDeCredito)
|
|
72
99
|
},
|
|
73
100
|
{
|
|
74
101
|
categoria: 'Protestos de Impostos',
|
|
75
|
-
quantidade:
|
|
102
|
+
quantidade: protestosDeImpostos.length,
|
|
103
|
+
ultimaOcorrencia: obterUltimaData(protestosDeImpostos)
|
|
76
104
|
},
|
|
77
105
|
{
|
|
78
106
|
categoria: 'Protestos Gerais',
|
|
79
|
-
quantidade:
|
|
80
|
-
|
|
81
|
-
return (!REGEX_PROTESTOS_DE_IMPOSTO.test(nomeCedente) &&
|
|
82
|
-
!REGEX_PROTESTOS_DE_CREDITO.test(nomeCedente));
|
|
83
|
-
}).length
|
|
107
|
+
quantidade: protestosGerais.length,
|
|
108
|
+
ultimaOcorrencia: obterUltimaData(protestosGerais)
|
|
84
109
|
}
|
|
85
110
|
];
|
|
86
111
|
}
|
|
@@ -4,6 +4,7 @@ export declare function formatDocument(documento: string): string;
|
|
|
4
4
|
export declare function isCpf(documento: string): boolean;
|
|
5
5
|
export declare function isCnpj(documento: string): boolean;
|
|
6
6
|
export declare const isDocumentoPF: (documento: string) => boolean;
|
|
7
|
+
export declare const converterParaFormatoValido: (data: string) => string;
|
|
7
8
|
export declare function formatDatePtBrToDate(date: string): Date;
|
|
8
9
|
export declare function capitalize(value: string): string | null;
|
|
9
10
|
export declare function capitalizeFirstLetter(value: string): string | null;
|
package/lib/esm/utils/string.js
CHANGED
|
@@ -29,6 +29,10 @@ export var isDocumentoPF = function (documento) {
|
|
|
29
29
|
var cleanDocument = documento.replace(/\D/g, '');
|
|
30
30
|
return cleanDocument.length === 11;
|
|
31
31
|
};
|
|
32
|
+
export var converterParaFormatoValido = function (data) {
|
|
33
|
+
var _a = data.split('/'), dia = _a[0], mes = _a[1], ano = _a[2];
|
|
34
|
+
return "".concat(mes, "/").concat(dia, "/").concat(ano);
|
|
35
|
+
};
|
|
32
36
|
export function formatDatePtBrToDate(date) {
|
|
33
37
|
var _a, _b;
|
|
34
38
|
return new Date((_b = (_a = date === null || date === void 0 ? void 0 : date.split('/')) === null || _a === void 0 ? void 0 : _a.reverse()) === null || _b === void 0 ? void 0 : _b.join('-'));
|