att
This commit is contained in:
@@ -7,6 +7,7 @@ function createDataset(fields, constraints, sortFields) {
|
||||
|
||||
try {
|
||||
var params = constraintsToMap(constraints);
|
||||
var autorizadorResponsavel = valueOrEmpty(params.autorizador_responsavel || params.autorizadorResponsavel);
|
||||
validateRequired(params);
|
||||
|
||||
var payload = {
|
||||
@@ -22,6 +23,7 @@ function createDataset(fields, constraints, sortFields) {
|
||||
tipo_documento: valueOrEmpty(params.tipo_documento),
|
||||
numero_documento: valueOrEmpty(params.numero_documento),
|
||||
valor: valueOrEmpty(params.valor),
|
||||
autorizador_responsavel: autorizadorResponsavel,
|
||||
justificativa: valueOrEmpty(params.justificativa)
|
||||
}
|
||||
};
|
||||
@@ -103,6 +105,11 @@ function validateRequired(params) {
|
||||
throw "Campo obrigatório não informado: " + fieldName;
|
||||
}
|
||||
}
|
||||
|
||||
var autorizador = valueOrEmpty(params.autorizador_responsavel || params.autorizadorResponsavel);
|
||||
if (!autorizador) {
|
||||
throw "Campo obrigatório não informado: autorizador_responsavel";
|
||||
}
|
||||
}
|
||||
|
||||
function extractProcessInstanceId(response) {
|
||||
|
||||
+139
-62
@@ -79,7 +79,7 @@
|
||||
|
||||
</div>
|
||||
|
||||
<h1 id="rcorners"> Lançamento de documento </h1>
|
||||
<h1 id="rcorners"> Lançamento de documento </h1>
|
||||
|
||||
<div class="container activity-all">
|
||||
|
||||
@@ -90,7 +90,7 @@
|
||||
<h2>
|
||||
<i class="flaticon flaticon-account-box" aria-hidden="true"></i> Dados do documento
|
||||
</h2>
|
||||
<h6>Dados referentes ao documento que será lançado.</h6>
|
||||
<h6>Dados referentes ao documento que será lançado.</h6>
|
||||
<br>
|
||||
</div>
|
||||
|
||||
@@ -103,21 +103,20 @@
|
||||
<input type="text" name="data_abertura" id="data_abertura" class="form-control" readonly />
|
||||
</div>
|
||||
<div class="form-group col-md-3 col-xs-12 divEmitidoPor alertaCampo">
|
||||
<label for="emitido_por"> Emitido por
|
||||
<label for="emitido_por"> Origem
|
||||
<strong class="required text-danger"> * </strong>
|
||||
</label>
|
||||
<select name="emitido_por" id="emitido_por" class="form-control">
|
||||
<option value="">Selecionar emissor do documento</option>
|
||||
<option value="fornecedor">Fornecedor</option>
|
||||
<option value="colaborador">Colaborador</option>
|
||||
</select>
|
||||
<p class="help-block" id="emitidoPor"
|
||||
style="display: none; position: absolute; font-size: 12px;">Preenchimento
|
||||
obrigatório</p>
|
||||
obrigatório</p>
|
||||
</div>
|
||||
|
||||
<div class="form-group col-md-3 col-xs-12 divResposavelPelaEmissao divEntidadeResponsavel alertaCampo">
|
||||
<label for="entidade_responsavel"> Nome do responsável pela emissão</label>
|
||||
<label for="entidade_responsavel"> Empresa emitente</label>
|
||||
<span class="required text-danger"><strong> * </strong></span>
|
||||
<input
|
||||
type="text"
|
||||
@@ -133,24 +132,9 @@
|
||||
/>
|
||||
<p class="help-block" id="entidadeResponsavel"
|
||||
style="display: none; position: absolute; font-size: 12px;">
|
||||
Preenchimento obrigatório
|
||||
Preenchimento obrigatório
|
||||
</p>
|
||||
</div>
|
||||
<div class="form-group col-md-3 col-xs-12">
|
||||
<label> E-mail do usuário </label>
|
||||
<input
|
||||
type="email"
|
||||
name="emailSolicitante"
|
||||
id="emailSolicitante"
|
||||
class="form-control"
|
||||
placeholder="Inserir e-mail do solicitante. Ex: joaodasilva@mail.com"
|
||||
data-protection="E-mail do solicitante"
|
||||
data-protection-anonymizable
|
||||
data-protection-sensitive
|
||||
data-protection-mail
|
||||
data-protection-class-legitimate-interests="Dado coletado para o funcionamento do processo"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div><br>
|
||||
@@ -161,13 +145,13 @@
|
||||
<label for="tipo_cadastro"> Tipo de cadastro </label><span
|
||||
class="required text-danger"><strong> * </strong></span>
|
||||
<select name="tipo_cadastro" id="tipo_cadastro" class="form-control">
|
||||
<option value="">Selecionar opção</option>
|
||||
<option value="">Selecionar opção</option>
|
||||
<option value="cpf">CPF</option>
|
||||
<option value="cnpj">CNPJ</option>
|
||||
</select>
|
||||
<p class="help-block" id="tipoCadastro"
|
||||
style="display: none; position: absolute; font-size: 12px;">Preenchimento
|
||||
obrigatório</p>
|
||||
obrigatório</p>
|
||||
</div>
|
||||
<div class="form-group col-md-3 col-xs-12 divCnpj alertaCampoj">
|
||||
<label for="cnpj"> CNPJ </label> <span class="required text-danger"><strong> *
|
||||
@@ -176,7 +160,7 @@
|
||||
mask="00.000.000/0000-00" class="form-control" readonly />
|
||||
<p class="help-block" id="errorCnpj"
|
||||
style="display: none; position: absolute; font-size: 12px;">Preenchimento
|
||||
obrigatório</p>
|
||||
obrigatório</p>
|
||||
<p class="help-block" style="color: #cc3d3d;" id="mensagemErroCnpj"></p>
|
||||
|
||||
</div>
|
||||
@@ -199,7 +183,7 @@
|
||||
/>
|
||||
<p class="help-block" id="errorCpf"
|
||||
style="display: none; position: absolute; font-size: 12px;">
|
||||
Preenchimento obrigatório
|
||||
Preenchimento obrigatório
|
||||
</p>
|
||||
<p class="help-block" style="color: #cc3d3d" id="mensagemErroCpf"></p>
|
||||
</div>
|
||||
@@ -207,9 +191,9 @@
|
||||
<label for="tipo_documento"> Tipo de documento </label>
|
||||
<select name="tipo_documento" id="tipo_documento" class="form-control">
|
||||
<option value="">Selecionar tipo de documento</option>
|
||||
<option value="energia">Documento de energia</option>
|
||||
<option value="agua">Documento de água</option>
|
||||
<option value="internet">Documento de Internet</option>
|
||||
<option value="energia">Nota de Energia Elétrica</option>
|
||||
<option value="agua">Nota de Consumo de Água</option>
|
||||
<option value="internet">Nota de Uso de Internet</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
@@ -220,13 +204,13 @@
|
||||
<div class="form-field">
|
||||
<div class="form-input">
|
||||
<div class="form-group col-md-6 col-xs-12 divNumeroDocumento alertaCampo">
|
||||
<label> Número do documento </label><span class="required text-danger"><strong> *
|
||||
<label> Número do documento </label><span class="required text-danger"><strong> *
|
||||
</strong></span>
|
||||
<input type="text" name="numero_documento" id="numero_documento"
|
||||
placeholder="Inserir número do documento" class="form-control" />
|
||||
<p class="help-block" id="numeroDocumento"
|
||||
style="display: none; position: absolute; font-size: 12px;">Preenchimento
|
||||
obrigatório</p>
|
||||
obrigatório</p>
|
||||
</div>
|
||||
<div class="form-group col-md-6 col-xs-12">
|
||||
<label for="valor_contrato"> Valor do documento (se houver)</label>
|
||||
@@ -239,6 +223,27 @@
|
||||
</div><br>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="form-field">
|
||||
<div class="form-input">
|
||||
<div class="form-group col-md-6 col-xs-12 divautorizadorResponsavel alertaCampo">
|
||||
<label for="autorizador_responsavel"> Nome do Autorizador </label>
|
||||
<span class="required text-danger"><strong> * </strong></span>
|
||||
<input
|
||||
type="text"
|
||||
name="autorizador_responsavel"
|
||||
id="autorizador_responsavel"
|
||||
placeholder="Digite seu nome"
|
||||
class="form-control"
|
||||
/>
|
||||
<p class="help-block" id="autorizadorResponsavel"
|
||||
style="display: none; position: absolute; font-size: 12px;">
|
||||
Preenchimento obrigatorio
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="form-field">
|
||||
<div class="form-input">
|
||||
@@ -246,8 +251,8 @@
|
||||
<label id="labelAnexaCota">Anexar documento</label>
|
||||
<span class="required text-danger"> <strong> * </strong>
|
||||
</span>
|
||||
<p id="descAnexaCota">Utilize a aba anexos para anexar o documento ou o botão
|
||||
abaixo. <strong> Anexo obrigatório. </strong></p>
|
||||
<p id="descAnexaCota">Utilize a aba anexos para anexar o documento ou o botão
|
||||
abaixo. <strong> Anexo obrigatório. </strong></p>
|
||||
<input type="button" class="btn btn-primary" id="anexaDocumento"
|
||||
value="Anexar documento" onclick="showCamera('anexo_documento');"
|
||||
style="margin-top: 25px;" />
|
||||
@@ -259,21 +264,21 @@
|
||||
<br>
|
||||
|
||||
<h2><i class="flaticon flaticon-message-question" aria-hidden="true">
|
||||
</i> Descrição dos serviços
|
||||
</i> Descrição dos serviços
|
||||
|
||||
</h2>
|
||||
<h6>Descrição detalhada dos serviços prestados e as possíveis informações complementares.</h6>
|
||||
<h6>Descrição detalhada dos serviços prestados e as possíveis informações complementares.</h6>
|
||||
<br>
|
||||
<div class="row">
|
||||
<div class="form-field">
|
||||
<div class="form-input">
|
||||
<div class="form-group col-md-12 col-xs-12 divJustificativa alertaCampo">
|
||||
<label for="justificativa"> Descrição dos serviços </label> <span
|
||||
<label for="justificativa"> Descrição dos serviços </label> <span
|
||||
class="required text-danger"><strong> * </strong></span>
|
||||
<textarea class="form-control" rows="3" id="justificativa" name="justificativa"
|
||||
placeholder="Descreva os serviços prestados."></textarea>
|
||||
<p class="help-block" id="msgJustificativa" style="display: none;">Preenchimento
|
||||
obrigatório</p>
|
||||
obrigatório</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -342,11 +347,7 @@
|
||||
<p class="help-block" id="prefixoAnalista" style="display: none;">Preenchimento obrigatorio</p>
|
||||
</div>
|
||||
<div class="form-group col-md-4 col-xs-12 divNumeroAnalista alertaCampo">
|
||||
<<<<<<< HEAD
|
||||
<label for="NUMERO">Número <span class="required text-danger"><strong>*</strong></span></label>
|
||||
=======
|
||||
<label for="NUMERO">Número <span class="required text-danger"><strong>*</strong></span></label>
|
||||
>>>>>>> 0bf4065e684532d46f9466f40b5418f98a0903e3
|
||||
<input type="text" name="NUMERO" id="NUMERO" class="form-control" placeholder="010203045" />
|
||||
<p class="help-block" id="numeroAnalista" style="display: none;">Preenchimento obrigatorio</p>
|
||||
</div>
|
||||
@@ -373,11 +374,7 @@
|
||||
<p class="help-block" id="naturezaAnalista" style="display: none;">Preenchimento obrigatorio</p>
|
||||
</div>
|
||||
<div class="form-group col-md-3 col-xs-12 divCodFornAnalista alertaCampo">
|
||||
<<<<<<< HEAD
|
||||
<label for="COD_FORN">Código do fornecedor <span class="required text-danger"><strong>*</strong></span></label>
|
||||
=======
|
||||
<label for="COD_FORN">Código do fornecedor <span class="required text-danger"><strong>*</strong></span></label>
|
||||
>>>>>>> 0bf4065e684532d46f9466f40b5418f98a0903e3
|
||||
<input type="text" name="COD_FORN" id="COD_FORN" class="form-control" placeholder="00000914" />
|
||||
<p class="help-block" id="codFornAnalista" style="display: none;">Preenchimento obrigatorio</p>
|
||||
</div>
|
||||
@@ -394,11 +391,7 @@
|
||||
<div class="form-field">
|
||||
<div class="form-input">
|
||||
<div class="form-group col-md-3 col-xs-12 divEmissaoAnalista alertaCampo">
|
||||
<<<<<<< HEAD
|
||||
<label for="EMISSAO">Emissão <span class="required text-danger"><strong>*</strong></span></label>
|
||||
=======
|
||||
<label for="EMISSAO">Emissão <span class="required text-danger"><strong>*</strong></span></label>
|
||||
>>>>>>> 0bf4065e684532d46f9466f40b5418f98a0903e3
|
||||
<input type="text" name="EMISSAO" id="EMISSAO" class="form-control" placeholder="20260402" />
|
||||
<p class="help-block" id="emissaoAnalista" style="display: none;">Preenchimento obrigatorio</p>
|
||||
</div>
|
||||
@@ -413,13 +406,8 @@
|
||||
<p class="help-block" id="vencRealAnalista" style="display: none;">Preenchimento obrigatorio</p>
|
||||
</div>
|
||||
<div class="form-group col-md-3 col-xs-12 divValorAnalista alertaCampo">
|
||||
<<<<<<< HEAD
|
||||
<label for="VALORtotal">Valor <span class="required text-danger"><strong>*</strong></span></label>
|
||||
<input type="number" step="0.01" name="VALORtotal" id="VALORtotal" class="form-control" placeholder="1500.75" />
|
||||
=======
|
||||
<label for="VALOR">Valor <span class="required text-danger"><strong>*</strong></span></label>
|
||||
<input type="number" step="0.01" name="VALOR" id="VALOR" class="form-control" placeholder="1500.75" />
|
||||
>>>>>>> 0bf4065e684532d46f9466f40b5418f98a0903e3
|
||||
<input type="text" name="VALORtotal" id="VALORtotal" class="form-control" placeholder="1.500,75" />
|
||||
<p class="help-block" id="valorAnalista" style="display: none;">Preenchimento obrigatorio</p>
|
||||
</div>
|
||||
</div>
|
||||
@@ -740,8 +728,23 @@
|
||||
|
||||
|
||||
document.querySelector("#valor").addEventListener("input", function () {
|
||||
mascaraApenasNumeros(this)
|
||||
mascaraValorMoedaBr(this)
|
||||
});
|
||||
document.querySelector("#valor").addEventListener("blur", function () {
|
||||
formataValorMoedaBr(this)
|
||||
});
|
||||
document.querySelector("#VALORtotal").addEventListener("input", function () {
|
||||
mascaraValorMoedaBr(this)
|
||||
});
|
||||
document.querySelector("#VALORtotal").addEventListener("blur", function () {
|
||||
formataValorMoedaBr(this)
|
||||
});
|
||||
if ($("#valor").val()) {
|
||||
formataValorMoedaBr(document.querySelector("#valor"));
|
||||
}
|
||||
if ($("#VALORtotal").val()) {
|
||||
formataValorMoedaBr(document.querySelector("#VALORtotal"));
|
||||
}
|
||||
|
||||
|
||||
if ($("#tipo_cadastro").val() == "cpf") {
|
||||
@@ -963,6 +966,7 @@
|
||||
var campoCnpj = $("#cnpj").val();
|
||||
var campoCpf = $("#cpf").val();
|
||||
var campoNumeroDocumento = $("#numero_documento").val();
|
||||
var campoAutorizadorResponsavel = $("#autorizador_responsavel").val();
|
||||
var campoPastaGed = $("#pasta_ged").val();
|
||||
var campoExpiracaoValidade = $("#expiracao_validade").val();
|
||||
var campoJustificativa = $("#justificativa").val();
|
||||
@@ -1025,6 +1029,12 @@
|
||||
erro++;
|
||||
}
|
||||
|
||||
if (campoAutorizadorResponsavel == undefined || campoAutorizadorResponsavel == "" || campoAutorizadorResponsavel == null) {
|
||||
$(".divautorizadorResponsavel").addClass("has-error");
|
||||
$("#autorizadorResponsavel").show();
|
||||
erro++;
|
||||
}
|
||||
|
||||
|
||||
|
||||
if (campoRadioGed == "publica_ged") {
|
||||
@@ -1062,7 +1072,7 @@
|
||||
{ valor: $("#EMISSAO").val(), classe: ".divEmissaoAnalista", help: "#emissaoAnalista" },
|
||||
{ valor: $("#VENCIMENTO").val(), classe: ".divVencimentoAnalista", help: "#vencimentoAnalista" },
|
||||
{ valor: $("#VENC_REAL").val(), classe: ".divVencRealAnalista", help: "#vencRealAnalista" },
|
||||
{ valor: $("#VALOR").val(), classe: ".divValorAnalista", help: "#valorAnalista" },
|
||||
{ valor: $("#VALORtotal").val(), classe: ".divValorAnalista", help: "#valorAnalista" },
|
||||
{ valor: $("#HISTORICO").val(), classe: ".divHistoricoAnalista", help: "#historicoAnalista" },
|
||||
{ valor: $("#CENTRO_CUSTO").val(), classe: ".divCentroCustoAnalista", help: "#centroCustoAnalista" }
|
||||
];
|
||||
@@ -1170,11 +1180,78 @@
|
||||
|
||||
}
|
||||
|
||||
const mascaraApenasNumeros = (field) => {
|
||||
valor = field.value;
|
||||
valor = valor.replace(/\D/g, ""); /**Substitui o que não é dÃÂgito por "", /g é [Global][1]*/
|
||||
valor = valor.replace()
|
||||
field.value = valor;
|
||||
const mascaraValorMoedaBr = (field) => {
|
||||
var raw = (field.value || "").toString().replace(/[^\d,]/g, "");
|
||||
if (!raw) {
|
||||
field.value = "";
|
||||
return;
|
||||
}
|
||||
|
||||
var commaIndex = raw.indexOf(",");
|
||||
var inteiro = "";
|
||||
var decimal = "";
|
||||
|
||||
if (commaIndex >= 0) {
|
||||
inteiro = raw.substring(0, commaIndex).replace(/\D/g, "");
|
||||
decimal = raw.substring(commaIndex + 1).replace(/\D/g, "").slice(0, 2);
|
||||
} else {
|
||||
inteiro = raw.replace(/\D/g, "");
|
||||
}
|
||||
|
||||
inteiro = inteiro.replace(/^0+(?=\d)/, "");
|
||||
if (!inteiro) inteiro = "0";
|
||||
inteiro = inteiro.replace(/\B(?=(\d{3})+(?!\d))/g, ".");
|
||||
|
||||
field.value = commaIndex >= 0 ? (inteiro + "," + decimal) : inteiro;
|
||||
};
|
||||
|
||||
const normalizarValorMoedaBr = (value) => {
|
||||
var raw = (value || "").toString().trim();
|
||||
if (!raw) return "0,00";
|
||||
|
||||
var cleaned = raw.replace(/\s/g, "").replace(/[^\d,\.]/g, "");
|
||||
var inteiro = "";
|
||||
var decimal = "";
|
||||
|
||||
if (cleaned.indexOf(",") >= 0) {
|
||||
var commaParts = cleaned.split(",");
|
||||
inteiro = (commaParts.shift() || "").replace(/\D/g, "");
|
||||
decimal = commaParts.join("").replace(/\D/g, "").slice(0, 2);
|
||||
} else if (cleaned.indexOf(".") >= 0) {
|
||||
var dotParts = cleaned.split(".");
|
||||
var isDecimalDot = dotParts.length === 2 && dotParts[1].length > 0 && dotParts[1].length <= 2;
|
||||
|
||||
if (isDecimalDot) {
|
||||
inteiro = (dotParts[0] || "").replace(/\D/g, "");
|
||||
decimal = (dotParts[1] || "").replace(/\D/g, "").slice(0, 2);
|
||||
} else {
|
||||
inteiro = cleaned.replace(/\D/g, "");
|
||||
}
|
||||
} else {
|
||||
inteiro = cleaned.replace(/\D/g, "");
|
||||
}
|
||||
|
||||
inteiro = inteiro.replace(/^0+(?=\d)/, "");
|
||||
if (!inteiro) inteiro = "0";
|
||||
if (!decimal) decimal = "00";
|
||||
if (decimal.length === 1) decimal = decimal + "0";
|
||||
|
||||
return inteiro + "," + decimal;
|
||||
};
|
||||
|
||||
const formataValorMoedaBr = (field) => {
|
||||
var normalized = normalizarValorMoedaBr(field.value);
|
||||
var parts = normalized.split(",");
|
||||
var inteiro = (parts[0] || "").replace(/\D/g, "");
|
||||
var decimal = (parts[1] || "").replace(/\D/g, "").slice(0, 2);
|
||||
|
||||
inteiro = inteiro.replace(/^0+(?=\d)/, "");
|
||||
if (!inteiro) inteiro = "0";
|
||||
if (!decimal) decimal = "00";
|
||||
if (decimal.length === 1) decimal = decimal + "0";
|
||||
|
||||
inteiro = inteiro.replace(/\B(?=(\d{3})+(?!\d))/g, ".");
|
||||
field.value = inteiro + "," + decimal;
|
||||
};
|
||||
|
||||
const mascaraCPF = (field) => {
|
||||
|
||||
@@ -29,6 +29,7 @@ Esse endpoint e quem usa `fluig_rest` no backend.
|
||||
"tipo_documento": "danfe",
|
||||
"numero_documento": "123456",
|
||||
"valor": "10,00",
|
||||
"autorizador_responsavel": "Nome do autorizador",
|
||||
"justificativa": "Descricao do servico"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -66,6 +66,8 @@ async def enviar(
|
||||
tipo_documento: str = Form(""),
|
||||
numero_documento: str = Form(...),
|
||||
valor: str = Form(""),
|
||||
autorizador_responsavel: str = Form(""),
|
||||
autorizadorResponsavel: str = Form(""),
|
||||
justificativa: str = Form(...),
|
||||
) -> PortalFornecedorSuccessResponse:
|
||||
file_name = arquivo.filename or "anexo"
|
||||
@@ -75,6 +77,10 @@ async def enviar(
|
||||
if not file_bytes:
|
||||
raise HTTPException(status_code=400, detail={"message": "Arquivo obrigatorio."})
|
||||
|
||||
autorizador = (autorizador_responsavel or autorizadorResponsavel or "").strip()
|
||||
if not autorizador:
|
||||
raise HTTPException(status_code=400, detail={"message": "Campo obrigatorio nao informado: autorizador_responsavel."})
|
||||
|
||||
auth = build_auth()
|
||||
upload_binary(file_name, file_bytes, auth)
|
||||
document_id = create_document(file_name, file_mime, auth)
|
||||
@@ -92,6 +98,7 @@ async def enviar(
|
||||
"tipo_documento": tipo_documento,
|
||||
"numero_documento": numero_documento,
|
||||
"valor": valor,
|
||||
"autorizador_responsavel": autorizador,
|
||||
"justificativa": justificativa,
|
||||
"anexo_documento_id": str(document_id),
|
||||
"anexo_documento_nome": file_name,
|
||||
|
||||
+20
-19
@@ -26,32 +26,21 @@ data-params="MyWidget.instance()">
|
||||
</div>
|
||||
|
||||
<div class="form-group col-md-3 divEmitidoPor alertaCampo">
|
||||
<label>Emitido por <strong class="text-danger">*</strong></label>
|
||||
<label>Origem<strong class="text-danger">*</strong></label>
|
||||
|
||||
<select name="emitido_por" id="emitido_por" class="form-control">
|
||||
<option value="">Selecionar emissor</option>
|
||||
<option value="fornecedor">Fornecedor</option>
|
||||
<option value="colaborador">Colaborador</option>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div class="form-group col-md-3 divEntidadeResponsavel alertaCampo">
|
||||
<label>Responsavel pela emissão <strong class="text-danger">*</strong></label>
|
||||
<label>Empresa emitente <strong class="text-danger">*</strong></label>
|
||||
|
||||
<input type="text" class="form-control"
|
||||
name="entidade_responsavel"
|
||||
id="entidade_responsavel"
|
||||
placeholder="Empresa ou colaborador">
|
||||
</div>
|
||||
|
||||
<div class="form-group col-md-3">
|
||||
<label>E-mail do solicitante</label>
|
||||
|
||||
<input type="email"
|
||||
name="emailSolicitante"
|
||||
id="emailSolicitante"
|
||||
class="form-control"
|
||||
placeholder="email@empresa.com">
|
||||
placeholder="Nome da companhia">
|
||||
</div>
|
||||
|
||||
</div>
|
||||
@@ -95,8 +84,10 @@ data-params="MyWidget.instance()">
|
||||
|
||||
<select name="tipo_documento" id="tipo_documento" class="form-control">
|
||||
<option value="">Selecionar</option>
|
||||
<option value="danfe">Nota Fiscal Mercadoria</option>
|
||||
<option value="nota_fiscal_servico">Nota Fiscal Servico</option>
|
||||
<option value="energia">Nota de Energia Elétrica</option>
|
||||
<option value="agua">Nota de Consumo de Água</option>
|
||||
<option value="internet">Nota de Uso de Internet</option>
|
||||
|
||||
</select>
|
||||
</div>
|
||||
|
||||
@@ -130,8 +121,8 @@ data-params="MyWidget.instance()">
|
||||
|
||||
<div class="row">
|
||||
|
||||
<div class="form-group col-md-6 alertaCampo">
|
||||
<label>Numero do documento <strong class="text-danger">*</strong></label>
|
||||
<div class="form-group col-md-3 alertaCampo">
|
||||
<label>Número do documento <strong class="text-danger">*</strong></label>
|
||||
|
||||
<input type="text"
|
||||
name="numero_documento"
|
||||
@@ -140,7 +131,7 @@ data-params="MyWidget.instance()">
|
||||
placeholder="Numero da nota">
|
||||
</div>
|
||||
|
||||
<div class="form-group col-md-6">
|
||||
<div class="form-group col-md-3">
|
||||
<label>Valor do documento</label>
|
||||
|
||||
<div class="input-group">
|
||||
@@ -156,6 +147,16 @@ data-params="MyWidget.instance()">
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="form-group col-md-3 divautorizadorResponsavel alertaCampo">
|
||||
<label>Nome do Autorizador <strong class="text-danger">*</strong></label>
|
||||
|
||||
<input type="text" class="form-control"
|
||||
name="autorizador_responsavel"
|
||||
id="autorizador_responsavel"
|
||||
placeholder="Digite seu nome">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
+89
-3
@@ -50,6 +50,18 @@ var MyWidget = SuperWidget.extend({
|
||||
this.root.find("#cnpj").off("input").on("input", function () {
|
||||
this.value = self.mascaraCNPJ(this.value);
|
||||
});
|
||||
|
||||
this.root.find("#valor").off("input").on("input", function () {
|
||||
this.value = self.mascaraValorDocumento(this.value);
|
||||
});
|
||||
|
||||
this.root.find("#valor").off("blur").on("blur", function () {
|
||||
var currentValue = (this.value || "").toString().trim();
|
||||
if (!currentValue) {
|
||||
return;
|
||||
}
|
||||
this.value = self.formatMoneyDisplay(currentValue);
|
||||
});
|
||||
},
|
||||
|
||||
setupInitialValues: function () {
|
||||
@@ -146,6 +158,7 @@ var MyWidget = SuperWidget.extend({
|
||||
var cnpj = this.onlyDigits(this.value("#cnpj"));
|
||||
var numeroDocumento = this.value("#numero_documento");
|
||||
var valor = this.normalizeMoney(this.value("#valor"));
|
||||
var autorizadorResponsavel = self.value("#autorizador_responsavel");
|
||||
var documentoPessoa = tipoCadastro === "cpf" ? cpf : cnpj;
|
||||
var cpfField = tipoCadastro === "cpf" ? cpf : "";
|
||||
|
||||
@@ -164,6 +177,8 @@ var MyWidget = SuperWidget.extend({
|
||||
tipo_documento: self.value("#tipo_documento"),
|
||||
numero_documento: numeroDocumento,
|
||||
valor: valor,
|
||||
autorizador_responsavel: autorizadorResponsavel,
|
||||
autorizadorResponsavel: autorizadorResponsavel,
|
||||
justificativa: self.value("#justificativa")
|
||||
}
|
||||
};
|
||||
@@ -316,6 +331,7 @@ var MyWidget = SuperWidget.extend({
|
||||
if (!this.value("#entidade_responsavel")) ok = this.markRequired("#entidade_responsavel") && ok;
|
||||
if (!this.value("#tipo_cadastro")) ok = this.markRequired("#tipo_cadastro") && ok;
|
||||
if (!this.value("#numero_documento")) ok = this.markRequired("#numero_documento") && ok;
|
||||
if (!this.value("#autorizador_responsavel")) ok = this.markRequired("#autorizador_responsavel") && ok;
|
||||
if (!this.value("#justificativa")) ok = this.markRequired("#justificativa") && ok;
|
||||
|
||||
if (tipoCadastro === "cpf") {
|
||||
@@ -382,6 +398,47 @@ var MyWidget = SuperWidget.extend({
|
||||
return v;
|
||||
},
|
||||
|
||||
mascaraValorDocumento: function (value) {
|
||||
var raw = (value || "").toString().replace(/[^\d,]/g, "");
|
||||
if (!raw) return "";
|
||||
|
||||
var commaIndex = raw.indexOf(",");
|
||||
var inteiro = "";
|
||||
var decimal = "";
|
||||
|
||||
if (commaIndex >= 0) {
|
||||
inteiro = raw.substring(0, commaIndex).replace(/\D/g, "");
|
||||
decimal = raw.substring(commaIndex + 1).replace(/\D/g, "").slice(0, 2);
|
||||
} else {
|
||||
inteiro = raw.replace(/\D/g, "");
|
||||
}
|
||||
|
||||
inteiro = inteiro.replace(/^0+(?=\d)/, "");
|
||||
if (!inteiro) inteiro = "0";
|
||||
inteiro = inteiro.replace(/\B(?=(\d{3})+(?!\d))/g, ".");
|
||||
|
||||
if (commaIndex >= 0) {
|
||||
return inteiro + "," + decimal;
|
||||
}
|
||||
|
||||
return inteiro;
|
||||
},
|
||||
|
||||
formatMoneyDisplay: function (value) {
|
||||
var normalized = this.normalizeMoney(value);
|
||||
var parts = normalized.split(",");
|
||||
var inteiro = (parts[0] || "").replace(/\D/g, "");
|
||||
var decimal = (parts[1] || "").replace(/\D/g, "").slice(0, 2);
|
||||
|
||||
inteiro = inteiro.replace(/^0+(?=\d)/, "");
|
||||
if (!inteiro) inteiro = "0";
|
||||
if (!decimal) decimal = "00";
|
||||
if (decimal.length === 1) decimal = decimal + "0";
|
||||
|
||||
inteiro = inteiro.replace(/\B(?=(\d{3})+(?!\d))/g, ".");
|
||||
return inteiro + "," + decimal;
|
||||
},
|
||||
|
||||
onlyDigits: function (value) {
|
||||
return (value || "").replace(/\D/g, "");
|
||||
},
|
||||
@@ -389,9 +446,38 @@ var MyWidget = SuperWidget.extend({
|
||||
normalizeMoney: function (value) {
|
||||
var raw = (value || "").toString().trim();
|
||||
if (!raw) return "0,00";
|
||||
if (raw.indexOf(",") >= 0) return raw;
|
||||
if (raw.indexOf(".") >= 0) return raw.replace(".", ",");
|
||||
return raw + ",00";
|
||||
|
||||
var cleaned = raw.replace(/\s/g, "").replace(/[^\d,\.]/g, "");
|
||||
var inteiro = "";
|
||||
var decimal = "";
|
||||
|
||||
if (cleaned.indexOf(",") >= 0) {
|
||||
var commaParts = cleaned.split(",");
|
||||
inteiro = (commaParts.shift() || "").replace(/\D/g, "");
|
||||
decimal = commaParts.join("").replace(/\D/g, "").slice(0, 2);
|
||||
} else if (cleaned.indexOf(".") >= 0) {
|
||||
var dotParts = cleaned.split(".");
|
||||
var isDecimalDot = dotParts.length === 2 && dotParts[1].length > 0 && dotParts[1].length <= 2;
|
||||
|
||||
if (isDecimalDot) {
|
||||
inteiro = (dotParts[0] || "").replace(/\D/g, "");
|
||||
decimal = (dotParts[1] || "").replace(/\D/g, "").slice(0, 2);
|
||||
} else {
|
||||
inteiro = cleaned.replace(/\D/g, "");
|
||||
decimal = "";
|
||||
}
|
||||
} else {
|
||||
inteiro = cleaned.replace(/\D/g, "");
|
||||
decimal = "";
|
||||
}
|
||||
|
||||
inteiro = inteiro.replace(/^0+(?=\d)/, "");
|
||||
if (!inteiro) inteiro = "0";
|
||||
|
||||
if (!decimal) decimal = "00";
|
||||
if (decimal.length === 1) decimal = decimal + "0";
|
||||
|
||||
return inteiro + "," + decimal;
|
||||
},
|
||||
|
||||
normalizeTipoCadastro: function (value) {
|
||||
|
||||
BIN
Binary file not shown.
+640
-277
File diff suppressed because it is too large
Load Diff
BIN
Binary file not shown.
|
Before Width: | Height: | Size: 17 KiB After Width: | Height: | Size: 26 KiB |
+1
-1
File diff suppressed because one or more lines are too long
|
Before Width: | Height: | Size: 7.3 KiB After Width: | Height: | Size: 10 KiB |
@@ -109,6 +109,9 @@
|
||||
<string>valor</string>
|
||||
</void>
|
||||
<void index="32">
|
||||
<string>autorizador_responsavel</string>
|
||||
</void>
|
||||
<void index="33">
|
||||
<string>WKNumProces</string>
|
||||
</void>
|
||||
</array>
|
||||
|
||||
@@ -121,6 +121,9 @@
|
||||
<string>valor</string>
|
||||
</void>
|
||||
<void index="36">
|
||||
<string>autorizador_responsavel</string>
|
||||
</void>
|
||||
<void index="37">
|
||||
<string>WKNumProces</string>
|
||||
</void>
|
||||
</array>
|
||||
|
||||
@@ -0,0 +1,155 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<java version="1.8.0_481" class="java.beans.XMLDecoder">
|
||||
<object class="java.util.HashMap">
|
||||
<void method="put">
|
||||
<string>volume</string>
|
||||
<array class="java.lang.String" length="1">
|
||||
<void index="0">
|
||||
<string>Default</string>
|
||||
</void>
|
||||
</array>
|
||||
</void>
|
||||
<void method="put">
|
||||
<string>expediente</string>
|
||||
<array class="java.lang.String" length="4">
|
||||
<void index="0">
|
||||
<string>Default</string>
|
||||
</void>
|
||||
<void index="1">
|
||||
<string>Expediente BackOffice, Logística e Motorista</string>
|
||||
</void>
|
||||
<void index="2">
|
||||
<string>Expediente Escritório Matriz</string>
|
||||
</void>
|
||||
<void index="3">
|
||||
<string>Expediente Lojas</string>
|
||||
</void>
|
||||
</array>
|
||||
</void>
|
||||
<void method="put">
|
||||
<string>mecanismo</string>
|
||||
<array class="[Ljava.lang.Object;" length="12">
|
||||
<void index="0">
|
||||
<array class="java.lang.Object" length="2">
|
||||
<void index="0">
|
||||
<string>Atribuição por Associação</string>
|
||||
</void>
|
||||
<void index="1">
|
||||
<string>Associado</string>
|
||||
</void>
|
||||
</array>
|
||||
</void>
|
||||
<void index="1">
|
||||
<array class="java.lang.Object" length="2">
|
||||
<void index="0">
|
||||
<string>Atribuição por Campo de Formulário</string>
|
||||
</void>
|
||||
<void index="1">
|
||||
<string>Campo Formulário</string>
|
||||
</void>
|
||||
</array>
|
||||
</void>
|
||||
<void index="2">
|
||||
<array class="java.lang.Object" length="2">
|
||||
<void index="0">
|
||||
<string>dpf_di_emp_filial_filtro</string>
|
||||
</void>
|
||||
<void index="1">
|
||||
<string>dpf_di_emp_filial_filtro</string>
|
||||
</void>
|
||||
</array>
|
||||
</void>
|
||||
<void index="3">
|
||||
<array class="java.lang.Object" length="2">
|
||||
<void index="0">
|
||||
<string>dpf_di_inicio_diadmissao</string>
|
||||
</void>
|
||||
<void index="1">
|
||||
<string>dpf_di_inicio_diadmissao</string>
|
||||
</void>
|
||||
</array>
|
||||
</void>
|
||||
<void index="4">
|
||||
<array class="java.lang.Object" length="2">
|
||||
<void index="0">
|
||||
<string>Atribuição por Executor de Atividade</string>
|
||||
</void>
|
||||
<void index="1">
|
||||
<string>Executor Atividade</string>
|
||||
</void>
|
||||
</array>
|
||||
</void>
|
||||
<void index="5">
|
||||
<array class="java.lang.Object" length="2">
|
||||
<void index="0">
|
||||
<string>Atribuição por Grupo</string>
|
||||
</void>
|
||||
<void index="1">
|
||||
<string>Grupo</string>
|
||||
</void>
|
||||
</array>
|
||||
</void>
|
||||
<void index="6">
|
||||
<array class="java.lang.Object" length="2">
|
||||
<void index="0">
|
||||
<string>Atribuição por Grupos do Colaborador</string>
|
||||
</void>
|
||||
<void index="1">
|
||||
<string>Grupos Colaborador</string>
|
||||
</void>
|
||||
</array>
|
||||
</void>
|
||||
<void index="7">
|
||||
<array class="java.lang.Object" length="2">
|
||||
<void index="0">
|
||||
<string>mecCustomAprov</string>
|
||||
</void>
|
||||
<void index="1">
|
||||
<string>mecCustomAprov</string>
|
||||
</void>
|
||||
</array>
|
||||
</void>
|
||||
<void index="8">
|
||||
<array class="java.lang.Object" length="2">
|
||||
<void index="0">
|
||||
<string>Atribuição por Papel</string>
|
||||
</void>
|
||||
<void index="1">
|
||||
<string>Papel</string>
|
||||
</void>
|
||||
</array>
|
||||
</void>
|
||||
<void index="9">
|
||||
<array class="java.lang.Object" length="2">
|
||||
<void index="0">
|
||||
<string>Atribuição para um Grupo</string>
|
||||
</void>
|
||||
<void index="1">
|
||||
<string>Pool Grupo</string>
|
||||
</void>
|
||||
</array>
|
||||
</void>
|
||||
<void index="10">
|
||||
<array class="java.lang.Object" length="2">
|
||||
<void index="0">
|
||||
<string>Atribuição para um Papel</string>
|
||||
</void>
|
||||
<void index="1">
|
||||
<string>Pool Papel</string>
|
||||
</void>
|
||||
</array>
|
||||
</void>
|
||||
<void index="11">
|
||||
<array class="java.lang.Object" length="2">
|
||||
<void index="0">
|
||||
<string>Atribuição por Usuário</string>
|
||||
</void>
|
||||
<void index="1">
|
||||
<string>Usuário</string>
|
||||
</void>
|
||||
</array>
|
||||
</void>
|
||||
</array>
|
||||
</void>
|
||||
</object>
|
||||
</java>
|
||||
@@ -0,0 +1,155 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<java version="1.8.0_481" class="java.beans.XMLDecoder">
|
||||
<object class="java.util.HashMap">
|
||||
<void method="put">
|
||||
<string>volume</string>
|
||||
<array class="java.lang.String" length="1">
|
||||
<void index="0">
|
||||
<string>Default</string>
|
||||
</void>
|
||||
</array>
|
||||
</void>
|
||||
<void method="put">
|
||||
<string>expediente</string>
|
||||
<array class="java.lang.String" length="4">
|
||||
<void index="0">
|
||||
<string>Default</string>
|
||||
</void>
|
||||
<void index="1">
|
||||
<string>Expediente BackOffice, Logística e Motorista</string>
|
||||
</void>
|
||||
<void index="2">
|
||||
<string>Expediente Escritório Matriz</string>
|
||||
</void>
|
||||
<void index="3">
|
||||
<string>Expediente Lojas</string>
|
||||
</void>
|
||||
</array>
|
||||
</void>
|
||||
<void method="put">
|
||||
<string>mecanismo</string>
|
||||
<array class="[Ljava.lang.Object;" length="12">
|
||||
<void index="0">
|
||||
<array class="java.lang.Object" length="2">
|
||||
<void index="0">
|
||||
<string>Atribuição por Associação</string>
|
||||
</void>
|
||||
<void index="1">
|
||||
<string>Associado</string>
|
||||
</void>
|
||||
</array>
|
||||
</void>
|
||||
<void index="1">
|
||||
<array class="java.lang.Object" length="2">
|
||||
<void index="0">
|
||||
<string>Atribuição por Campo de Formulário</string>
|
||||
</void>
|
||||
<void index="1">
|
||||
<string>Campo Formulário</string>
|
||||
</void>
|
||||
</array>
|
||||
</void>
|
||||
<void index="2">
|
||||
<array class="java.lang.Object" length="2">
|
||||
<void index="0">
|
||||
<string>dpf_di_emp_filial_filtro</string>
|
||||
</void>
|
||||
<void index="1">
|
||||
<string>dpf_di_emp_filial_filtro</string>
|
||||
</void>
|
||||
</array>
|
||||
</void>
|
||||
<void index="3">
|
||||
<array class="java.lang.Object" length="2">
|
||||
<void index="0">
|
||||
<string>dpf_di_inicio_diadmissao</string>
|
||||
</void>
|
||||
<void index="1">
|
||||
<string>dpf_di_inicio_diadmissao</string>
|
||||
</void>
|
||||
</array>
|
||||
</void>
|
||||
<void index="4">
|
||||
<array class="java.lang.Object" length="2">
|
||||
<void index="0">
|
||||
<string>Atribuição por Executor de Atividade</string>
|
||||
</void>
|
||||
<void index="1">
|
||||
<string>Executor Atividade</string>
|
||||
</void>
|
||||
</array>
|
||||
</void>
|
||||
<void index="5">
|
||||
<array class="java.lang.Object" length="2">
|
||||
<void index="0">
|
||||
<string>Atribuição por Grupo</string>
|
||||
</void>
|
||||
<void index="1">
|
||||
<string>Grupo</string>
|
||||
</void>
|
||||
</array>
|
||||
</void>
|
||||
<void index="6">
|
||||
<array class="java.lang.Object" length="2">
|
||||
<void index="0">
|
||||
<string>Atribuição por Grupos do Colaborador</string>
|
||||
</void>
|
||||
<void index="1">
|
||||
<string>Grupos Colaborador</string>
|
||||
</void>
|
||||
</array>
|
||||
</void>
|
||||
<void index="7">
|
||||
<array class="java.lang.Object" length="2">
|
||||
<void index="0">
|
||||
<string>mecCustomAprov</string>
|
||||
</void>
|
||||
<void index="1">
|
||||
<string>mecCustomAprov</string>
|
||||
</void>
|
||||
</array>
|
||||
</void>
|
||||
<void index="8">
|
||||
<array class="java.lang.Object" length="2">
|
||||
<void index="0">
|
||||
<string>Atribuição por Papel</string>
|
||||
</void>
|
||||
<void index="1">
|
||||
<string>Papel</string>
|
||||
</void>
|
||||
</array>
|
||||
</void>
|
||||
<void index="9">
|
||||
<array class="java.lang.Object" length="2">
|
||||
<void index="0">
|
||||
<string>Atribuição para um Grupo</string>
|
||||
</void>
|
||||
<void index="1">
|
||||
<string>Pool Grupo</string>
|
||||
</void>
|
||||
</array>
|
||||
</void>
|
||||
<void index="10">
|
||||
<array class="java.lang.Object" length="2">
|
||||
<void index="0">
|
||||
<string>Atribuição para um Papel</string>
|
||||
</void>
|
||||
<void index="1">
|
||||
<string>Pool Papel</string>
|
||||
</void>
|
||||
</array>
|
||||
</void>
|
||||
<void index="11">
|
||||
<array class="java.lang.Object" length="2">
|
||||
<void index="0">
|
||||
<string>Atribuição por Usuário</string>
|
||||
</void>
|
||||
<void index="1">
|
||||
<string>Usuário</string>
|
||||
</void>
|
||||
</array>
|
||||
</void>
|
||||
</array>
|
||||
</void>
|
||||
</object>
|
||||
</java>
|
||||
+884
-97
File diff suppressed because it is too large
Load Diff
+182
@@ -0,0 +1,182 @@
|
||||
function servicetask15(attempt, message) {
|
||||
var payload = buildSe2010Payload();
|
||||
appendDebugSe2010("servicetask15: payload=" + safeStringify(payload));
|
||||
|
||||
var response = invokeSe2010(payload);
|
||||
appendDebugSe2010("servicetask15: status=" + response.httpStatus + " body=" + response.raw);
|
||||
|
||||
if (!response.success) {
|
||||
throw "Falha ao enviar dados para Protheus SE2010. Status HTTP: " + response.httpStatus + ".";
|
||||
}
|
||||
}
|
||||
|
||||
function buildSe2010Payload() {
|
||||
var payload = {
|
||||
FILIAL: requiredCard("FILIAL"),
|
||||
PREFIXO: requiredCard("PREFIXO"),
|
||||
NUMERO: requiredCard("NUMERO"),
|
||||
PARCELA: requiredCard("PARCELA"),
|
||||
TIPO: requiredCard("TIPO"),
|
||||
NATUREZA: requiredCard("NATUREZA"),
|
||||
COD_FORN: requiredCard("COD_FORN"),
|
||||
LOJA: requiredCard("LOJA"),
|
||||
EMISSAO: normalizeDate(requiredCard("EMISSAO"), "EMISSAO"),
|
||||
VENCIMENTO: normalizeDate(requiredCard("VENCIMENTO"), "VENCIMENTO"),
|
||||
VENC_REAL: normalizeDate(requiredCard("VENC_REAL"), "VENC_REAL"),
|
||||
VALOR: parseMoney(requiredCard("VALORtotal", "VALOR")),
|
||||
HISTORICO: requiredCard("HISTORICO"),
|
||||
CODIGO_BARRAS: card("CODIGO_BARRAS"),
|
||||
CENTRO_CUSTO: requiredCard("CENTRO_CUSTO")
|
||||
};
|
||||
|
||||
return payload;
|
||||
}
|
||||
|
||||
function invokeSe2010(payload) {
|
||||
var serviceCode = card("service_code_se2010") || "protheus_teste";
|
||||
var endpoint = card("endpoint_se2010") || "https://comerciode186920.protheus.cloudtotvs.com.br:4050/rest/uf_se2010";
|
||||
|
||||
var requestData = {
|
||||
companyId: getCompanyIdSafe(),
|
||||
serviceCode: serviceCode,
|
||||
endpoint: endpoint,
|
||||
method: "post",
|
||||
timeoutService: "120",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
"Accept": "application/json"
|
||||
},
|
||||
options: {
|
||||
encoding: "UTF-8",
|
||||
mediaType: "application/json",
|
||||
useSSL: true
|
||||
},
|
||||
params: payload
|
||||
};
|
||||
|
||||
var clientService = fluigAPI.getAuthorizeClientService();
|
||||
var vo = clientService.invoke(JSON.stringify(requestData));
|
||||
var raw = vo ? String(vo.getResult() || "") : "";
|
||||
|
||||
if (!raw) {
|
||||
throw "Resposta vazia da API SE2010.";
|
||||
}
|
||||
|
||||
var httpStatus = getHttpStatus(vo);
|
||||
var parsed = parseJsonSafe(raw);
|
||||
var success = httpStatus >= 200 && httpStatus < 300;
|
||||
|
||||
if (parsed && parsed.success === false) {
|
||||
success = false;
|
||||
}
|
||||
|
||||
return {
|
||||
success: success,
|
||||
httpStatus: httpStatus,
|
||||
raw: raw,
|
||||
parsed: parsed
|
||||
};
|
||||
}
|
||||
|
||||
function requiredCard() {
|
||||
var value = "";
|
||||
|
||||
for (var i = 0; i < arguments.length; i++) {
|
||||
value = card(arguments[i]);
|
||||
if (value) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!value) {
|
||||
throw "Campo obrigatorio nao informado para envio Protheus: " + arguments[0];
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
function card(name) {
|
||||
return ((hAPI.getCardValue(name) || "") + "").replace(/^\s+|\s+$/g, "");
|
||||
}
|
||||
|
||||
function normalizeDate(value, fieldName) {
|
||||
var digits = (value || "").replace(/\D/g, "");
|
||||
if (digits.length !== 8) {
|
||||
throw "Data invalida no campo " + fieldName + ". Informe no formato YYYYMMDD.";
|
||||
}
|
||||
return digits;
|
||||
}
|
||||
|
||||
function parseMoney(value) {
|
||||
var raw = (value || "").toString().replace(/\s/g, "");
|
||||
if (!raw) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (raw.indexOf(",") >= 0) {
|
||||
raw = raw.replace(/\./g, "").replace(",", ".");
|
||||
} else {
|
||||
var dotCount = (raw.match(/\./g) || []).length;
|
||||
if (dotCount > 1) {
|
||||
raw = raw.replace(/\./g, "");
|
||||
}
|
||||
}
|
||||
|
||||
var parsed = parseFloat(raw);
|
||||
if (isNaN(parsed)) {
|
||||
throw "Valor invalido para envio Protheus: " + value;
|
||||
}
|
||||
|
||||
return parseFloat(parsed.toFixed(2));
|
||||
}
|
||||
|
||||
function getCompanyIdSafe() {
|
||||
try {
|
||||
if (typeof getValue === "function") {
|
||||
return String(getValue("WKCompany") || "1");
|
||||
}
|
||||
} catch (e) {
|
||||
// ignore
|
||||
}
|
||||
return "1";
|
||||
}
|
||||
|
||||
function getHttpStatus(vo) {
|
||||
try {
|
||||
var status = parseInt(String(vo.getHttpStatusResult() || "0"), 10);
|
||||
if (!isNaN(status) && status > 0) {
|
||||
return status;
|
||||
}
|
||||
} catch (e) {
|
||||
// ignore
|
||||
}
|
||||
|
||||
return 200;
|
||||
}
|
||||
|
||||
function parseJsonSafe(value) {
|
||||
try {
|
||||
return JSON.parse(value);
|
||||
} catch (e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
function safeStringify(value) {
|
||||
try {
|
||||
return JSON.stringify(value);
|
||||
} catch (e) {
|
||||
return String(value);
|
||||
}
|
||||
}
|
||||
|
||||
function appendDebugSe2010(message) {
|
||||
try {
|
||||
var prefix = "[SE2010] ";
|
||||
var atual = (hAPI.getCardValue("debug_publicacao") || "") + "";
|
||||
var linha = prefix + message;
|
||||
hAPI.setCardValue("debug_publicacao", atual ? (atual + "\n" + linha) : linha);
|
||||
} catch (e) {
|
||||
log.warn("appendDebugSe2010 falhou: " + e);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user