Skip to content

Commit

Permalink
ajustado codigo de acordo com PSR-2
Browse files Browse the repository at this point in the history
  • Loading branch information
realfabecker committed Mar 31, 2017
2 parents a37a781 + 1af7606 commit 15c630a
Showing 1 changed file with 31 additions and 3 deletions.
34 changes: 31 additions & 3 deletions src/Tools.php
Original file line number Diff line number Diff line change
Expand Up @@ -366,8 +366,7 @@ public function sefazInutiliza(
$nIni = (integer) $nIni;
$nFin = (integer) $nFin;
$xJust = Strings::cleanString($xJust);
//Função comentada por não estar implementada.
// $this->zValidParamInut($xJust, $nSerie, $nIni, $nFin);
$this->zValidParamInut($xJust, $nSerie, $nIni, $nFin);
if ($tpAmb == '') {
$tpAmb = $this->aConfig['tpAmb'];
}
Expand Down Expand Up @@ -434,7 +433,7 @@ public function sefazInutiliza(
$this->zGravaFile('cte', $tpAmb, $filename, $retorno);
}
//tratar dados de retorno
$aRetorno = Response::readReturnSefaz($servico, $retorno);
$aRetorno = Response::readReturnSefaz($servico, $retorno);
if ($aRetorno['cStat'] == '102') {
$retorno = $this->zAddProtMsg('ProcInutCTe', 'inutCTe', $signedMsg, 'retInutCTe', $retorno);
if ($salvarMensagens) {
Expand Down Expand Up @@ -490,6 +489,35 @@ protected function zAddProtMsg($tagproc, $tagmsg, $xmlmsg, $tagretorno, $xmlreto
return $procXML;
}

/*
* zValidParamInut
*
* @param string $xJust
* @param int $nSerie
* @param int $nIni
* @param int $nFin
* @throws Exception\InvalidArgumentException
*/
private function zValidParamInut($xJust, $nSerie, $nIni, $nFin)
{
$msg = '';
//valida dos dados de entrada
if (strlen($xJust) < 15 || strlen($xJust) > 255) {
$msg = "A justificativa deve ter entre 15 e 255 digitos!!";
} elseif ($nSerie < 0 || $nSerie > 999) {
$msg = "O campo serie está errado: $nSerie!!";
} elseif ($nIni < 1 || $nIni > 1000000000) {
$msg = "O campo numero inicial está errado: $nIni!!";
} elseif ($nFin < 1 || $nFin > 1000000000) {
$msg = "O campo numero final está errado: $nFin!!";
} elseif ($this->enableSVCRS || $this->enableSVCAN) {
$msg = "A inutilização não pode ser feita em contingência!!";
}
if ($msg != '') {
throw new Exception\InvalidArgumentException($msg);
}
}

/**
* Cancelamento de numero CT-e
*
Expand Down

0 comments on commit 15c630a

Please sign in to comment.