@credithub/harlan-components 1.91.1 → 1.91.3
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/dist/components/chart/utils/dataProcessing.js +5 -3
- package/dist/components/falencia/falencia.d.ts +3 -0
- package/dist/components/falencia/falencia.js +70 -35
- package/dist/components/protestos/protestos.js +17 -21
- package/dist/components/protestos/protestosList.d.ts +3 -2
- package/dist/components/protestos/protestosList.js +16 -18
- package/dist/hooks/useProtestosClassification.d.ts +6 -5
- package/dist/hooks/useProtestosClassification.js +21 -30
- package/dist/utils/parseProtesto.d.ts +11 -0
- package/dist/utils/parseProtesto.js +14 -0
- package/lib/cjs/index.js +140 -98
- package/lib/esm/index.js +140 -98
- package/package.json +1 -1
|
@@ -11,6 +11,7 @@ var __assign = (this && this.__assign) || function () {
|
|
|
11
11
|
};
|
|
12
12
|
import { classifyProtestos } from '../../../hooks/useProtestosClassification';
|
|
13
13
|
import { converterParaFormatoValido, formatDatePtBrToDate } from '../../../utils/date';
|
|
14
|
+
import { parseProtesto } from '../../../utils/parseProtesto';
|
|
14
15
|
import XPathUtils from '../../../utils/xpath';
|
|
15
16
|
import { groupBy, sortBy, unique } from 'underscore';
|
|
16
17
|
/**
|
|
@@ -108,14 +109,15 @@ export var processData = function (data, quantidadeProcessosJuridicos) {
|
|
|
108
109
|
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 }) });
|
|
109
110
|
};
|
|
110
111
|
export function processProtestData(document, iaOverrides) {
|
|
111
|
-
|
|
112
|
+
// Converte Node[] para Protesto[]
|
|
113
|
+
var protestos = XPathUtils.selectArray('//body//protesto', document).map(parseProtesto);
|
|
114
|
+
var _a = classifyProtestos(protestos, iaOverrides), protestosDeCredito = _a.protestosDeCredito, protestosDeImposto = _a.protestosDeImposto, protestosGerais = _a.protestosGerais;
|
|
112
115
|
var obterUltimaData = function (protestos) {
|
|
113
116
|
if (!protestos.length)
|
|
114
117
|
return null;
|
|
115
118
|
var datas = protestos
|
|
116
119
|
.map(function (p) {
|
|
117
|
-
|
|
118
|
-
return new Date(converterParaFormatoValido(data)).getTime();
|
|
120
|
+
return new Date(converterParaFormatoValido(p.dataProtesto)).getTime();
|
|
119
121
|
})
|
|
120
122
|
.filter(function (d) { return !isNaN(d); });
|
|
121
123
|
return datas.length
|
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
+
/** ------------------------------------------------------------------
|
|
3
|
+
* Componente principal ---------------------------------------------
|
|
4
|
+
* ------------------------------------------------------------------*/
|
|
2
5
|
declare const Falencia: React.FC<{
|
|
3
6
|
documento: string;
|
|
4
7
|
}>;
|
|
@@ -12,54 +12,72 @@ var __assign = (this && this.__assign) || function () {
|
|
|
12
12
|
import React, { useEffect, useMemo, useState } from 'react';
|
|
13
13
|
import FalenciaIcon from '../../assets/icones/falenciaIcon';
|
|
14
14
|
import { useGlobalData } from '../../contexts/globalDataContext';
|
|
15
|
+
import AddItemField from '../common/addItem';
|
|
16
|
+
import { Result, ResultContent } from '../interface/result';
|
|
15
17
|
import Section from '../section';
|
|
16
18
|
import { RequestStatus, useQuery } from '../webservice';
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
});
|
|
43
|
-
});
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
catch (_c) { }
|
|
47
|
-
return [];
|
|
19
|
+
/** ------------------------------------------------------------------
|
|
20
|
+
* Helpers -----------------------------------------------------------
|
|
21
|
+
* ------------------------------------------------------------------*/
|
|
22
|
+
function normalizeMovimentacao(text) {
|
|
23
|
+
return text
|
|
24
|
+
.replace('Falências', 'Falência')
|
|
25
|
+
.replace('Requeridas', 'Requerida')
|
|
26
|
+
.replace('Decretadas', 'Decretada')
|
|
27
|
+
.replace('Extintos', 'Extinto')
|
|
28
|
+
.trim();
|
|
29
|
+
}
|
|
30
|
+
function cleanDate(dateStr) {
|
|
31
|
+
return dateStr.replace(/\s+\d{2}h\d{2}/, '').trim();
|
|
32
|
+
}
|
|
33
|
+
function buildSubtitle(records) {
|
|
34
|
+
// Busca o primeiro registro que realmente possua movimentação
|
|
35
|
+
var rec = records.find(function (r) { return Array.isArray(r.falimentar) && r.falimentar.length; });
|
|
36
|
+
if (!rec)
|
|
37
|
+
return 'Movimentos falimentares encontrados.';
|
|
38
|
+
var latest = rec.falimentar[0];
|
|
39
|
+
if (!latest)
|
|
40
|
+
return 'Movimentos falimentares encontrados.';
|
|
41
|
+
var movimentacao = normalizeMovimentacao(latest.movimentacao);
|
|
42
|
+
var date = cleanDate(latest.data);
|
|
43
|
+
return "".concat(movimentacao, " - ").concat(date);
|
|
48
44
|
}
|
|
45
|
+
/** ------------------------------------------------------------------
|
|
46
|
+
* Componente principal ---------------------------------------------
|
|
47
|
+
* ------------------------------------------------------------------*/
|
|
49
48
|
var Falencia = function (_a) {
|
|
50
49
|
var documento = _a.documento;
|
|
51
50
|
var setData = useGlobalData().setData;
|
|
52
51
|
var _b = useState(false), dataUpdated = _b[0], setDataUpdated = _b[1];
|
|
53
52
|
var _c = useQuery("SELECT FROM 'ValorEconomico'.'Falencia'", { documento: documento }), response = _c.response, error = _c.error, isLoading = _c.isLoading, loadingProgress = _c.loadingProgress, refetch = _c.refetch;
|
|
54
|
-
|
|
55
|
-
var
|
|
53
|
+
// Transforma o retorno em array tipado ----------------------------------
|
|
54
|
+
var records = useMemo(function () {
|
|
55
|
+
if (!(response === null || response === void 0 ? void 0 : response.document))
|
|
56
|
+
return [];
|
|
57
|
+
try {
|
|
58
|
+
if (Array.isArray(response.document))
|
|
59
|
+
return response.document;
|
|
60
|
+
return JSON.parse(response.document);
|
|
61
|
+
}
|
|
62
|
+
catch (_a) {
|
|
63
|
+
return [];
|
|
64
|
+
}
|
|
65
|
+
}, [response]);
|
|
66
|
+
/**
|
|
67
|
+
* Há insolvência quando existe pelo menos UMA movimentação falimentar.
|
|
68
|
+
*/
|
|
69
|
+
var insolvencia = useMemo(function () {
|
|
70
|
+
return records.some(function (r) { return Array.isArray(r.falimentar) && r.falimentar.length > 0; });
|
|
71
|
+
}, [records]);
|
|
72
|
+
/** Atualiza o contexto global apenas uma vez ---------------------------*/
|
|
56
73
|
useEffect(function () {
|
|
57
74
|
if (insolvencia && !dataUpdated) {
|
|
58
75
|
setData(function (prev) { return (__assign(__assign({}, prev), { insolvencia: insolvencia })); });
|
|
59
76
|
setDataUpdated(true);
|
|
60
77
|
}
|
|
61
78
|
}, [insolvencia, setData, dataUpdated]);
|
|
62
|
-
|
|
79
|
+
/** Se não há dados e não estamos carregando, não renderiza o componente */
|
|
80
|
+
if (!isLoading && !insolvencia)
|
|
63
81
|
return null;
|
|
64
82
|
var variant = isLoading
|
|
65
83
|
? 'loading'
|
|
@@ -79,6 +97,23 @@ var Falencia = function (_a) {
|
|
|
79
97
|
Section: Section,
|
|
80
98
|
progress: loadingProgress
|
|
81
99
|
};
|
|
82
|
-
|
|
100
|
+
var subtitle = buildSubtitle(records);
|
|
101
|
+
/** ------------------------------------------------------------------
|
|
102
|
+
* RENDERIZA LISTA DE MOVIMENTAÇÕES ANTERIORES ------------------------
|
|
103
|
+
* ------------------------------------------------------------------*/
|
|
104
|
+
var renderMovimentacoes = function () {
|
|
105
|
+
var movimentos = records
|
|
106
|
+
.flatMap(function (r) { return r.falimentar; })
|
|
107
|
+
.map(function (m) { return ({
|
|
108
|
+
movimentacao: normalizeMovimentacao(m.movimentacao),
|
|
109
|
+
data: cleanDate(m.data)
|
|
110
|
+
}); });
|
|
111
|
+
if (!movimentos.length)
|
|
112
|
+
return null;
|
|
113
|
+
return (React.createElement(Result, { resultContentStriped: true, className: "falencia" }, movimentos.map(function (mov, idx) { return (React.createElement(ResultContent, { desktop: "repeat(2, 1fr)", tablet: "repeat(2, 1fr)", mobile: "repeat(2, 1fr)", key: idx },
|
|
114
|
+
React.createElement(AddItemField, { name: "Movimenta\u00E7\u00E3o", value: mov.movimentacao, style: { display: 'inline-block' } }),
|
|
115
|
+
React.createElement(AddItemField, { name: "Data", value: mov.data, style: { display: 'inline-block' } }))); })));
|
|
116
|
+
};
|
|
117
|
+
return (React.createElement(Section, { title: "Movimento Falimentar", subtitle: subtitle, icon: FalenciaIcon, variant: variant, minimized: false, ctx: ctx, onError: renderMovimentacoes, onSuccess: renderMovimentacoes }));
|
|
83
118
|
};
|
|
84
119
|
export default Falencia;
|
|
@@ -28,8 +28,8 @@ import ProtestosGeraisIcon from '../../assets/icones/protestosGerais';
|
|
|
28
28
|
import ProtestosImpostosIcon from '../../assets/icones/protestosImpostos';
|
|
29
29
|
import { useGlobalData } from '../../contexts/globalDataContext';
|
|
30
30
|
import { classifyProtestos, useProtestosClassification } from '../../hooks/useProtestosClassification';
|
|
31
|
-
import { formatDatePtBrToDate } from '../../utils/date';
|
|
32
31
|
import { extractIntegerFromText } from '../../utils/number';
|
|
32
|
+
import { parseProtesto } from '../../utils/parseProtesto';
|
|
33
33
|
import XPathUtils from '../../utils/xpath';
|
|
34
34
|
import React, { useCallback, useContext, useEffect, useMemo, useState } from 'react';
|
|
35
35
|
import styled from 'styled-components';
|
|
@@ -41,17 +41,9 @@ import ProtestosCategory from './protestosCategory';
|
|
|
41
41
|
import { ProtestoItem } from './protestosList';
|
|
42
42
|
var ResultProtestos = styled.div(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n display: flex;\n flex-direction: column;\n row-gap: 20px;\n margin-top: 20px;\n"], ["\n display: flex;\n flex-direction: column;\n row-gap: 20px;\n margin-top: 20px;\n"])));
|
|
43
43
|
var BtnWrapper = styled.div(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n text-align: center;\n @media print {\n display: none;\n }\n"], ["\n text-align: center;\n @media print {\n display: none;\n }\n"])));
|
|
44
|
-
//
|
|
45
|
-
var byDate = function (protesto, protesto2) {
|
|
46
|
-
var _a, _b;
|
|
47
|
-
var v0 = ((_a = formatDatePtBrToDate(XPathUtils.select('string(./dataProtesto)', protesto2))) === null || _a === void 0 ? void 0 : _a.getTime()) || 0;
|
|
48
|
-
var v1 = ((_b = formatDatePtBrToDate(XPathUtils.select('string(./dataProtesto)', protesto))) === null || _b === void 0 ? void 0 : _b.getTime()) || 0;
|
|
49
|
-
return v0 - v1;
|
|
50
|
-
};
|
|
44
|
+
// Remover função de ordenação por data não usada
|
|
51
45
|
// Função utilitária para extrair as chaves dos protestos
|
|
52
|
-
var getChaves = function (arr) {
|
|
53
|
-
return arr.map(function (protesto) { return XPathUtils.select('string(./nm_chave)', protesto); });
|
|
54
|
-
};
|
|
46
|
+
var getChaves = function (arr) { return arr.map(function (p) { return p.nm_chave; }); };
|
|
55
47
|
var Protestos = function () {
|
|
56
48
|
var _a;
|
|
57
49
|
var ctx = useContext(Queries.Protestos);
|
|
@@ -67,9 +59,16 @@ var Protestos = function () {
|
|
|
67
59
|
}
|
|
68
60
|
return 0;
|
|
69
61
|
}, [ctxLiminar === null || ctxLiminar === void 0 ? void 0 : ctxLiminar.type, ctxLiminar === null || ctxLiminar === void 0 ? void 0 : ctxLiminar.document]);
|
|
70
|
-
//
|
|
62
|
+
// converte XML → Protesto[]
|
|
63
|
+
var protestosAll = useMemo(function () {
|
|
64
|
+
if (!ctx.document)
|
|
65
|
+
return [];
|
|
66
|
+
return XPathUtils.selectArray('//body//protesto', ctx.document).map(parseProtesto);
|
|
67
|
+
}, [ctx.document]);
|
|
71
68
|
var iaOverrides = (_a = globalData.protestosData) === null || _a === void 0 ? void 0 : _a.iaOverrides;
|
|
72
|
-
var _d = useProtestosClassification(
|
|
69
|
+
var _d = useProtestosClassification(protestosAll, iaOverrides), protestosDeCredito = _d.protestosDeCredito, protestosDeImposto = _d.protestosDeImposto, protestosGerais = _d.protestosGerais;
|
|
70
|
+
// Total de protestos
|
|
71
|
+
var registros = protestosAll.length;
|
|
73
72
|
useEffect(function () {
|
|
74
73
|
if ((ctx === null || ctx === void 0 ? void 0 : ctx.type) === RequestStatus.Error ||
|
|
75
74
|
(ctx === null || ctx === void 0 ? void 0 : ctx.type) === RequestStatus.Empty) {
|
|
@@ -121,14 +120,11 @@ var Protestos = function () {
|
|
|
121
120
|
}
|
|
122
121
|
}, [ctx.type]);
|
|
123
122
|
// Callback memorizado para a renderização do conteúdo em caso de sucesso
|
|
124
|
-
var handleSuccess = useCallback(function (data
|
|
123
|
+
var handleSuccess = useCallback(function (data) {
|
|
125
124
|
var registrosText = XPathUtils.select('string(//registros)', data);
|
|
126
|
-
var
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
: extractIntegerFromText(registrosText);
|
|
130
|
-
// Usa função pura para classificar
|
|
131
|
-
var _a = classifyProtestos(data, iaOverrides), protestosDeCredito = _a.protestosDeCredito, protestosDeImposto = _a.protestosDeImposto, protestosGerais = _a.protestosGerais;
|
|
125
|
+
var parsed = XPathUtils.selectArray('//body//protesto', data).map(parseProtesto);
|
|
126
|
+
// ✅ função pura – não adiciona hooks extras dentro de Section
|
|
127
|
+
var _a = classifyProtestos(parsed, iaOverrides), protestosDeCredito = _a.protestosDeCredito, protestosDeImposto = _a.protestosDeImposto, protestosGerais = _a.protestosGerais;
|
|
132
128
|
var elements = [
|
|
133
129
|
{
|
|
134
130
|
total: protestosDeCredito.length,
|
|
@@ -157,7 +153,7 @@ var Protestos = function () {
|
|
|
157
153
|
: "Encontrados ".concat(registros, " protestos")
|
|
158
154
|
: 'Não há ocorrência de protesto'))
|
|
159
155
|
};
|
|
160
|
-
}, [
|
|
156
|
+
}, [iaOverrides]);
|
|
161
157
|
return (React.createElement(Section, { ctx: ctx, title: "Apontamentos na Central de Protestos (CENPROT)", subtitle: "Consulta de protestos de cr\u00E9dito, imposto e gerais.", icon: ProtestosIcon, onSuccess: handleSuccess, actions: typeof harlan !== 'undefined' ? (React.createElement(BtnWrapper, null,
|
|
162
158
|
React.createElement(Button, { onClick: function () {
|
|
163
159
|
var _a;
|
|
@@ -1,11 +1,12 @@
|
|
|
1
|
+
import { Protesto } from '../../utils/parseProtesto';
|
|
1
2
|
import React from 'react';
|
|
2
3
|
export declare const ProtestoItem: React.MemoExoticComponent<({ protesto }: {
|
|
3
|
-
protesto:
|
|
4
|
+
protesto: Protesto;
|
|
4
5
|
}) => React.JSX.Element>;
|
|
5
6
|
export declare const Instrumento: ({ nm_chave, cpfCnpj }: {
|
|
6
7
|
nm_chave?: string;
|
|
7
8
|
cpfCnpj?: string;
|
|
8
9
|
}) => React.JSX.Element | null;
|
|
9
10
|
export declare const ProtestosList: React.FC<{
|
|
10
|
-
protestos:
|
|
11
|
+
protestos: Protesto[];
|
|
11
12
|
}>;
|
|
@@ -49,8 +49,7 @@ import { useGlobalData } from '../../contexts/globalDataContext';
|
|
|
49
49
|
import { formatMoney } from '../../utils/number';
|
|
50
50
|
import { openFormThenRedirect } from '../../utils/protestosp';
|
|
51
51
|
import { formatDocument } from '../../utils/string';
|
|
52
|
-
import
|
|
53
|
-
import React, { memo, useContext, useEffect, useMemo, useState } from 'react';
|
|
52
|
+
import React, { memo, useContext, useEffect, useState } from 'react';
|
|
54
53
|
import AddItemField from '../common/addItem';
|
|
55
54
|
import Button from '../common/button';
|
|
56
55
|
import { ResultContent } from '../interface/result';
|
|
@@ -114,12 +113,8 @@ export var ProtestoItem = memo(function (_a) {
|
|
|
114
113
|
var _e = useState(false), loading = _e[0], setLoading = _e[1];
|
|
115
114
|
var _f = useState(false), queued = _f[0], setQueued = _f[1];
|
|
116
115
|
var _g = useState(false), isAIData = _g[0], setIsAIData = _g[1];
|
|
117
|
-
var
|
|
118
|
-
|
|
119
|
-
return formatter ? formatter(value) : value;
|
|
120
|
-
};
|
|
121
|
-
var documento = useMemo(function () { return getField('//consulta/@documento'); }, [protesto]);
|
|
122
|
-
var nm_chave = getField('./nm_chave');
|
|
116
|
+
var documento = protesto.cpfCnpj;
|
|
117
|
+
var nm_chave = protesto.nm_chave;
|
|
123
118
|
var formatBooleanField = function (value) {
|
|
124
119
|
return value === 'true' ? 'Sim' : 'Não';
|
|
125
120
|
};
|
|
@@ -155,7 +150,10 @@ export var ProtestoItem = memo(function (_a) {
|
|
|
155
150
|
setData(function (prev) {
|
|
156
151
|
var _a;
|
|
157
152
|
var _b;
|
|
158
|
-
|
|
153
|
+
// Garante que só string é atribuída
|
|
154
|
+
if (!nomeDetectado_1)
|
|
155
|
+
return prev;
|
|
156
|
+
return __assign(__assign({}, prev), { protestosData: __assign(__assign({}, prev.protestosData), { iaOverrides: __assign(__assign({}, (((_b = prev.protestosData) === null || _b === void 0 ? void 0 : _b.iaOverrides) || {})), (_a = {}, _a[nm_chave] = nomeDetectado_1, _a)) }) });
|
|
159
157
|
});
|
|
160
158
|
}
|
|
161
159
|
return [3 /*break*/, 6];
|
|
@@ -187,7 +185,7 @@ export var ProtestoItem = memo(function (_a) {
|
|
|
187
185
|
}
|
|
188
186
|
};
|
|
189
187
|
useEffect(function () {
|
|
190
|
-
var nomeCedente =
|
|
188
|
+
var nomeCedente = protesto.nomeCedente;
|
|
191
189
|
if (nomeCedente && nomeCedente.trim() !== '')
|
|
192
190
|
return;
|
|
193
191
|
if (nm_chave) {
|
|
@@ -202,7 +200,7 @@ export var ProtestoItem = memo(function (_a) {
|
|
|
202
200
|
};
|
|
203
201
|
}, []);
|
|
204
202
|
var getQuemProtestouDisplay = function () {
|
|
205
|
-
var original =
|
|
203
|
+
var original = protesto.nomeCedente;
|
|
206
204
|
var override = iaOverrides[nm_chave];
|
|
207
205
|
if (override && override.trim() !== '') {
|
|
208
206
|
return (React.createElement(React.Fragment, null,
|
|
@@ -221,12 +219,12 @@ export var ProtestoItem = memo(function (_a) {
|
|
|
221
219
|
};
|
|
222
220
|
return (React.createElement(ResultContent, { print: "repeat(7, 1fr)", desktop: "repeat(8, 1fr)", tablet: "repeat(4, 1fr)", mobile: "repeat(2, 1fr)" },
|
|
223
221
|
React.createElement(AddItemField, { name: "Quem Protestou", value: getQuemProtestouDisplay() }),
|
|
224
|
-
React.createElement(AddItemField, { name: "Atrav\u00E9s De", value:
|
|
225
|
-
React.createElement(AddItemField, { name: "CPF/CNPJ Protestado", value: formatDocument(
|
|
226
|
-
React.createElement(AddItemField, { name: "Data Do Protesto", value:
|
|
227
|
-
React.createElement(AddItemField, { name: "Possui Anu\u00EAncia / Protesto Pago", value: formatBooleanField(
|
|
228
|
-
React.createElement(AddItemField, { name: "Valor Do Protesto", value: formatMoney(
|
|
229
|
-
|
|
222
|
+
React.createElement(AddItemField, { name: "Atrav\u00E9s De", value: protesto.nomeApresentante }),
|
|
223
|
+
React.createElement(AddItemField, { name: "CPF/CNPJ Protestado", value: formatDocument(protesto.cpfCnpj) }),
|
|
224
|
+
React.createElement(AddItemField, { name: "Data Do Protesto", value: protesto.dataProtesto }),
|
|
225
|
+
React.createElement(AddItemField, { name: "Possui Anu\u00EAncia / Protesto Pago", value: formatBooleanField(String(protesto.temAnuencia)) }),
|
|
226
|
+
React.createElement(AddItemField, { name: "Valor Do Protesto", value: formatMoney(protesto.valor) }),
|
|
227
|
+
protesto.vl_custas && (React.createElement(AddItemField, { name: "Custas de Cart\u00F3rio para Baixa", value: formatMoney(protesto.vl_custas) })),
|
|
230
228
|
React.createElement(Instrumento, { nm_chave: nm_chave, cpfCnpj: documento })));
|
|
231
229
|
});
|
|
232
230
|
export var Instrumento = function (_a) {
|
|
@@ -276,5 +274,5 @@ export var Instrumento = function (_a) {
|
|
|
276
274
|
};
|
|
277
275
|
export var ProtestosList = function (_a) {
|
|
278
276
|
var protestos = _a.protestos;
|
|
279
|
-
return (React.createElement(ResultContent, null, (protestos === null || protestos === void 0 ? void 0 : protestos.length) ? (protestos.map(function (protesto
|
|
277
|
+
return (React.createElement(ResultContent, null, (protestos === null || protestos === void 0 ? void 0 : protestos.length) ? (protestos.map(function (protesto) { return (React.createElement(ProtestoItem, { key: protesto.nm_chave, protesto: protesto })); })) : (React.createElement(AddItemField, { name: "Informa\u00E7\u00E3o", value: "N\u00E3o h\u00E1 registros de protestos." }))));
|
|
280
278
|
};
|
|
@@ -1,12 +1,13 @@
|
|
|
1
|
+
import { Protesto } from '../utils/parseProtesto';
|
|
1
2
|
export interface ProtestosClassificados {
|
|
2
|
-
protestosDeCredito:
|
|
3
|
-
protestosDeImposto:
|
|
4
|
-
protestosGerais:
|
|
3
|
+
protestosDeCredito: Protesto[];
|
|
4
|
+
protestosDeImposto: Protesto[];
|
|
5
|
+
protestosGerais: Protesto[];
|
|
5
6
|
}
|
|
6
|
-
export declare function classifyProtestos(
|
|
7
|
+
export declare function classifyProtestos(protestos: Protesto[], iaOverrides?: Record<string, string>): ProtestosClassificados;
|
|
7
8
|
/**
|
|
8
9
|
* Hook para classificar protestos em Crédito, Imposto e Gerais, com suporte a overrides de IA.
|
|
9
10
|
* @param document Documento XML dos protestos
|
|
10
11
|
* @param iaOverrides Mapa opcional de chaves para nomes de cedente ajustados por IA
|
|
11
12
|
*/
|
|
12
|
-
export declare function useProtestosClassification(
|
|
13
|
+
export declare function useProtestosClassification(protestos: Protesto[], iaOverrides?: Record<string, string>): ProtestosClassificados;
|
|
@@ -1,46 +1,37 @@
|
|
|
1
1
|
import { REGEX_PROTESTOS_DE_CREDITO, REGEX_PROTESTOS_DE_IMPOSTO } from '../constants/regex';
|
|
2
2
|
import { formatDatePtBrToDate } from '../utils/date';
|
|
3
|
-
import XPathUtils from '../utils/xpath';
|
|
4
3
|
import { useMemo } from 'react';
|
|
5
4
|
// Função de ordenação por data
|
|
6
|
-
var byDate = function (
|
|
5
|
+
var byDate = function (a, b) {
|
|
7
6
|
var _a, _b;
|
|
8
|
-
var v0 = ((_a = formatDatePtBrToDate(
|
|
9
|
-
var v1 = ((_b = formatDatePtBrToDate(
|
|
7
|
+
var v0 = ((_a = formatDatePtBrToDate(b.dataProtesto)) === null || _a === void 0 ? void 0 : _a.getTime()) || 0;
|
|
8
|
+
var v1 = ((_b = formatDatePtBrToDate(a.dataProtesto)) === null || _b === void 0 ? void 0 : _b.getTime()) || 0;
|
|
10
9
|
return v0 - v1;
|
|
11
10
|
};
|
|
12
|
-
export function classifyProtestos(
|
|
13
|
-
if (!
|
|
11
|
+
export function classifyProtestos(protestos, iaOverrides) {
|
|
12
|
+
if (!(protestos === null || protestos === void 0 ? void 0 : protestos.length)) {
|
|
14
13
|
return {
|
|
15
14
|
protestosDeCredito: [],
|
|
16
15
|
protestosDeImposto: [],
|
|
17
16
|
protestosGerais: []
|
|
18
17
|
};
|
|
19
18
|
}
|
|
20
|
-
var
|
|
21
|
-
return
|
|
22
|
-
var
|
|
23
|
-
var
|
|
24
|
-
|
|
25
|
-
if (iaNome) {
|
|
26
|
-
return regex.test(iaNome);
|
|
27
|
-
}
|
|
28
|
-
return regex.test(cedente);
|
|
19
|
+
var filter = function (regex) {
|
|
20
|
+
return protestos.filter(function (_a) {
|
|
21
|
+
var nomeCedente = _a.nomeCedente, nm_chave = _a.nm_chave;
|
|
22
|
+
var iaNome = (iaOverrides === null || iaOverrides === void 0 ? void 0 : iaOverrides[nm_chave]) || '';
|
|
23
|
+
return iaNome ? regex.test(iaNome) : regex.test(nomeCedente);
|
|
29
24
|
});
|
|
30
25
|
};
|
|
31
|
-
var protestosDeCredito =
|
|
32
|
-
var protestosDeImposto =
|
|
33
|
-
var protestosGerais =
|
|
34
|
-
.filter(function (
|
|
35
|
-
var
|
|
36
|
-
var
|
|
37
|
-
var
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
!REGEX_PROTESTOS_DE_CREDITO.test(iaNome));
|
|
41
|
-
}
|
|
42
|
-
return (!REGEX_PROTESTOS_DE_IMPOSTO.test(cedente) &&
|
|
43
|
-
!REGEX_PROTESTOS_DE_CREDITO.test(cedente));
|
|
26
|
+
var protestosDeCredito = filter(REGEX_PROTESTOS_DE_CREDITO).sort(byDate);
|
|
27
|
+
var protestosDeImposto = filter(REGEX_PROTESTOS_DE_IMPOSTO).sort(byDate);
|
|
28
|
+
var protestosGerais = protestos
|
|
29
|
+
.filter(function (_a) {
|
|
30
|
+
var nomeCedente = _a.nomeCedente, nm_chave = _a.nm_chave;
|
|
31
|
+
var iaNome = (iaOverrides === null || iaOverrides === void 0 ? void 0 : iaOverrides[nm_chave]) || '';
|
|
32
|
+
var target = iaNome || nomeCedente;
|
|
33
|
+
return (!REGEX_PROTESTOS_DE_IMPOSTO.test(target) &&
|
|
34
|
+
!REGEX_PROTESTOS_DE_CREDITO.test(target));
|
|
44
35
|
})
|
|
45
36
|
.sort(byDate);
|
|
46
37
|
return {
|
|
@@ -54,6 +45,6 @@ export function classifyProtestos(document, iaOverrides) {
|
|
|
54
45
|
* @param document Documento XML dos protestos
|
|
55
46
|
* @param iaOverrides Mapa opcional de chaves para nomes de cedente ajustados por IA
|
|
56
47
|
*/
|
|
57
|
-
export function useProtestosClassification(
|
|
58
|
-
return useMemo(function () { return classifyProtestos(
|
|
48
|
+
export function useProtestosClassification(protestos, iaOverrides) {
|
|
49
|
+
return useMemo(function () { return classifyProtestos(protestos, iaOverrides); }, [protestos, iaOverrides]);
|
|
59
50
|
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export interface Protesto {
|
|
2
|
+
nm_chave: string;
|
|
3
|
+
cpfCnpj: string;
|
|
4
|
+
nomeCedente: string;
|
|
5
|
+
nomeApresentante: string;
|
|
6
|
+
dataProtesto: string;
|
|
7
|
+
valor: string;
|
|
8
|
+
vl_custas?: string;
|
|
9
|
+
temAnuencia: boolean;
|
|
10
|
+
}
|
|
11
|
+
export declare const parseProtesto: (node: Node) => Protesto;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import XPathUtils from '../utils/xpath';
|
|
2
|
+
export var parseProtesto = function (node) {
|
|
3
|
+
var $ = function (xp) { return XPathUtils.select("string(".concat(xp, ")"), node); };
|
|
4
|
+
return {
|
|
5
|
+
nm_chave: $('./nm_chave'),
|
|
6
|
+
cpfCnpj: $('./cpfCnpj'),
|
|
7
|
+
nomeCedente: $('./nomeCedente'),
|
|
8
|
+
nomeApresentante: $('./nomeApresentante'),
|
|
9
|
+
dataProtesto: $('./dataProtesto'),
|
|
10
|
+
valor: $('./valor'),
|
|
11
|
+
vl_custas: $('./vl_custas') || undefined,
|
|
12
|
+
temAnuencia: $('./temAnuencia') === 'true'
|
|
13
|
+
};
|
|
14
|
+
};
|