Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Evento de inclusão de DF-e #123

Merged
merged 3 commits into from
Feb 3, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
57 changes: 57 additions & 0 deletions examples/testaIncluirDFe.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
<?php
error_reporting(E_ALL);
ini_set('display_errors', 'On');

include_once '../bootstrap.php';

use NFePHP\Common\Certificate;
use NFePHP\MDFe\Common\Standardize;
use NFePHP\MDFe\Tools;

$config = [
"atualizacao" => date('Y-m-d H:i:s'),
"tpAmb" => 2,
"razaosocial" => 'FÁBRICA DE SOFTWARE MATRIZ',
"cnpj" => '',
"ie" => '',
"siglaUF" => 'PR',
"versao" => '3.00'
];

try {
$certificate = Certificate::readPfx(
'',
''
);

$tools = new Tools(json_encode($config), $certificate);

$chave = '41190822545265000108580260000000081326846774';
$nSeqEvento = '1';
$nProt = '950210000000205';
$cMunCarrega = '5008305';
$xMunCarrega = 'Três Lagoas';
$cMunDescarga = '5008305';
$xMunDescarga = 'Três Lagoas';
$chNFe = '50201137182360000161550100000001051770795689';

$resp = $tools->sefazIncluiDFe(
$chave,
$nProt,
$cMunCarrega,
$xMunCarrega,
$cMunDescarga,
$xMunDescarga,
$chNFe,
$nSeqEvento
);

$st = new Standardize();
$std = $st->toStd($resp);

echo '<pre>';
print_r($std);
echo "</pre>";
} catch (Exception $e) {
echo $e->getMessage();
}
48 changes: 25 additions & 23 deletions src/Make.php
Original file line number Diff line number Diff line change
Expand Up @@ -608,14 +608,16 @@ public function tagide(stdClass $std)
false,
$identificador . "Indicador de participação do Canal Verde"
);
$this->dom->addChild(
$ide,
"indCarregaPosterior",
$std->indCarregaPosterior,
false,
$identificador . "Indicador de MDF-e com inclusão da Carga posterior"
. " a emissão por evento de inclusão de DF-e"
);
if ($std->indCarregaPosterior && $std->indCarregaPosterior == '1') {
$this->dom->addChild(
$ide,
"indCarregaPosterior",
$std->indCarregaPosterior,
false,
$identificador . "Indicador de MDF-e com inclusão da Carga posterior"
. " a emissão por evento de inclusão de DF-e"
);
}

