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 +6 -4
- package/dist/index.js +51 -13
- package/package.json +1 -1
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(
|
|
6
|
-
|
|
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(
|
|
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
|
|
18
|
-
validarCampo(fn, '
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
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(
|
|
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
|
|
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) {
|