flit-modulo-exportacoes 2.0.88 → 2.0.89

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/index.d.ts CHANGED
@@ -1,6 +1,5 @@
1
1
  import { Client } from '@elastic/elasticsearch';
2
2
  import { SourceConta } from './dao/model/conta-model';
3
- import { SourceEmpresa } from './dao/model/empresa-model';
4
3
  import { SourceJornada } from './dao/model/jornada-model';
5
4
  import { SearchHit } from '@elastic/elasticsearch/lib/api/types';
6
5
  import { PayloadExportacaoPadrao, TipoEventoExportacao, TiposEventosExportar, ValoresEventosExportacao, ValorEventoExportacao, ValorEventoExportacaoFalta } from './dao/model/general-models';
@@ -9,13 +8,10 @@ export declare function validarDadosPayload({ fn, data, validarCampoReferencia }
9
8
  data: PayloadExportacaoPadrao;
10
9
  validarCampoReferencia: boolean;
11
10
  }): boolean;
12
- export declare function calcularValoresExportacao({ contaId, dataFinal, dataInicial, elasticClient, conta, empresas, jornadas, eventosExportacao, parametrosIntegracao }: {
11
+ export declare function calcularValoresExportacao({ contaId, elasticClient, conta, jornadas, eventosExportacao, parametrosIntegracao }: {
13
12
  contaId: string;
14
- dataFinal: Date;
15
- dataInicial: Date;
16
13
  elasticClient: Client;
17
14
  conta?: SearchHit<SourceConta>;
18
- empresas: Array<SearchHit<SourceEmpresa>>;
19
15
  jornadas: Array<SearchHit<SourceJornada>>;
20
16
  eventosExportacao: Array<TipoEventoExportacao>;
21
17
  parametrosIntegracao: {
package/dist/index.js CHANGED
@@ -2,7 +2,6 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.processarTiposEventosExportacao = exports.retornaValorEvento = exports.calcularValoresExportacao = exports.validarDadosPayload = void 0;
4
4
  const contas_elastic_1 = require("./dao/contas-elastic");
5
- const feriados_elastic_1 = require("./dao/feriados-elastic");
6
5
  const unificacao_eventos_repetidos_1 = require("./unificacao-eventos-repetidos");
7
6
  const utils_1 = require("flit-calcular-jornada/dist/lib/helpers/utils");
8
7
  const jornada_model_1 = require("flit-calcular-jornada/dist/lib/models/jornada.model");
@@ -220,12 +219,7 @@ function aplicarFatorConversaoValoresEventos(valoresEventos) {
220
219
  function exportarHorasExtrasEvento({ tipoEventoExportacao, eventosExportacao, parametrosIntegracao }) {
221
220
  return Boolean((parametrosIntegracao ?? {})[tipoEventoExportacao]) && eventosExportacao.includes(tipoEventoExportacao);
222
221
  }
223
- async function calcularValoresExportacao({ contaId, dataFinal, dataInicial, elasticClient, conta, empresas, jornadas, eventosExportacao, parametrosIntegracao }) {
224
- const feriados = await new feriados_elastic_1.FeriadosElastic(elasticClient).getFeriadosElastic({
225
- contaId: contaId,
226
- dataFinal: dataFinal,
227
- dataInicial: dataInicial
228
- });
222
+ async function calcularValoresExportacao({ contaId, elasticClient, conta, jornadas, eventosExportacao, parametrosIntegracao }) {
229
223
  let dadosConta = conta ?? null;
230
224
  if (!dadosConta) {
231
225
  dadosConta = await new contas_elastic_1.ContasElastic(elasticClient).getContaElastic(contaId);
@@ -460,17 +454,7 @@ async function calcularValoresExportacao({ contaId, dataFinal, dataInicial, elas
460
454
  valoresEventos.FaixaHibrida.ValorFaixa8.Minutos += (jornada.faixas_horas_extras?.hibrida?.faixa8 ?? 0) * 60;
461
455
  valoresEventos.FaixaHibrida.ValorFaixa9.Horas += jornada.faixas_horas_extras?.hibrida?.faixa9 ?? 0;
462
456
  valoresEventos.FaixaHibrida.ValorFaixa9.Minutos += (jornada.faixas_horas_extras?.hibrida?.faixa9 ?? 0) * 60;
463
- const jornadaFeriado = await (0, utils_2.feriado)({
464
- empresas: empresas,
465
- feriados: feriados,
466
- elasticClient: elasticClient,
467
- dataHoraJornada: new Date(jornada.data_hora),
468
- ufEmpresaUsuarioJornada: jornada.usuario.empresa.uf,
469
- idEmpresaUsuarioJornada: jornada.usuario.empresa.uid,
470
- idDepartamentoUsuario: jornada.usuario.departamento?.uid,
471
- cidadeEmpresaUsuarioJornada: jornada.usuario.empresa.cidade,
472
- tipoOcorrenciaFrequenciaJornadaPrevista: jornada.jornada_prevista?.ocorrencia_frequencia?.tipo ?? ''
473
- });
457
+ const jornadaFeriado = (0, utils_2.feriado)(jornada.jornada_prevista?.ocorrencia_frequencia?.tipo ?? '');
474
458
  if ((jornada.jornada_realizada?.periodos ?? []).length > 0) {
475
459
  if (jornadaFeriado) {
476
460
  valoresEventos.DiasTrabalhadosFeriados.push(new Date(jornada.data_hora));
package/dist/utils.d.ts CHANGED
@@ -1,27 +1,15 @@
1
- import { Client } from '@elastic/elasticsearch';
2
1
  import { SourceEmpresa } from './dao/model/empresa-model';
3
- import { SourceFeriado } from './dao/model/feriado-model';
4
2
  import { SourceUsuario } from './dao/model/usuario-model';
5
3
  import { SourceJornada } from './dao/model/jornada-model';
6
- import { SearchHit } from '@elastic/elasticsearch/lib/api/types';
7
4
  import { DadosIntegracao } from './dao/model/general-models';
5
+ import { SearchHit } from '@elastic/elasticsearch/lib/api/types';
8
6
  import { JornadaPrevistaOuRealizada, PeriodoJornada } from 'flit-calcular-jornada/dist/lib/models/jornada.model';
9
7
  import { EnumParametrosTipoHorarioNoturno } from 'flit-calcular-jornada/dist/lib/models/parametrosHorasNoturnas.model';
10
8
  export declare function arredondarTempoDecimal(tempoDecimal: number, minutosArred: number): number;
11
9
  export declare function colaboradorFaltou(jornadaRealizada?: JornadaPrevistaOuRealizada): boolean;
12
10
  export declare function sabado(data: Date): boolean;
13
11
  export declare function domingo(data: Date): boolean;
14
- export declare function feriado({ elasticClient, dataHoraJornada, idDepartamentoUsuario, idEmpresaUsuarioJornada, ufEmpresaUsuarioJornada, cidadeEmpresaUsuarioJornada, empresas, feriados, tipoOcorrenciaFrequenciaJornadaPrevista }: {
15
- elasticClient: Client;
16
- dataHoraJornada: Date;
17
- idDepartamentoUsuario?: string;
18
- idEmpresaUsuarioJornada: string;
19
- ufEmpresaUsuarioJornada: string;
20
- cidadeEmpresaUsuarioJornada: string;
21
- empresas: Array<SearchHit<SourceEmpresa>>;
22
- feriados: Array<SearchHit<SourceFeriado>>;
23
- tipoOcorrenciaFrequenciaJornadaPrevista: string;
24
- }): Promise<boolean>;
12
+ export declare function feriado(tipoOcorrenciaFrequenciaJornadaPrevista: string): boolean;
25
13
  export declare function retornaNumeroMinutosPrevistosEscala(periodosJornadaPrevista: PeriodoJornada[]): number;
26
14
  export declare function retornaListaUsuariosJornadas(jornadas: Array<SearchHit<SourceJornada>>): Array<string>;
27
15
  export declare function getEnumParametrosTipoHorarioNoturno(tipoHorarioNoturno?: string): EnumParametrosTipoHorarioNoturno;
package/dist/utils.js CHANGED
@@ -5,7 +5,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.getDadosCadastraisExportacao = exports.getEnumParametrosTipoHorarioNoturno = exports.retornaListaUsuariosJornadas = exports.retornaNumeroMinutosPrevistosEscala = exports.feriado = exports.domingo = exports.sabado = exports.colaboradorFaltou = exports.arredondarTempoDecimal = void 0;
7
7
  const moment_1 = __importDefault(require("moment"));
8
- const empresas_feriado_elastic_1 = require("./dao/empresas-feriado-elastic");
9
8
  const parametrosHorasNoturnas_model_1 = require("flit-calcular-jornada/dist/lib/models/parametrosHorasNoturnas.model");
10
9
  function arredondarTempoDecimal(tempoDecimal, minutosArred) {
11
10
  return (Math.round((tempoDecimal * 60) / minutosArred) * minutosArred) / 60;
@@ -26,95 +25,8 @@ function domingo(data) {
26
25
  return data.getDay() === 0;
27
26
  }
28
27
  exports.domingo = domingo;
29
- function getDadosEmpresa({ idEmpresaUsuarioJornada, ufEmpresaUsuarioJornada, cidadeEmpresaUsuarioJornada, empresas }) {
30
- if (ufEmpresaUsuarioJornada && cidadeEmpresaUsuarioJornada) {
31
- return {
32
- id: idEmpresaUsuarioJornada ?? '',
33
- endereco: {
34
- uf: ufEmpresaUsuarioJornada ?? '',
35
- cidade: cidadeEmpresaUsuarioJornada ?? ''
36
- }
37
- };
38
- }
39
- else {
40
- const empresaFiltrada = (empresas ?? []).filter(e => e._source?.i_id === idEmpresaUsuarioJornada);
41
- if (empresaFiltrada.length > 0) {
42
- return {
43
- id: idEmpresaUsuarioJornada ?? '',
44
- endereco: {
45
- uf: empresaFiltrada[0]?._source?.endereco?.uf ?? '',
46
- cidade: empresaFiltrada[0]?._source?.endereco?.cidade ?? ''
47
- }
48
- };
49
- }
50
- else {
51
- return {
52
- id: idEmpresaUsuarioJornada ?? '',
53
- endereco: {
54
- uf: '',
55
- cidade: ''
56
- }
57
- };
58
- }
59
- }
60
- }
61
- function validarDepartamentoFeriado({ idDepartamentoUsuario, idsDepartamentosFeriado }) {
62
- return (!idDepartamentoUsuario) ||
63
- ((idsDepartamentosFeriado ?? []).length <= 0) ||
64
- (idsDepartamentosFeriado ?? []).includes(idDepartamentoUsuario);
65
- }
66
- async function feriado({ elasticClient, dataHoraJornada, idDepartamentoUsuario, idEmpresaUsuarioJornada, ufEmpresaUsuarioJornada, cidadeEmpresaUsuarioJornada, empresas, feriados, tipoOcorrenciaFrequenciaJornadaPrevista }) {
67
- if (tipoOcorrenciaFrequenciaJornadaPrevista.trim().toUpperCase() === 'FERIADO') {
68
- return true;
69
- }
70
- const dadosEmpresa = getDadosEmpresa({
71
- empresas: empresas,
72
- idEmpresaUsuarioJornada: idEmpresaUsuarioJornada,
73
- ufEmpresaUsuarioJornada: ufEmpresaUsuarioJornada,
74
- cidadeEmpresaUsuarioJornada: cidadeEmpresaUsuarioJornada,
75
- });
76
- for (const feriado of feriados) {
77
- if (feriado?._source && validarDepartamentoFeriado({
78
- idDepartamentoUsuario: idDepartamentoUsuario,
79
- idsDepartamentosFeriado: feriado._source?.departamentos
80
- })) {
81
- const dataFeriado = new Date(feriado._source.data);
82
- const dataJornada = dataHoraJornada ?? new Date();
83
- if ((dataFeriado.getDate() === dataJornada.getDate()) && (dataFeriado.getMonth() === dataJornada.getMonth()) && (dataFeriado.getFullYear() === dataJornada.getFullYear())) {
84
- if ((feriado._source.tipo ?? '').toUpperCase() === 'NACIONAL') {
85
- return true;
86
- }
87
- else {
88
- if ((feriado._source.tipo ?? '').toUpperCase() === 'ESTADUAL') {
89
- if (!feriado._source.uf) {
90
- return true;
91
- }
92
- if (feriado._source.todas_empresas && (feriado._source.uf === dadosEmpresa.endereco.uf)) {
93
- return true;
94
- }
95
- }
96
- if ((feriado._source.tipo ?? '').toUpperCase() === 'MUNICIPAL') {
97
- if ((!feriado._source.uf) || (!feriado._source.municipio)) {
98
- return true;
99
- }
100
- if (feriado._source.todas_empresas && (feriado._source.uf === dadosEmpresa.endereco.uf) && (feriado._source.municipio === dadosEmpresa.endereco.cidade)) {
101
- return true;
102
- }
103
- }
104
- if (!feriado._source.todas_empresas) {
105
- const empresasFeriado = await new empresas_feriado_elastic_1.EmpresasFeriadoElastic(elasticClient).getEmpresasFeriadoElastic({
106
- empresaId: dadosEmpresa.id,
107
- feriadoId: feriado._source.i_id
108
- });
109
- if (empresasFeriado.length > 0) {
110
- return true;
111
- }
112
- }
113
- }
114
- }
115
- }
116
- }
117
- return false;
28
+ function feriado(tipoOcorrenciaFrequenciaJornadaPrevista) {
29
+ return tipoOcorrenciaFrequenciaJornadaPrevista.trim().toUpperCase() === 'FERIADO';
118
30
  }
119
31
  exports.feriado = feriado;
120
32
  function retornarDiferencaMinutosHorarios(dataHora1, dataHora2) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "flit-modulo-exportacoes",
3
- "version": "2.0.88",
3
+ "version": "2.0.89",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "directories": {
@@ -17,7 +17,7 @@
17
17
  "devDependencies": {
18
18
  "@elastic/elasticsearch": "^8.19.1",
19
19
  "@types/luxon": "^3.7.1",
20
- "flit-calcular-jornada": "2.6.2",
20
+ "flit-calcular-jornada": "2.6.5",
21
21
  "prettier": "^3.6.2",
22
22
  "tsc-alias": "^1.8.16",
23
23
  "typescript": "^4.9.5"