flit-modulo-exportacoes 2.0.30 → 2.0.32

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.
Files changed (38) hide show
  1. package/dist/dao/contas-elastic.js +36 -0
  2. package/dist/dao/elastic-base.js +38 -0
  3. package/dist/dao/empresas-elastic.js +42 -0
  4. package/dist/dao/empresas-feriado-elastic.js +43 -0
  5. package/dist/dao/eventos-exportacoes-elastic.js +45 -0
  6. package/dist/dao/feriados-elastic.js +56 -0
  7. package/dist/dao/jornadas-elastic.js +85 -0
  8. package/dist/dao/usuarios-elastic.js +35 -0
  9. package/dist/eventos-exportacoes-model.d.ts +49 -0
  10. package/dist/eventos-exportacoes-model.js +19 -0
  11. package/{lib → dist}/index.d.ts +1 -2
  12. package/dist/index.js +458 -0
  13. package/{lib → dist}/models.d.ts +0 -49
  14. package/{lib → dist}/models.js +4 -20
  15. package/{lib → dist}/unificacao-eventos-repetidos.js +63 -94
  16. package/dist/utils.js +244 -0
  17. package/package.json +13 -12
  18. package/tslint.json +118 -0
  19. package/lib/dao/contas-elastic.js +0 -110
  20. package/lib/dao/elastic-base.js +0 -110
  21. package/lib/dao/empresas-elastic.js +0 -116
  22. package/lib/dao/empresas-feriado-elastic.js +0 -119
  23. package/lib/dao/eventos-exportacoes-elastic.js +0 -122
  24. package/lib/dao/feriados-elastic.js +0 -132
  25. package/lib/dao/jornadas-elastic.js +0 -163
  26. package/lib/dao/usuarios-elastic.js +0 -109
  27. package/lib/index.js +0 -523
  28. package/lib/utils.js +0 -301
  29. /package/{lib → dist}/dao/contas-elastic.d.ts +0 -0
  30. /package/{lib → dist}/dao/elastic-base.d.ts +0 -0
  31. /package/{lib → dist}/dao/empresas-elastic.d.ts +0 -0
  32. /package/{lib → dist}/dao/empresas-feriado-elastic.d.ts +0 -0
  33. /package/{lib → dist}/dao/eventos-exportacoes-elastic.d.ts +0 -0
  34. /package/{lib → dist}/dao/feriados-elastic.d.ts +0 -0
  35. /package/{lib → dist}/dao/jornadas-elastic.d.ts +0 -0
  36. /package/{lib → dist}/dao/usuarios-elastic.d.ts +0 -0
  37. /package/{lib → dist}/unificacao-eventos-repetidos.d.ts +0 -0
  38. /package/{lib → dist}/utils.d.ts +0 -0
