Skip to content

Commit

Permalink
Merge pull request #98 from realfabecker/adiciona-zValidParamInut-Tools
Browse files Browse the repository at this point in the history
adicionado metodo zValidParamInut para uso em sefazInutiliza
  • Loading branch information
maisonsakamoto authored Mar 31, 2017
2 parents 6f56620 + 9851de5 commit 1af7606
Showing 1 changed file with 30 additions and 2 deletions.
32 changes: 30 additions & 2 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 @@ -445,6 +444,35 @@ public function sefazInutiliza(
// }
return (string) $retorno;
}

/**
* 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 1af7606

Please sign in to comment.