flit-modulo-exportacoes 2.0.17 → 2.0.18

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,9 +1,12 @@
1
1
  import { Client } from '@elastic/elasticsearch';
2
2
  import { SearchHit } from '@elastic/elasticsearch/lib/api/types';
3
- import { EnumFormaEnvioFaltasEventosExportacoes } from './eventos-exportacoes-model';
4
3
  import { PayloadExportacaoPadrao, TipoEventoExportacao, TiposEventosExportacaoArquivo, TiposEventosExportar, ValoresEventosExportacao, ValorEventoExportacao, ValorEventoExportacaoFalta } from './models';
5
- export declare function validarDadosPayload(data: PayloadExportacaoPadrao, fn: () => Array<string>): boolean;
6
- export declare function calcularValoresExportacao({ contaId, dataFinal, dataInicial, elasticClient, parametrosIntegracao, empresas, jornadas, formaEnvioFaltas }: {
4
+ export declare function validarDadosPayload({ fn, data, validarCampoReferencia }: {
5
+ fn: () => Array<string>;
6
+ data: PayloadExportacaoPadrao;
7
+ validarCampoReferencia: boolean;
8
+ }): boolean;
9
+ export declare function calcularValoresExportacao({ contaId, dataFinal, dataInicial, elasticClient, parametrosIntegracao, empresas, jornadas }: {
7
10
  contaId: string;
8
11
  dataFinal: Date;
9
12
  dataInicial: Date;
@@ -11,7 +14,6 @@ export declare function calcularValoresExportacao({ contaId, dataFinal, dataInic
11
14
  parametrosIntegracao: any;
12
15
  empresas: Array<SearchHit<any>>;
13
16
  jornadas: Array<SearchHit<any>>;
14
- formaEnvioFaltas: EnumFormaEnvioFaltasEventosExportacoes;
15
17
  }): Promise<ValoresEventosExportacao>;
16
18
  export declare function retornaValorEvento(tipoEvento: TipoEventoExportacao, valoresEventos: ValoresEventosExportacao): ValorEventoExportacao | ValorEventoExportacaoFalta;
17
19
  export declare function processarTiposEventosExportar(tiposEventos: Array<TiposEventosExportar>): TiposEventosExportacaoArquivo;
package/dist/index.js CHANGED
@@ -9,20 +9,61 @@ const utils_1 = require("flit-calcular-jornada/dist/lib/helpers/utils");
9
9
  const parametrosHorasNoturnas_model_1 = require("flit-calcular-jornada/dist/lib/models/parametrosHorasNoturnas.model");
10
10
  const utils_2 = require("./utils");
11
11
  const models_1 = require("./models");
12
- function validarCampo(fn, fieldName, campo) {
13
- if (!campo || campo.length <= 0) {
12
+ function validarCampo({ campo, fieldName, fn }) {
13
+ if ((!campo) || (campo.length <= 0)) {
14
14
  fn().push(`${fieldName} não informada.`);
15
+ return false;
15
16
  }
17
+ return true;
16
18
  }
17
- function validarDadosPayload(data, fn) {
18
- validarCampo(fn, 'Conta', data.conta_id);
19
- validarCampo(fn, 'Data final', data.data_final);
20
- validarCampo(fn, 'Data inicial', data.data_inicial);
21
- validarCampo(fn, 'Tabela de eventos', data.tabela_eventos_id);
19
+ function validarReferencia({ referencia, fn }) {
20
+ if (validarCampo({ fn: fn, fieldName: 'Referência', campo: referencia })) {
21
+ if ((referencia ?? '').length !== 6) {
22
+ fn().push(`Referência inválida. O formato esperado é "MMYYYY".`);
23
+ }
24
+ else {
25
+ const mes = (referencia ?? '').substring(0, 2);
26
+ if ((!Number.isInteger(Number.parseInt(mes))) || (Number.parseInt(mes) < 1) || (Number.parseInt(mes) > 12)) {
27
+ fn().push(`Mês de referência inválido. O formato esperado é "MM".`);
28
+ }
29
+ const ano = (referencia ?? '').substring(2, 6);
30
+ if ((!Number.isInteger(Number.parseInt(ano))) || (Number.parseInt(ano) < 1899) || (Number.parseInt(ano) > 2999)) {
31
+ fn().push(`Ano de referência inválido. O formato esperado é "YYYY".`);
32
+ }
33
+ }
34
+ }
35
+ }
36
+ function validarDadosPayload({ fn, data, validarCampoReferencia }) {
37
+ validarCampo({
38
+ fn: fn,
39
+ fieldName: 'Conta',
40
+ campo: data.conta_id
41
+ });
42
+ validarCampo({
43
+ fn: fn,
44
+ campo: data.data_final,
45
+ fieldName: 'Data final'
46
+ });
47
+ validarCampo({
48
+ fn: fn,
49
+ campo: data.data_inicial,
50
+ fieldName: 'Data inicial'
51
+ });
52
+ validarCampo({
53
+ fn: fn,
54
+ campo: data.tabela_eventos_id,
55
+ fieldName: 'Tabela de eventos'
56
+ });
57
+ if (validarCampoReferencia) {
58
+ validarReferencia({
59
+ fn: fn,
60
+ referencia: data.referencia
61
+ });
62
+ }
22
63
  return fn().length === 0;
23
64
  }
24
65
  exports.validarDadosPayload = validarDadosPayload;
25
- function aplicarFatorConversaoValoresEventos({ valoresEventos, formaEnvioFaltas }) {
66
+ function aplicarFatorConversaoValoresEventos(valoresEventos) {
26
67
  return {
27
68
  datas_faltas: valoresEventos.datas_faltas,
28
69
  ValorNormal: {
@@ -120,7 +161,7 @@ function aplicarFatorConversaoValoresEventos({ valoresEventos, formaEnvioFaltas
120
161
  }
121
162
  };
122
163
  }
123
- async function calcularValoresExportacao({ contaId, dataFinal, dataInicial, elasticClient, parametrosIntegracao, empresas, jornadas, formaEnvioFaltas }) {
164
+ async function calcularValoresExportacao({ contaId, dataFinal, dataInicial, elasticClient, parametrosIntegracao, empresas, jornadas }) {
124
165
  const feriados = await new feriados_elastic_1.FeriadosElastic(elasticClient).getFeriadosElastic({
125
166
  contaId: contaId,
126
167
  dataFinal: dataFinal,
@@ -315,10 +356,7 @@ async function calcularValoresExportacao({ contaId, dataFinal, dataInicial, elas
315
356
  valoresEventos: valoresEventos,
316
357
  parametrosIntegracao: parametrosIntegracao ?? {}
317
358
  });
318
- return aplicarFatorConversaoValoresEventos({
319
- valoresEventos: valoresEventos,
320
- formaEnvioFaltas: formaEnvioFaltas
321
- });
359
+ return aplicarFatorConversaoValoresEventos(valoresEventos);
322
360
  }
323
361
  exports.calcularValoresExportacao = calcularValoresExportacao;
324
362
  function retornaValorEvento(tipoEvento, valoresEventos) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "flit-modulo-exportacoes",
3
- "version": "2.0.17",
3
+ "version": "2.0.18",
4
4
  "description": "",
5
5
  "main": "dist/lib/index.js",
6
6
  "directories": {