@@ -0,0 +1,36 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ContasElastic = void 0;
4
+ const elastic_base_1 = require("./elastic-base");
5
+ class ContasElastic extends elastic_base_1.ElasticBase {
6
+ async internalGetContasElastic(contaId) {
7
+ return await this.elasticClient.search({
8
+ scroll: '1m',
9
+ index: 'contas',
10
+ size: this.totalRegistrosFiltradosElastic,
11
+ _source: [
12
+ 'parametros.horario_noturno'
13
+ ],
14
+ query: {
15
+ bool: {
16
+ must: [{
17
+ match: {
18
+ i_id: contaId
19
+ }
20
+ }, {
21
+ match: {
22
+ excluido: false
23
+ }
24
+ }]
25
+ }
26
+ },
27
+ sort: [{
28
+ i_id: 'asc'
29
+ }]
30
+ });
31
+ }
32
+ async getContaElastic(contaId) {
33
+ return (await this.retornaTodosDadosPaginacaoElastic(await this.internalGetContasElastic(contaId)))[0];
34
+ }
35
+ }
36
+ exports.ContasElastic = ContasElastic;
@@ -0,0 +1,38 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ElasticBase = void 0;
4
+ class ElasticBase {
5
+ elasticClient;
6
+ totalRegistrosFiltradosElastic = 500;
7
+ constructor(elasticClient) {
8
+ this.elasticClient = elasticClient;
9
+ }
10
+ async searchScrollObjectElastic(scrollId) {
11
+ return await this.elasticClient.scroll({
12
+ scroll: '1m',
13
+ scroll_id: scrollId
14
+ });
15
+ }
16
+ async adicionarRegistrosPaginacaoElastic({ scrollId, retorno }) {
17
+ let objetosPaginacao = await this.searchScrollObjectElastic(scrollId);
18
+ while ((objetosPaginacao?.hits?.hits ?? []).length > 0) {
19
+ (objetosPaginacao?.hits?.hits ?? []).forEach(objeto => retorno.push(objeto));
20
+ objetosPaginacao = await this.searchScrollObjectElastic(scrollId);
21
+ }
22
+ }
23
+ async retornaTodosDadosPaginacaoElastic(filtroInicial) {
24
+ const retorno = new Array();
25
+ (filtroInicial?.hits?.hits ?? []).forEach(objeto => retorno.push(objeto));
26
+ if (filtroInicial?._scroll_id) {
27
+ if ((filtroInicial?.hits?.total ?? 0) > this.totalRegistrosFiltradosElastic) {
28
+ await this.adicionarRegistrosPaginacaoElastic({
29
+ retorno: retorno,
30
+ scrollId: filtroInicial?._scroll_id
31
+ });
32
+ }
33
+ await this.elasticClient.clearScroll({ scroll_id: filtroInicial?._scroll_id });
34
+ }
35
+ return retorno;
36
+ }
37
+ }
38
+ exports.ElasticBase = ElasticBase;
@@ -0,0 +1,42 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.EmpresasElastic = void 0;
4
+ const elastic_base_1 = require("./elastic-base");
5
+ class EmpresasElastic extends elastic_base_1.ElasticBase {
6
+ async internalGetEmpresasElastic(contaId) {
7
+ return await this.elasticClient.search({
8
+ scroll: '1m',
9
+ index: 'contas_empresas',
10
+ size: this.totalRegistrosFiltradosElastic,
11
+ _source: [
12
+ 'i_id',
13
+ 'cnpj',
14
+ 'razao',
15
+ 'fantasia',
16
+ 'endereco.uf',
17
+ 'endereco.cidade',
18
+ 'parametros.codigo_externo'
19
+ ],
20
+ query: {
21
+ bool: {
22
+ must: [{
23
+ match: {
24
+ i_parent_id: contaId
25
+ }
26
+ }, {
27
+ match: {
28
+ excluido: false
29
+ }
30
+ }]
31
+ }
32
+ },
33
+ sort: [{
34
+ i_id: 'asc'
35
+ }]
36
+ });
37
+ }
38
+ async getEmpresasElastic(contaId) {
39
+ return await this.retornaTodosDadosPaginacaoElastic(await this.internalGetEmpresasElastic(contaId));
40
+ }
41
+ }
42
+ exports.EmpresasElastic = EmpresasElastic;
@@ -0,0 +1,43 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.EmpresasFeriadoElastic = void 0;
4
+ const elastic_base_1 = require("./elastic-base");
5
+ class EmpresasFeriadoElastic extends elastic_base_1.ElasticBase {
6
+ async internalGeEmpresasFeriadoElastic({ empresaId, feriadoId }) {
7
+ return await this.elasticClient.search({
8
+ scroll: '1m',
9
+ index: 'contas_feriados_empresasferiado',
10
+ size: this.totalRegistrosFiltradosElastic,
11
+ _source: [
12
+ 'i_id'
13
+ ],
14
+ query: {
15
+ bool: {
16
+ must: [{
17
+ match: {
18
+ i_parent_id: feriadoId
19
+ }
20
+ }, {
21
+ match: {
22
+ 'ref.i_id': empresaId
23
+ }
24
+ }, {
25
+ match: {
26
+ excluido: false
27
+ }
28
+ }]
29
+ }
30
+ },
31
+ sort: [{
32
+ i_id: 'asc'
33
+ }]
34
+ });
35
+ }
36
+ async getEmpresasFeriadoElastic({ empresaId, feriadoId }) {
37
+ return await this.retornaTodosDadosPaginacaoElastic(await this.internalGeEmpresasFeriadoElastic({
38
+ empresaId: empresaId,
39
+ feriadoId: feriadoId
40
+ }));
41
+ }
42
+ }
43
+ exports.EmpresasFeriadoElastic = EmpresasFeriadoElastic;
@@ -0,0 +1,45 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.EventosExportacoesElastic = void 0;
4
+ const elastic_base_1 = require("./elastic-base");
5
+ class EventosExportacoesElastic extends elastic_base_1.ElasticBase {
6
+ async internalGetEventosExportacoesElastic({ contaId, tabelaEventosId }) {
7
+ return await this.elasticClient.search({
8
+ scroll: '1m',
9
+ index: 'contas_eventosexportacoes',
10
+ size: this.totalRegistrosFiltradosElastic,
11
+ _source: [
12
+ 'eventos',
13
+ 'forma_envio_faltas'
14
+ ],
15
+ query: {
16
+ bool: {
17
+ must: [{
18
+ match: {
19
+ i_parent_id: contaId
20
+ }
21
+ }, {
22
+ match: {
23
+ i_id: tabelaEventosId
24
+ }
25
+ }, {
26
+ match: {
27
+ excluido: false
28
+ }
29
+ }]
30
+ }
31
+ },
32
+ sort: [{
33
+ i_id: 'asc'
34
+ }]
35
+ });
36
+ }
37
+ async getEventosExportacoesElastic({ contaId, tabelaEventosId }) {
38
+ const retorno = await this.retornaTodosDadosPaginacaoElastic(await this.internalGetEventosExportacoesElastic({
39
+ contaId: contaId,
40
+ tabelaEventosId: tabelaEventosId
41
+ }));
42
+ return retorno[0];
43
+ }
44
+ }
45
+ exports.EventosExportacoesElastic = EventosExportacoesElastic;
@@ -0,0 +1,56 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.FeriadosElastic = void 0;
7
+ const moment_1 = __importDefault(require("moment"));
8
+ const elastic_base_1 = require("./elastic-base");
9
+ class FeriadosElastic extends elastic_base_1.ElasticBase {
10
+ async internalGetFeriadosElastic({ contaId, dataFinal, dataInicial }) {
11
+ return await this.elasticClient.search({
12
+ scroll: '1m',
13
+ index: 'contas_feriados',
14
+ size: this.totalRegistrosFiltradosElastic,
15
+ _source: [
16
+ 'uf',
17
+ 'i_id',
18
+ 'tipo',
19
+ 'data',
20
+ 'municipio',
21
+ 'todas_empresas'
22
+ ],
23
+ query: {
24
+ bool: {
25
+ must: [{
26
+ match: {
27
+ i_parent_id: contaId
28
+ }
29
+ }, {
30
+ match: {
31
+ excluido: false
32
+ }
33
+ }, {
34
+ range: {
35
+ data: {
36
+ gte: (0, moment_1.default)(dataInicial).format('YYYY-MM-DDTHH:mm:ss.SSS'),
37
+ lte: (0, moment_1.default)(dataFinal).format('YYYY-MM-DDTHH:mm:ss.SSS')
38
+ }
39
+ }
40
+ }]
41
+ }
42
+ },
43
+ sort: [{
44
+ data: 'asc'
45
+ }]
46
+ });
47
+ }
48
+ async getFeriadosElastic({ contaId, dataFinal, dataInicial }) {
49
+ return await this.retornaTodosDadosPaginacaoElastic(await this.internalGetFeriadosElastic({
50
+ contaId: contaId,
51
+ dataFinal: dataFinal,
52
+ dataInicial: dataInicial
53
+ }));
54
+ }
55
+ }
56
+ exports.FeriadosElastic = FeriadosElastic;
@@ -0,0 +1,85 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.JornadasElastic = void 0;
7
+ const moment_1 = __importDefault(require("moment"));
8
+ const elastic_base_1 = require("./elastic-base");
9
+ class JornadasElastic extends elastic_base_1.ElasticBase {
10
+ async internalGetJornadasElastic({ fim, inicio, contaId, empresaId, usuarioId }) {
11
+ const queryMust = new Array();
12
+ queryMust.push({
13
+ match: {
14
+ i_parent_id: contaId
15
+ }
16
+ });
17
+ queryMust.push({
18
+ match: {
19
+ 'usuario.empresa.uid': empresaId
20
+ }
21
+ });
22
+ if (usuarioId) {
23
+ queryMust.push({
24
+ match: {
25
+ 'usuario.uid': usuarioId
26
+ }
27
+ });
28
+ }
29
+ queryMust.push({
30
+ range: {
31
+ data_hora: {
32
+ gte: (0, moment_1.default)(inicio).format('YYYY-MM-DDTHH:mm:ss.SSS'),
33
+ lte: (0, moment_1.default)(fim).format('YYYY-MM-DDTHH:mm:ss.SSS')
34
+ }
35
+ }
36
+ });
37
+ return await this.elasticClient.search({
38
+ scroll: '1m',
39
+ index: 'contas_jornadas',
40
+ size: this.totalRegistrosFiltradosElastic,
41
+ _source: [
42
+ 'data_hora',
43
+ 'usuario.uid',
44
+ 'usuario.cpf',
45
+ 'usuario.pis',
46
+ 'horas_extras',
47
+ 'horas_normais',
48
+ 'horas_noturnas',
49
+ 'horas_negativas',
50
+ 'jornada_prevista',
51
+ 'jornada_realizada',
52
+ 'regime_compensacao',
53
+ 'usuario.cargo.nome',
54
+ 'usuario.empresa.uf',
55
+ 'faixas_horas_extras',
56
+ 'usuario.empresa.uid',
57
+ 'marcacoes_ignoradas',
58
+ 'usuario.empresa.cnpj',
59
+ 'horas_noturnas_extras',
60
+ 'usuario.empresa.cidade',
61
+ 'horas_extras_intrajornada',
62
+ 'usuario.parametros.codigo_externo',
63
+ 'usuario.empresa.parametros.codigo_externo'
64
+ ],
65
+ query: {
66
+ bool: {
67
+ must: queryMust
68
+ }
69
+ },
70
+ sort: [{
71
+ data_hora: 'asc'
72
+ }]
73
+ });
74
+ }
75
+ async getJornadasElastic({ contaId, dataFinal, usuarioId, empresaId, dataInicial }) {
76
+ return await this.retornaTodosDadosPaginacaoElastic(await this.internalGetJornadasElastic({
77
+ fim: dataFinal,
78
+ contaId: contaId,
79
+ inicio: dataInicial,
80
+ empresaId: empresaId,
81
+ usuarioId: usuarioId
82
+ }));
83
+ }
84
+ }
85
+ exports.JornadasElastic = JornadasElastic;
@@ -0,0 +1,35 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.UsuariosElastic = void 0;
4
+ const elastic_base_1 = require("./elastic-base");
5
+ class UsuariosElastic extends elastic_base_1.ElasticBase {
6
+ async internalGetUsuariosElastic(idsUsuarios) {
7
+ return await this.elasticClient.search({
8
+ scroll: '1m',
9
+ index: 'usuarios',
10
+ size: this.totalRegistrosFiltradosElastic,
11
+ _source: [
12
+ 'pis',
13
+ 'cpf',
14
+ 'i_id',
15
+ 'parametros.codigo_externo'
16
+ ],
17
+ query: {
18
+ bool: {
19
+ filter: {
20
+ terms: {
21
+ i_id: idsUsuarios
22
+ }
23
+ }
24
+ }
25
+ },
26
+ sort: [{
27
+ i_id: 'asc'
28
+ }]
29
+ });
30
+ }
31
+ async getUsuariosElastic(idsUsuarios) {
32
+ return await this.retornaTodosDadosPaginacaoElastic(await this.internalGetUsuariosElastic(idsUsuarios));
33
+ }
34
+ }
35
+ exports.UsuariosElastic = UsuariosElastic;
@@ -0,0 +1,49 @@
1
+ export declare enum EnumTipoEventosExportacoes {
2
+ Dexion = "DEXION",
3
+ Dominio = "DOMINIO",
4
+ Najason = "NAJASON",
5
+ Prosoft = "PROSOFT",
6
+ Questor = "QUESTOR",
7
+ NetSpeed = "NETSPEED",
8
+ Alterdata = "ALTERDATA"
9
+ }
10
+ export declare enum EnumFormaEnvioFaltasEventosExportacoes {
11
+ Dias = "DIAS",
12
+ Horas = "HORAS",
13
+ Minutos = "MINUTOS"
14
+ }
15
+ export type PropsCodigosEventosExportacoes<T = any> = {
16
+ [Property in keyof CodigosEventosExportacoes]: T;
17
+ };
18
+ export interface EventosExportacoes {
19
+ excluido: boolean;
20
+ descricao: string;
21
+ tipo: EnumTipoEventosExportacoes;
22
+ eventos: CodigosEventosExportacoes;
23
+ forma_envio_faltas: EnumFormaEnvioFaltasEventosExportacoes;
24
+ }
25
+ interface CodigosEventosExportacoes {
26
+ falta: string;
27
+ atraso: string;
28
+ hora_normal?: string;
29
+ horas_trabalhadas?: string;
30
+ hora_extra: string;
31
+ hora_extra_sabado?: string;
32
+ hora_extra_feriado: string;
33
+ hora_extra_domingo?: string;
34
+ hora_extra_noturna: string;
35
+ hora_extra_noturna_sabado?: string;
36
+ hora_extra_noturna_feriado: string;
37
+ hora_extra_noturna_domingo?: string;
38
+ hora_extra_intrajornada?: string;
39
+ hora_extra_intrajornada_com_reducao?: string;
40
+ hora_noturna: string;
41
+ horas_noturnas_totais?: string;
42
+ faixa_hora_extra_semanal_1?: string;
43
+ faixa_hora_extra_semanal_2?: string;
44
+ faixa_hora_extra_semanal_3?: string;
45
+ faixa_hora_extra_diferenciada_1?: string;
46
+ faixa_hora_extra_diferenciada_2?: string;
47
+ faixa_hora_extra_diferenciada_3?: string;
48
+ }
49
+ export {};
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.EnumFormaEnvioFaltasEventosExportacoes = exports.EnumTipoEventosExportacoes = void 0;
4
+ var EnumTipoEventosExportacoes;
5
+ (function (EnumTipoEventosExportacoes) {
6
+ EnumTipoEventosExportacoes["Dexion"] = "DEXION";
7
+ EnumTipoEventosExportacoes["Dominio"] = "DOMINIO";
8
+ EnumTipoEventosExportacoes["Najason"] = "NAJASON";
9
+ EnumTipoEventosExportacoes["Prosoft"] = "PROSOFT";
10
+ EnumTipoEventosExportacoes["Questor"] = "QUESTOR";
11
+ EnumTipoEventosExportacoes["NetSpeed"] = "NETSPEED";
12
+ EnumTipoEventosExportacoes["Alterdata"] = "ALTERDATA";
13
+ })(EnumTipoEventosExportacoes = exports.EnumTipoEventosExportacoes || (exports.EnumTipoEventosExportacoes = {}));
14
+ var EnumFormaEnvioFaltasEventosExportacoes;
15
+ (function (EnumFormaEnvioFaltasEventosExportacoes) {
16
+ EnumFormaEnvioFaltasEventosExportacoes["Dias"] = "DIAS";
17
+ EnumFormaEnvioFaltasEventosExportacoes["Horas"] = "HORAS";
18
+ EnumFormaEnvioFaltasEventosExportacoes["Minutos"] = "MINUTOS";
19
+ })(EnumFormaEnvioFaltasEventosExportacoes = exports.EnumFormaEnvioFaltasEventosExportacoes || (exports.EnumFormaEnvioFaltasEventosExportacoes = {}));
@@ -1,6 +1,6 @@
1
1
  import { Client } from '@elastic/elasticsearch';