$this->mod = $std->mod;
$this->ide = $ide;
Expand Down Expand Up @@ -915,7 +917,7 @@ public function taginfANTT(stdClass $std)
$std->RNTRC,
false,
$identificador . "Registro Nacional de Transportadores Rodoviários"
. " de Carga"
. " de Carga"
);
$this->infANTT = $infANTT;
return $infANTT;
Expand Down Expand Up @@ -1027,7 +1029,7 @@ public function taginfContratante(stdClass $std)
$std->idEstrangeiro,
true,
$identificador . "Identificador do contratante do serviço em "
. "caso de ser estrangeiro"
. "caso de ser estrangeiro"
);
}
$this->infContratante[] = $infContratante;
Expand Down Expand Up @@ -1624,10 +1626,10 @@ public function tagprodPred($std)
$std->tpCarga,
true,
"Tipo da Carga. 01-Granel sólido; 02-Granel líquido; "
. "03-Frigorificada; 04-Conteinerizada; 05-Carga Geral; "
. "06-Neogranel; 07-Perigosa (granel sólido); 08-Perigosa (granel "
. "líquido); 09-Perigosa (carga frigorificada); 10-Perigosa "
. "(conteinerizada); 11-Perigosa (carga geral)."
. "03-Frigorificada; 04-Conteinerizada; 05-Carga Geral; "
. "06-Neogranel; 07-Perigosa (granel sólido); 08-Perigosa (granel "
. "líquido); 09-Perigosa (carga frigorificada); 10-Perigosa "
. "(conteinerizada); 11-Perigosa (carga geral)."
);
$this->dom->addChild(
$this->prodPred,
Expand All @@ -1642,7 +1644,7 @@ public function tagprodPred($std)
$std->cEAN,
false,
"GTIN (Global Trade Item Number) do produto, antigo código EAN "
. "ou código de barras"
. "ou código de barras"
);
$this->dom->addChild(
$this->prodPred,
Expand Down Expand Up @@ -1991,7 +1993,7 @@ private function buildIde()
if ($this->ide->getElementsByTagName('infPercurso')->length > 1) {
$node = $this->ide->getElementsByTagName('infPercurso')
->item($this->ide->getElementsByTagName('infPercurso')
->length - 1);
->length - 1);
}
}
$this->dom->insertAfter($percurso, $node);
Expand Down Expand Up @@ -2936,31 +2938,31 @@ public function taginfRespTec(stdClass $std)
$std->CNPJ,
true,
"Informar o CNPJ da pessoa jurídica responsável pelo sistema "
. "utilizado na emissão do documento fiscal eletrônico"
. "utilizado na emissão do documento fiscal eletrônico"
);
$this->dom->addChild(
$infRespTec,
"xContato",
$std->xContato,
true,
"Informar o nome da pessoa a ser contatada na empresa desenvolvedora "
. "do sistema utilizado na emissão do documento fiscal eletrônico"
. "do sistema utilizado na emissão do documento fiscal eletrônico"
);
$this->dom->addChild(
$infRespTec,
"email",
$std->email,
true,
"Informar o e-mail da pessoa a ser contatada na empresa "
. "desenvolvedora do sistema."
. "desenvolvedora do sistema."
);
$this->dom->addChild(
$infRespTec,
"fone",
$std->fone,
true,
"Informar o telefone da pessoa a ser contatada na empresa "
. "desenvolvedora do sistema."
. "desenvolvedora do sistema."
);
if (!empty($std->CSRT) && !empty($std->idCSRT)) {
$this->csrt = $std->CSRT;
Expand Down Expand Up @@ -3036,7 +3038,7 @@ public function taginfPag(stdClass $std)
$std->idEstrangeiro,
true,
$identificador . "Identificador do responsável pelo pgto em "
. "caso de ser estrangeiro"
. "caso de ser estrangeiro"
);
}
foreach ($std->Comp as $value) {
Expand Down Expand Up @@ -3271,8 +3273,8 @@ private function equilizeParameters(stdClass $std, $possible)
{
return Strings::equilizeParameters($std, $possible, $this->replaceAccentedChars);
}
/**

/**
* Formatação numerica condicional
* @param string|float|int|null $value
* @param int $decimal
Expand Down
45 changes: 45 additions & 0 deletions src/Tools.php
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,51 @@ public function sefazIncluiCondutor(
);
}

/**
* @author João Gabriel
*
* @param string $chave
* @param string $nProt
* @param string $cMunCarrega
* @param string $xMunCarrega
* @param string $cMunDescarga
* @param string $xMunDescarga
* @param string $chNFe
* @param int $nSeqEvento
* @return string
*/
public function sefazIncluiDFe(
$chave = '',
$nProt = '',
$cMunCarrega = '',
$xMunCarrega = '',
$cMunDescarga = '',
$xMunDescarga = '',
$chNFe = '',
$nSeqEvento = '1'
) {
$tpEvento = 110115;
$tagAdic = "<evIncDFeMDFe>"
. "<descEvento>Inclusao DF-e</descEvento>"
. "<nProt>$nProt</nProt>"
. "<cMunCarrega>$cMunCarrega</cMunCarrega>"
. "<xMunCarrega>$xMunCarrega</xMunCarrega>"
. "<infDoc>"
. "<cMunDescarga>$cMunDescarga</cMunDescarga>"
. "<xMunDescarga>$xMunDescarga</xMunDescarga>"
. "<chNFe>$chNFe</chNFe>"
. "</infDoc>"
. "</evIncDFeMDFe>";

return $this->sefazEvento(
$this->config->siglaUF,
$chave,
$tpEvento,
$nSeqEvento,
$tagAdic
);
}

/**
* @author Cleiton Perin
*
Expand Down