awacode/importnfe

Importe suas Nfe de maneira facil utilizando o XML

1.0.0 2022-09-30 03:30 UTC

This package is not auto-updated.

Last update: 2024-05-25 09:56:59 UTC


README

Maintainer Source Code PHP from Packagist Latest Version Software License Build Quality Score Total Downloads

ImportNfe é um componente extremamente compacto e fácil de usar. Você só precisa configurar seu comportamento uma vez pelo contrutor, e depois enviar os aquivos xml para fazer a importação e cadastro no Banco de Dados.

ImportNfe Library is an extremely compact and easy-to-use component. You only need to configure its behavior once by the constructor, and then send the xml files to make the remittance and register in the Bank.

Sobre AwaCode

AwaCode é um conjunto de pequenos e otimizados componentes PHP para tarefas comuns. Mantido por Rhyann C. Com eles você executa tarefas rotineiras com poucas linhas, escrevendo menos e fazendo muito mais.

AwaCode is a set of small, optimized PHP components for common tasks. Maintained by Rhyan C. With them you can do routine tasks with few lines, writing less and doing a lot more.

Destaques

  • Fácil para configurar e personalizar via construtor da classe (Easy to configure and customize via constructor class)
  • Simples de integra e fazer a importação de suas Notas Fiscais em XML (Simple to integrate and import your Invoices in XML)
  • Controle para nao importar Nfe emitidas em Homologação e sem numero de protocolo (Control not to import Nfe issued in Homologation and without protocol number)
  • Controle para nao importar Nfe duplicadas. (Control not to import duplicate Nfe.)
  • Organização de pasta de Nfe importadas com sucesso e com erros (Nfe folder organization imported successfully and with errors)
  • Pronto para o composer e compatível com PSR-2 (Composer ready and PSR-2 compliant)

Installation

ImportNfe está disponível via Composer:

"awacode/importnfe": "^1.0"

or run

composer require AwaCode/ImportNfe

Documentation

For details on how to use the ImportNfe, see the sample folder with details in the component directory

Para mais detalhes sobre como usar o ImportNfe, veja a pasta de exemplo com detalhes no diretório do componente

<?php
require __DIR__ . "/../src/ImportNfe.php";
        require __DIR__ . "/../src/Xml.php";
        require __DIR__ . "/conexao.php";


    $xml = new AwaCode\ImportNfe\Xml("uploads", "xmlnfe", "imports", "error", false); //("importados", "xmlnfe");

    //NORMALIZA O ARRAY PARA ENVIAR PARA CADASTRO
    if ($_FILES)
    {
          $nfe = $_FILES["xml"];
          for ($i = 0; $i < count($nfe["type"]); $i++)
         {
            foreach (array_keys($nfe) as $keys)
             {
                $nfeFiles[$i][$keys] = $nfe[$keys][$i];
              }
         }

         //CORRE PELO ARRAY NORMALIZADO E FAZ O UPLOAD
         foreach ($nfeFiles as $file)
         {
            $upload = $xml->upload($file);
         }

        //PEGA O ARRAY DE TODOS OS ARQUIVOS ENVIADO NA PASTA TEMPORARIA
        $post = $xml->gravaarquivo();

        // GRAVA NO BD
      if (!empty($post->items)):
        foreach ($post->items as $notas)
        {
             //VERIFICA SE JA FOI IMPORTADA ANTES
             $chnotes = $conn->prepare("SELECT * FROM tbl_notas WHERE chave = :CHAVE");
             $chnotes->bindParam(":CHAVE", $notas['chave']);
             $chnotes->execute();
             $check = $chnotes->rowCount();
        
             if ($check == 0 )
                { /* GRAVA A NOTA NA TABELA */ }
             foreach ($notas['itens'] as $iten)
                { /* GRAVA OS PRODUTOS  DA NOTA NA TABELA DE ITENS */ }
        }      
      endif;

    }
HTML
<form name="env" method="post" enctype="multipart/form-data">

   <h1>Importar XML da NFe</h1>
   <input type="file" multiple="multiple" name="xml[]" id="xml[]" required/>
   <button>Enviar Nfe</button>

</form>

Contributing

Please see CONTRIBUTING for details.

Support

Security: If you discover any security related issues, please email rhyannc@hotmail.com.br instead of using the issue tracker.

Se você descobrir algum problema relacionado à segurança, envie um e-mail para rhyannc@hotmail.com.br em vez de usar o rastreador de problemas.

Thank you

Credits

License

The MIT License (MIT). Please see License File for more information.