2
2
  import { SearchHit } from '@elastic/elasticsearch/lib/api/types';
3
- import { PayloadExportacaoPadrao, TipoEventoExportacao, TiposEventosExportacaoArquivo, TiposEventosExportar, ValoresEventosExportacao, ValorEventoExportacao, ValorEventoExportacaoFalta, DadosEmpresaExportacao, EnumFormaEnvioFaltasEventosExportacoes, EnumTipoEventosExportacoes, EventosExportacoes, PropsCodigosEventosExportacoes, TipoFolhaExportacao } from './models';
3
+ import { PayloadExportacaoPadrao, TipoEventoExportacao, TiposEventosExportacaoArquivo, TiposEventosExportar, ValoresEventosExportacao, ValorEventoExportacao, ValorEventoExportacaoFalta } from './models';
4
4
  export declare function validarDadosPayload({ fn, data, validarCampoReferencia }: {
5
5
  fn: () => Array<string>;
6
6
  data: PayloadExportacaoPadrao;
@@ -17,4 +17,3 @@ export declare function calcularValoresExportacao({ contaId, dataFinal, dataInic
17
17
  }): Promise<ValoresEventosExportacao>;
18
18
  export declare function retornaValorEvento(tipoEvento: TipoEventoExportacao, valoresEventos: ValoresEventosExportacao): ValorEventoExportacao | ValorEventoExportacaoFalta;
19
19
  export declare function processarTiposEventosExportar(tiposEventos: Array<TiposEventosExportar>): TiposEventosExportacaoArquivo;
20
- export { PayloadExportacaoPadrao, TipoEventoExportacao, TiposEventosExportacaoArquivo, TiposEventosExportar, ValoresEventosExportacao, ValorEventoExportacao, ValorEventoExportacaoFalta, DadosEmpresaExportacao, EnumFormaEnvioFaltasEventosExportacoes, EnumTipoEventosExportacoes, EventosExportacoes, PropsCodigosEventosExportacoes, TipoFolhaExportacao, };