@credithub/harlan-components 1.51.0 → 1.51.1

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@credithub/harlan-components",
3
- "version": "1.51.0",
3
+ "version": "1.51.1",
4
4
  "description": "Provide a set of web components to be used in Harlan and other projects",
5
5
  "keywords": [
6
6
  "harlan",
@@ -1,6 +0,0 @@
1
- import { SCRQuery } from '../../@types/domain';
2
- declare const getResumoDeCreditos: (scr: SCRQuery) => {
3
- descricao: string;
4
- valor: string;
5
- }[];
6
- export default getResumoDeCreditos;
@@ -1,79 +0,0 @@
1
- var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
2
- if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
3
- if (ar || !(i in from)) {
4
- if (!ar) ar = Array.prototype.slice.call(from, 0, i);
5
- ar[i] = from[i];
6
- }
7
- }
8
- return to.concat(ar || Array.prototype.slice.call(from));
9
- };
10
- import { formatMoney } from '../../utils/number';
11
- import { compose, groupBy } from 'underscore';
12
- var agruparPorCategoriaDeVencimento = function (detalhamento) {
13
- if (!Array.isArray(detalhamento) || detalhamento.length === 0) {
14
- return { avencer: [], vencido: [] };
15
- }
16
- var flatVencimentos = detalhamento.flatMap(function (item) { return item.vencimentos || []; });
17
- var _a = groupBy(flatVencimentos, function (_a) {
18
- var categoria = _a.categoria;
19
- return categoria;
20
- }), _b = _a.avencer, avencer = _b === void 0 ? [] : _b, _c = _a.vencido, vencido = _c === void 0 ? [] : _c;
21
- return { avencer: avencer, vencido: vencido };
22
- };
23
- var agruparPorDescricao = function (_a) {
24
- var avencer = _a.avencer, vencido = _a.vencido;
25
- return ({
26
- avencer: groupBy(avencer, function (_a) {
27
- var descricao = _a.descricao;
28
- return descricao;
29
- }),
30
- vencido: groupBy(vencido, function (_a) {
31
- var descricao = _a.descricao;
32
- return descricao;
33
- })
34
- });
35
- };
36
- var adicionarCreditosADescricao = function (description, valor) {
37
- var isAvencerVencido = /(A Vencer|Vencido)$/i.test(description.trim());
38
- return {
39
- descricao: !isAvencerVencido
40
- ? "Cr\u00E9ditos ".concat(description.toLowerCase())
41
- : description,
42
- valor: valor ? formatMoney(valor) : ''
43
- };
44
- };
45
- var somarDadosAgrupadosPorDescricao = function (_a) {
46
- var avencer = _a.avencer, vencido = _a.vencido;
47
- var avencerEntries = avencer ? Object.entries(avencer) : [];
48
- var vencidoEntries = vencido ? Object.entries(vencido) : [];
49
- return {
50
- avencer: avencerEntries.map(function (_a) {
51
- var descricao = _a[0], values = _a[1];
52
- return adicionarCreditosADescricao(descricao, values.map(function (v) { return Number(v.valor); }).reduce(function (a, b) { return a + b; }, 0));
53
- }),
54
- vencido: vencidoEntries.map(function (_a) {
55
- var descricao = _a[0], values = _a[1];
56
- return adicionarCreditosADescricao(descricao, values.map(function (v) { return Number(v.valor); }).reduce(function (a, b) { return a + b; }, 0));
57
- })
58
- };
59
- };
60
- var getVencidosEAvencer = compose(agruparPorCategoriaDeVencimento, agruparPorDescricao, somarDadosAgrupadosPorDescricao);
61
- var getResumoDeCreditos = function (scr) {
62
- var _a, _b, _c;
63
- if (!((_a = scr === null || scr === void 0 ? void 0 : scr.analise) === null || _a === void 0 ? void 0 : _a.detalhamento)) {
64
- return [];
65
- }
66
- var _d = getVencidosEAvencer(scr.analise.detalhamento), avencer = _d.avencer, vencido = _d.vencido;
67
- return __spreadArray(__spreadArray(__spreadArray([
68
- {
69
- descricao: 'A Vencer',
70
- valor: formatMoney(((_b = scr.analise.total) === null || _b === void 0 ? void 0 : _b.aVencer) || 0)
71
- }
72
- ], avencer, true), [
73
- {
74
- descricao: 'Vencido',
75
- valor: formatMoney(((_c = scr.analise.total) === null || _c === void 0 ? void 0 : _c.vencido) || 0)
76
- }
77
- ], false), vencido, true);
78
- };
79
- export default getResumoDeCreditos;
@@ -1,8 +0,0 @@
1
- import { SCRQuery } from '../../@types/domain';
2
- declare function getResumoDeModalidades(scr: SCRQuery): {
3
- modalidade: string;
4
- vencido: number;
5
- aVencer: number;
6
- valor: number;
7
- }[];
8
- export default getResumoDeModalidades;
@@ -1,109 +0,0 @@
1
- var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
2
- if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
3
- if (ar || !(i in from)) {
4
- if (!ar) ar = Array.prototype.slice.call(from, 0, i);
5
- ar[i] = from[i];
6
- }
7
- }
8
- return to.concat(ar || Array.prototype.slice.call(from));
9
- };
10
- import { sum } from '../../utils/number';
11
- import * as _ from 'underscore';
12
- function getResumoDeModalidades(scr) {
13
- var _a, _b, _c;
14
- if (!((_a = scr === null || scr === void 0 ? void 0 : scr.analise) === null || _a === void 0 ? void 0 : _a.detalhamento)) {
15
- return [];
16
- }
17
- var agruparPorTitulo = function (detalhamento) {
18
- return _.groupBy(detalhamento, function (_a) {
19
- var modalidade = _a.modalidade;
20
- return (modalidade === null || modalidade === void 0 ? void 0 : modalidade.titulo) || 'Indefinido';
21
- });
22
- };
23
- var agruparPorTituloESubtitulo = function (detalhamento) {
24
- return Object.fromEntries(Object.entries(detalhamento).map(function (_a) {
25
- var key = _a[0], values = _a[1];
26
- return [
27
- key,
28
- Object.entries(_.groupBy(values, function (_a) {
29
- var modalidade = _a.modalidade;
30
- return modalidade === null || modalidade === void 0 ? void 0 : modalidade.subtitulo;
31
- })).map(function (_a) {
32
- var _b;
33
- var subtitulo = _a[0], detalhes = _a[1];
34
- return ({
35
- subtitulo: subtitulo,
36
- variacaoCambial: (_b = detalhes === null || detalhes === void 0 ? void 0 : detalhes.find(function (e) { return e === null || e === void 0 ? void 0 : e.variacaoCambial; })) === null || _b === void 0 ? void 0 : _b.variacaoCambial,
37
- valor: detalhes
38
- .map(function (detalhe) { return detalhe === null || detalhe === void 0 ? void 0 : detalhe.vencimentos; })
39
- .flat()
40
- .reduce(function (a, b) { return a + Number(b === null || b === void 0 ? void 0 : b.valor); }, 0),
41
- vencimentos: detalhes === null || detalhes === void 0 ? void 0 : detalhes.map(function (detalhe) { return detalhe === null || detalhe === void 0 ? void 0 : detalhe.vencimentos; }).flat()
42
- });
43
- })
44
- ];
45
- }));
46
- };
47
- var modalidades = agruparPorTituloESubtitulo(agruparPorTitulo((_b = scr === null || scr === void 0 ? void 0 : scr.analise) === null || _b === void 0 ? void 0 : _b.detalhamento));
48
- var resumoDeOperacoes = ((_c = scr === null || scr === void 0 ? void 0 : scr.listaDeResumoDasOperacoes) === null || _c === void 0 ? void 0 : _c.filter(function (_a) {
49
- var modalidade = _a.modalidade;
50
- return /^(19)/.test(modalidade);
51
- })) || [];
52
- var COD_LIMIT = {
53
- 1901: 'Limite global',
54
- 1902: 'Cheque especial',
55
- 1903: 'Conta garantida',
56
- 1904: 'Cartão de Crédito',
57
- 1905: 'Capital de giro',
58
- 1906: 'Crédito pessoal',
59
- 1907: 'Vendor',
60
- 1908: 'Compror',
61
- 1909: 'Descontos',
62
- 1910: 'Aquisição de bens',
63
- 1999: 'Outros'
64
- };
65
- var limite = resumoDeOperacoes.flatMap(function (_a) {
66
- var _b, _c;
67
- var modalidade = _a.modalidade, listaDeVencimentos = _a.listaDeVencimentos, variacaoCambial = _a.variacaoCambial;
68
- var sumSalaries = sum(listaDeVencimentos === null || listaDeVencimentos === void 0 ? void 0 : listaDeVencimentos.map(function (e) { return Number(e === null || e === void 0 ? void 0 : e.valorVencimento); }));
69
- return (((_c = (_b = modalidades.Limite) === null || _b === void 0 ? void 0 : _b.filter(function (r) { return sumSalaries === (r === null || r === void 0 ? void 0 : r.valor); })) === null || _c === void 0 ? void 0 : _c.map(function (r) {
70
- var _a;
71
- return ({
72
- subtitulo: (r === null || r === void 0 ? void 0 : r.subtitulo) || COD_LIMIT[modalidade] || 'Indefinido',
73
- vencimentos: r === null || r === void 0 ? void 0 : r.vencimentos,
74
- variacaoCambial: (_a = r === null || r === void 0 ? void 0 : r.variacaoCambial) !== null && _a !== void 0 ? _a : variacaoCambial,
75
- valor: r === null || r === void 0 ? void 0 : r.valor
76
- });
77
- })) || []);
78
- });
79
- modalidades.Limite = limite;
80
- var sumVencimentos = function (vencimentos, tipo) {
81
- return sum(vencimentos.filter(function (e) { return (e === null || e === void 0 ? void 0 : e.categoria) === tipo; }).map(function (e) { return Number(e.valor); }));
82
- };
83
- return Object.entries(modalidades).flatMap(function (_a) {
84
- var _b;
85
- var modalidade = _a[0], subcategorias = _a[1];
86
- return __spreadArray([
87
- {
88
- modalidade: "".concat(modalidade, " (Cambial: ").concat(((_b = subcategorias === null || subcategorias === void 0 ? void 0 : subcategorias[0]) === null || _b === void 0 ? void 0 : _b.variacaoCambial) || 'Não', ")"),
89
- vencido: sumVencimentos(subcategorias.flatMap(function (s) { return s.vencimentos; }), 'vencido'),
90
- aVencer: sumVencimentos(subcategorias.flatMap(function (s) { return s.vencimentos; }), 'avencer'),
91
- valor: sum(subcategorias.map(function (s) { return s.valor; }))
92
- }
93
- ], subcategorias.flatMap(function (subcategoria) { return __spreadArray([
94
- {
95
- modalidade: subcategoria.subtitulo,
96
- valor: subcategoria.valor
97
- }
98
- ], subcategoria.vencimentos.map(function (vencimento) {
99
- var _a;
100
- return ({
101
- modalidade: !/^Limite/.test(modalidade)
102
- ? "Cr\u00E9ditos ".concat((_a = vencimento === null || vencimento === void 0 ? void 0 : vencimento.descricao) === null || _a === void 0 ? void 0 : _a.toLowerCase())
103
- : vencimento === null || vencimento === void 0 ? void 0 : vencimento.descricao,
104
- valor: vencimento === null || vencimento === void 0 ? void 0 : vencimento.valor
105
- });
106
- }), true); }), true);
107
- });
108
- }
109
- export default getResumoDeModalidades;