├── .gitignore ├── .vscode └── launch.json ├── GeraConemb.php ├── GeraDoccob.php ├── GeraKC.php ├── GeraNotfis.php ├── GeraOcoren.php ├── GeraPernod.php ├── GeraProcter.php ├── LICENSE ├── README.md ├── app ├── Campo.php ├── Kimberly_Clark │ ├── Estoque.php │ └── Sellout.php ├── Layout.php ├── Pernod │ ├── Estoque.php │ └── Venda.php ├── Proceda │ ├── Conemb.php │ ├── Doccob.php │ ├── Notfis.php │ └── Ocoren.php └── Procter │ ├── Clientes.php │ ├── Inventarios.php │ ├── Produtividades.php │ ├── Vendas.php │ └── Vendedores.php ├── arquivos ├── .directory ├── BLZ_STOR_NC_10908082005.txt ├── BZL_FACTSINV_NC_10908092005.txt ├── BZL_FACT_NC_10908092005.txt ├── BZL_PROD_NC_10908092005.txt ├── BZL_SREP_NC_10908092005.txt ├── ESTOQUE_00000000_20150701.txt ├── KC.txt ├── SELLOUT_CodigoFIA_AAAAMMDD.txt ├── conemb.txt ├── doccob.txt ├── notfis.txt └── ocoren.txt ├── composer-setup.php ├── composer.json ├── composer.lock ├── dados ├── KimberlyClark.xml ├── Pernod.xml ├── conemb.xml ├── doccob.xml ├── notfis.xml ├── ocoren.xml └── procter.xml ├── layouts ├── kc │ ├── Layout FIA Estoque_FINAL.pdf │ └── Layout FIA.pdf ├── proceda │ └── DOCCOB-50.pdf └── procter │ └── EDI PROCTER GAMBLE.pdf └── teste.php /.gitignore: -------------------------------------------------------------------------------- 1 | .vscode/* 2 | vendor/* 3 | -------------------------------------------------------------------------------- /.vscode/launch.json: -------------------------------------------------------------------------------- 1 | { 2 | // Use IntelliSense to learn about possible attributes. 3 | // Passe o mouse para ver as descrições dos atributos existentes. 4 | // Para obter mais informações, visite: https://go.microsoft.com/fwlink/?linkid=830387 5 | "version": "0.2.0", 6 | "configurations": [ 7 | { 8 | "name": "Listen for XDebug", 9 | "type": "php", 10 | "request": "launch", 11 | "port": 9000 12 | }, 13 | { 14 | "name": "Launch currently open script", 15 | "type": "php", 16 | "request": "launch", 17 | "program": "${file}", 18 | "cwd": "${fileDirname}", 19 | "port": 9000 20 | } 21 | ] 22 | } -------------------------------------------------------------------------------- /GeraConemb.php: -------------------------------------------------------------------------------- 1 | | 10 | * | | 11 | * | Programa...: GeraProceda.php | 12 | * | | 13 | * | Autor......: Helder | 14 | * | | 15 | * | Criação....: 26-06-2018 | 16 | * | | 17 | * | Objetivo...: Gerar todos os registros conforme Layout PROCEDA/CONEMB. | 18 | * | Os dados devem estar no arquivo dados/conemb.xml | 19 | * | | 20 | * | Layout EDI.: 6.0 - 31/07/2008 | 21 | * | | 22 | * +-----------------------------------------------------------------------+ 23 | * | Versões....: | 24 | * | | 25 | * | | 26 | * | | 27 | * +-----------------------------------------------------------------------+ 28 | */ 29 | 30 | // Campo ORIGATÒRIO preencher o conteudo 31 | const OBRIGATORIO = true; 32 | 33 | // Delimitador 34 | const DELIMITADOR = ''; 35 | 36 | // Tamanho da linha 37 | const TAMANHO = 350; 38 | 39 | // Tipo de campo A/N 40 | const NUMERICO = 'N'; 41 | const PREENCHIMENTO = ' '; 42 | const ALFA = 'A'; 43 | 44 | require_once "vendor/autoload.php"; 45 | 46 | use App\Proceda\Conemb; 47 | 48 | try { 49 | // Variavel memória de todas as linhas 50 | $linhas = ''; 51 | 52 | // Instancia objeto DOCCOB 53 | $conemb = new Conemb(); 54 | 55 | 56 | // Obtem os dados de arquivo XML: dados/proceda.xml 57 | $xml = simplexml_load_file('dados/conemb.xml'); 58 | 59 | // Acrescenta registro 000 60 | $linhas = $conemb->registro_000($xml->remetente, $xml->destinatario, $xml->data, $xml->hora, $xml->intercambio, TAMANHO); 61 | 62 | foreach ($xml->documentos->sequencia as $documento) { 63 | // Acrescenta registro 520 64 | $linhas .= $conemb->registro_520($documento->documento, TAMANHO); 65 | // Acrescenta registro 521 66 | $linhas .= $conemb->registro_521($documento->transportadora->cnpj, $documento->transportadora->razao, TAMANHO); 67 | // Acrescenta registro 522 68 | $linhas .= $conemb->registro_522($documento->embarcados->filial_emissora, $documento->embarcados->serie_conhecimento, $documento->embarcados->numero_conhecimento, $documento->embarcados->data_emissao, $documento->embarcados->condicao_frete, $documento->embarcados->cnpj_local, $documento->embarcados->cnpj_emissor_nf, $documento->embarcados->cnpj_destino_conhecimento_devolucao, $documento->embarcados->cnpj_destinatario_notas, $documento->embarcados->cnpj_consignatario, $documento->embarcados->codigo_fiscal, $documento->embarcados->placa_veiculo, $documento->embarcados->numero_romaneio, $documento->embarcados->numero_sap1, $documento->embarcados->numero_sap2, $documento->embarcados->numero_sap3, $documento->embarcados->identificacao_autorizacao_carregamento, $documento->embarcados->chave_consulta, $documento->embarcados->protocolo, $documento->embarcados->codigo_chave_acesso, $documento->embarcados->filial_emissora_conhecimento, $documento->embarcados->serie_conhecimento_transportadora, $documento->embarcados->numero_conhecimento_transportadora, $documento->embarcados->tipo_transporte, $documento->embarcados->tipo_conhecimento, $documento->embarcados->tipo_frete, $documento->embarcados->acao_documento, $documento->embarcados->frete_diferenciado, $documento->embarcados->tabela_frete, $documento->embarcados->carga_rapida, $documento->embarcados->uf_embarcador, $documento->embarcados->uf_emissor, $documento->embarcados->uf_destinatario, TAMANHO); 69 | // Acrescenta registro 523 70 | $linhas .= $conemb->registro_523($documento->vlr_conhecimento->qntd_tot_volume, $documento->vlr_conhecimento->peso_bruto, $documento->vlr_conhecimento->peso_cubado, $documento->vlr_conhecimento->peso_densidade, $documento->vlr_conhecimento->valor_frete_total, $documento->vlr_conhecimento->valor_frete_peso, $documento->vlr_conhecimento->frete_valor, $documento->vlr_conhecimento->frete_ad_valorem, $documento->vlr_conhecimento->valor_sec, $documento->vlr_conhecimento->valor_itr, $documento->vlr_conhecimento->valor_despacho, $documento->vlr_conhecimento->valor_pedagio, $documento->vlr_conhecimento->valor_ademe_gris, $documento->vlr_conhecimento->valor_total_despesa_extra, $documento->vlr_conhecimento->valor_desconto_ou_acrescimo, $documento->vlr_conhecimento->indicador_desconto_ou_acrescimo, $documento->vlr_conhecimento->base_calculo_apuracao_icms, $documento->vlr_conhecimento->taxa_icms, $documento->vlr_conhecimento->valor_icms, $documento->vlr_conhecimento->substituicao_tributaria, $documento->vlr_conhecimento->base_calculo_icms_subst_tributaria, $documento->vlr_conhecimento->taxa_icms_subst_tributaria, $documento->vlr_conhecimento->valor_icms_subst_tributaria, $documento->vlr_conhecimento->base_calculo_iss, $documento->vlr_conhecimento->taxa_iss, $documento->vlr_conhecimento->valor_iss, $documento->vlr_conhecimento->valor_ir, $documento->vlr_conhecimento->direito_fiscal, $documento->vlr_conhecimento->tipo_imposto, TAMANHO); 71 | // Acrescenta registro 524 72 | $linhas .= $conemb->registro_524($documento->componente_conhecimento->cnpj, $documento->componente_conhecimento->numero_nf, $documento->componente_conhecimento->serie, $documento->componente_conhecimento->data_emissao, $documento->componente_conhecimento->valor_nf, $documento->componente_conhecimento->otde_total, $documento->componente_conhecimento->peso_bruto, $documento->componente_conhecimento->peso_densidade, $documento->componente_conhecimento->peso_cubado, $documento->componente_conhecimento->identificacao_pedido, $documento->componente_conhecimento->numero_romaneio, $documento->componente_conhecimento->numero_sap1, $documento->componente_conhecimento->numero_sap2, $documento->componente_conhecimento->numero_sap3, $documento->componente_conhecimento->nf_devolucao, $documento->componente_conhecimento->tipo_nf, $documento->componente_conhecimento->indicacao_bonificacao, $documento->componente_conhecimento->cfop, $documento->componente_conhecimento->uf, $documento->componente_conhecimento->desdobro, TAMANHO); 73 | // Acrescenta registro 525 74 | $linhas .= $conemb->registro_525($documento->dados_entrega->cnpj1, $documento->dados_entrega->razao1, $documento->dados_entrega->serie1, $documento->dados_entrega->numero_nf1, $documento->dados_entrega->cnpj2, $documento->dados_entrega->razao2, $documento->dados_entrega->serie2, $documento->dados_entrega->numero_nf2, $documento->dados_entrega->cnpj3, $documento->dados_entrega->razao3, $documento->dados_entrega->serie3, $documento->dados_entrega->numero_nf3, $documento->dados_entrega->redespacho_filial_emissora, $documento->dados_entrega->redespacho_serie_conhecimento, $documento->dados_entrega->redespacho_numero_conhecimento, $documento->dados_entrega->redespacho_cnpj_transportadora, TAMANHO); 75 | // Acrescenta registro 527 76 | $linhas .= $conemb->registro_527($documento->dados_consignatario->razao, $documento->dados_consignatario->cnpj, $documento->dados_consignatario->inscricao_estadual, $documento->dados_consignatario->endereco, $documento->dados_consignatario->bairro, $documento->dados_consignatario->cidade, $documento->dados_consignatario->codigo_postal, $documento->dados_consignatario->codigo_municipio, $documento->dados_consignatario->uf, $documento->dados_consignatario->numero_comunicacao, TAMANHO); 77 | // Acrescenta registro 529 78 | $linhas .= $conemb->registro_529($documento->final->qntd_total_conhecimentos, $documento->final->valor_total_conhecimentos, TAMANHO); 79 | 80 | } 81 | // Mostra resultado 82 | file_put_contents('arquivos/conemb.txt', $linhas); 83 | echo "

\n"; 84 | echo $linhas; 85 | 86 | } catch (Exception $e) { 87 | echo 'ERRO: ' .$e->getMessage(); 88 | } 89 | -------------------------------------------------------------------------------- /GeraDoccob.php: -------------------------------------------------------------------------------- 1 | | 10 | * | | 11 | * | Programa...: GeraProceda.php | 12 | * | | 13 | * | Autor......: Helder | 14 | * | | 15 | * | Criação....: 26-06-2018 | 16 | * | | 17 | * | Objetivo...: Gerar todos os registros conforme Layout PROCEDA/DOCCOB. | 18 | * | Os dados devem estar no arquivo dados/doccob.xml | 19 | * | | 20 | * | Layout EDI.: 6.0 - 31/07/2008 | 21 | * | | 22 | * +-----------------------------------------------------------------------+ 23 | * | Versões....: | 24 | * | | 25 | * | | 26 | * | | 27 | * +-----------------------------------------------------------------------+ 28 | */ 29 | 30 | // Campo ORIGATÒRIO preencher o conteudo 31 | const OBRIGATORIO = true; 32 | 33 | // Tamanho da linha 34 | const TAMANHO = 280; 35 | 36 | // Delimitador 37 | const DELIMITADOR = ''; 38 | 39 | // Tipo de campo A/N 40 | const NUMERICO = 'N'; 41 | const PREENCHIMENTO = ' '; 42 | const ALFA = 'A'; 43 | 44 | require_once "vendor/autoload.php"; 45 | 46 | use App\Proceda\Doccob; 47 | 48 | try { 49 | // Variavel memória de todas as linhas 50 | $linhas = ''; 51 | 52 | // Instancia objeto DOCCOB 53 | $doccob = new Doccob(); 54 | 55 | 56 | // Obtem os dados de arquivo XML: dados/proceda.xml 57 | $xml = simplexml_load_file('dados/doccob.xml'); 58 | 59 | // Acrescenta registro 000 60 | $linhas = $doccob->registro_000($xml->remetente, $xml->destinatario, $xml->data, $xml->hora, $xml->intercambio, TAMANHO); 61 | 62 | foreach ($xml->documentos->sequencia as $documento) { 63 | // Acrescenta registro 550 64 | $linhas .= $doccob->registro_550($documento->documento, TAMANHO); 65 | // Acrescenta registro 551 66 | $linhas .= $doccob->registro_551($documento->cnpj, $documento->razao, TAMANHO); 67 | // Acrescenta registro 552 68 | $linhas .= $doccob->registro_552($documento->cobranca->filial, $documento->cobranca->tipo,$documento->cobranca->serie, $documento->cobranca->numero, $documento->cobranca->emissao, $documento->cobranca->vencimento, $documento->cobranca->valor, $documento->cobranca->tipo_cobranca, $documento->cobranca->multa, $documento->cobranca->juros, $documento->cobranca->limite, $documento->cobranca->desconto, $documento->cobranca->agente, $documento->cobranca->nome, $documento->cobranca->agencia, $documento->cobranca->digito, $documento->cobranca->conta, $documento->cobranca->digito_conta, $documento->cobranca->acao, $documento->cobranca->pre_fatura, $documento->cobranca->complementar, $documento->cobranca->cfop, $documento->cobranca->codigo, $documento->cobranca->chave, $documento->cobranca->protocolo, TAMANHO); 69 | // Acrescenta registro 553 70 | $linhas .= $doccob->registro_553($documento->cobranca->imposto->valorICMS, $documento->cobranca->imposto->aliquotaICMS, $documento->cobranca->imposto->baseICMS, $documento->cobranca->imposto->valorISS, $documento->cobranca->imposto->aliquotaISS, $documento->cobranca->imposto->baseISS, $documento->cobranca->imposto->valorSUBS, $documento->cobranca->imposto->aliquotaSUBS, $documento->cobranca->imposto->baseSUBS, $documento->cobranca->imposto->valorIR, TAMANHO); 71 | // Acrescenta registro 555 72 | $linhas .= $doccob->registro_555($documento->fatura->filial, $documento->fatura->serie, $documento->fatura->numero, $documento->fatura->valor, $documento->fatura->emissao, $documento->fatura->remetente, $documento->fatura->destinatario, $documento->fatura->emissor_do_conhecimento, $documento->fatura->uf_embarcador, $documento->fatura->uf_emissora, $documento->fatura->uf_destinatario, $documento->fatura->conta_razao, $documento->fatura->iva, $documento->fatura->identificacao_embarque, $documento->fatura->identificacao_carga, $documento->fatura->numero_sap, $documento->fatura->outro_sap, $documento->fatura->devolucao, TAMANHO); 73 | // Acrescenta registro 556 74 | $linhas .= $doccob->registro_556($documento->cobranca->nota_fiscal->serie, $documento->cobranca->nota_fiscal->numero, $documento->cobranca->nota_fiscal->emissao, $documento->cobranca->nota_fiscal->peso, $documento->cobranca->nota_fiscal->valor, $documento->cobranca->nota_fiscal->emissor, $documento->cobranca->nota_fiscal->identificacao_embarque, $documento->cobranca->nota_fiscal->identificacao_carga, $documento->cobranca->nota_fiscal->numero_sap, $documento->cobranca->nota_fiscal->outro_sap, $documento->cobranca->nota_fiscal->nf_devolucao, TAMANHO); 75 | // Acrescenta registro 559 76 | $linhas .= $doccob->registro_559($documento->final->qntde_total, $documento->final->valor, TAMANHO); 77 | } 78 | // Mostra resultado 79 | file_put_contents('arquivos/doccob.txt', $linhas); 80 | echo "

\n"; 81 | echo $linhas; 82 | 83 | } catch (Exception $e) { 84 | echo 'ERRO: ' .$e->getMessage(); 85 | } 86 | -------------------------------------------------------------------------------- /GeraKC.php: -------------------------------------------------------------------------------- 1 | | 11 | * | | 12 | * | Programa...: GeraKC.php | 13 | * | | 14 | * | Autor......: Helder | 15 | * | | 16 | * | Criação....: 23-09-2018 | 17 | * | | 18 | * | Objetivo...: Gerar todos os registros conforme Layout KimberlyClark. | 19 | * | Os dados devem estar no arquivo dados/KimberlyClark.xml | 20 | * | | 21 | * | Layout EDI.: | 22 | * | | 23 | * +-----------------------------------------------------------------------+ 24 | * | Versões....: | 25 | * | | 26 | * | | 27 | * | | 28 | * +-----------------------------------------------------------------------+ 29 | */ 30 | 31 | // Campo ORIGATÒRIO preencher o conteudo 32 | const OBRIGATORIO = true; 33 | const OPCIONAL = false; 34 | 35 | const NUMERICO = 'N'; 36 | const ALFA = 'A'; 37 | 38 | const DELIMITADOR = ''; 39 | const PREENCHIMENTO = ' '; 40 | 41 | 42 | require_once "vendor/autoload.php"; 43 | 44 | use App\Kimberly_Clark\Estoque; 45 | use App\Kimberly_Clark\Sellout; 46 | 47 | try { 48 | // Variavel memória de todas as linhas 49 | $linhas = ''; 50 | 51 | // Instancia objetos 52 | $estoque = new Estoque(); 53 | $sellout = new Sellout(); 54 | 55 | 56 | // Obtem os dados de arquivo XML: dados/proceda.xml 57 | $xml = simplexml_load_file('dados/KimberlyClark.xml'); 58 | 59 | // Acrescenta registro 60 | $linhas = $estoque->header_estoque($xml->cod_sap)."\n"; 61 | 62 | $linhas .= $estoque->detalhe_estoque($xml->cod_sap, $xml->ean, $xml->cod_interno, $xml->sku, $xml->estoque_fisico, $xml->estoque_transito, $xml->estoque_reservado, $xml->estoque_total); 63 | file_put_contents('arquivos/ESTOQUE_00000000_20150701.txt', $linhas); 64 | echo $linhas."\n"; 65 | echo "\n\n"; 66 | 67 | 68 | $linhas = $sellout->header_sellout($xml->cod_sap, $xml->sellout->data)."\n"; 69 | 70 | $linhas .= $sellout->detalhe_sellout($xml->sellout->cod_sap_dist, $xml->sellout->cod_sap_ent, $xml->sellout->cod_cliente, $xml->sellout->nome_cliente, $xml->sellout->cnpj_cliente_indireto, $xml->sellout->cpf_cliente_indireto, $xml->sellout->endereco, $xml->sellout->cep, $xml->sellout->estado, $xml->sellout->bairro, $xml->sellout->municipio, $xml->sellout->telefone, $xml->sellout->pais, $xml->sellout->contato, $xml->sellout->tipo_negocio, $xml->sellout->zona_estabelecida_distribuidor, $xml->sellout->representante_distribuidor, $xml->sellout->nome_representante, $xml->sellout->cod_produto_atacado, $xml->sellout->cod_ean, $xml->sellout->cod_sap_produto, $xml->sellout->venda_qntd, $xml->sellout->valor_venda, $xml->sellout->preco_unitario, $xml->sellout->tipo_moeda, $xml->sellout->data_faturamento, $xml->sellout->data_entrega, $xml->sellout->tipo_documento, $xml->sellout->cod_documento, $xml->sellout->unidade_medida_qntd, $xml->sellout->numerador_conversao_qntd_unidade, $xml->sellout->denominador_conversor_qntd_unidade, $xml->sellout->unidade_medida_preco, $xml->sellout->numerador_conversao_preco_unidade, $xml->sellout->denominador_conversor_preco_unidade, $xml->sellout->data_fim_periodo_reportado, $xml->sellout->data_transmissao_informacao, $xml->sellout->numero_transmissao, $xml->sellout->cpf_representante_vendas_atacado, $xml->sellout->chave_acesso); 71 | file_put_contents('arquivos/SELLOUT_CodigoFIA_AAAAMMDD.txt', $linhas); 72 | echo $linhas."\n"; 73 | 74 | } catch (Exception $e) { 75 | echo 'ERRO: ' .$e->getMessage(); 76 | } -------------------------------------------------------------------------------- /GeraNotfis.php: -------------------------------------------------------------------------------- 1 | | 10 | * | | 11 | * | Programa...: GeraNotfis.php | 12 | * | | 13 | * | Autor......: Helder | 14 | * | | 15 | * | Criação....: 26-06-2018 | 16 | * | | 17 | * | Objetivo...: Gerar todos os registros conforme Layout PROCEDA/NOTFIS. | 18 | * | Os dados devem estar no arquivo dados/notfis.xml | 19 | * | | 20 | * | Layout EDI.: 6.0 - 31/07/2008 | 21 | * | | 22 | * +-----------------------------------------------------------------------+ 23 | * | Versões....: | 24 | * | | 25 | * | | 26 | * | | 27 | * +-----------------------------------------------------------------------+ 28 | */ 29 | 30 | // Campo ORIGATÒRIO preencher o conteudo 31 | const OBRIGATORIO = true; 32 | 33 | // Delimitador 34 | const DELIMITADOR = ''; 35 | 36 | // Tamanho da linha 37 | const TAMANHO = 320; 38 | 39 | // Tipo de campo A/N 40 | const NUMERICO = 'N'; 41 | const PREENCHIMENTO = ' '; 42 | const ALFA = 'A'; 43 | 44 | require_once "vendor/autoload.php"; 45 | 46 | use App\Proceda\Notfis; 47 | 48 | try { 49 | // Variavel memória de todas as linhas 50 | $linhas = ''; 51 | 52 | // Instancia objeto DOCCOB 53 | $notfis = new Notfis(); 54 | 55 | 56 | // Obtem os dados de arquivo XML: dados/proceda.xml 57 | $xml = simplexml_load_file('dados/notfis.xml'); 58 | 59 | // Acrescenta registro 000 60 | $linhas = $notfis->registro_000($xml->remetente, $xml->destinatario, $xml->data, $xml->hora, $xml->intercambio, TAMANHO); 61 | 62 | foreach ($xml->documentos->sequencia as $documento) { 63 | // Acrescenta registro 500 64 | $linhas .= $notfis->registro_500($documento->documento, TAMANHO); 65 | // Acrescenta registro 501 66 | $linhas .= $notfis->registro_501($documento->documento, $documento->cnpj, $documento->insc_embarq, $documento->insc_subs_tribut, $documento->insc_muni, $documento->endereco, $documento->bairro, $documento->cidade, $documento->cod_postal, $documento->cod_municipio, $documento->uf, $documento->data_embarque, $documento->area_frete, $documento->contato_emerg, TAMANHO); 67 | // Acrescenta registro 502 68 | $linhas .= $notfis->registro_502($documento->coleta->razao, $documento->coleta->cnpj, $documento->coleta->endereco, $documento->coleta->bairro, $documento->coleta->cidade, $documento->coleta->cod_postal, $documento->coleta->cod_municipio, $documento->coleta->uf, $documento->coleta->numero_contato, $documento->coleta->area_frete, TAMANHO); 69 | // Acrescenta registro 503 70 | $linhas .= $notfis->registro_503($documento->destinatario_nota->razao, $documento->destinatario_nota->cnpj, $documento->destinatario_nota->insc_estadual, $documento->destinatario_nota->insc_suframa, $documento->destinatario_nota->endereco, $documento->destinatario_nota->bairro, $documento->destinatario_nota->cidade, $documento->destinatario_nota->cod_postal, $documento->destinatario_nota->cod_municipio, $documento->destinatario_nota->uf, $documento->destinatario_nota->numero_contato, $documento->destinatario_nota->cod_pais, $documento->destinatario_nota->area_frete, $documento->destinatario_nota->tipo_identificacao_dest, $documento->destinatario_nota->tipo_estabelecimento_dest, TAMANHO); 71 | // Acrescenta registro 504 72 | $linhas .= $notfis->registro_504($documento->entrega->razao, $documento->entrega->cnpj, $documento->entrega->insc_estadual, $documento->entrega->endereco, $documento->entrega->bairro, $documento->entrega->cidade, $documento->entrega->cod_postal, $documento->entrega->cod_municipio, $documento->entrega->uf, $documento->entrega->numero_contato, $documento->entrega->cod_pais, $documento->entrega->area_frete, $documento->entrega->tipo_identificacao_dest, $documento->entrega->tipo_estabelecimento_dest, TAMANHO); 73 | // Acrescenta registro 505 74 | $linhas .= $notfis->registro_505($documento->dados_nf->serie, $documento->dados_nf->numero, $documento->dados_nf->data, $documento->dados_nf->tipo, $documento->dados_nf->especie_acond, $documento->dados_nf->cod_rota, $documento->dados_nf->meio_transporte, $documento->dados_nf->tipo_transporte, $documento->dados_nf->tipo_carga, $documento->dados_nf->condicao_frete, $documento->dados_nf->data_embarque, $documento->dados_nf->desdobro, $documento->dados_nf->plano_cargarapida, $documento->dados_nf->tipo_doc_fiscal, $documento->dados_nf->bonificacao, $documento->dados_nf->cfop, $documento->dados_nf->uf, $documento->dados_nf->frete_diferenciado, $documento->dados_nf->tabela_frete, $documento->dados_nf->modalidade_frete, $documento->dados_nf->identf_pedido_cliente, $documento->dados_nf->identf_embarque, $documento->dados_nf->numero_sap, $documento->dados_nf->outro_sap, $documento->dados_nf->outro_sap1, $documento->dados_nf->tipo_periodo_entrega, $documento->dados_nf->data_init_entrega, $documento->dados_nf->hora_init_entrega, $documento->dados_nf->data_final_entrega, $documento->dados_nf->hora_final_entrega, $documento->dados_nf->cod_numerico_chaveacesso_nfe, $documento->dados_nf->chaveacesso_nfe_dv, $documento->dados_nf->numero_protocolo, $documento->dados_nf->acao_doc, TAMANHO); 75 | // Acrescenta registro 506 76 | $linhas .= $notfis->registro_506($documento->valores_nf->otde_tot, $documento->valores_nf->pesobruto_tot, $documento->valores_nf->pesoliqui_tot, $documento->valores_nf->peso_densidade, $documento->valores_nf->peso_cubado, $documento->valores_nf->incidencia_icms, $documento->valores_nf->seguro_efetuado, $documento->valores_nf->valor_cliente, $documento->valores_nf->valor_tot_nota, $documento->valores_nf->valor_tot_seguro, $documento->valores_nf->valor_tot_desconto, $documento->valores_nf->valor_tot_outrasdispensas, $documento->valores_nf->calculo_icms, $documento->valores_nf->valor_tot_icms, $documento->valores_nf->calculo_icms_subst_tributaria, $documento->valores_nf->valor_tot_icms_subst_tributaria, $documento->valores_nf->valor_icms_retido, $documento->valores_nf->valor_tot_imposto_importacao, $documento->valores_nf->valor_ipi, $documento->valores_nf->valor_pis, $documento->valores_nf->valor_cofins, $documento->valores_nf->valor_calculado_frete, $documento->valores_nf->valor_tot_icms_frete, $documento->valores_nf->valor_tot_icms_subst_tributaria_frete, $documento->valores_nf->valor_tot_iss_frete, TAMANHO); 77 | // Acrescenta registro 507 78 | $linhas .= $notfis->registro_507($documento->calc_frete->qntd_total_volumes_embalagens, $documento->calc_frete->peso_total_transportado, $documento->calc_frete->peso_cubado, $documento->calc_frete->peso_densidade, $documento->calc_frete->valor_tot_frete, $documento->calc_frete->valor_frete_peso, $documento->calc_frete->frete_valor, $documento->calc_frete->frete_ad_valorem, $documento->calc_frete->valor_sec_cat, $documento->calc_frete->valor_itr_gris, $documento->calc_frete->valor_despacho, $documento->calc_frete->valor_pedagio, $documento->calc_frete->valor_ademe_gris, $documento->calc_frete->valor_despesas_extras, $documento->calc_frete->base_calculo_apuracao_icms_frete, $documento->calc_frete->taxa_icms_frete, $documento->calc_frete->valor_icms_frete, $documento->calc_frete->subst_tributaria, $documento->calc_frete->base_calculo_icms_subst_tributaria, $documento->calc_frete->taxa_icms_subst_tributaria, $documento->calc_frete->valor_icms_subst_tributaria, $documento->calc_frete->base_calculo_iss, $documento->calc_frete->taxa_iss, $documento->calc_frete->valor_tot_iss, $documento->calc_frete->valor_tot_ir, $documento->calc_frete->direito_fiscal, $documento->calc_frete->taxa_imposto, $documento->calc_frete->uf, TAMANHO); 79 | // Acrescenta registro 508 80 | $linhas .= $notfis->registro_508($documento->indentf_cargas->marca_volumes, $documento->indentf_cargas->num_volumes_transportados, $documento->indentf_cargas->num_lacres, TAMANHO); 81 | // Acrescenta registro 509 82 | $linhas .= $notfis->registro_509($documento->dados_entrega->cnpj1, $documento->dados_entrega->nome1, $documento->dados_entrega->serie1, $documento->dados_entrega->numero1, $documento->dados_entrega->cnpj2, $documento->dados_entrega->nome2, $documento->dados_entrega->serie2, $documento->dados_entrega->numero2, $documento->dados_entrega->cnpj3, $documento->dados_entrega->nome3, $documento->dados_entrega->serie3, $documento->dados_entrega->numero3, $documento->dados_entrega->desp_filial_emissora_conhecimento, $documento->dados_entrega->desp_serie_conhecimento, $documento->dados_entrega->desp_numero_conhecimento, $documento->dados_entrega->desp_cnpj_transp_contratante, TAMANHO); 83 | // Acrescenta registro 511 84 | $linhas .= $notfis->registro_511($documento->item_nf->qntd_volume, $documento->item_nf->especie_acond, $documento->item_nf->cod_item_nf, $documento->item_nf->desc_item_nf, $documento->item_nf->cfop_item, $documento->item_nf->lote_item, $documento->item_nf->data_validade_item, $documento->item_nf->marca_volumes_transportados, $documento->item_nf->num_volumes_transportados, $documento->item_nf->num_lacres, $documento->item_nf->identf_pedido_cliente, TAMANHO); 85 | // Acrescenta registro 513 86 | $linhas .= $notfis->registro_513($documento->dado_consignado->documento, $documento->dado_consignado->cnpj, $documento->dado_consignado->insc_estadual, $documento->dado_consignado->endereco, $documento->dado_consignado->bairro, $documento->dado_consignado->cidade, $documento->dado_consignado->cod_postal, $documento->dado_consignado->cod_municipio, $documento->dado_consignado->uf, $documento->dado_consignado->numero_contato, TAMANHO); 87 | // Acrescenta registro 514 88 | $linhas .= $notfis->registro_514($documento->dado_redespacho->documento, $documento->dado_redespacho->cnpj, $documento->dado_redespacho->insc_estadual, $documento->dado_redespacho->endereco, $documento->dado_redespacho->bairro, $documento->dado_redespacho->cidade, $documento->dado_redespacho->cod_postal, $documento->dado_redespacho->cod_municipio, $documento->dado_redespacho->uf, $documento->dado_redespacho->numero_contato, $documento->dado_redespacho->area_frete, TAMANHO); 89 | // Acrescenta registro 515 90 | $linhas .= $notfis->registro_515($documento->dado_frete->documento, $documento->dado_frete->cnpj, $documento->dado_frete->insc_estadual, $documento->dado_frete->endereco, $documento->dado_frete->bairro, $documento->dado_frete->cidade, $documento->dado_frete->cod_postal, $documento->dado_frete->cod_municipio, $documento->dado_frete->uf, $documento->dado_frete->numero_contato, TAMANHO); 91 | // Acrescenta registro 519 92 | $linhas .= $notfis->registro_519($documento->final->valor_tot_nf, $documento->final->peso_bruto_nf, $documento->final->qntd_tot_volumes, $documento->final->num_notas, TAMANHO); 93 | 94 | } 95 | // Mostra resultado 96 | file_put_contents('arquivos/notfis.txt', $linhas); 97 | echo "

\n"; 98 | echo $linhas; 99 | 100 | } catch (Exception $e) { 101 | echo 'ERRO: ' .$e->getMessage(); 102 | } 103 | -------------------------------------------------------------------------------- /GeraOcoren.php: -------------------------------------------------------------------------------- 1 | | 10 | * | | 11 | * | Programa...: GeraOcorren.php | 12 | * | | 13 | * | Autor......: Helder | 14 | * | | 15 | * | Criação....: 26-06-2018 | 16 | * | | 17 | * | Objetivo...: Gerar todos os registros conforme Layout PROCEDA/Ocorren.| 18 | * | Os dados devem estar no arquivo dados/ocoren.xml | 19 | * | | 20 | * | Layout EDI.: 6.0 - 31/07/2008 | 21 | * | | 22 | * +-----------------------------------------------------------------------+ 23 | * | Versões....: | 24 | * | | 25 | * | | 26 | * | | 27 | * +-----------------------------------------------------------------------+ 28 | */ 29 | 30 | // Campo ORIGATÒRIO preencher o conteudo 31 | const OBRIGATORIO = true; 32 | 33 | // Tamanho da linha 34 | const TAMANHO = 250; 35 | 36 | // Delimitador 37 | const DELIMITADOR = ''; 38 | 39 | // Tipo de campo A/N 40 | const NUMERICO = 'N'; 41 | const PREENCHIMENTO = ' '; 42 | const ALFA = 'A'; 43 | 44 | require_once "vendor/autoload.php"; 45 | 46 | use App\Proceda\Ocoren; 47 | 48 | try { 49 | // Variavel memória de todas as linhas 50 | $linhas = ''; 51 | 52 | // Instancia objeto DOCCOB 53 | $ocoren = new Ocoren(); 54 | 55 | 56 | // Obtem os dados de arquivo XML: dados/proceda.xml 57 | $xml = simplexml_load_file('dados/ocoren.xml'); 58 | 59 | // Acrescenta registro 000 60 | $linhas = $ocoren->registro_000($xml->remetente, $xml->destinatario, $xml->data, $xml->hora, $xml->intercambio, TAMANHO); 61 | 62 | foreach ($xml->documentos->sequencia as $documento) { 63 | // Acrescenta registro 540 64 | $linhas .= $ocoren->registro_540($documento->documento, TAMANHO); 65 | // Acrescenta registro 541 66 | $linhas .= $ocoren->registro_541($documento->cnpj, $documento->razao, TAMANHO); 67 | // Acrescenta registro 542 68 | $linhas .= $ocoren->registro_542($documento->ocorr_entrega->cnpj_emissor_nf, $documento->ocorr_entrega->serie_nf, $documento->ocorr_entrega->numero_nf, $documento->ocorr_entrega->codigo_ocorrencia_entrega, $documento->ocorr_entrega->data_ocorrencia, $documento->ocorr_entrega->hora_ocorrencia, $documento->ocorr_entrega->cod_observacao_ocorrencia_entrada, $documento->ocorr_entrega->numero_romaneio_identf_embarque, $documento->ocorr_entrega->identf_carga1, $documento->ocorr_entrega->identf_carga2, $documento->ocorr_entrega->identf_carga3, $documento->ocorr_entrega->filial_emissora_conhecimento, $documento->ocorr_entrega->serie_conhecimento, $documento->ocorr_entrega->numero_conhecimento, $documento->ocorr_entrega->indicacao_tipo_entrega, $documento->ocorr_entrega->codigo_empresa_emissora_nf, $documento->ocorr_entrega->codigo_filial_empresa_emissora_nf, $documento->ocorr_entrega->data_chegada_nf, $documento->ocorr_entrega->hora_chegada_nf, $documento->ocorr_entrega->data_inicio_descarregamento_destino, $documento->ocorr_entrega->hora_inicio_descarregamento_destino, $documento->ocorr_entrega->data_termino_descarregamento_destino, $documento->ocorr_entrega->hora_termino_descarregamento_destino, $documento->ocorr_entrega->data_saida_destino_nf, $documento->ocorr_entrega->hora_saida_destino_nf, $documento->ocorr_entrega->cnpj_emissor_nf_devolucao, $documento->ocorr_entrega->serie_nf_devolucao, $documento->ocorr_entrega->numero_nf_devolucao, TAMANHO); 69 | // Acrescenta registro 543 70 | $linhas .= $ocoren->registro_543($documento->texto_complementar->texto_livre1, $documento->texto_complementar->texto_livre2, $documento->texto_complementar->texto_livre3, TAMANHO); 71 | // Acrescenta registro 544 72 | $linhas .= $ocoren->registro_544($documento->dados_item_nf->qntd_volumes_nf, $documento->dados_item_nf->qntd_volumes_entregues, $documento->dados_item_nf->cod_item_nf, $documento->dados_item_nf->descricao_item_nf, TAMANHO); 73 | /// Acrescenta registro 545 74 | $linhas .= $ocoren->registro_545($documento->ocorr_despacho->cnpj_empresa_frete, $documento->ocorr_despacho->cnpj_empresa_emissora_ocorrencia, $documento->ocorr_despacho->filial_emissor_ocorrencia, $documento->ocorr_despacho->serie_conhecimento_ocorrencia, $documento->ocorr_despacho->numero_conhecimento_ocorrencia, TAMANHO); 75 | // Acrescenta registro 549 76 | $linhas .= $ocoren->registro_549($documento->final->numero_ocorrencias, TAMANHO); 77 | 78 | } 79 | // Mostra resultado 80 | file_put_contents('arquivos/ocoren.txt', $linhas); 81 | echo "

\n"; 82 | echo $linhas; 83 | 84 | } catch (Exception $e) { 85 | echo 'ERRO: ' .$e->getMessage(); 86 | } 87 | -------------------------------------------------------------------------------- /GeraPernod.php: -------------------------------------------------------------------------------- 1 | | 11 | * | | 12 | * | Programa...: GeraPernod.php | 13 | * | | 14 | * | Autor......: Ivan | 15 | * | | 16 | * | Criação....: 28-11-2019 | 17 | * | | 18 | * | Objetivo...: Gerar todos os registros conforme Layout Pernod. | 19 | * | Os dados devem estar no arquivo dados/Pernod.xml | 20 | * | | 21 | * | Layout EDI.: | 22 | * | | 23 | * +-----------------------------------------------------------------------+ 24 | * | Versões....: | 25 | * | | 26 | * | | 27 | * | | 28 | * +-----------------------------------------------------------------------+ 29 | */ 30 | 31 | // Campo ORIGATÒRIO preencher o conteudo 32 | const OBRIGATORIO = true; 33 | const OPCIONAL = false; 34 | 35 | const NUMERICO = 'N'; 36 | const ALFA = 'A'; 37 | 38 | const DELIMITADOR = ''; 39 | const PREENCHIMENTO = ' '; 40 | 41 | 42 | require_once "vendor/autoload.php"; 43 | 44 | use App\Pernod\Venda; 45 | use App\Pernod\Estoque; 46 | 47 | try { 48 | // Variavel memória de todas as linhas 49 | $linhas = ''; 50 | 51 | date_default_timezone_set("Brazil/East"); 52 | 53 | $data = Date('d-m-Y H:i:s'); 54 | 55 | $data = str_replace ([':','-',' '], '' , $data); 56 | $segundos = Date('s'); 57 | 58 | $milesimos = round($segundos * 1000); 59 | // Instancia objetos 60 | $venda = new Venda(); 61 | $estoque = new Estoque(); 62 | 63 | 64 | // Obtem os dados de arquivo XML: dados/proceda.xml 65 | $xml = simplexml_load_file('dados/Pernod.xml'); 66 | 67 | // Acrescenta registro 68 | $linhas = $venda->header_venda($xml->identificador, $xml->cnpj_fornecedor)."\n"; 69 | 70 | 71 | $linhas .= $venda->detalhe_venda($xml->movimento_de_vendas->cnpj_distribuicao, $xml->movimento_de_vendas->identificacao_do_cliente, 72 | $xml->movimento_de_vendas->data_transacao, $xml->movimento_de_vendas->numero_documento, 73 | $xml->movimento_de_vendas->codigo_do_produto, $xml->movimento_de_vendas->quantidade, 74 | $xml->movimento_de_vendas->preco_de_venda,$xml->movimento_de_vendas->codigo_vendedor, 75 | $xml->movimento_de_vendas->campo_reservado, $xml->movimento_de_vendas->tipo_documento, 76 | $xml->movimento_de_vendas->cep, $xml->movimento_de_vendas->codigo_lote, $xml->movimento_de_vendas->validade_lote, 77 | $xml->movimento_de_vendas->dia_validade_lote,$xml->movimento_de_vendas->pedido_sugerido, 78 | $xml->movimento_de_vendas->preco_de_venda_dolar,$xml->movimento_de_vendas->tipo_de_unidade); 79 | 80 | file_put_contents("arquivos/VENDA{$data}{$milesimos}.txt", $linhas); 81 | echo $linhas."\n"; 82 | echo "\n\n"; 83 | 84 | 85 | $linhas = $estoque->header_estoque($xml->estoque_cabecalho->indentificador, $xml->estoque_cabecalho->cnpj_fornecedor,$xml->estoque_cabecalho->data_do_estoque)."\n"; 86 | 87 | /*$linhas .= $sellout->detalhe_sellout($xml->sellout->cod_sap_dist, $xml->sellout->cod_sap_ent, $xml->sellout->cod_cliente, $xml->sellout->nome_cliente, $xml->sellout->cnpj_cliente_indireto, $xml->sellout->cpf_cliente_indireto, $xml->sellout->endereco, $xml->sellout->cep, $xml->sellout->estado, $xml->sellout->bairro, $xml->sellout->municipio, $xml->sellout->telefone, $xml->sellout->pais, $xml->sellout->contato, $xml->sellout->tipo_negocio, $xml->sellout->zona_estabelecida_distribuidor, $xml->sellout->representante_distribuidor, $xml->sellout->nome_representante, $xml->sellout->cod_produto_atacado, $xml->sellout->cod_ean, $xml->sellout->cod_sap_produto, $xml->sellout->venda_qntd, $xml->sellout->valor_venda, $xml->sellout->preco_unitario, $xml->sellout->tipo_moeda, $xml->sellout->data_faturamento, $xml->sellout->data_entrega, $xml->sellout->tipo_documento, $xml->sellout->cod_documento, $xml->sellout->unidade_medida_qntd, $xml->sellout->numerador_conversao_qntd_unidade, $xml->sellout->denominador_conversor_qntd_unidade, $xml->sellout->unidade_medida_preco, $xml->sellout->numerador_conversao_preco_unidade, $xml->sellout->denominador_conversor_preco_unidade, $xml->sellout->data_fim_periodo_reportado, $xml->sellout->data_transmissao_informacao, $xml->sellout->numero_transmissao, $xml->sellout->cpf_representante_vendas_atacado, $xml->sellout->chave_acesso); 88 | */ file_put_contents('arquivos/ESTOQUE.txt', $linhas); 89 | // echo $linhas."\n"; 90 | 91 | } catch (Exception $e) { 92 | echo 'ERRO: ' .$e->getMessage(); 93 | } -------------------------------------------------------------------------------- /GeraProcter.php: -------------------------------------------------------------------------------- 1 | | 11 | * | | 12 | * | Programa...: GeraProcter.php | 13 | * | | 14 | * | Autor......: Helder | 15 | * | | 16 | * | Criação....: 23-09-2018 | 17 | * | | 18 | * | Objetivo...: Gerar todos os registros conforme Layout PROCTER. Os | 19 | * | dados devem estar no arquivo dados/procter.xml | 20 | * | | 21 | * | Layout EDI.: | 22 | * | | 23 | * +-----------------------------------------------------------------------+ 24 | * | Versões....: | 25 | * | | 26 | * | | 27 | * | | 28 | * +-----------------------------------------------------------------------+ 29 | */ 30 | 31 | // Campo ORIGATÒRIO preencher o conteudo 32 | const OBRIGATORIO = true; 33 | const OPCIONAL = false; 34 | 35 | const NUMERICO = 'N'; 36 | const ALFA = 'A'; 37 | 38 | const DELIMITADOR = ';'; 39 | 40 | require_once "vendor/autoload.php"; 41 | 42 | use App\Procter\Clientes; 43 | use App\Procter\Inventarios; 44 | use App\Procter\Produtividades; 45 | use App\Procter\Vendas; 46 | use App\Procter\Vendedores; 47 | 48 | try { 49 | // Variavel memória de todas as linhas 50 | $linhas = ''; 51 | 52 | // Instancia objetos 53 | $cliente = new Clientes(); 54 | $vendedor = new Vendedores(); 55 | $venda = new Vendas(); 56 | $produtividade = new Produtividades(); 57 | $inventario = new Inventarios(); 58 | 59 | 60 | // Obtem os dados de arquivo XML: dados/procter.xml 61 | $xml = simplexml_load_file('dados/procter.xml'); 62 | 63 | // Acrescenta registro clientes 64 | $linhas = $cliente->registro_clientes($xml->cliente->sap_mae, $xml->cliente->sap_filial, $xml->cliente->cgc_cpf, $xml->cliente->razao, $xml->cliente->ramo, $xml->cliente->endereco, $xml->cliente->bairro, $xml->cliente->cidade, $xml->cliente->estado, $xml->cliente->cep, $xml->cliente->telefone, $xml->cliente->setor, $xml->cliente->numero); 65 | file_put_contents('arquivos/BLZ_STOR_NC_10908082005.txt', $linhas); 66 | echo $linhas."\n"; 67 | 68 | // Acrescenta registro vendedores 69 | $linhas = $vendedor->registro_vendedores($xml->vendedor->sap_mae, $xml->vendedor->sap_filial, $xml->vendedor->cod_vendedor, $xml->vendedor->nome_vendedor, $xml->vendedor->cod_supervisor, $xml->vendedor->nome_supervisor); 70 | file_put_contents('arquivos/BZL_SREP_NC_10908092005.txt', $linhas); 71 | echo $linhas."\n"; 72 | 73 | // Acrescenta registro vendas 74 | $linhas = $venda->registro_vendas($xml->vendas->sap_mae, $xml->vendas->sap_filial, $xml->vendas->numero_nf, $xml->vendas->tipo_transacao, $xml->vendas->data_doc, $xml->vendas->cgc_cpf_distribuidor, $xml->vendas->cod_vendedor, $xml->vendas->dun_produto, $xml->vendas->qntd_vendida, $xml->vendas->vlr_faturado); 75 | file_put_contents('arquivos/BZL_FACT_NC_10908092005.txt', $linhas); 76 | echo $linhas."\n"; 77 | 78 | // Acrescenta registro prdutividade 79 | $linhas = $produtividade->registro_produtividade($xml->produtividade->sap_mae, $xml->produtividade->sap_filial, $xml->produtividade->data_visitas, $xml->produtividade->cod_vendedor, $xml->produtividade->visitas_dia, $xml->produtividade->visitas_com_vendas); 80 | file_put_contents('arquivos/BZL_PROD_NC_10908092005.txt', $linhas); 81 | echo $linhas."\n"; 82 | 83 | // Acrescenta registro inventario 84 | $linhas = $inventario->registro_inventarios($xml->inventario->sap_mae, $xml->inventario->sap_filial, $xml->inventario->dun_produto, $xml->inventario->qntd_fisica, $xml->inventario->qntd_transito, $xml->inventario->data_leitura); 85 | file_put_contents('arquivos/BZL_FACTSINV_NC_10908092005.txt', $linhas); 86 | echo $linhas."\n"; 87 | 88 | } catch (Exception $e) { 89 | echo 'ERRO: ' .$e->getMessage(); 90 | } -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # php-edi 2 | 3 | Sistema para geração de Electronic Data Interchange - EDI - com fornecedores e indústrias. 4 | 5 | O Sistema será composto de vários programas em PHP, que formatarão os registros informados, no formato exigido pelo LAYOUT do EDI. 6 | 7 | Incluiremos tambem agendamento de tarefas para automatizar operações. 8 | 9 | Sobre EDI: https://pt.wikipedia.org/wiki/EDI 10 | 11 | 12 | # Layout PROCEDA 13 | 14 | Pronto para uso imediato, lê dados dos arquivos no /dados, a saber: conemb.xml, doccob.xml, notfis.xml, ocoren.xml e gera arquivos prontos a serem enviados aos fornecedores/transportadoras no /arquivos. 15 | 16 | # Layout PROCTER 17 | 18 | Em fase de testes, ptemite gerar aruivos conforme formato solicitado pelo fornecdor/industria, inclusive formatando o nome do arquivos conforme padrão exigido. 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /app/Campo.php: -------------------------------------------------------------------------------- 1 | $tamanho_inteiro) { 30 | throw new \Exception("PARTE INTEIRA CAMPO '{$descricao}' MAIOR QUE {$tamanho_inteiro}"); 31 | } 32 | if (strlen($valor_decimais) > $tamanho_decimal) { 33 | #var_dump($tamanho_decimal); var_dump($valor_decimais); exit; 34 | throw new \Exception("PARTE DECIMAL CAMPO '{$descricao}' MAIOR QUE {$tamanho_decimal}"); 35 | } 36 | $formatado = str_pad($valor_inteiro, $tamanho_inteiro, '0', STR_PAD_LEFT) . 37 | str_pad($valor_decimais, $tamanho_decimal, '0', STR_PAD_RIGHT); 38 | } else { 39 | if (strlen($conteudo) > $tamanho) { 40 | throw new \Exception("TAMANHO CAMPO '{$descricao}' MAIOR QUE {$tamanho}"); 41 | } 42 | 43 | if(!empty($preenchimento)){ 44 | $formatado = str_pad($conteudo, $tamanho, $preenchimento, STR_PAD_RIGHT); 45 | }else 46 | { 47 | $formatado = $conteudo; 48 | } 49 | 50 | 51 | 52 | } 53 | 54 | if ($ordem < 1) { 55 | throw new \Exception("ORDEM CAMPO '{$descricao}' DEVE SER MAIOR QUE 1"); 56 | } 57 | if (strlen($conteudo) === 0 && $obrigatorio) { 58 | throw new \Exception("CAMPO {$descricao} É OBRIGATÓRIO"); 59 | } 60 | 61 | // formata campo conforme parametros 62 | #return str_pad($conteudo, $tamanho, $preenchimento, $lado); 63 | $this->ordem = $ordem; 64 | $this->descricao = $descricao; 65 | $this->conteudo = $conteudo; 66 | $this->tipo = $tipo; 67 | $this->tamanho = $tamanho; 68 | $this->obrigatorio = $obrigatorio; 69 | $this->formatado = $formatado; 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /app/Kimberly_Clark/Estoque.php: -------------------------------------------------------------------------------- 1 | | 11 | * | | 12 | * | Programa...: Estoque.php | 13 | * | | 14 | * | Autor......: Helder | 15 | * | | 16 | * | Criação....: 26-06-2018 | 17 | * | | 18 | * | Objetivo...: Formatar registros conforme Layout Kimberly Clark Estoque| 19 | * | | 20 | * | Layout EDI.: 6.0 - 31/07/2008 | 21 | * | | 22 | * +-----------------------------------------------------------------------+ 23 | * | Versões....: | 24 | * | | 25 | * | | 26 | * | | 27 | * +-----------------------------------------------------------------------+ 28 | */ 29 | 30 | namespace App\Kimberly_Clark; 31 | 32 | use App\Layout; 33 | use App\Campo; 34 | 35 | class Estoque 36 | { 37 | 38 | 39 | public function header_estoque($cod_sap) 40 | { 41 | $layout = new Layout(); 42 | 43 | // CAMPO: ORDEM, DESCRIÇÃO, CONTEUDO, TIPO N/A, TAMANHO, OBRIGATORIO, PREENCHIMENTO 44 | $layout->adiciona(new Campo(1, 'INDICADOR DE REGISTRO', 'H', ALFA, 1, OBRIGATORIO, PREENCHIMENTO)); 45 | $layout->adiciona(new Campo(2, 'CÓDIGO SAP DO DISTRIBUIDOR', $cod_sap, ALFA, 8, OBRIGATORIO, PREENCHIMENTO)); 46 | 47 | $linha = $layout->gera_linha(); 48 | // Gera linha conforme o layout 49 | return $linha; 50 | } 51 | 52 | public function detalhe_estoque($cod_sap, $ean, $cod_interno, $sku, $estoque_fisico, $estoque_transito, $estoque_reservado, $estoque_total) 53 | { 54 | $layout = new Layout(); 55 | 56 | // CAMPO: ORDEM, DESCRIÇÃO, CONTEUDO, TIPO N/A, TAMANHO, OBRIGATORIO, PREENCHIMENTO 57 | $layout->adiciona(new Campo(1, 'INDICADOR DE REGISTRO', 'D', ALFA, 1, OBRIGATORIO, PREENCHIMENTO)); 58 | $layout->adiciona(new Campo(2, 'CÓDIGO SAP DO DISTRIBUIDOR', $cod_sap, ALFA, 8, OBRIGATORIO, PREENCHIMENTO)); 59 | $layout->adiciona(new Campo(3, 'EAN', $ean, ALFA, 14, OPCIONAL, PREENCHIMENTO)); 60 | $layout->adiciona(new Campo(4, 'COD INTERNO', $cod_interno, ALFA, 8, OPCIONAL, PREENCHIMENTO)); 61 | $layout->adiciona(new Campo(5, 'SKU', $sku, ALFA, 40, OPCIONAL, PREENCHIMENTO)); 62 | $layout->adiciona(new Campo(6, 'ESTOQUE FISICO', $estoque_fisico, NUMERICO, 15, OPCIONAL, PREENCHIMENTO)); 63 | $layout->adiciona(new Campo(7, 'ESTOQUE TRANSITO', $estoque_transito, NUMERICO, 15, OPCIONAL, PREENCHIMENTO)); 64 | $layout->adiciona(new Campo(8, 'ESTOQUE RESERVADO', $estoque_reservado, NUMERICO, 15, OBRIGATORIO, PREENCHIMENTO)); 65 | $layout->adiciona(new Campo(9, 'ESTOQUE TOTAL', $estoque_total, NUMERICO, 15, OBRIGATORIO, PREENCHIMENTO)); 66 | 67 | $linha = $layout->gera_linha(); 68 | // Gera linha conforme o layout 69 | return $linha; 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /app/Kimberly_Clark/Sellout.php: -------------------------------------------------------------------------------- 1 | | 10 | * | | 11 | * | Programa...: Sellout.php | 12 | * | | 13 | * | Autor......: Helder | 14 | * | | 15 | * | Criação....: 26-06-2018 | 16 | * | | 17 | * | Objetivo...: Formatar registros conforme Layout Kimberly Clark Sellout| 18 | * | | 19 | * | Layout EDI.: 6.0 - 31/07/2008 | 20 | * | | 21 | * +-----------------------------------------------------------------------+ 22 | * | Versões....: | 23 | * | | 24 | * | | 25 | * | | 26 | * +-----------------------------------------------------------------------+ 27 | */ 28 | 29 | namespace App\Kimberly_Clark; 30 | 31 | use App\Layout; 32 | use App\Campo; 33 | 34 | class Sellout 35 | { 36 | 37 | 38 | public function header_sellout($cod_sap, $data) 39 | { 40 | $layout = new Layout(); 41 | 42 | // CAMPO: ORDEM, DESCRIÇÃO, CONTEUDO, TIPO N/A, TAMANHO, OBRIGATORIO, PREENCHIMENTO 43 | $layout->adiciona(new Campo(1, 'INDICADOR DE REGISTRO', 'H', ALFA, 1, OBRIGATORIO, PREENCHIMENTO)); 44 | $layout->adiciona(new Campo(2, 'CÓDIGO SAP DO DISTRIBUIDOR', $cod_sap, ALFA, 8, OBRIGATORIO, PREENCHIMENTO)); 45 | $layout->adiciona(new Campo(2, 'DATA FIM DO PERIODO REPORTADO', $data, ALFA, 10, OBRIGATORIO, PREENCHIMENTO)); 46 | 47 | $linha = $layout->gera_linha(); 48 | // Gera linha conforme o layout 49 | return $linha; 50 | } 51 | 52 | public function detalhe_sellout($cod_sap_dist, $cod_sap_ent, $cod_cliente, $nome_cliente, $cnpj_cliente_indireto, $cpf_cliente_indireto, $endereco, $cep, $estado, 53 | $bairro, $municipio, $telefone, $pais, $contato, $tipo_negocio, $zona_estabelecida_distribuidor, $representante_distribuidor, $nome_representante, $codigo_produto_atacado, 54 | $codigo_ean, $codigo_sap_produto, $venda_qntd, $valor_venda, $preco_unitario_venda, $tipo_moeda, $data_faturamento, $data_entrega, $tipo_documento, $cod_documento, 55 | $unidade_medida_qntd, $numerador_conversao_qntd_unidade, $denominador_conversor_qntd_unidade, $unidade_medida_preco, $numerador_conversor_preco_unidade, $denominador_conversor_preco_unidade, $data_fim_periodo_reportado, $data_transmissao_informacao, $numero_transmissao, $cpf_representante_vendas, $chave_acesso) 56 | { 57 | $layout = new Layout(); 58 | #23-24-25-32-33-35-36 59 | // CAMPO: ORDEM, DESCRIÇÃO, CONTEUDO, TIPO N/A, TAMANHO, OBRIGATORIO, PREENCHIMENTO 60 | $layout->adiciona(new Campo(1, 'INDICADOR DE REGISTRO', 'D', ALFA, 1, OBRIGATORIO, PREENCHIMENTO)); 61 | $layout->adiciona(new Campo(2, 'CÓDIGO SAP DO DISTRIBUIDOR (FATURAMENTO)', $cod_sap_dist, ALFA, 8, OBRIGATORIO, PREENCHIMENTO)); 62 | $layout->adiciona(new Campo(3, 'COD SAP DO DISTRIBUIDOR (ENTREGA)', $cod_sap_ent, ALFA, 8, OPCIONAL, PREENCHIMENTO)); 63 | $layout->adiciona(new Campo(4, 'COD CLIENTE', $cod_cliente, ALFA, 15, OBRIGATORIO, PREENCHIMENTO)); 64 | $layout->adiciona(new Campo(5, 'NOME CLIENTE', $nome_cliente, ALFA, 80, OBRIGATORIO, PREENCHIMENTO)); 65 | $layout->adiciona(new Campo(6, 'CNPJ DO CLIENTE INDIRETO (JURIDICA)', $cnpj_cliente_indireto, ALFA, 20, OBRIGATORIO, PREENCHIMENTO)); 66 | $layout->adiciona(new Campo(7, 'CPF DO CLIENTE INDIRETO (FISICA)', $cpf_cliente_indireto, ALFA, 60, OBRIGATORIO, PREENCHIMENTO)); 67 | $layout->adiciona(new Campo(8, 'ENDERECO', $endereco, ALFA, 80, OPCIONAL, PREENCHIMENTO)); 68 | $layout->adiciona(new Campo(9, 'CEP', $cep, ALFA, 8, OBRIGATORIO, PREENCHIMENTO)); 69 | $layout->adiciona(new Campo(10, 'ESTADO', $estado, ALFA, 3, OBRIGATORIO, PREENCHIMENTO)); 70 | $layout->adiciona(new Campo(11, 'BAIRRO', $bairro, ALFA, 40, OPCIONAL, PREENCHIMENTO)); 71 | $layout->adiciona(new Campo(12, 'MUNICIPIO', $municipio, ALFA, 40, OBRIGATORIO, PREENCHIMENTO)); 72 | $layout->adiciona(new Campo(13, 'TELEFONE', $telefone, ALFA, 30, OPCIONAL, PREENCHIMENTO)); 73 | $layout->adiciona(new Campo(14, 'PAIS', $pais, ALFA, 3, OBRIGATORIO, PREENCHIMENTO)); 74 | $layout->adiciona(new Campo(15, 'CONTATO', $contato, ALFA, 70, OPCIONAL, PREENCHIMENTO)); 75 | $layout->adiciona(new Campo(16, 'TIPO DE NEGOCIO', $tipo_negocio, ALFA, 4, OBRIGATORIO, PREENCHIMENTO)); 76 | $layout->adiciona(new Campo(17, 'ZONA ESTABELECIDA PELO DISTRIBUIDOR', $zona_estabelecida_distribuidor, ALFA, 40, OPCIONAL, PREENCHIMENTO)); 77 | $layout->adiciona(new Campo(18, 'REPRESENTANTE DO DISTRIBUIDOR', $representante_distribuidor, ALFA, 10, OBRIGATORIO, PREENCHIMENTO)); 78 | $layout->adiciona(new Campo(19, 'NOME DO REPRESENTANTE', $nome_representante, ALFA, 80, OBRIGATORIO, PREENCHIMENTO)); 79 | $layout->adiciona(new Campo(20, 'CODIGO DO PRODUTO (ATACADO)', $codigo_produto_atacado, ALFA, 35, OPCIONAL, PREENCHIMENTO)); 80 | $layout->adiciona(new Campo(21, 'CODIGO EAN13', $codigo_ean, ALFA, 14, OBRIGATORIO, PREENCHIMENTO)); 81 | $layout->adiciona(new Campo(22, 'CODIGO SAP PRODUTO (KCC)', $codigo_sap_produto, ALFA, 35, OPCIONAL, PREENCHIMENTO)); 82 | $layout->adiciona(new Campo(23, 'VENDA EM QUANTIDADE', $venda_qntd, NUMERICO, 5, OBRIGATORIO, PREENCHIMENTO)); 83 | $layout->adiciona(new Campo(24, 'VALOR DA VENDA', $valor_venda, NUMERICO, 13.2, OBRIGATORIO, PREENCHIMENTO)); 84 | $layout->adiciona(new Campo(25, 'PREÇO UNITARIO DA VENDA', $preco_unitario_venda, NUMERICO, 13.2, OBRIGATORIO, PREENCHIMENTO)); 85 | $layout->adiciona(new Campo(26, 'TIPO DE MOEDA', $tipo_moeda, ALFA, 3, OBRIGATORIO, PREENCHIMENTO)); 86 | $layout->adiciona(new Campo(27, 'DATA DE FATURAMENTO', $data_faturamento, ALFA, 10, OBRIGATORIO, PREENCHIMENTO)); 87 | $layout->adiciona(new Campo(28, 'DATA DE ENTREGA', $data_entrega, ALFA, 10, OPCIONAL, PREENCHIMENTO)); 88 | $layout->adiciona(new Campo(29, 'TIPO DE DOCUMENTO', $tipo_documento, ALFA, 1, OBRIGATORIO, PREENCHIMENTO)); 89 | $layout->adiciona(new Campo(30, 'CODIGO DO DOCUMENTO', $cod_documento, ALFA, 35, OBRIGATORIO, PREENCHIMENTO)); 90 | $layout->adiciona(new Campo(31, 'UNIDADE DE MEDIDA DE QUANTIDADE', $unidade_medida_qntd, ALFA, 3, OBRIGATORIO, PREENCHIMENTO)); 91 | $layout->adiciona(new Campo(32, 'NUMERADOR DE CONVERSAO DAS QUANTIDADES PARA UNIDADE', $numerador_conversao_qntd_unidade, NUMERICO, 15, OBRIGATORIO, PREENCHIMENTO)); 92 | $layout->adiciona(new Campo(33, 'DENOMINADOR DE CONVERSOR DAS QUANTIDADES PARA UNIDADE', $denominador_conversor_qntd_unidade, NUMERICO, 15, OBRIGATORIO, PREENCHIMENTO)); 93 | $layout->adiciona(new Campo(34, 'UNIDADE DE MEDIDA DO PRECO', $unidade_medida_preco, ALFA, 3, OBRIGATORIO, PREENCHIMENTO)); 94 | $layout->adiciona(new Campo(35, 'NUMERADOR DE CONVERSOR DO PRECO PARA UNIDADE', $numerador_conversor_preco_unidade, NUMERICO, 15, OBRIGATORIO, PREENCHIMENTO)); 95 | $layout->adiciona(new Campo(36, 'DENOMINADOR DE CONVERSOR DO PRECO PARA UNIDADE', $denominador_conversor_preco_unidade, NUMERICO, 15, OBRIGATORIO, PREENCHIMENTO)); 96 | $layout->adiciona(new Campo(37, 'DATA DE FIM DO PERIODO REPORTADO', $data_fim_periodo_reportado, ALFA, 10, OBRIGATORIO, PREENCHIMENTO)); 97 | $layout->adiciona(new Campo(38, 'DATA DE TRANSMISSAO DA INFORMACAO', $data_transmissao_informacao, ALFA, 10, OBRIGATORIO, PREENCHIMENTO)); 98 | $layout->adiciona(new Campo(39, 'NUMERO DE TRANSMISSAO', $numero_transmissao, ALFA, 35, OPCIONAL, PREENCHIMENTO)); 99 | $layout->adiciona(new Campo(40, 'CPF REPRESENTANTE VENDAS ATACADO', $cpf_representante_vendas, ALFA, 11, OBRIGATORIO, PREENCHIMENTO)); 100 | $layout->adiciona(new Campo(41, 'CHAVE DE ACESSO NFE', $chave_acesso, ALFA, 44, OBRIGATORIO, PREENCHIMENTO)); 101 | 102 | $linha = $layout->gera_linha(); 103 | // Gera linha conforme o layout 104 | return $linha; 105 | } 106 | } 107 | -------------------------------------------------------------------------------- /app/Layout.php: -------------------------------------------------------------------------------- 1 | | 10 | * | | 11 | * | Programa...: Layout.php | 12 | * | | 13 | * | Autor......: Helder | 14 | * | | 15 | * | Criação....: 02-08-2018 | 16 | * | | 17 | * | Objetivo...: Gerar linhas com os Campos conform layout | 18 | * | | 19 | * | | 20 | * +-----------------------------------------------------------------------+ 21 | * | Versões....: | 22 | * | | 23 | * | | 24 | * | | 25 | * +-----------------------------------------------------------------------+ 26 | */ 27 | 28 | namespace App; 29 | 30 | use App\Campo; 31 | 32 | 33 | /** 34 | * Layout 35 | * 36 | * @version 1.0 37 | * @package APP 38 | * @author Helder Afonso de Morais 39 | * @copyright Copyright (c) 2018 php-edi 40 | */ 41 | class Layout 42 | { 43 | private $campos; 44 | 45 | public function adiciona(Campo $campo) 46 | { 47 | $this->campos[] = $campo; 48 | } 49 | 50 | public function __construct() 51 | { 52 | $this->campos = NULL; 53 | } 54 | 55 | /** 56 | * Verifica campo tamanho e conteudo e retorna formatado 57 | * @param $ordem - Ordem do campo no layout 58 | * @param $descrição Request 59 | * @param $conteudo Request 60 | * @param $tipo Request 61 | * @param $tamanho Request 62 | * @param $obrigatorio FALSE 63 | * @param $preenchimento ESPAÇO 64 | * @param $lado STR_PAD_RIGHT 65 | */ 66 | public function gera_linha() 67 | 68 | { 69 | #var_dump($this->campos); 70 | #exit; 71 | $linha = ''; 72 | foreach($this->campos as $campo) { 73 | // formata campo conforme parametros 74 | $linha .= $campo->formatado.DELIMITADOR; 75 | 76 | } 77 | return $linha; 78 | } 79 | } 80 | -------------------------------------------------------------------------------- /app/Pernod/Estoque.php: -------------------------------------------------------------------------------- 1 | | 11 | * | | 12 | * | Programa...: Estoque.php | 13 | * | | 14 | * | Autor......: Ivan | 15 | * | | 16 | * | Criação....: 10-12-2019 | 17 | * | | 18 | * | Objetivo...: Formatar registros conforme Layout Pernod Estoque | 19 | * | | 20 | * | Layout EDI.: 6.0 - 31/07/2008 | 21 | * | | 22 | * +-----------------------------------------------------------------------+ 23 | * | Versões....: | 24 | * | | 25 | * | | 26 | * | | 27 | * +-----------------------------------------------------------------------+ 28 | */ 29 | 30 | namespace App\Pernod; 31 | 32 | use App\Layout; 33 | use App\Campo; 34 | 35 | class Estoque 36 | { 37 | 38 | 39 | public function header_estoque($identificador, $cnpj_fornecedor, $data_do_estoque) 40 | { 41 | $layout = new Layout(); 42 | 43 | // CAMPO: ORDEM, DESCRIÇÃO, CONTEUDO, TIPO N/A, TAMANHO, OBRIGATORIO, PREENCHIMENTO 44 | $layout->adiciona(new Campo(1, 'TIPO DO REGISTRO', 'H', ALFA, 1, OBRIGATORIO, PREENCHIMENTO)); 45 | $layout->adiciona(new Campo(2, 'IDENTIFICADOR', $identificador, ALFA, 7, OBRIGATORIO, PREENCHIMENTO)); 46 | $layout->adiciona(new Campo(3, 'CNPJ FORNECEDOR', $cnpj_fornecedor, NUMERICO, 14, OBRIGATORIO, PREENCHIMENTO)); 47 | $layout->adiciona(new Campo(4, 'DATA DO ESTOQUE', $data_do_estoque, ALFA, 8, OBRIGATORIO, PREENCHIMENTO)); 48 | 49 | $linha = $layout->gera_linha(); 50 | // Gera linha conforme o layout 51 | return $linha; 52 | } 53 | 54 | /* public function detalhe_venda($cnpj_distribuicao, $identificacao_do_cliente, $data_transacao, $numero_documento, 55 | $codigo_do_produto, $quantidade, $preco_de_venda,$codigo_vendedor, $campo_reservado, 56 | $tipo_documento, $cep, $codigo_lote, $validade_lote, $dia_validade_lote, $pedido_sugerido, 57 | $preco_de_venda_dolar, $tipo_de_unidade) 58 | { 59 | $layout = new Layout(); 60 | 61 | // CAMPO: ORDEM, DESCRIÇÃO, CONTEUDO, TIPO N/A, TAMANHO, OBRIGATORIO, PREENCHIMENTO 62 | $layout->adiciona(new Campo(1, 'TIPO DO REGISTRO', 'D', ALFA, 1, OBRIGATORIO, PREENCHIMENTO)); 63 | $layout->adiciona(new Campo(2, 'INDENTIFICAÇÃO CLIENTE', $identificacao_do_cliente, ALFA, 18, OBRIGATORIO, PREENCHIMENTO)); 64 | $layout->adiciona(new Campo(3, 'CNPJ DISTRIBUIÇÃO', $cnpj_distribuicao, NUMERICO, 14, OBRIGATORIO, PREENCHIMENTO)); 65 | $layout->adiciona(new Campo(4, 'DATA TRANSAÇÃO', $data_transacao, ALFA, 8, OBRIGATORIO, PREENCHIMENTO)); 66 | $layout->adiciona(new Campo(5, 'NUMERO DOCUMENTO', $numero_documento, ALFA, 20, OBRIGATORIO, PREENCHIMENTO)); 67 | $layout->adiciona(new Campo(6, 'CODIGO DO PRODUTO', $codigo_do_produto, NUMERICO, 14, OBRIGATORIO, PREENCHIMENTO)); 68 | $layout->adiciona(new Campo(7, 'QUANTIDADE', $quantidade, NUMERICO, 15.4, OBRIGATORIO, PREENCHIMENTO)); 69 | $layout->adiciona(new Campo(8, 'PREÇO DE VENDA', $preco_de_venda, NUMERICO, 5.2, OBRIGATORIO, PREENCHIMENTO)); 70 | $layout->adiciona(new Campo(9, 'CODIGO VENDEDOR', $codigo_vendedor, ALFA, 20, OBRIGATORIO, PREENCHIMENTO)); 71 | $layout->adiciona(new Campo(10,'CAMPO RESERVADO', $campo_reservado, ALFA, 10, OPCIONAL, PREENCHIMENTO)); 72 | $layout->adiciona(new Campo(11, 'TIPO DOCUMENTO', $tipo_documento, ALFA, 10, OBRIGATORIO, PREENCHIMENTO)); 73 | $layout->adiciona(new Campo(12, 'CEP', $cep, NUMERICO, 8, OBRIGATORIO, PREENCHIMENTO)); 74 | $layout->adiciona(new Campo(13, 'CODIGO LOTE', $codigo_lote, ALFA, 13, OPCIONAL, PREENCHIMENTO)); 75 | $layout->adiciona(new Campo(14, 'VALIDADE LOTE', $validade_lote, NUMERICO, 6, OPCIONAL, PREENCHIMENTO)); 76 | $layout->adiciona(new Campo(15, 'DIA VALIDADE LOTE', $dia_validade_lote, NUMERICO, 2, OPCIONAL, PREENCHIMENTO)); 77 | $layout->adiciona(new Campo(16, 'PEDIDO SUGERIDO', $pedido_sugerido, ALFA, 1, OPCIONAL, PREENCHIMENTO)); 78 | $layout->adiciona(new Campo(17, 'PREÇO DE VENDA DOLAR', $preco_de_venda_dolar, NUMERICO, 5.2, OPCIONAL, PREENCHIMENTO)); 79 | $layout->adiciona(new Campo(18, 'TIPO DE UNIDADE', $tipo_de_unidade, NUMERICO, 4, OBRIGATORIO, PREENCHIMENTO)); 80 | 81 | 82 | 83 | $linha = $layout->gera_linha(); 84 | // Gera linha conforme o layout 85 | return $linha; 86 | }*/ 87 | } 88 | -------------------------------------------------------------------------------- /app/Pernod/Venda.php: -------------------------------------------------------------------------------- 1 | | 11 | * | | 12 | * | Programa...: Venda.php | 13 | * | | 14 | * | Autor......: Ivan | 15 | * | | 16 | * | Criação....: 29-12-2019 | 17 | * | | 18 | * | Objetivo...: Formatar registros conforme Layout Pernod Venda | 19 | * | | 20 | * | Layout EDI.: 6.0 - 31/07/2008 | 21 | * | | 22 | * +-----------------------------------------------------------------------+ 23 | * | Versões....: | 24 | * | | 25 | * | | 26 | * | | 27 | * +-----------------------------------------------------------------------+ 28 | */ 29 | 30 | namespace App\Pernod; 31 | 32 | use App\Layout; 33 | use App\Campo; 34 | 35 | class Venda 36 | { 37 | 38 | 39 | public function header_venda($identificador, $cnpj_fornecedor) 40 | { 41 | $layout = new Layout(); 42 | 43 | // CAMPO: ORDEM, DESCRIÇÃO, CONTEUDO, TIPO N/A, TAMANHO, OBRIGATORIO, PREENCHIMENTO 44 | $layout->adiciona(new Campo(1, 'TIPO DE REGISTRO', 'H', ALFA, 1, OBRIGATORIO, PREENCHIMENTO)); 45 | $layout->adiciona(new Campo(2, 'IDENTIFICADOR', $identificador, ALFA, 7, OBRIGATORIO, PREENCHIMENTO)); 46 | $layout->adiciona(new Campo(3, 'CNPJ FORNECEDOR', $cnpj_fornecedor, NUMERICO, 14, OBRIGATORIO, PREENCHIMENTO)); 47 | 48 | $linha = $layout->gera_linha(); 49 | // Gera linha conforme o layout 50 | return $linha; 51 | } 52 | 53 | public function detalhe_venda($cnpj_distribuicao, $identificacao_do_cliente, $data_transacao, $numero_documento, 54 | $codigo_do_produto, $quantidade, $preco_de_venda,$codigo_vendedor, $campo_reservado, 55 | $tipo_documento, $cep, $codigo_lote, $validade_lote, $dia_validade_lote, $pedido_sugerido, 56 | $preco_de_venda_dolar, $tipo_de_unidade) 57 | { 58 | $layout = new Layout(); 59 | 60 | // CAMPO: ORDEM, DESCRIÇÃO, CONTEUDO, TIPO N/A, TAMANHO, OBRIGATORIO, PREENCHIMENTO 61 | $layout->adiciona(new Campo(1, 'TIPO DO REGISTRO', 'D', ALFA, 1, OBRIGATORIO, PREENCHIMENTO)); 62 | $layout->adiciona(new Campo(2, 'INDENTIFICAÇÃO CLIENTE', $identificacao_do_cliente, ALFA, 18, OBRIGATORIO, PREENCHIMENTO)); 63 | $layout->adiciona(new Campo(3, 'CNPJ DISTRIBUIÇÃO', $cnpj_distribuicao, NUMERICO, 14, OBRIGATORIO, PREENCHIMENTO)); 64 | $layout->adiciona(new Campo(4, 'DATA TRANSAÇÃO', $data_transacao, ALFA, 8, OBRIGATORIO, PREENCHIMENTO)); 65 | $layout->adiciona(new Campo(5, 'NUMERO DOCUMENTO', $numero_documento, ALFA, 20, OBRIGATORIO, PREENCHIMENTO)); 66 | $layout->adiciona(new Campo(6, 'CODIGO DO PRODUTO', $codigo_do_produto, NUMERICO, 14, OBRIGATORIO, PREENCHIMENTO)); 67 | $layout->adiciona(new Campo(7, 'QUANTIDADE', $quantidade, NUMERICO, 15.4, OBRIGATORIO, PREENCHIMENTO)); 68 | $layout->adiciona(new Campo(8, 'PREÇO DE VENDA', $preco_de_venda, NUMERICO, 5.2, OBRIGATORIO, PREENCHIMENTO)); 69 | $layout->adiciona(new Campo(9, 'CODIGO VENDEDOR', $codigo_vendedor, ALFA, 20, OBRIGATORIO, PREENCHIMENTO)); 70 | $layout->adiciona(new Campo(10,'CAMPO RESERVADO', $campo_reservado, ALFA, 10, OPCIONAL, PREENCHIMENTO)); 71 | $layout->adiciona(new Campo(11, 'TIPO DOCUMENTO', $tipo_documento, ALFA, 10, OBRIGATORIO, PREENCHIMENTO)); 72 | $layout->adiciona(new Campo(12, 'CEP', $cep, NUMERICO, 8, OBRIGATORIO, PREENCHIMENTO)); 73 | $layout->adiciona(new Campo(13, 'CODIGO LOTE', $codigo_lote, ALFA, 13, OPCIONAL, PREENCHIMENTO)); 74 | $layout->adiciona(new Campo(14, 'VALIDADE LOTE', $validade_lote, NUMERICO, 6, OPCIONAL, PREENCHIMENTO)); 75 | $layout->adiciona(new Campo(15, 'DIA VALIDADE LOTE', $dia_validade_lote, NUMERICO, 2, OPCIONAL, PREENCHIMENTO)); 76 | $layout->adiciona(new Campo(16, 'PEDIDO SUGERIDO', $pedido_sugerido, ALFA, 1, OPCIONAL, PREENCHIMENTO)); 77 | $layout->adiciona(new Campo(17, 'PREÇO DE VENDA DOLAR', $preco_de_venda_dolar, NUMERICO, 5.2, OPCIONAL, PREENCHIMENTO)); 78 | $layout->adiciona(new Campo(18, 'TIPO DE UNIDADE', $tipo_de_unidade, NUMERICO, 4, OBRIGATORIO, PREENCHIMENTO)); 79 | 80 | 81 | 82 | $linha = $layout->gera_linha(); 83 | // Gera linha conforme o layout 84 | return $linha; 85 | } 86 | } 87 | -------------------------------------------------------------------------------- /app/Proceda/Conemb.php: -------------------------------------------------------------------------------- 1 | | 10 | * | | 11 | * | Programa...: Conemb.php | 12 | * | | 13 | * | Autor......: Helder | 14 | * | | 15 | * | Criação....: 26-06-2018 | 16 | * | | 17 | * | Objetivo...: Formatar registros conforme Layout PROCEDA/CONEMB | 18 | * | | 19 | * | Layout EDI.: 6.0 - 31/07/2008 | 20 | * | | 21 | * +-----------------------------------------------------------------------+ 22 | * | Versões....: | 23 | * | | 24 | * | | 25 | * | | 26 | * +-----------------------------------------------------------------------+ 27 | */ 28 | namespace App\Proceda; 29 | 30 | use App\Layout; 31 | use App\Campo; 32 | 33 | class Conemb 34 | { 35 | 36 | var $conta_000 = 0; 37 | var $conta_520 = 0; 38 | var $conta_521 = 0; 39 | var $conta_522 = 0; 40 | var $conta_523 = 0; 41 | var $conta_524 = 0; 42 | var $conta_525 = 0; 43 | var $conta_527 = 0; 44 | var $conta_529 = 0; 45 | 46 | /** 47 | * Formata campos recebidos para registro 000 48 | * @param $remetente Request 49 | * @param $destinatario Request 50 | * @param $data Request 51 | * @param $hora Request 52 | * @param $intercambio Request 53 | * @param $tamanho Request 54 | */ 55 | public function registro_000($remetente, $destinatario, $data, $hora, $intercambio, $tamanho) 56 | { 57 | // Zera contador de 520 - ocorre até 200 para cada 000 58 | $this->conta_520 = 0; 59 | 60 | $layout = new Layout(); 61 | 62 | // CAMPO: ORDEM, DESCRIÇÃO, CONTEUDO, TIPO N/A, TAMANHO, OBRIGATORIO, PREENCHIMENTO 63 | $layout->adiciona(new Campo(1,'IDENTIFICADOR DO REGISTRO', 0, NUMERICO, 3, OBRIGATORIO, PREENCHIMENTO)); 64 | $layout->adiciona(new Campo(2,'IDENTIFICAÇÃO DO REMETENTE', $remetente, ALFA, 35, OBRIGATORIO, PREENCHIMENTO)); 65 | $layout->adiciona(new Campo(3,'IDENTIFICAÇÃO DO DESTINATARIO', $destinatario, ALFA, 35, OBRIGATORIO, PREENCHIMENTO)); 66 | $layout->adiciona(new Campo(4,'DATA', $data, NUMERICO, 6, OBRIGATORIO, PREENCHIMENTO)); 67 | $layout->adiciona(new Campo(5,'HORA', $hora, NUMERICO, 4, OBRIGATORIO, PREENCHIMENTO)); 68 | $layout->adiciona(new Campo(6,'INTERCAMBIO', "CON50DDMMSSS", ALFA, 12, OBRIGATORIO, PREENCHIMENTO)); 69 | $layout->adiciona(new Campo(7,'ESPAÇO', ' ', ALFA, 255, OBRIGATORIO, PREENCHIMENTO)); 70 | 71 | $linha = $layout->gera_linha(); 72 | // Verifica se tamanho gerado está conforme o tamanho esperado 73 | if ($tamanho != mb_strlen($linha)) { 74 | echo $linha."\n\n"; 75 | throw new \Exception("REGISTRO 000 NAO CONFERE TAMANHO DE {$tamanho}"); 76 | } 77 | 78 | // Conta linhas para conferencia final 79 | $this->conta_000++; 80 | 81 | // Verifica se tem mais de 1 registro 000 82 | if ($this->conta_000 > 1) { 83 | throw new Exception("REGISTRO 000 OCORRE MAIS DE 1 VEZ"); 84 | } 85 | 86 | // Gera linha conforme o layout 87 | return $linha."\n"; 88 | } 89 | 90 | public function registro_520($documento, $tamanho) 91 | { 92 | // Zera contador de 521 - ocorre até 1 para cada 520 93 | $this->conta_521 = 0; 94 | 95 | $layout = new Layout(); 96 | 97 | // CAMPO: ORDEM, DESCRIÇÃO, CONTEUDO, TIPO N/A, TAMANHO, OBRIGATORIO, PREENCHIMENTO 98 | $layout->adiciona(new Campo(1,'IDENTIFICADOR DO REGISTRO', 520, NUMERICO, 3, OBRIGATORIO, PREENCHIMENTO)); 99 | $layout->adiciona(new Campo(2,'IDENTIFICAÇÃO DO REMETENTE', $documento, ALFA, 14, OBRIGATORIO, PREENCHIMENTO)); 100 | $layout->adiciona(new Campo(3,'ESPAÇO', ' ', ALFA, 333, OBRIGATORIO, PREENCHIMENTO)); 101 | 102 | $linha = $layout->gera_linha(); 103 | // Verifica se tamanho gerado está conforme o tamanho esperado 104 | if ($tamanho != mb_strlen($linha)) { 105 | throw new Exception("REGISTRO 520 NAO CONFERE TAMANHO DE {$tamanho}"); 106 | } 107 | 108 | // Conta linhas para conferencia final 109 | $this->conta_520++; 110 | 111 | // Verifica se tem mais de 200 registro 520 112 | if ($this->conta_520 > 200) { 113 | throw new Exception("REGISTRO 520 OCORRE MAIS DE 200 VEZES"); 114 | } 115 | 116 | // Gera linha conforme o layout 117 | return $linha."\n"; 118 | } 119 | 120 | public function registro_521($cnpj_transportadora, $nome_transportadora, $tamanho) 121 | { 122 | // Zera contador de 522 - ocorre até 50000 para cada 521 123 | $this->conta_522 = 0; 124 | 125 | $layout = new Layout(); 126 | 127 | // CAMPO: ORDEM, DESCRIÇÃO, CONTEUDO, TIPO N/A, TAMANHO, OBRIGATORIO, PREENCHIMENTO 128 | $layout->adiciona(new Campo(1,'IDENTIFICADOR DO REGISTRO', 521, NUMERICO, 3, OBRIGATORIO, PREENCHIMENTO)); 129 | $layout->adiciona(new Campo(2,'CNPJ DA TRANSPORTADORA', $cnpj_transportadora, NUMERICO, 14, OBRIGATORIO, PREENCHIMENTO)); 130 | $layout->adiciona(new Campo(3,'NOME DA TRANSPORTADORA(RAZAO SOCIAL)', $nome_transportadora, ALFA, 50, OBRIGATORIO, PREENCHIMENTO)); 131 | $layout->adiciona(new Campo(4,'ESPAÇO', ' ', ALFA, 283, OBRIGATORIO, PREENCHIMENTO)); 132 | 133 | $linha = $layout->gera_linha(); 134 | // Verifica se tamanho gerado está conforme o tamanho esperado 135 | if ($tamanho != mb_strlen($linha)) { 136 | throw new Exception("REGISTRO 521 NAO CONFERE TAMANHO DE {$tamanho}"); 137 | } 138 | 139 | // Conta linhas para conferencia final 140 | $this->conta_521++; 141 | 142 | // Verifica se tem mais de 1 registro 521 143 | if ($this->conta_521 > 1) { 144 | throw new Exception("REGISTRO 521 OCORRE MAIS DE 1 VEZ"); 145 | } 146 | 147 | // Gera linha conforme o layout 148 | return $linha."\n"; 149 | } 150 | 151 | public function registro_522($filial, $serie, $numero, $data_emissao, $condicao_frete, $cnpj_filial, $cnpj_emissor_nf, $cnpj_destino_devolucao, $cnpj_destinatario_nf, 152 | $cnpj_consignatario, $codigo_fiscal_da_operacao, $placa_veiculo, $numero_romaneio_coleta_de_carga, $numeroSAP, $numeroSAP1, $numeroSAP2, 153 | $identf_documento_de_autorizacao, $chave_consulta_com_dv, $protocolo, $codigo_numerico_chave_acesso, $filial_emissora_trasportadora, 154 | $serie_conhecimento_transportadora, $numero_conhecimento_transportadora, $tipo_transporte, $tipo_conhecimento, $tipo_frete, $acao_documento, 155 | $frete_diferenciado, $tabela_frete, $plano_carga_rapida, $uf_embarcador_local_coleta, $uf_emissora, $uf_destinatario_nf , $tamanho) 156 | { 157 | // Zera contador de 523 - ocorre até 1 para cada 522 158 | $this->conta_523 = 0; 159 | 160 | $layout = new Layout(); 161 | 162 | // CAMPO: ORDEM, DESCRIÇÃO, CONTEUDO, TIPO N/A, TAMANHO, OBRIGATORIO, PREENCHIMENTO 163 | $layout->adiciona(new Campo(1,'IDENTIFICADOR DO REGISTRO', 522, NUMERICO, 3, OBRIGATORIO, PREENCHIMENTO)); 164 | $layout->adiciona(new Campo(2,'FILIAL EMISSORA DO CONHECIMENTO', $filial, ALFA, 10, OBRIGATORIO, PREENCHIMENTO)); 165 | $layout->adiciona(new Campo(3,'SERIE DO CONHECIMENTO', $serie, ALFA, 5, OBRIGATORIO, PREENCHIMENTO)); 166 | $layout->adiciona(new Campo(4,'NUMERO DO CONHECIMENTO', $numero, ALFA, 12, OBRIGATORIO, PREENCHIMENTO)); 167 | $layout->adiciona(new Campo(5,'DATA DA EMISSAO DO CONHECIMENTO', $data_emissao, NUMERICO, 8, OBRIGATORIO, PREENCHIMENTO)); 168 | $layout->adiciona(new Campo(6,'CONDICAO DE FRETE', $condicao_frete, ALFA, 1, OBRIGATORIO, PREENCHIMENTO)); 169 | $layout->adiciona(new Campo(7,'CNPJ DO LOCAL/FILIAL EMISSORA DO CONHECIMENTO', $cnpj_filial, NUMERICO, 14, OBRIGATORIO, PREENCHIMENTO)); 170 | $layout->adiciona(new Campo(8,'CNPJ DO EMISSOR DA NOTA FISCAL', $cnpj_emissor_nf, NUMERICO, 14, OBRIGATORIO, PREENCHIMENTO)); 171 | $layout->adiciona(new Campo(9,'CNPJ DO DESTINO DO CONHECIMENTO DE DEVOLUCAO', $cnpj_destino_devolucao, NUMERICO, 14, OBRIGATORIO, PREENCHIMENTO)); 172 | $layout->adiciona(new Campo(10,'CNPJ DO DESTINATARIO DAS NOTAS DO CONHECIMENTO', $cnpj_destinatario_nf, NUMERICO, 14, OBRIGATORIO, PREENCHIMENTO)); 173 | $layout->adiciona(new Campo(11,'CNPJ DO CONSIGNATARIO', $cnpj_consignatario, NUMERICO, 14, OBRIGATORIO, PREENCHIMENTO)); 174 | $layout->adiciona(new Campo(12,'CODIGO FISCAL DA NATUREZA DA OPERACAO', $codigo_fiscal_da_operacao, ALFA, 5, OBRIGATORIO, PREENCHIMENTO)); 175 | $layout->adiciona(new Campo(13,'PLACA DO VEICULO', $placa_veiculo, ALFA, 9, OBRIGATORIO, PREENCHIMENTO)); 176 | $layout->adiciona(new Campo(14,'NUMERO ROMANEIO ORDEM DE COLETA RESUMO DE CARGA', $numero_romaneio_coleta_de_carga, ALFA, 20, OBRIGATORIO, PREENCHIMENTO)); 177 | $layout->adiciona(new Campo(15,'NUMERO SAP SHIPMENT ETC - 1', $numeroSAP, ALFA, 20, OBRIGATORIO, PREENCHIMENTO)); 178 | $layout->adiciona(new Campo(16,'NUMERO SAP SHIPMENT ETC - 2', $numeroSAP1, ALFA, 20, OBRIGATORIO, PREENCHIMENTO)); 179 | $layout->adiciona(new Campo(17,'NUMERO SAP SHIPMENT ETC - 3', $numeroSAP2, ALFA, 20, OBRIGATORIO, PREENCHIMENTO)); 180 | $layout->adiciona(new Campo(18,'IDENTIFICACAO DO DOCUMENTO DE AUTORIZACAO DE CARREGAMENTO E TRANSPORTE DA TRANSPORTADORA', $identf_documento_de_autorizacao, ALFA, 15, OBRIGATORIO, PREENCHIMENTO)); 181 | $layout->adiciona(new Campo(19,'CHAVE DE CONSULTA COM DV', $chave_consulta_com_dv, ALFA, 45, OBRIGATORIO, PREENCHIMENTO)); 182 | $layout->adiciona(new Campo(20,'PROTOCOLO', $protocolo, ALFA, 15, OBRIGATORIO, PREENCHIMENTO)); 183 | $layout->adiciona(new Campo(21,'CODIGO NUMERICO DA CHAVE DE ACESSO', $codigo_numerico_chave_acesso, NUMERICO, 9, OBRIGATORIO, PREENCHIMENTO)); 184 | $layout->adiciona(new Campo(22,'FILIAL EMISSORA DO CONHECIMENTO ORIGINADOR DO CONHECIMENTO - TRANSPORTADORA CONTRATANTE', $filial_emissora_trasportadora, ALFA, 10, OBRIGATORIO, PREENCHIMENTO)); 185 | $layout->adiciona(new Campo(23,'SERIE DO CONHECIMENTO ORIGINADOR DO CONHECIMENTO - TRANSPORTADORA CONTRATANTE', $serie_conhecimento_transportadora, ALFA, 5, OBRIGATORIO, PREENCHIMENTO)); 186 | $layout->adiciona(new Campo(24,'NUMERO DO CONHECIMENTO ORIGINADOR DESTE CONHECIMENTO - TRANSPORTADORA CONTRATANTE', $numero_conhecimento_transportadora, ALFA, 12, OBRIGATORIO, PREENCHIMENTO)); 187 | $layout->adiciona(new Campo(25,'TIPO DO MEIO DE TRANSPORTE', $tipo_transporte, ALFA, 5, OBRIGATORIO, PREENCHIMENTO)); 188 | $layout->adiciona(new Campo(26,'TIPO DO CONHECIMENTO', $tipo_conhecimento, ALFA, 1, OBRIGATORIO, PREENCHIMENTO)); 189 | $layout->adiciona(new Campo(27,'TIPO DE FRETE', $tipo_frete, NUMERICO, 1, OBRIGATORIO, PREENCHIMENTO)); 190 | $layout->adiciona(new Campo(28,'ACAO DO DOCUMENTO', $acao_documento, ALFA, 1, OBRIGATORIO, PREENCHIMENTO)); 191 | $layout->adiciona(new Campo(29,'CALCULO DO FRETE DIFERENCIADO', $frete_diferenciado, ALFA, 1, OBRIGATORIO, PREENCHIMENTO)); 192 | $layout->adiciona(new Campo(30,'TABELA DE FRETE', $tabela_frete, ALFA, 10, OBRIGATORIO, PREENCHIMENTO)); 193 | $layout->adiciona(new Campo(31,'PLANO DE CARGA RAPIDA', $plano_carga_rapida, ALFA, 1, OBRIGATORIO, PREENCHIMENTO)); 194 | $layout->adiciona(new Campo(32,'UF DO EMBARCADOR - LOCAL DA COLETA', $uf_embarcador_local_coleta, ALFA, 2, OBRIGATORIO, PREENCHIMENTO)); 195 | $layout->adiciona(new Campo(33,'UF DA UNIDADE EMISSORA DO CONHECIMENTO', $uf_emissora, ALFA, 2, OBRIGATORIO, PREENCHIMENTO)); 196 | $layout->adiciona(new Campo(34,'UF DO DESTINATARIO/LOCAL DE ENTREGA DA MERCADORIA/NOTA FISCAL', $uf_destinatario_nf, ALFA, 2, OBRIGATORIO, PREENCHIMENTO)); 197 | $layout->adiciona(new Campo(35,'ESPAÇO', ' ', ALFA, 10, OBRIGATORIO, PREENCHIMENTO)); 198 | 199 | $linha = $layout->gera_linha(); 200 | // Verifica se tamanho gerado está conforme o tamanho esperado 201 | if ($tamanho != mb_strlen($linha)) { 202 | throw new Exception("REGISTRO 522 NAO CONFERE TAMANHO DE {$tamanho}"); 203 | } 204 | 205 | // Conta linhas para conferencia final 206 | $this->conta_522++; 207 | 208 | // Verifica se tem mais de 5000 registro 522 209 | if ($this->conta_522 > 5000) { 210 | throw new Exception("REGISTRO 522 OCORRE MAIS DE 5000 VEZES"); 211 | } 212 | 213 | // Gera linha conforme o layout 214 | return $linha."\n"; 215 | } 216 | 217 | public function registro_523($qntd_total_volume, $peso_total_bruto, $peso_total_cubado, $peso_densidade, $valor_total_frete, $valor_frete_por_peso, $frete_valor, 218 | $frete_valorem, $valor_sec, $valor_itr, $valor_despacho, $valor_pedagio, $valor_ademe_griss, $valor_total_extra, $valor_desconto_acrescimo, 219 | $indicador_desconto_acrescimo, $base_calculo_apuracao_icms, $taxa_icms, $valor_icms, $subst_tributaria, $base_calculo_icms_subst_tributaria, $taxa_icms_subst_tributaria, 220 | $valor_icms_subst_tributaria, $base_calculo_iss, $taxa_iss_subst_tributaria, $valor_iss, $valor_ir, $direito_fiscal, $tipo_imposto , $tamanho) 221 | { 222 | // Zera contador de 524 - ocorre até 9999 para cada 522 223 | $this->conta_524 = 0; 224 | 225 | $layout = new Layout(); 226 | 227 | // CAMPO: ORDEM, DESCRIÇÃO, CONTEUDO, TIPO N/A, TAMANHO, OBRIGATORIO, PREENCHIMENTO 228 | $layout->adiciona(new Campo(1,'IDENTIFICADOR DO REGISTRO', 523, NUMERICO, 3, OBRIGATORIO, PREENCHIMENTO)); 229 | $layout->adiciona(new Campo(2,'QUANTIDADE TOTAL DE VOLUMES/EMBALAGENS', $qntd_total_volume, NUMERICO, 6.2, OBRIGATORIO, PREENCHIMENTO)); 230 | $layout->adiciona(new Campo(3,'PESO TOTAL TRANSPORTADO(PESO BRUTO)', $peso_total_bruto, NUMERICO, 6.3, OBRIGATORIO, PREENCHIMENTO)); 231 | $layout->adiciona(new Campo(4,'PESO TOTAL CUBADO(VxD)', $peso_total_cubado, NUMERICO, 6.4, OBRIGATORIO, PREENCHIMENTO)); 232 | $layout->adiciona(new Campo(5,'PESO DENSIDADE/CUBAGEM', $peso_densidade, NUMERICO, 6.4, OBRIGATORIO, PREENCHIMENTO)); 233 | $layout->adiciona(new Campo(6,'VALOR TOTAL DO FRETE', $valor_total_frete, NUMERICO, 13.2, OBRIGATORIO, PREENCHIMENTO)); 234 | $layout->adiciona(new Campo(7,'VALOR DO FRETE POR PESO/VOLUME', $valor_frete_por_peso, NUMERICO, 13.2, OBRIGATORIO, PREENCHIMENTO)); 235 | $layout->adiciona(new Campo(8,'FRETE VALOR', $frete_valor, NUMERICO, 13.2, OBRIGATORIO, PREENCHIMENTO)); 236 | $layout->adiciona(new Campo(9,'FRETE AD VALOREM', $frete_valorem, NUMERICO, 13.2, OBRIGATORIO, PREENCHIMENTO)); 237 | $layout->adiciona(new Campo(10,'VALOR SEC - CAT', $valor_sec, NUMERICO, 13.2, OBRIGATORIO, PREENCHIMENTO)); 238 | $layout->adiciona(new Campo(11,'VALOR ITR', $valor_itr, NUMERICO, 13.2, OBRIGATORIO, PREENCHIMENTO)); 239 | $layout->adiciona(new Campo(12,'VALOR DO DESPACHO', $valor_despacho, NUMERICO, 13.2, OBRIGATORIO, PREENCHIMENTO)); 240 | $layout->adiciona(new Campo(13,'VALOR DO PEDAGIO', $valor_pedagio, NUMERICO, 13.2, OBRIGATORIO, PREENCHIMENTO)); 241 | $layout->adiciona(new Campo(14,'VALOR ADEME/GRIS', $valor_ademe_griss, NUMERICO, 13.2, OBRIGATORIO, PREENCHIMENTO)); 242 | $layout->adiciona(new Campo(15,'VALOR TOTAL DE DESPESAS EXTRAS/ADICIONAIS', $valor_total_extra, NUMERICO, 13.2, OBRIGATORIO, PREENCHIMENTO)); 243 | $layout->adiciona(new Campo(16,'VALOR DO DESCONTO OU DO ACRESCIMO', $valor_desconto_acrescimo, NUMERICO, 13.2, OBRIGATORIO, PREENCHIMENTO)); 244 | $layout->adiciona(new Campo(17,'INDICADOR DE DESCONTO OU ACRESCIMO', $indicador_desconto_acrescimo, ALFA, 1, OBRIGATORIO, PREENCHIMENTO)); 245 | $layout->adiciona(new Campo(18,'BASE DE CALCULO PARA APURACAO ICMS', $base_calculo_apuracao_icms, NUMERICO, 13.2, OBRIGATORIO, PREENCHIMENTO)); 246 | $layout->adiciona(new Campo(19,'$ DE TAXA DO ICMS', $taxa_icms, NUMERICO, 3.2, OBRIGATORIO, PREENCHIMENTO)); 247 | $layout->adiciona(new Campo(20,'VALOR DO ICMS', $valor_icms, NUMERICO, 13.2, OBRIGATORIO, PREENCHIMENTO)); 248 | $layout->adiciona(new Campo(21,'SUBSTITUICAO TRIBUTARIA', $subst_tributaria, NUMERICO, 1, OBRIGATORIO, PREENCHIMENTO)); 249 | $layout->adiciona(new Campo(22,'BASE DE CALCULO ICMS - SUBSTITUICAO TRIBUTARIA', $base_calculo_icms_subst_tributaria, NUMERICO, 13.2, OBRIGATORIO, PREENCHIMENTO)); 250 | $layout->adiciona(new Campo(23,'% DE TAXA DO ICMS - SUBSTITUICAO TRIBUTARIA', $taxa_icms_subst_tributaria, NUMERICO, 3.2, OBRIGATORIO, PREENCHIMENTO)); 251 | $layout->adiciona(new Campo(24,'VALOR DO ICMS - SUBSTITUICAO TRIBUTARIA', $valor_icms_subst_tributaria, NUMERICO, 13.2, OBRIGATORIO, PREENCHIMENTO)); 252 | $layout->adiciona(new Campo(25,'BASE DE CALCULO DO ISS', $base_calculo_iss, NUMERICO, 13.2, OBRIGATORIO, PREENCHIMENTO)); 253 | $layout->adiciona(new Campo(26,'% DE TAXA DO ISS', $taxa_iss_subst_tributaria, NUMERICO, 3.2, OBRIGATORIO, PREENCHIMENTO)); 254 | $layout->adiciona(new Campo(27,'VALOR DO ISS', $valor_iss, NUMERICO, 13.2, OBRIGATORIO, PREENCHIMENTO)); 255 | $layout->adiciona(new Campo(28,'VALOR DO IR', $valor_ir, NUMERICO, 13.2, OBRIGATORIO, PREENCHIMENTO)); 256 | $layout->adiciona(new Campo(29,'DIREITO FISCAL', $direito_fiscal, ALFA, 3, OBRIGATORIO, PREENCHIMENTO)); 257 | $layout->adiciona(new Campo(30,'TIPO DE IMPOSTO', $tipo_imposto, ALFA, 4, OBRIGATORIO, PREENCHIMENTO)); 258 | $layout->adiciona(new Campo(31,'ESPACO', ' ', ALFA, 16, OBRIGATORIO, PREENCHIMENTO)); 259 | 260 | $linha = $layout->gera_linha(); 261 | // Verifica se tamanho gerado está conforme o tamanho esperado 262 | if ($tamanho != mb_strlen($linha)) { 263 | throw new Exception("REGISTRO 523 NAO CONFERE TAMANHO DE {$tamanho}"); 264 | } 265 | 266 | // Conta linhas para conferencia final 267 | $this->conta_523++; 268 | 269 | // Verifica se tem mais de 1 registro 523 270 | if ($this->conta_523 > 1) { 271 | throw new Exception("REGISTRO 523 OCORRE MAIS DE 1 VEZ"); 272 | } 273 | 274 | // Gera linha conforme o layout 275 | return $linha."\n"; 276 | } 277 | 278 | public function registro_524($cnpj_emissor_nf, $numero_nf, $serie_nf, $data_emissao_nf, $valor_nf, $otde_total_volumes, $peso_bruto_total_mercadoria, $peso_densidade, $peso_total_cubado, $identf_pedido_cliente, 279 | $numero_romaneio_identf_embarque, $numeroSAP, $numeroSAP1, $numeroSAP2, $nota_fiscal_devolucao, $tipo_nf, $indicacao_bonificacao, $codigo_fiscal_da_operacao, $uf, $desdobro, 280 | $tamanho) 281 | { 282 | // Zera contador de 525 - ocorre até 50 para cada 522 283 | $this->conta_525 = 0; 284 | 285 | $layout = new Layout(); 286 | 287 | // CAMPO: ORDEM, DESCRIÇÃO, CONTEUDO, TIPO N/A, TAMANHO, OBRIGATORIO, PREENCHIMENTO 288 | $layout->adiciona(new Campo(1,'IDENTIFICADOR DO REGISTRO', 524, NUMERICO, 3, OBRIGATORIO, PREENCHIMENTO)); 289 | $layout->adiciona(new Campo(2,'CNPJ DO EMISSOR DA NOTA FISCAL', $cnpj_emissor_nf, NUMERICO, 14, OBRIGATORIO, PREENCHIMENTO)); 290 | $layout->adiciona(new Campo(3,'NUMERO DA NOTA FISCAL', $numero_nf, NUMERICO, 9, OBRIGATORIO, PREENCHIMENTO)); 291 | $layout->adiciona(new Campo(4,'SERIE', $serie_nf, ALFA, 3, OBRIGATORIO, PREENCHIMENTO)); 292 | $layout->adiciona(new Campo(5,'DATA DE EMISSAO DA NOTA FISCAL', $data_emissao_nf, NUMERICO, 8, OBRIGATORIO, PREENCHIMENTO)); 293 | $layout->adiciona(new Campo(6,'VALOR DA NOTA FISCAL', $valor_nf, NUMERICO, 13.2, OBRIGATORIO, PREENCHIMENTO)); 294 | $layout->adiciona(new Campo(7,'OTDE TOTAL DE VOLUMES/EMBALAGENS', $otde_total_volumes, NUMERICO, 6.2, OBRIGATORIO, PREENCHIMENTO)); 295 | $layout->adiciona(new Campo(8,'PESO BRUTO TOTAL DA MERCADORIA/NOTA', $peso_bruto_total_mercadoria, NUMERICO, 6.3, OBRIGATORIO, PREENCHIMENTO)); 296 | $layout->adiciona(new Campo(9,'PESO DENSIDADE/CUBAGEM', $peso_densidade, NUMERICO, 6.4, OBRIGATORIO, PREENCHIMENTO)); 297 | $layout->adiciona(new Campo(10,'PESO CUBADO(DxV)', $peso_total_cubado, NUMERICO, 6.4, OBRIGATORIO, PREENCHIMENTO)); 298 | $layout->adiciona(new Campo(11,'IDENTIFICACAO DO PEDIDO DO CLIENTE', $identf_pedido_cliente, ALFA, 20, OBRIGATORIO, PREENCHIMENTO)); 299 | $layout->adiciona(new Campo(12,'NUMERO ROMANEIO, ORDEM DE COLETA, RESUMO DE CARGA, ETC.(IDENTIFICACAO DE EMBARQUE)', $numero_romaneio_identf_embarque, ALFA, 20, OBRIGATORIO, PREENCHIMENTO)); 300 | $layout->adiciona(new Campo(13,'NUMERO SAP, SHIPMENT, ETC. - 1', $numeroSAP, ALFA, 20, OBRIGATORIO, PREENCHIMENTO)); 301 | $layout->adiciona(new Campo(14,'NUMERO SAP, SHIPMENT, ETC. - 2', $numeroSAP1, ALFA, 20, OBRIGATORIO, PREENCHIMENTO)); 302 | $layout->adiciona(new Campo(15,'NUMERO SAP, SHIPMENT, ETC. - 3', $numeroSAP2, ALFA, 20, OBRIGATORIO, PREENCHIMENTO)); 303 | $layout->adiciona(new Campo(16,'NOTA FISCAL DE DEVOLUCAO', $nota_fiscal_devolucao, ALFA, 1, OBRIGATORIO, PREENCHIMENTO)); 304 | $layout->adiciona(new Campo(17,'TIPO DA NOTA FISCAL', $tipo_nf, NUMERICO, 1, OBRIGATORIO, PREENCHIMENTO)); 305 | $layout->adiciona(new Campo(18,'INDICACAO DE BONITIFICACAO', $indicacao_bonificacao, ALFA, 1, OBRIGATORIO, PREENCHIMENTO)); 306 | $layout->adiciona(new Campo(19,'CODIGO FISCAL DE OPERACAO', $codigo_fiscal_da_operacao, NUMERICO, 4, OBRIGATORIO, PREENCHIMENTO)); 307 | $layout->adiciona(new Campo(20,'SIGLA DO ESTADO(UF) DO FATO GERADOR', $uf, ALFA, 2, OBRIGATORIO, PREENCHIMENTO)); 308 | $layout->adiciona(new Campo(21,'DESDOBRO', $desdobro, ALFA, 10, OBRIGATORIO, PREENCHIMENTO)); 309 | $layout->adiciona(new Campo(22,'ESPACO', ' ', ALFA, 142, OBRIGATORIO, PREENCHIMENTO)); 310 | 311 | $linha = $layout->gera_linha(); 312 | // Verifica se tamanho gerado está conforme o tamanho esperado 313 | if ($tamanho != mb_strlen($linha)) { 314 | throw new Exception("REGISTRO 524 NAO CONFERE TAMANHO DE {$tamanho}"); 315 | } 316 | 317 | // Conta linhas para conferencia final 318 | $this->conta_524++; 319 | 320 | // Verifica se tem mais de 9999 registro 524 321 | if ($this->conta_524 > 9999) { 322 | throw new Exception("REGISTRO 524 OCORRE MAIS DE 9999 VEZES"); 323 | } 324 | 325 | // Gera linha conforme o layout 326 | return $linha."\n"; 327 | } 328 | 329 | public function registro_525($entrega_casada_cnpj_emissor1, $nome1, $serie_nf1, $numero_nf1, $entrega_casada_cnpj_emissor2, $nome2, $serie_nf2, $numero_nf2, $entrega_casada_cnpj_emissor3, $nome3, 330 | $serie_nf3, $numero_nf3, $redespacho_filial, $redespacho_serie, $redespacho_numero, $redespacho_cnpj_transp_contratatante , $tamanho) 331 | { 332 | // Zera contador de 527 - ocorre até 1 para cada 522 333 | $this->conta_527 = 0; 334 | 335 | $layout = new Layout(); 336 | 337 | // CAMPO: ORDEM, DESCRIÇÃO, CONTEUDO, TIPO N/A, TAMANHO, OBRIGATORIO, PREENCHIMENTO 338 | $layout->adiciona(new Campo(1,'IDENTIFICADOR DO REGISTRO', 525, NUMERICO, 3, OBRIGATORIO, PREENCHIMENTO)); 339 | $layout->adiciona(new Campo(2,'ENTREGA CASADA: CNPJ/CGC DO EMISSOR DA NOTA - 1', $entrega_casada_cnpj_emissor1, NUMERICO, 14, OBRIGATORIO, PREENCHIMENTO)); 340 | $layout->adiciona(new Campo(3,'NOME DO EMISSOR DA NOTA(RAZAO SOCIAL) - 1', $nome1, ALFA, 50, OBRIGATORIO, PREENCHIMENTO)); 341 | $layout->adiciona(new Campo(4,'SERIE DA NOTA FISCAL - 1', $serie_nf1, ALFA, 3, OBRIGATORIO, PREENCHIMENTO)); 342 | $layout->adiciona(new Campo(5,'NUMERO DA NOTA FISCAL - 1', $numero_nf1, NUMERICO, 9, OBRIGATORIO, PREENCHIMENTO)); 343 | $layout->adiciona(new Campo(6,'ENTREGA CASADA: CNPJ/CGC DO EMISSOR DA NOTA - 2', $entrega_casada_cnpj_emissor2, NUMERICO, 14, OBRIGATORIO, PREENCHIMENTO)); 344 | $layout->adiciona(new Campo(7,'NOME DO EMISSOR DA NOTA(RAZAO SOCIAL) - 2', $nome2, ALFA, 50, OBRIGATORIO, PREENCHIMENTO)); 345 | $layout->adiciona(new Campo(8,'SERIE DA NOTA FISCAL - 2', $serie_nf2, ALFA, 3, OBRIGATORIO, PREENCHIMENTO)); 346 | $layout->adiciona(new Campo(9,'NUMERO DA NOTA FISCAL - 2', $numero_nf2, NUMERICO, 9, OBRIGATORIO, PREENCHIMENTO)); 347 | $layout->adiciona(new Campo(10,'ENTREGA CASADA: CNPJ/CGC DO EMISSOR DA NOTA - 3', $entrega_casada_cnpj_emissor3, NUMERICO, 14, OBRIGATORIO, PREENCHIMENTO)); 348 | $layout->adiciona(new Campo(11,'NOME DO EMISSOR DA NOTA(RAZAO SOCIAL) - 3', $nome3, ALFA, 50, OBRIGATORIO, PREENCHIMENTO)); 349 | $layout->adiciona(new Campo(12,'SERIE DA NOTA FISCAL - 3', $serie_nf3, ALFA, 3, OBRIGATORIO, PREENCHIMENTO)); 350 | $layout->adiciona(new Campo(13,'NUMERO DA NOTA FISCAL - 3', $numero_nf3, NUMERICO, 9, OBRIGATORIO, PREENCHIMENTO)); 351 | $layout->adiciona(new Campo(14,'REDESPACHO: FILIAL EMISSORA CONHECIMENTO', $redespacho_filial, ALFA, 10, OBRIGATORIO, PREENCHIMENTO)); 352 | $layout->adiciona(new Campo(15,'REDESPACHO: SERIE CONHECIMENTO', $redespacho_serie, ALFA, 5, OBRIGATORIO, PREENCHIMENTO)); 353 | $layout->adiciona(new Campo(16,'REDESPACHO: NUMERO DO CONHECIMENTO', $redespacho_numero, ALFA, 12, OBRIGATORIO, PREENCHIMENTO)); 354 | $layout->adiciona(new Campo(17,'REDESPACHO: CNPJ/CGC DA TRANSP. CONTRATANTE', $redespacho_cnpj_transp_contratatante, NUMERICO, 14, OBRIGATORIO, PREENCHIMENTO)); 355 | $layout->adiciona(new Campo(18,'ESPACO', ' ', ALFA, 78, OBRIGATORIO, PREENCHIMENTO)); 356 | 357 | $linha = $layout->gera_linha(); 358 | // Verifica se tamanho gerado está conforme o tamanho esperado 359 | if ($tamanho != mb_strlen($linha)) { 360 | throw new Exception("REGISTRO 525 NAO CONFERE TAMANHO DE {$tamanho}"); 361 | } 362 | 363 | // Conta linhas para conferencia final 364 | $this->conta_525++; 365 | 366 | // Verifica se tem mais de 50 registro 525 367 | if ($this->conta_525 > 50) { 368 | throw new Exception("REGISTRO 525 OCORRE MAIS DE 50 VEZES"); 369 | } 370 | 371 | // Gera linha conforme o layout 372 | return $linha."\n"; 373 | } 374 | 375 | public function registro_527($razao_social, $cnpj, $inscricao_estadual, $enredeço, $bairro, $cidade, $codigo_postal, $codigo_municipio, $uf, $numero_comunicacao, 376 | $tamanho) 377 | { 378 | // Zera contador de 529 - ocorre até 1 para cada 520 379 | $this->conta_529 = 0; 380 | 381 | $layout = new Layout(); 382 | 383 | // CAMPO: ORDEM, DESCRIÇÃO, CONTEUDO, TIPO N/A, TAMANHO, OBRIGATORIO, PREENCHIMENTO 384 | $layout->adiciona(new Campo(1,'IDENTIFICADOR DO REGISTRO', 524, NUMERICO, 3, OBRIGATORIO, PREENCHIMENTO)); 385 | $layout->adiciona(new Campo(2,'RAZAO SOCIAL', $razao_social, ALFA, 60, OBRIGATORIO, PREENCHIMENTO)); 386 | $layout->adiciona(new Campo(3,'CNPJ(CGC)', $cnpj, NUMERICO, 14, OBRIGATORIO, PREENCHIMENTO)); 387 | $layout->adiciona(new Campo(4,'INSCRICAO ESTADUAL', $inscricao_estadual, ALFA, 15, OBRIGATORIO, PREENCHIMENTO)); 388 | $layout->adiciona(new Campo(5,'ENDERECO(LOGRADOURO)', $enredeço, ALFA, 60, OBRIGATORIO, PREENCHIMENTO)); 389 | $layout->adiciona(new Campo(6,'BAIRRO', $bairro, ALFA, 35, OBRIGATORIO, PREENCHIMENTO)); 390 | $layout->adiciona(new Campo(7,'CIDADE(MUNICIPIO)', $cidade, ALFA, 35, OBRIGATORIO, PREENCHIMENTO)); 391 | $layout->adiciona(new Campo(8,'CODIGO POSTAL', $codigo_postal, ALFA, 9, OBRIGATORIO, PREENCHIMENTO)); 392 | $layout->adiciona(new Campo(9,'CODIGO DE MUNICIPIO', $codigo_municipio, ALFA, 9, OBRIGATORIO, PREENCHIMENTO)); 393 | $layout->adiciona(new Campo(10,'SIGLA DA UNIDADE DA FEDERACAO DO PAIS(ESTADO)', $uf, ALFA, 9, OBRIGATORIO, PREENCHIMENTO)); 394 | $layout->adiciona(new Campo(11,'NUMERO DE COMUNICACAO', $numero_comunicacao, ALFA, 35, OBRIGATORIO, PREENCHIMENTO)); 395 | $layout->adiciona(new Campo(12,'ESPACO', ' ', ALFA, 66, OBRIGATORIO, PREENCHIMENTO)); 396 | 397 | $linha = $layout->gera_linha(); 398 | // Verifica se tamanho gerado está conforme o tamanho esperado 399 | if ($tamanho != mb_strlen($linha)) { 400 | throw new Exception("REGISTRO 527 NAO CONFERE TAMANHO DE {$tamanho}"); 401 | } 402 | 403 | // Conta linhas para conferencia final 404 | $this->conta_527++; 405 | 406 | // Verifica se tem mais de 1 registro 527 407 | if ($this->conta_527 > 1) { 408 | throw new Exception("REGISTRO 527 OCORRE MAIS DE 1 VEZ"); 409 | } 410 | 411 | // Gera linha conforme o layout 412 | return $linha."\n"; 413 | } 414 | 415 | public function registro_529($qntd_total_conhecimentos, $valor_total_conhecimentos, $tamanho) 416 | { 417 | 418 | $layout = new Layout(); 419 | 420 | // CAMPO: ORDEM, DESCRIÇÃO, CONTEUDO, TIPO N/A, TAMANHO, OBRIGATORIO, PREENCHIMENTO 421 | $layout->adiciona(new Campo(1,'IDENTIFICADOR DO REGISTRO', 529, NUMERICO, 3, OBRIGATORIO, PREENCHIMENTO)); 422 | $layout->adiciona(new Campo(2,'QUANTIDADE TOTAL DE CONHECIMENTOS', $qntd_total_conhecimentos, NUMERICO, 4, OBRIGATORIO, PREENCHIMENTO)); 423 | $layout->adiciona(new Campo(3,'VALOR TOTAL DOS CONHECIMENTOS', $valor_total_conhecimentos, NUMERICO, 13.2, OBRIGATORIO, PREENCHIMENTO)); 424 | $layout->adiciona(new Campo(4,'ESPACO', ' ', ALFA, 328, OBRIGATORIO, PREENCHIMENTO)); 425 | 426 | $linha = $layout->gera_linha(); 427 | // Verifica se tamanho gerado está conforme o tamanho esperado 428 | if ($tamanho != mb_strlen($linha)) { 429 | throw new Exception("REGISTRO 529 NAO CONFERE TAMANHO DE {$tamanho}"); 430 | } 431 | 432 | // Conta linhas para conferencia final 433 | $this->conta_529++; 434 | 435 | // Verifica se tem mais de 1 registro 529 436 | if ($this->conta_529 > 1) { 437 | throw new Exception("REGISTRO 529 OCORRE MAIS DE 1 VEZ"); 438 | } 439 | 440 | // Gera linha conforme o layout 441 | return $linha."\n"; 442 | } 443 | } -------------------------------------------------------------------------------- /app/Proceda/Doccob.php: -------------------------------------------------------------------------------- 1 | | 10 | * | | 11 | * | Programa...: Doccob.php | 12 | * | | 13 | * | Autor......: Helder | 14 | * | | 15 | * | Criação....: 26-06-2018 | 16 | * | | 17 | * | Objetivo...: Formatar registros conforme Layout DOCCOB | 18 | * | | 19 | * | Layout EDI.: 6.0 - 31/07/2008 | 20 | * | | 21 | * +-----------------------------------------------------------------------+ 22 | * | Versões....: | 23 | * | | 24 | * | | 25 | * | | 26 | * +-----------------------------------------------------------------------+ 27 | */ 28 | 29 | namespace App\Proceda; 30 | 31 | use App\Layout; 32 | use App\Campo; 33 | 34 | /** 35 | * Doccob 36 | * 37 | * @version 1.0 38 | * @package proceda 39 | * @author Helder Afonso de Morais 40 | * @copyright Copyright (c) 2018 php-edi 41 | */ 42 | class Doccob 43 | { 44 | 45 | var $conta_000 = 0; 46 | var $conta_550 = 0; 47 | var $conta_551 = 0; 48 | var $conta_552 = 0; 49 | var $conta_553 = 0; 50 | var $conta_555 = 0; 51 | var $conta_556 = 0; 52 | var $conta_559 = 0; 53 | 54 | 55 | /** 56 | * Formata campos recebidos para registro 000 57 | * @param $remetente Request 58 | * @param $destinatario Request 59 | * @param $data Request 60 | * @param $hora Request 61 | * @param $intercambio Request 62 | * @param $tamanho Request 63 | */ 64 | public function registro_000($remetente, $destinatario, $data, $hora, $intercambio, $tamanho) 65 | { 66 | // Zera contador de 550 - ocorre até 200 para cada 000 67 | $this->conta_550 = 0; 68 | 69 | $layout = new Layout(); 70 | 71 | // CAMPO: ORDEM, DESCRIÇÃO, CONTEUDO, TIPO N/A, TAMANHO, OBRIGATORIO, PREENCHIMENTO 72 | $layout->adiciona(new Campo(1,'IDENTIFICADOR DO REGISTRO', 0, NUMERICO, 3, OBRIGATORIO, PREENCHIMENTO)); 73 | $layout->adiciona(new Campo(2,'IDENTIFICAÇÃO DO REMETENTE', $remetente, ALFA, 35, OBRIGATORIO, PREENCHIMENTO)); 74 | $layout->adiciona(new Campo(3,'IDENTIFICAÇÃO DO DESTINATARIO', $destinatario, ALFA, 35, OBRIGATORIO, PREENCHIMENTO)); 75 | $layout->adiciona(new Campo(4,'DATA', $data, NUMERICO, 6, OBRIGATORIO, PREENCHIMENTO)); 76 | $layout->adiciona(new Campo(5,'HORA', $hora, NUMERICO, 4, OBRIGATORIO, PREENCHIMENTO)); 77 | $layout->adiciona(new Campo(6,'INTERCAMBIO', 'COB502906001', ALFA, 12, OBRIGATORIO, PREENCHIMENTO)); 78 | $layout->adiciona(new Campo(7,'ESPACO', ' ', ALFA, 185, OBRIGATORIO, PREENCHIMENTO)); 79 | 80 | $linha = $layout->gera_linha(); 81 | // Verifica se tamanho gerado está conforme o tamanho esperado 82 | if ($tamanho != strlen($linha)) { 83 | throw new \Exception("REGISTRO 000 NAO CONFERE TAMANHO DE {$tamanho}/".strlen($linha)); 84 | } 85 | 86 | // Conta linhas para conferencia final 87 | $this->conta_000++; 88 | 89 | // Verifica se tem mais de 1 registro 000 90 | if ($this->conta_000 > 1) { 91 | throw new \Exception("REGISTRO 000 OCORRE MAIS DE 1 VEZ"); 92 | } 93 | 94 | // Gera linha conforme o layout 95 | return $linha."\n"; 96 | } 97 | 98 | /** 99 | * Formata campos recebidos para registro 550 100 | * @param $documento Request 101 | * @param $tamanho Request 102 | */ 103 | public function registro_550($documento, $tamanho) 104 | { 105 | // Zera contador de 551 - ocorre 1 para cada 550 106 | $this->conta_551 = 0; 107 | 108 | $layout = new Layout(); 109 | 110 | // CAMPO: ORDEM, DESCRIÇÃO, CONTEUDO, TIPO N/A, TAMANHO, OBRIGATORIO, PREENCHIMENTO 111 | $layout->adiciona(new Campo(1,'IDENTIFICADOR DO REGISTRO', 550, NUMERICO, 3, OBRIGATORIO, PREENCHIMENTO)); 112 | $layout->adiciona(new Campo(2,'IDENTIFICAÇÃO DO DOCUMENTO', $documento, ALFA, 14, OBRIGATORIO, PREENCHIMENTO)); 113 | $layout->adiciona(new Campo(3,'ESPACO', ' ', ALFA, 263, OBRIGATORIO, PREENCHIMENTO)); 114 | 115 | $linha = $layout->gera_linha(); 116 | // Verifica se tamanho gerado está conforme o tamanho esperado 117 | if ($tamanho != strlen($linha)) { 118 | throw new \Exception("REGISTRO 550 NAO CONFERE TAMANHO DE {$tamanho} : ".strlen($linha)); 119 | } 120 | 121 | // Conta linhas para conferencia final 122 | $this->conta_550++; 123 | 124 | // Verifica se tem mais de 200 registro 520 125 | if ($this->conta_550 > 200) { 126 | throw new Exception("REGISTRO 550 OCORRE MAIS DE 200 VEZES"); 127 | } 128 | 129 | // Gera linha conforme o layout 130 | return $linha."\n"; 131 | } 132 | 133 | /** 134 | * Formata campos recebidos para registro 551 135 | * @param $cnpj Request 136 | * @param $razao Request 137 | * @param $tamanho Request 138 | */ 139 | public function registro_551($cnpj, $razao, $tamanho) 140 | { 141 | // Zera contador de 552 - ocorre ate 500 para cada 551 142 | $this->conta_552 = 0; 143 | 144 | $layout = new Layout(); 145 | 146 | // CAMPO: ORDEM, DESCRIÇÃO, CONTEUDO, TIPO N/A, TAMANHO, OBRIGATORIO, PREENCHIMENTO 147 | $layout->adiciona(new Campo(1,'IDENTIFICADOR DO REGISTRO', 551, NUMERICO, 3, OBRIGATORIO, PREENCHIMENTO)); 148 | $layout->adiciona(new Campo(2,'CNPJ REMETENTE', $cnpj, NUMERICO, 14, OBRIGATORIO, PREENCHIMENTO)); 149 | $layout->adiciona(new Campo(2,'RAZAO SOCIAL', $razao, ALFA, 50, OBRIGATORIO, PREENCHIMENTO)); 150 | $layout->adiciona(new Campo(3,'ESPACO', ' ', ALFA, 213, OBRIGATORIO, PREENCHIMENTO)); 151 | 152 | $linha = $layout->gera_linha(); 153 | 154 | // Verifica se tamanho gerado está conforme o tamanho esperado 155 | if ($tamanho != strlen($linha)) { 156 | throw new \Exception("REGISTRO 551 NAO CONFERE TAMANHO DE {$tamanho} :".strlen($linha)); 157 | } 158 | 159 | // Conta linhas para conferencia final 160 | $this->conta_551++; 161 | 162 | // Verifica se tem mais de 1 registro 550 163 | if ($this->conta_551 > 1) { 164 | throw new \Exception("REGISTRO 551 OCORRE MAIS DE 1 VEZ"); 165 | } 166 | 167 | // Gera linha conforme o layout 168 | return $linha."\n"; 169 | } 170 | 171 | /** 172 | * Formata campos recebidos para registro 552 173 | * @param $cnpj Request 174 | * @param $razao Request 175 | * @param $tamanho Request 176 | */ 177 | public function registro_552($filial, $tipo, $serie, $numero, $emissao, 178 | $vencimento, $valor, $tipo_cobranca, $multa, $juros, $limite, $desconto, $agente, 179 | $nome, $agencia, $digito, $conta, $digito_conta, $acao, $pre_fatura, $complementar, 180 | $cfop, $codigo, $chave, $protocolo, $tamanho) 181 | { 182 | // Zera contador de 553 - ocorre 1 para cada 552 183 | $this->conta_553 = 0; 184 | 185 | $layout = new Layout(); 186 | 187 | // CAMPO: ORDEM, DESCRIÇÃO, CONTEUDO, TIPO N/A, TAMANHO, OBRIGATORIO, PREENCHIMENTO 188 | $layout->adiciona(new Campo(1,'IDENTIFICADOR DO REGISTRO', 552, NUMERICO, 3, OBRIGATORIO, PREENCHIMENTO)); 189 | $layout->adiciona(new Campo(2,'FILIAL', $filial, ALFA, 10, OBRIGATORIO, PREENCHIMENTO)); 190 | $layout->adiciona(new Campo(3,'TIPO', $tipo, NUMERICO, 1, OBRIGATORIO, PREENCHIMENTO)); 191 | $layout->adiciona(new Campo(4,'SERIE', $serie, ALFA, 3, OBRIGATORIO, PREENCHIMENTO)); 192 | $layout->adiciona(new Campo(5,'NUMERO', $numero, NUMERICO, 10, OBRIGATORIO, PREENCHIMENTO)); 193 | $layout->adiciona(new Campo(6,'EMISSAO', $emissao, NUMERICO, 8, OBRIGATORIO, PREENCHIMENTO)); 194 | $layout->adiciona(new Campo(7,'VENCIMENTO', $vencimento, NUMERICO, 8, OBRIGATORIO, PREENCHIMENTO)); 195 | $layout->adiciona(new Campo(8,'VALOR', $valor, NUMERICO, 13.2, OBRIGATORIO, PREENCHIMENTO)); 196 | $layout->adiciona(new Campo(9,'TIPO DE COBRANCA', $tipo_cobranca, ALFA, 3, OBRIGATORIO, PREENCHIMENTO)); 197 | $layout->adiciona(new Campo(10,'MULTA', $multa, NUMERICO, 2.2, OBRIGATORIO, PREENCHIMENTO)); 198 | $layout->adiciona(new Campo(11,'JUROS', $juros, NUMERICO, 13.2, OBRIGATORIO, PREENCHIMENTO)); 199 | $layout->adiciona(new Campo(12,'DATA LIMITE', $limite, NUMERICO, 8, OBRIGATORIO, PREENCHIMENTO)); 200 | $layout->adiciona(new Campo(13,'DESCONTO', $desconto, NUMERICO, 13.2, OBRIGATORIO, PREENCHIMENTO)); 201 | $layout->adiciona(new Campo(14,'AGENTE', $agente, NUMERICO, 5, OBRIGATORIO, PREENCHIMENTO)); 202 | $layout->adiciona(new Campo(15,'NOME', $nome, ALFA, 30, OBRIGATORIO, PREENCHIMENTO)); 203 | $layout->adiciona(new Campo(16,'AGENCIA', $agencia, NUMERICO, 4, OBRIGATORIO, PREENCHIMENTO)); 204 | $layout->adiciona(new Campo(17,'DIGITO', $digito, ALFA, 1, OBRIGATORIO, PREENCHIMENTO)); 205 | $layout->adiciona(new Campo(18,'CONTA', $conta, NUMERICO, 10, OBRIGATORIO, PREENCHIMENTO)); 206 | $layout->adiciona(new Campo(19,'DIGITO DA CONTA', $digito_conta, ALFA, 2, OBRIGATORIO, PREENCHIMENTO)); 207 | $layout->adiciona(new Campo(20,'ACAO', $acao, ALFA, 1, OBRIGATORIO, PREENCHIMENTO)); 208 | $layout->adiciona(new Campo(21,'PRE FATURA', $pre_fatura, NUMERICO, 10, OBRIGATORIO, PREENCHIMENTO)); 209 | $layout->adiciona(new Campo(22,'COMPLEMENTAR', $complementar, ALFA, 20, OBRIGATORIO, PREENCHIMENTO)); 210 | $layout->adiciona(new Campo(23,'CFOP', $cfop, ALFA, 5, OBRIGATORIO, PREENCHIMENTO)); 211 | $layout->adiciona(new Campo(24,'CODIGO', $codigo, NUMERICO, 9, OBRIGATORIO, PREENCHIMENTO)); 212 | $layout->adiciona(new Campo(25,'CHAVE', $chave, ALFA, 45, OBRIGATORIO, PREENCHIMENTO)); 213 | $layout->adiciona(new Campo(26,'PROTOCOLO', $protocolo, ALFA, 15, OBRIGATORIO, PREENCHIMENTO)); 214 | $layout->adiciona(new Campo(27,'ESPACO', ' ', ALFA, 20, OBRIGATORIO, PREENCHIMENTO)); 215 | 216 | 217 | $linha = $layout->gera_linha(); 218 | 219 | // Verifica se tamanho gerado está conforme o tamanho esperado 220 | if ($tamanho != strlen($linha)) { 221 | throw new \Exception("REGISTRO 552 NAO CONFERE TAMANHO DE {$tamanho}"); 222 | } 223 | 224 | // Conta linhas para conferencia final 225 | $this->conta_552++; 226 | 227 | // Verifica se tem mais de 500 registro 552 228 | if ($this->conta_552 > 500) { 229 | throw new \Exception("REGISTRO 552 OCORRE MAIS DE 500 VEZES"); 230 | } 231 | 232 | // Gera linha conforme o layout 233 | return $linha."\n"; 234 | } 235 | 236 | 237 | /** 238 | * Formata campos recebidos para registro 553 239 | * @param $cnpj Request 240 | * @param $razao Request 241 | * @param $tamanho Request 242 | */ 243 | 244 | public function registro_553($valor_icms, $aliq_icms, $base_icms, $valor_iss, $aliq_iss, 245 | $base_iss, $valor_subst, $aliq_subst, $base_subst, $valor_ir, $tamanho) 246 | { 247 | // Zera contador de 555 - ocorre até 5000 para cada 552 248 | $this->conta_555 = 0; 249 | 250 | $layout = new Layout(); 251 | 252 | // CAMPO: ORDEM, DESCRIÇÃO, CONTEUDO, TIPO N/A, TAMANHO, OBRIGATORIO, PREENCHIMENTO 253 | $layout->adiciona(new Campo(1,'IDENTIFICADOR DO REGISTRO', 553, NUMERICO, 3, OBRIGATORIO, PREENCHIMENTO)); 254 | $layout->adiciona(new Campo(2,'VALOR_ICMS', $valor_icms, NUMERICO, 13.2, OBRIGATORIO, PREENCHIMENTO)); 255 | $layout->adiciona(new Campo(3,'ALIQUOTA_ICMS', $aliq_icms, NUMERICO, 3.2, OBRIGATORIO, PREENCHIMENTO)); 256 | $layout->adiciona(new Campo(4,'BASE_ICMS', $base_icms, NUMERICO, 13.2, OBRIGATORIO, PREENCHIMENTO)); 257 | $layout->adiciona(new Campo(5,'VALOR_ISS', $valor_iss, NUMERICO, 13.2, OBRIGATORIO, PREENCHIMENTO)); 258 | $layout->adiciona(new Campo(6,'ALIQUOTA_ISS', $aliq_iss, NUMERICO, 3.2, OBRIGATORIO, PREENCHIMENTO)); 259 | $layout->adiciona(new Campo(7,'BASE_ISS', $base_iss, NUMERICO, 13.2, OBRIGATORIO, PREENCHIMENTO)); 260 | $layout->adiciona(new Campo(8,'VALOR_SUBSTITUICAO', $valor_subst, NUMERICO, 13.2, OBRIGATORIO, PREENCHIMENTO)); 261 | $layout->adiciona(new Campo(9,'ALIQUOTA_SUBSTITUICAO', $aliq_subst, NUMERICO, 3.2, OBRIGATORIO, PREENCHIMENTO)); 262 | $layout->adiciona(new Campo(10,'BASE_SUBSTITUICAO', $base_subst, NUMERICO, 13.2, OBRIGATORIO, PREENCHIMENTO)); 263 | $layout->adiciona(new Campo(11,'VALOR_IR', $valor_ir, NUMERICO, 13.2, OBRIGATORIO, PREENCHIMENTO)); 264 | $layout->adiciona(new Campo(12,'ESPACO', ' ', ALFA, 157, OBRIGATORIO, PREENCHIMENTO)); 265 | 266 | $linha = $layout->gera_linha(); 267 | 268 | // Verifica se tamanho gerado está conforme o tamanho esperado 269 | if ($tamanho != strlen($linha)) { 270 | throw new \Exception("REGISTRO 553 NAO CONFERE TAMANHO DE {$tamanho}"); 271 | } 272 | 273 | // Conta linhas para conferencia final 274 | $this->conta_553++; 275 | 276 | // Verifica se tem mais de 1 registro 553 277 | if ($this->conta_553 > 1) { 278 | throw new \Exception("REGISTRO 553 OCORRE MAIS DE 1 VEZ"); 279 | } 280 | 281 | // Gera linha conforme o layout 282 | return $linha."\n"; 283 | } 284 | 285 | /** 286 | * Formata campos recebidos para registro 555 287 | * @param $cnpj Request 288 | * @param $razao Request 289 | * @param $tamanho Request 290 | */ 291 | 292 | public function registro_555($filial, $serie, $numero, $valor, $emissao, 293 | $remetente, $destinatario, $emissor_do_conhecimento, $uf_embarcador, $uf_emissora, $uf_destinatario, $conta_razao, $iva, 294 | $identificacao_embarque, $identificacao_carga, $numero_SAP, $outro_SAP, $devolucao, $tamanho) 295 | { 296 | // Zera contador de 556 - ocorre até 9999 para cada 552 297 | $this->conta_556 = 0; 298 | 299 | $layout = new Layout(); 300 | 301 | // CAMPO: ORDEM, DESCRIÇÃO, CONTEUDO, TIPO N/A, TAMANHO, OBRIGATORIO, PREENCHIMENTO 302 | $layout->adiciona(new Campo(1,'IDENTIFICADOR DO REGISTRO', 555, NUMERICO, 3, OBRIGATORIO, PREENCHIMENTO)); 303 | $layout->adiciona(new Campo(2,'FILIAL', $filial, ALFA, 10, OBRIGATORIO, PREENCHIMENTO)); 304 | $layout->adiciona(new Campo(3,'SERIE', $serie, ALFA, 5, OBRIGATORIO, PREENCHIMENTO)); 305 | $layout->adiciona(new Campo(4,'NUMERO', $numero, ALFA, 12, OBRIGATORIO, PREENCHIMENTO)); 306 | $layout->adiciona(new Campo(5,'VALOR', $valor, NUMERICO, 13.2, OBRIGATORIO, PREENCHIMENTO)); 307 | $layout->adiciona(new Campo(6,'EMISSAO', $emissao, NUMERICO, 8, OBRIGATORIO, PREENCHIMENTO)); 308 | $layout->adiciona(new Campo(7,'REMETENTE', $remetente, NUMERICO, 14, OBRIGATORIO, PREENCHIMENTO)); 309 | $layout->adiciona(new Campo(8,'DESTINATARIO', $destinatario, NUMERICO, 14, OBRIGATORIO, PREENCHIMENTO)); 310 | $layout->adiciona(new Campo(9,'EMISSOR DO CONHECIMENTO', $emissor_do_conhecimento, NUMERICO, 14, OBRIGATORIO, PREENCHIMENTO)); 311 | $layout->adiciona(new Campo(10,'UF EMBARCADOR', $uf_embarcador, ALFA, 2, OBRIGATORIO, PREENCHIMENTO)); 312 | $layout->adiciona(new Campo(11,'UF EMISSORA', $uf_emissora, ALFA, 2, OBRIGATORIO, PREENCHIMENTO)); 313 | $layout->adiciona(new Campo(12,'UF DESTINATARIO', $uf_destinatario, ALFA, 2, OBRIGATORIO, PREENCHIMENTO)); 314 | $layout->adiciona(new Campo(13,'CONTA RAZAO', $conta_razao, ALFA, 10, OBRIGATORIO, PREENCHIMENTO)); 315 | $layout->adiciona(new Campo(14,'IVA', $iva, ALFA, 2, OBRIGATORIO, PREENCHIMENTO)); 316 | $layout->adiciona(new Campo(15,'IDENTIFICACAO EMBARQUE', $identificacao_embarque, ALFA, 20, OBRIGATORIO, PREENCHIMENTO)); 317 | $layout->adiciona(new Campo(16,'IDENTIFICACAO CARGA', $identificacao_carga, ALFA, 20, OBRIGATORIO, PREENCHIMENTO)); 318 | $layout->adiciona(new Campo(17,'NUMERO SAP', $numero_SAP, ALFA, 20, OBRIGATORIO, PREENCHIMENTO)); 319 | $layout->adiciona(new Campo(18,'OUTRO SAP', $outro_SAP, ALFA, 20, OBRIGATORIO, PREENCHIMENTO)); 320 | $layout->adiciona(new Campo(19,'DEVOLUCAO', $devolucao, ALFA, 1, OBRIGATORIO, PREENCHIMENTO)); 321 | $layout->adiciona(new Campo(20,'ESPACO', ' ', ALFA, 86, OBRIGATORIO, PREENCHIMENTO)); 322 | 323 | $linha = $layout->gera_linha(); 324 | 325 | // Verifica se tamanho gerado está conforme o tamanho esperado 326 | if ($tamanho != strlen($linha)) { 327 | throw new \Exception("REGISTRO 555 NAO CONFERE TAMANHO DE {$tamanho}"); 328 | } 329 | 330 | // Conta linhas para conferencia final 331 | $this->conta_555++; 332 | 333 | // Verifica se tem mais de 5000 registro 555 334 | if ($this->conta_555 > 5000) { 335 | throw new \Exception("REGISTRO 555 OCORRE MAIS DE 5000 VEZES"); 336 | } 337 | 338 | // Gera linha conforme o layout 339 | return $linha."\n"; 340 | } 341 | 342 | /** 343 | * Formata campos recebidos para registro 556 344 | * @param $cnpj Request 345 | * @param $razao Request 346 | * @param $tamanho Request 347 | */ 348 | 349 | public function registro_556($serie, $numero, $emissao, $peso, $valor, 350 | $emissor, $identificacao_embarque, $identificacao_carga, $numero_SAP, $outro_SAP, $devolucao, $tamanho) 351 | { 352 | // Zera contador de 559 - ocorre até 1 para cada 550 353 | $this->conta_559 = 0; 354 | 355 | $layout = new Layout(); 356 | 357 | // CAMPO: ORDEM, DESCRIÇÃO, CONTEUDO, TIPO N/A, TAMANHO, OBRIGATORIO, PREENCHIMENTO 358 | $layout->adiciona(new Campo(1,'IDENTIFICADOR DO REGISTRO', 556, NUMERICO, 3, OBRIGATORIO, PREENCHIMENTO)); 359 | $layout->adiciona(new Campo(2,'SERIE', $serie, ALFA, 3, OBRIGATORIO, PREENCHIMENTO)); 360 | $layout->adiciona(new Campo(3,'NUMERO', $numero, NUMERICO, 9, OBRIGATORIO, PREENCHIMENTO)); 361 | $layout->adiciona(new Campo(4,'EMISSAO', $emissao, NUMERICO, 8, OBRIGATORIO, PREENCHIMENTO)); 362 | $layout->adiciona(new Campo(5,'PESO', $peso, NUMERICO, 5.2, OBRIGATORIO, PREENCHIMENTO)); 363 | $layout->adiciona(new Campo(6,'VALOR', $valor, NUMERICO, 13.2, OBRIGATORIO, PREENCHIMENTO)); 364 | $layout->adiciona(new Campo(7,'EMISSOR', $emissor, NUMERICO, 14, OBRIGATORIO, PREENCHIMENTO)); 365 | $layout->adiciona(new Campo(8,'IDENTIFICACAO EMBARQUE', $identificacao_embarque, ALFA, 20, OBRIGATORIO, PREENCHIMENTO)); 366 | $layout->adiciona(new Campo(9,'IDENTIFICACAO CARGA', $identificacao_carga, ALFA, 20, OBRIGATORIO, PREENCHIMENTO)); 367 | $layout->adiciona(new Campo(10,'NUMERO SAP', $numero_SAP, ALFA, 20, OBRIGATORIO, PREENCHIMENTO)); 368 | $layout->adiciona(new Campo(11,'OUTRO SAP', $outro_SAP, ALFA, 20, OBRIGATORIO, PREENCHIMENTO)); 369 | $layout->adiciona(new Campo(12,'DEVOLUCAO', $devolucao, ALFA, 1, OBRIGATORIO, PREENCHIMENTO)); 370 | $layout->adiciona(new Campo(13,'ESPACO', ' ', ALFA, 140, OBRIGATORIO, PREENCHIMENTO)); 371 | 372 | $linha = $layout->gera_linha(); 373 | 374 | // Verifica se tamanho gerado está conforme o tamanho esperado 375 | if ($tamanho != strlen($linha)) { 376 | throw new \Exception("REGISTRO 556 NAO CONFERE TAMANHO DE {$tamanho}"); 377 | } 378 | 379 | // Conta linhas para conferencia final 380 | $this->conta_556++; 381 | 382 | // Verifica se tem mais de 9999 registro 556 383 | if ($this->conta_556 > 9999) { 384 | throw new \Exception("REGISTRO 556 OCORRE MAIS DE 9999 VEZES"); 385 | } 386 | 387 | // Gera linha conforme o layout 388 | return $linha."\n"; 389 | } 390 | 391 | /** 392 | * Formata campos recebidos para registro 9 393 | * @param $cnpj Request 394 | * @param $razao Request 395 | * @param $tamanho Request 396 | */ 397 | 398 | public function registro_559($qtde_total, $valor_total , $tamanho) 399 | { 400 | 401 | $layout = new Layout(); 402 | 403 | // CAMPO: ORDEM, DESCRIÇÃO, CONTEUDO, TIPO N/A, TAMANHO, OBRIGATORIO, PREENCHIMENTO 404 | $layout->adiciona(new Campo(1,'IDENTIFICADOR DO REGISTRO', 559, NUMERICO, 3, OBRIGATORIO, PREENCHIMENTO)); 405 | $layout->adiciona(new Campo(2,'QTDE TOTAL', $qtde_total, NUMERICO, 4, OBRIGATORIO, PREENCHIMENTO)); 406 | $layout->adiciona(new Campo(3,'VALOR TOTAL', $valor_total, NUMERICO, 13.2, OBRIGATORIO, PREENCHIMENTO)); 407 | $layout->adiciona(new Campo(4,'ESPACO', ' ', ALFA, 258, OBRIGATORIO, PREENCHIMENTO)); 408 | 409 | $linha = $layout->gera_linha(); 410 | 411 | // Verifica se tamanho gerado está conforme o tamanho esperado 412 | if ($tamanho != strlen($linha)) { 413 | throw new \Exception("REGISTRO 559 NAO CONFERE TAMANHO DE {$tamanho}"); 414 | } 415 | 416 | // Conta linhas para conferencia final 417 | $this->conta_559++; 418 | 419 | // Verifica se tem mais de 1 registro 559 420 | if ($this->conta_559 > 1) { 421 | throw new \Exception("REGISTRO 559 OCORRE MAIS DE 1 VEZ"); 422 | } 423 | 424 | // Gera linha conforme o layout 425 | return $linha."\n"; 426 | } 427 | 428 | } -------------------------------------------------------------------------------- /app/Proceda/Ocoren.php: -------------------------------------------------------------------------------- 1 | | 10 | * | | 11 | * | Programa...: Ocoren.php | 12 | * | | 13 | * | Autor......: Helder | 14 | * | | 15 | * | Criação....: 26-06-2018 | 16 | * | | 17 | * | Objetivo...: Formatar registros conforme Layout PROCEDA/OCOREN | 18 | * | | 19 | * | Layout EDI.: 6.0 - 31/07/2008 | 20 | * | | 21 | * +-----------------------------------------------------------------------+ 22 | * | Versões....: | 23 | * | | 24 | * | | 25 | * | | 26 | * +-----------------------------------------------------------------------+ 27 | */ 28 | 29 | namespace App\Proceda; 30 | 31 | use App\Layout; 32 | use App\Campo; 33 | 34 | class Ocoren 35 | { 36 | 37 | var $conta_000 = 0; 38 | var $conta_520 = 0; 39 | var $conta_521 = 0; 40 | var $conta_542 = 0; 41 | var $conta_543 = 0; 42 | var $conta_544 = 0; 43 | var $conta_545 = 0; 44 | var $conta_549 = 0; 45 | 46 | /** 47 | * Formata campos recebidos para registro 000 48 | * @param $remetente Request 49 | * @param $destinatario Request 50 | * @param $data Request 51 | * @param $hora Request 52 | * @param $intercambio Request 53 | * @param $tamanho Request 54 | */ 55 | public function registro_000($remetente, $destinatario, $data, $hora, $intercambio, $tamanho) 56 | { 57 | // Zera contador de 540 - ocorre até 200 para cada 000 58 | $this->conta_540 = 0; 59 | 60 | $layout = new Layout(); 61 | 62 | // CAMPO: ORDEM, DESCRIÇÃO, CONTEUDO, TIPO N/A, TAMANHO, OBRIGATORIO, PREENCHIMENTO 63 | $layout->adiciona(new Campo(1,'IDENTIFICADOR DO REGISTRO', 000, NUMERICO, 3, OBRIGATORIO, PREENCHIMENTO)); 64 | $layout->adiciona(new Campo(2,'IDENTIFICAÇÃO DO REMETENTE', $remetente, ALFA, 35, OBRIGATORIO, PREENCHIMENTO)); 65 | $layout->adiciona(new Campo(3,'IDENTIFICAÇÃO DO DESTINATARIO', $destinatario, ALFA, 35, OBRIGATORIO, PREENCHIMENTO)); 66 | $layout->adiciona(new Campo(4,'DATA', $data, NUMERICO, 6, OBRIGATORIO, PREENCHIMENTO)); 67 | $layout->adiciona(new Campo(5,'HORA', $hora, NUMERICO, 4, OBRIGATORIO, PREENCHIMENTO)); 68 | $layout->adiciona(new Campo(6,'INTERCAMBIO', 'OCO50DDMM999', ALFA, 12, OBRIGATORIO, PREENCHIMENTO)); 69 | $layout->adiciona(new Campo(7,'ESPAÇO', ' ', ALFA, 155, OBRIGATORIO, PREENCHIMENTO)); 70 | 71 | $linha = $layout->gera_linha(); 72 | // Verifica se tamanho gerado está conforme o tamanho esperado 73 | if ($tamanho != strlen($linha)) { 74 | throw new Exception("REGISTRO 000 NAO CONFERE TAMANHO DE {$tamanho}"); 75 | } 76 | 77 | // Conta linhas para conferencia final 78 | $this->conta_000++; 79 | 80 | // Verifica se tem mais de 1 registro 000 81 | if ($this->conta_000 > 1) { 82 | throw new Exception("REGISTRO 000 OCORRE MAIS DE 1 VEZ"); 83 | } 84 | 85 | // Gera linha conforme o layout 86 | return $linha."\n"; 87 | } 88 | 89 | public function registro_540($documento, $tamanho) 90 | { 91 | // Zera contador de 541 - ocorre até 1 para cada 540 92 | $this->conta_541 = 0; 93 | 94 | $layout = new Layout(); 95 | 96 | // CAMPO: ORDEM, DESCRIÇÃO, CONTEUDO, TIPO N/A, TAMANHO, OBRIGATORIO, PREENCHIMENTO 97 | $layout->adiciona(new Campo(1,'IDENTIFICADOR DO REGISTRO', 540, NUMERICO, 3, OBRIGATORIO, PREENCHIMENTO)); 98 | $layout->adiciona(new Campo(2,'IDENTIFICAÇÃO DO DOCUMENTO', $documento, ALFA, 14, OBRIGATORIO, PREENCHIMENTO)); 99 | $layout->adiciona(new Campo(3,'ESPAÇO', ' ', ALFA, 233, OBRIGATORIO, PREENCHIMENTO)); 100 | 101 | $linha = $layout->gera_linha(); 102 | // Verifica se tamanho gerado está conforme o tamanho esperado 103 | if ($tamanho != strlen($linha)) { 104 | throw new Exception("REGISTRO 540 NAO CONFERE TAMANHO DE {$tamanho}"); 105 | } 106 | 107 | // Conta linhas para conferencia final 108 | $this->conta_540++; 109 | 110 | // Verifica se tem mais de 200 registro 540 111 | if ($this->conta_540 > 200) { 112 | throw new Exception("REGISTRO 540 OCORRE MAIS DE 200 VEZES"); 113 | } 114 | 115 | // Gera linha conforme o layout 116 | return $linha."\n"; 117 | } 118 | 119 | public function registro_541($cnpj_transportadora, $razao_social_transportadora, $tamanho) 120 | { 121 | // Zera contador de 542 - ocorre até 9999 para cada 541 122 | $this->conta_542 = 0; 123 | 124 | $layout = new Layout(); 125 | 126 | // CAMPO: ORDEM, DESCRIÇÃO, CONTEUDO, TIPO N/A, TAMANHO, OBRIGATORIO, PREENCHIMENTO 127 | $layout->adiciona(new Campo(1,'IDENTIFICADOR DO REGISTRO', 541, NUMERICO, 3, OBRIGATORIO, PREENCHIMENTO)); 128 | $layout->adiciona(new Campo(2,'CNPJ(CGC) DA TRANSPORTADORA', $cnpj_transportadora, NUMERICO, 14, OBRIGATORIO, PREENCHIMENTO)); 129 | $layout->adiciona(new Campo(3,'RAZAO SOCIAL DA TRANSPORTADORA', $razao_social_transportadora, ALFA, 50, OBRIGATORIO, PREENCHIMENTO)); 130 | $layout->adiciona(new Campo(4,'ESPAÇO', ' ', ALFA, 183, OBRIGATORIO, PREENCHIMENTO)); 131 | 132 | $linha = $layout->gera_linha(); 133 | // Verifica se tamanho gerado está conforme o tamanho esperado 134 | if ($tamanho != strlen($linha)) { 135 | throw new Exception("REGISTRO 541 NAO CONFERE TAMANHO DE {$tamanho}"); 136 | } 137 | 138 | // Conta linhas para conferencia final 139 | $this->conta_541++; 140 | 141 | // Verifica se tem mais de 1 registro 541 142 | if ($this->conta_541 > 1) { 143 | throw new Exception("REGISTRO 541 OCORRE MAIS DE 1 VEZ"); 144 | } 145 | 146 | // Gera linha conforme o layout 147 | return $linha."\n"; 148 | } 149 | 150 | public function registro_542($cnpj_emissor_nf, $serie_nf, $numero_nf, $codigo_ocorrencia_entrega, $data_ocorrencia, $hora_ocorrencia, $cod_observacao_ocorrencia_entrada, $numero_romaneio_identf_embarque, $identf_carga1, $identf_carga2, 151 | $identf_carga3, $filial_emissora_conhecimento, $serie_conhecimento, $numero_conhecimento, $indicacao_tipo_entrega, $codigo_empresa_emissora_nf, $codigo_filial_empresa_emissora_nf, $data_chegada_nf, $hora_chegada_nf, $data_inicio_descarregamento_destino, 152 | $hora_inicio_descarregamento_destino, $data_termino_descarregamento_destino, $hora_termino_descarregamento_destino, $data_saida_destino_nf, $hora_saida_destino_nf, $cnpj_emissor_nf_devolucao, $serie_nf_devolucao, $numero_nf_devolucao, $tamanho) 153 | { 154 | // Zera contador de 543 - ocorre até 1 para cada 542 155 | $this->conta_543 = 0; 156 | 157 | $layout = new Layout(); 158 | 159 | // CAMPO: ORDEM, DESCRIÇÃO, CONTEUDO, TIPO N/A, TAMANHO, OBRIGATORIO, PREENCHIMENTO 160 | $layout->adiciona(new Campo(1,'IDENTIFICADOR DO REGISTRO', 542, NUMERICO, 3, OBRIGATORIO, PREENCHIMENTO)); 161 | $layout->adiciona(new Campo(2,'CNPJ(CGC) DO EMISSOR DA NOTA FISCAL', $cnpj_emissor_nf, NUMERICO, 14, OBRIGATORIO, PREENCHIMENTO)); 162 | $layout->adiciona(new Campo(3,'SERIE DA NOTA FISCAL', $serie_nf, ALFA, 3, OBRIGATORIO, PREENCHIMENTO)); 163 | $layout->adiciona(new Campo(4,'NUMERO DA NOTA FISCAL', $numero_nf, NUMERICO, 9, OBRIGATORIO, PREENCHIMENTO)); 164 | $layout->adiciona(new Campo(5,'CODIGO DE OCORRENCIA NA ENTREGA', $codigo_ocorrencia_entrega, NUMERICO, 3, OBRIGATORIO, PREENCHIMENTO)); 165 | $layout->adiciona(new Campo(6,'DATA DA OCORRENCIA', $data_ocorrencia, NUMERICO, 8, OBRIGATORIO, PREENCHIMENTO)); 166 | $layout->adiciona(new Campo(7,'HORA DA OCORRENCIA', $hora_ocorrencia, NUMERICO, 4, OBRIGATORIO, PREENCHIMENTO)); 167 | $layout->adiciona(new Campo(8,'CODIGO DE OBSERVACAO DE OCORRENCIA NA ENTRADA', $cod_observacao_ocorrencia_entrada, NUMERICO, 2, OBRIGATORIO, PREENCHIMENTO)); 168 | $layout->adiciona(new Campo(9,'NUMERO ROMANEIO, ORDEM DE COLETA, RESUMO DE CARGA, ETC(IDENTIFICACAO DE EMBARQUE)', $numero_romaneio_identf_embarque, ALFA, 20, OBRIGATORIO, PREENCHIMENTO)); 169 | $layout->adiciona(new Campo(10,'NUMERO SAP, SHIPMENT, ETC(IDENTIFICACAO DE CARGA) - #1', $identf_carga1, ALFA, 20, OBRIGATORIO, PREENCHIMENTO)); 170 | $layout->adiciona(new Campo(11,'NUMERO SAP, SHIPMENT, ETC(IDENTIFICACAO DE CARGA) - #2', $identf_carga2, ALFA, 20, OBRIGATORIO, PREENCHIMENTO)); 171 | $layout->adiciona(new Campo(12,'NUMERO SAP, SHIPMENT, ETC(IDENTIFICACAO DE CARGA) - #3', $identf_carga3, ALFA, 20, OBRIGATORIO, PREENCHIMENTO)); 172 | $layout->adiciona(new Campo(13,'FILIAL EMISSORA DO CONHECIMENTO', $filial_emissora_conhecimento, ALFA, 10, OBRIGATORIO, PREENCHIMENTO)); 173 | $layout->adiciona(new Campo(14,'SERIE DO CONHECIMENTO', $serie_conhecimento, ALFA, 5, OBRIGATORIO, PREENCHIMENTO)); 174 | $layout->adiciona(new Campo(15,'NUMERO DO CONHECIMENTO', $numero_conhecimento, ALFA, 12, OBRIGATORIO, PREENCHIMENTO)); 175 | $layout->adiciona(new Campo(16,'INDICACAO DO TIPO DE ENTREGA', $indicacao_tipo_entrega, ALFA, 1, OBRIGATORIO, PREENCHIMENTO)); 176 | $layout->adiciona(new Campo(17,'CODIGO DA EMPRESA EMISSORA DA NOTA FISCAL', $codigo_empresa_emissora_nf, ALFA, 5, OBRIGATORIO, PREENCHIMENTO)); 177 | $layout->adiciona(new Campo(18,'CODIGO DA FILIAL DA EMPRESA EMISSORA DA NF', $codigo_filial_empresa_emissora_nf, ALFA, 5, OBRIGATORIO, PREENCHIMENTO)); 178 | $layout->adiciona(new Campo(19,'DATA DA CHEGADA NO DESTINO DA NF', $data_chegada_nf, NUMERICO, 8, OBRIGATORIO, PREENCHIMENTO)); 179 | $layout->adiciona(new Campo(20,'HORA DA CHEGADA NO DESTINO DA NF', $hora_chegada_nf, NUMERICO, 4, OBRIGATORIO, PREENCHIMENTO)); 180 | $layout->adiciona(new Campo(21,'DATA DO INICIO DO DESCARREGAMENTO NO DESTINO', $data_inicio_descarregamento_destino, NUMERICO, 8, OBRIGATORIO, PREENCHIMENTO)); 181 | $layout->adiciona(new Campo(22,'HORA DO INICIO DO DESCARREGAMENTO NO DESTINO', $hora_inicio_descarregamento_destino, NUMERICO, 4, OBRIGATORIO, PREENCHIMENTO)); 182 | $layout->adiciona(new Campo(23,'DATA DO TERMINO DO DESCARREGAMENTO NO DESTINO', $data_termino_descarregamento_destino, NUMERICO, 8, OBRIGATORIO, PREENCHIMENTO)); 183 | $layout->adiciona(new Campo(24,'HORA DO TERMINO DO DESCARREGAMENTO NO DESTINO', $hora_termino_descarregamento_destino, NUMERICO, 4, OBRIGATORIO, PREENCHIMENTO)); 184 | $layout->adiciona(new Campo(25,'DATA DA SAIDA DO DESTINO DA NF', $data_saida_destino_nf, NUMERICO, 8, OBRIGATORIO, PREENCHIMENTO)); 185 | $layout->adiciona(new Campo(26,'HORA DA SAIDA DO DESTINO DA NF', $hora_saida_destino_nf, NUMERICO, 4, OBRIGATORIO, PREENCHIMENTO)); 186 | $layout->adiciona(new Campo(27,'CNPJ(CGC) DO EMISSOR DA NOTA FISCAL DEVOLUCAO', $cnpj_emissor_nf_devolucao, NUMERICO, 14, OBRIGATORIO, PREENCHIMENTO)); 187 | $layout->adiciona(new Campo(28,'SERIE DA NOTA FISCAL DEVOLUCAO', $serie_nf_devolucao, ALFA, 3, OBRIGATORIO, PREENCHIMENTO)); 188 | $layout->adiciona(new Campo(29,'NUMERO DA NOTA FISCAL DEVOLUCAO', $numero_nf_devolucao, NUMERICO, 9, OBRIGATORIO, PREENCHIMENTO)); 189 | $layout->adiciona(new Campo(30,'ESPAÇO', ' ', ALFA, 12, OBRIGATORIO, PREENCHIMENTO)); 190 | 191 | $linha = $layout->gera_linha(); 192 | // Verifica se tamanho gerado está conforme o tamanho esperado 193 | if ($tamanho != strlen($linha)) { 194 | throw new Exception("REGISTRO 542 NAO CONFERE TAMANHO DE {$tamanho}"); 195 | } 196 | 197 | // Conta linhas para conferencia final 198 | $this->conta_542++; 199 | 200 | // Verifica se tem mais de 9999 registro 542 201 | if ($this->conta_542 > 9999) { 202 | throw new Exception("REGISTRO 542 OCORRE MAIS DE 9999 VEZ"); 203 | } 204 | 205 | // Gera linha conforme o layout 206 | return $linha."\n"; 207 | } 208 | 209 | public function registro_543($texto_livre1, $texto_livre2, $texto_livre3, $tamanho) 210 | { 211 | // Zera contador de 544 - ocorre até 9999 para cada 542 212 | $this->conta_544 = 0; 213 | 214 | $layout = new Layout(); 215 | 216 | // CAMPO: ORDEM, DESCRIÇÃO, CONTEUDO, TIPO N/A, TAMANHO, OBRIGATORIO, PREENCHIMENTO 217 | $layout->adiciona(new Campo(1,'IDENTIFICADOR DO REGISTRO', 543, NUMERICO, 3, OBRIGATORIO, PREENCHIMENTO)); 218 | $layout->adiciona(new Campo(2,'TEXTO LIVRE - 1', $texto_livre1, ALFA, 70, OBRIGATORIO, PREENCHIMENTO)); 219 | $layout->adiciona(new Campo(3,'TEXTO LIVRE - 2', $texto_livre2, ALFA, 70, OBRIGATORIO, PREENCHIMENTO)); 220 | $layout->adiciona(new Campo(4,'TEXTO LIVRE - 3', $texto_livre3, ALFA, 70, OBRIGATORIO, PREENCHIMENTO)); 221 | $layout->adiciona(new Campo(5,'ESPAÇO', ' ', ALFA, 37, OBRIGATORIO, PREENCHIMENTO)); 222 | 223 | $linha = $layout->gera_linha(); 224 | // Verifica se tamanho gerado está conforme o tamanho esperado 225 | if ($tamanho != strlen($linha)) { 226 | throw new Exception("REGISTRO 543 NAO CONFERE TAMANHO DE {$tamanho}"); 227 | } 228 | 229 | // Conta linhas para conferencia final 230 | $this->conta_543++; 231 | 232 | // Verifica se tem mais de 1 registro 543 233 | if ($this->conta_543 > 1) { 234 | throw new Exception("REGISTRO 543 OCORRE MAIS DE 1 VEZ"); 235 | } 236 | 237 | // Gera linha conforme o layout 238 | return $linha."\n"; 239 | } 240 | 241 | public function registro_544($qntd_volumes_nf, $qntd_volumes_entregues, $cod_item_nf, $descricao_item_nf, $tamanho) 242 | { 243 | // Zera contador de 545 - ocorre até 9999 para cada 542 244 | $this->conta_545 = 0; 245 | 246 | $layout = new Layout(); 247 | 248 | // CAMPO: ORDEM, DESCRIÇÃO, CONTEUDO, TIPO N/A, TAMANHO, OBRIGATORIO, PREENCHIMENTO 249 | $layout->adiciona(new Campo(6,'IDENTIFICADOR DO REGISTRO', 544, NUMERICO, 3, OBRIGATORIO, PREENCHIMENTO)); 250 | $layout->adiciona(new Campo(7,'QUANTIDADE DE VOLUMES DA NOTA', $qntd_volumes_nf, NUMERICO, 6.2, OBRIGATORIO, PREENCHIMENTO)); 251 | $layout->adiciona(new Campo(8,'QUANTIDADE DE VOLUMES ENTREGUES', $qntd_volumes_entregues, NUMERICO, 6.2, OBRIGATORIO, PREENCHIMENTO)); 252 | $layout->adiciona(new Campo(9,'CODIGO DO ITEM DA NOTA FISCAL', $cod_item_nf, ALFA, 20, OBRIGATORIO, PREENCHIMENTO)); 253 | $layout->adiciona(new Campo(10,'DESCRICAO DO ITEM DA NOTA FISCAL', $descricao_item_nf, ALFA, 50, OBRIGATORIO, PREENCHIMENTO)); 254 | $layout->adiciona(new Campo(11,'ESPAÇO', ' ', ALFA, 161, OBRIGATORIO, PREENCHIMENTO)); 255 | 256 | $linha = $layout->gera_linha(); 257 | // Verifica se tamanho gerado está conforme o tamanho esperado 258 | if ($tamanho != strlen($linha)) { 259 | throw new Exception("REGISTRO 544 NAO CONFERE TAMANHO DE {$tamanho}"); 260 | } 261 | 262 | // Conta linhas para conferencia final 263 | $this->conta_544++; 264 | 265 | // Verifica se tem mais de 1 registro 544 266 | if ($this->conta_544 > 9999) { 267 | throw new Exception("REGISTRO 544 OCORRE MAIS DE 9999 VEZES"); 268 | } 269 | 270 | // Gera linha conforme o layout 271 | return $linha."\n"; 272 | } 273 | 274 | public function registro_545($cnpj_empresa_frete, $cnpj_empresa_emissora_ocorrencia, $filial_emissor_ocorrencia, $serie_conhecimento_ocorrencia, $numero_conhecimento_ocorrencia , $tamanho) 275 | { 276 | // Zera contador de 549 - ocorre até 1 para cada 540 277 | $this->conta_549 = 0; 278 | 279 | $layout = new Layout(); 280 | 281 | // CAMPO: ORDEM, DESCRIÇÃO, CONTEUDO, TIPO N/A, TAMANHO, OBRIGATORIO, PREENCHIMENTO 282 | $layout->adiciona(new Campo(1,'IDENTIFICADOR DO REGISTRO', 545, NUMERICO, 3, OBRIGATORIO, PREENCHIMENTO)); 283 | $layout->adiciona(new Campo(2,'CNPJ DA EMPRESA CONTRATANTE DO FRETE', $cnpj_empresa_frete, NUMERICO, 14, OBRIGATORIO, PREENCHIMENTO)); 284 | $layout->adiciona(new Campo(3,'CNPJ DA EMPRESA EMISSORA DO CONHECIMENTO ORIGINADOR DA OCORRENCIA', $cnpj_empresa_emissora_ocorrencia, NUMERICO, 14, OBRIGATORIO, PREENCHIMENTO)); 285 | $layout->adiciona(new Campo(4,'FILIAL EMISSOR DO CTRC ORIGINADOR DA OCORRENCIA', $filial_emissor_ocorrencia, ALFA, 10, OBRIGATORIO, PREENCHIMENTO)); 286 | $layout->adiciona(new Campo(5,'SERIE DO CONHECIMENTO ORIGINADOR DA OCORRENCIA', $serie_conhecimento_ocorrencia, ALFA, 5, OBRIGATORIO, PREENCHIMENTO)); 287 | $layout->adiciona(new Campo(6,'NUMERO DO CONHECIMENTO ORIGINADOR DA OCORRENCIA', $numero_conhecimento_ocorrencia, ALFA, 12, OBRIGATORIO, PREENCHIMENTO)); 288 | $layout->adiciona(new Campo(7,'ESPAÇO', ' ', ALFA, 192, OBRIGATORIO, PREENCHIMENTO)); 289 | 290 | $linha = $layout->gera_linha(); 291 | // Verifica se tamanho gerado está conforme o tamanho esperado 292 | if ($tamanho != strlen($linha)) { 293 | throw new Exception("REGISTRO 545 NAO CONFERE TAMANHO DE {$tamanho}"); 294 | } 295 | 296 | // Conta linhas para conferencia final 297 | $this->conta_545++; 298 | 299 | // Verifica se tem mais de 1 registro 545 300 | if ($this->conta_545 > 1) { 301 | throw new Exception("REGISTRO 545 OCORRE MAIS DE 1 VEZ"); 302 | } 303 | 304 | // Gera linha conforme o layout 305 | return $linha."\n"; 306 | } 307 | 308 | public function registro_549($numero_ocorrencias, $tamanho) 309 | { 310 | 311 | $layout = new Layout(); 312 | 313 | // CAMPO: ORDEM, DESCRIÇÃO, CONTEUDO, TIPO N/A, TAMANHO, OBRIGATORIO, PREENCHIMENTO 314 | $layout->adiciona(new Campo(1,'IDENTIFICADOR DO REGISTRO', 549, NUMERICO, 3, OBRIGATORIO, PREENCHIMENTO)); 315 | $layout->adiciona(new Campo(2,'NUMERO DE REGISTRO DE OCORRENCIA', $numero_ocorrencias, NUMERICO, 4, OBRIGATORIO, PREENCHIMENTO)); 316 | $layout->adiciona(new Campo(3,'ESPAÇO', ' ', ALFA, 243, OBRIGATORIO, PREENCHIMENTO)); 317 | 318 | $linha = $layout->gera_linha(); 319 | // Verifica se tamanho gerado está conforme o tamanho esperado 320 | if ($tamanho != strlen($linha)) { 321 | throw new Exception("REGISTRO 549 NAO CONFERE TAMANHO DE {$tamanho}"); 322 | } 323 | 324 | // Conta linhas para conferencia final 325 | $this->conta_549++; 326 | 327 | // Verifica se tem mais de 1 registro 549 328 | if ($this->conta_549 > 1) { 329 | throw new Exception("REGISTRO 549 OCORRE MAIS DE 1 VEZ"); 330 | } 331 | 332 | // Gera linha conforme o layout 333 | return $linha."\n"; 334 | } 335 | 336 | 337 | } -------------------------------------------------------------------------------- /app/Procter/Clientes.php: -------------------------------------------------------------------------------- 1 | | 10 | * | | 11 | * | Programa...: Clientes.php | 12 | * | | 13 | * | Autor......: Helder | 14 | * | | 15 | * | Criação....: 26-06-2018 | 16 | * | | 17 | * | Objetivo...: Formatar registros conforme Layout PROCTER/Clientes | 18 | * | | 19 | * | Layout EDI.: | 20 | * | | 21 | * +-----------------------------------------------------------------------+ 22 | * | Versões....: | 23 | * | | 24 | * | | 25 | * | | 26 | * +-----------------------------------------------------------------------+ 27 | */ 28 | 29 | namespace App\Procter; 30 | 31 | use App\Layout; 32 | use App\Campo; 33 | 34 | class Clientes 35 | { 36 | public $conta_clientes; 37 | 38 | public function registro_clientes($sap_mae, $sap_filial, $cgc_cpf, $razao, $ramo, $endereco, $bairro, $cidade, $estado, $cep, $telefone, $setor, $numero) 39 | { 40 | $conta_clientes = 0; 41 | 42 | $layout = new Layout(); 43 | 44 | if (strlen($cgc_cpf) == 11) { 45 | $cgc_cpf = "CPF".$cgc_cpf; 46 | } 47 | // CAMPO: ORDEM, DESCRIÇÃO, CONTEUDO, TIPO N/A, TAMANHO, OBRIGATORIO 48 | $layout->adiciona(new Campo(1, 'COD SAP MAE', $sap_mae, ALFA, 15, OBRIGATORIO)); 49 | $layout->adiciona(new Campo(2, 'COD SAP FILIAL', $sap_filial, ALFA, 15, OBRIGATORIO)); 50 | $layout->adiciona(new Campo(3, 'CGC/CPF', $cgc_cpf, ALFA, 14, OBRIGATORIO)); 51 | $layout->adiciona(new Campo(4, 'RAZAO SOCIAL', $razao, ALFA, 50, OBRIGATORIO)); 52 | $layout->adiciona(new Campo(5, 'RAMO', $ramo, ALFA, 50, OBRIGATORIO)); 53 | $layout->adiciona(new Campo(6, 'ENDERECO', $endereco, ALFA, 50, OBRIGATORIO)); 54 | $layout->adiciona(new Campo(7, 'BAIRRO', $bairro, ALFA, 50, OBRIGATORIO)); 55 | $layout->adiciona(new Campo(8, 'CIDADE', $cidade, ALFA, 50, OBRIGATORIO)); 56 | $layout->adiciona(new Campo(9, 'ESTADO', $estado, ALFA, 2, OBRIGATORIO)); 57 | $layout->adiciona(new Campo(10, 'CEP', $cep, ALFA, 10, OPCIONAL)); 58 | $layout->adiciona(new Campo(11, 'TELEFONE', $telefone, ALFA, 20, OPCIONAL)); 59 | $layout->adiciona(new Campo(12, 'SETOR', $setor, ALFA, 10, OBRIGATORIO)); 60 | $layout->adiciona(new Campo(13, 'NUMERO', $numero, ALFA, 2, OBRIGATORIO)); 61 | 62 | $conta_clientes++; 63 | 64 | $linha = $layout->gera_linha(); 65 | // Gera linha conforme o layout 66 | return $linha; 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /app/Procter/Inventarios.php: -------------------------------------------------------------------------------- 1 | | 10 | * | | 11 | * | Programa...: Inventarios.php | 12 | * | | 13 | * | Autor......: Helder | 14 | * | | 15 | * | Criação....: 26-06-2018 | 16 | * | | 17 | * | Objetivo...: Formatar registros conforme Layout PROCTER/inventarios | 18 | * | | 19 | * | Layout EDI.: | 20 | * | | 21 | * +-----------------------------------------------------------------------+ 22 | * | Versões....: | 23 | * | | 24 | * | | 25 | * | | 26 | * +-----------------------------------------------------------------------+ 27 | */ 28 | 29 | namespace App\Procter; 30 | 31 | use App\Layout; 32 | use App\Campo; 33 | 34 | class Inventarios 35 | { 36 | public $conta_inventario; 37 | public function registro_inventarios($sap_mae, $sap_filial, $dun_produto, $qntd_fisica, $qntd_transito, $data_leitura) 38 | { 39 | $inventario = 0; 40 | $layout = new Layout(); 41 | 42 | // CAMPO: ORDEM, DESCRIÇÃO, CONTEUDO, TIPO N/A, TAMANHO, OBRIGATORIO 43 | $layout->adiciona(new Campo(1, 'COD SAP MAE', $sap_mae, ALFA, 15, OBRIGATORIO)); 44 | $layout->adiciona(new Campo(2, 'COD SAP FILIAL', $sap_filial, ALFA, 15, OBRIGATORIO)); 45 | $layout->adiciona(new Campo(3, 'DUN DO PROTUDO', $dun_produto, ALFA, 14, OBRIGATORIO)); 46 | $layout->adiciona(new Campo(4, 'QUANTIDADE FISICA', $qntd_fisica, ALFA, 10.3, OBRIGATORIO)); 47 | $layout->adiciona(new Campo(5, 'QUANTIDADE EM TRANSIO', $qntd_transito, ALFA, 10.3, OBRIGATORIO)); 48 | $layout->adiciona(new Campo(6, 'DATA DA LEITURA', $data_leitura, ALFA, 10, OBRIGATORIO)); 49 | 50 | $inventario++; 51 | 52 | $linha = $layout->gera_linha(); 53 | 54 | // Gera linha conforme o layout 55 | return $linha; 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /app/Procter/Produtividades.php: -------------------------------------------------------------------------------- 1 | | 10 | * | | 11 | * | Programa...: Produtividades.php | 12 | * | | 13 | * | Autor......: Helder | 14 | * | | 15 | * | Criação....: 26-06-2018 | 16 | * | | 17 | * | Objetivo...: Formatar registros conforme Layout PROCTER/Produtividades| 18 | * | | 19 | * | Layout EDI.: | 20 | * | | 21 | * +-----------------------------------------------------------------------+ 22 | * | Versões....: | 23 | * | | 24 | * | | 25 | * | | 26 | * +-----------------------------------------------------------------------+ 27 | */ 28 | 29 | namespace App\Procter; 30 | 31 | use App\Layout; 32 | use App\Campo; 33 | 34 | class Produtividades 35 | { 36 | public $conta_produtividade; 37 | 38 | public function registro_produtividade($sap_mae, $sap_filial, $data_visitas, $cod_vendedor, $visitas_dia, $visitas_com_vendas) 39 | { 40 | $conta_produtividade = 0; 41 | 42 | $layout = new Layout(); 43 | 44 | // CAMPO: ORDEM, DESCRIÇÃO, CONTEUDO, TIPO N/A, TAMANHO, OBRIGATORIO 45 | $layout->adiciona(new Campo(1, 'COD SAP MAE', $sap_mae, ALFA, 15, OBRIGATORIO)); 46 | $layout->adiciona(new Campo(2, 'COD SAP FILIAL', $sap_filial, ALFA, 15, OBRIGATORIO)); 47 | $layout->adiciona(new Campo(3, 'DATA DAS VISITAS', $data_visitas, ALFA, 10, OBRIGATORIO)); 48 | $layout->adiciona(new Campo(4, 'SETOR/CODIGO DO VENDEDOR', $cod_vendedor, ALFA, 10, OBRIGATORIO)); 49 | $layout->adiciona(new Campo(5, 'VISITAS NO DIA', $visitas_dia, ALFA, 14, OBRIGATORIO)); 50 | $layout->adiciona(new Campo(6, 'VISITAS COM VENDAS', $visitas_com_vendas, ALFA, 10, OBRIGATORIO)); 51 | 52 | $conta_produtividade++; 53 | 54 | $linha = $layout->gera_linha(); 55 | 56 | // Gera linha conforme o layout 57 | return $linha; 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /app/Procter/Vendas.php: -------------------------------------------------------------------------------- 1 | | 10 | * | | 11 | * | Programa...: Vendas.php | 12 | * | | 13 | * | Autor......: Helder | 14 | * | | 15 | * | Criação....: 26-06-2018 | 16 | * | | 17 | * | Objetivo...: Formatar registros conforme Layout PROCTER/Vendas | 18 | * | | 19 | * | Layout EDI.: | 20 | * | | 21 | * +-----------------------------------------------------------------------+ 22 | * | Versões....: | 23 | * | | 24 | * | | 25 | * | | 26 | * +-----------------------------------------------------------------------+ 27 | */ 28 | 29 | namespace App\Procter; 30 | 31 | use App\Layout; 32 | use App\Campo; 33 | 34 | class Vendas 35 | { 36 | public $conta_vendas; 37 | 38 | public function registro_vendas($sap_mae, $sap_filial, $numero_nf, $tipo_transacao, $data_doc, $cgc_cpf, $cod_vendedor, $dun_protudo, $qntd_vendida, $vlr_faturado) 39 | { 40 | $conta_vendas = 0; 41 | 42 | $layout = new Layout(); 43 | 44 | if (strlen($cgc_cpf) == 11) { 45 | $cgc_cpf = "CPF".$cgc_cpf; 46 | } 47 | 48 | // CAMPO: ORDEM, DESCRIÇÃO, CONTEUDO, TIPO N/A, TAMANHO, OBRIGATORIO 49 | $layout->adiciona(new Campo(1, 'COD SAP MAE', $sap_mae, ALFA, 15, OBRIGATORIO)); 50 | $layout->adiciona(new Campo(2, 'COD SAP FILIAL', $sap_filial, ALFA, 15, OBRIGATORIO)); 51 | $layout->adiciona(new Campo(3, 'NUMERO DO DOCUMENTO', $numero_nf, ALFA, 10, OBRIGATORIO)); 52 | $layout->adiciona(new Campo(4, 'TIPO DE TRANSAÇÃO', $tipo_transacao, ALFA, 3, OBRIGATORIO)); 53 | $layout->adiciona(new Campo(5, 'DATA DO DOCUMENTO', $data_doc, ALFA, 10, OBRIGATORIO)); 54 | $layout->adiciona(new Campo(6, 'CGC/CPF', $cgc_cpf, ALFA, 14, OBRIGATORIO)); 55 | $layout->adiciona(new Campo(7, 'SETOR/CODIGO DO VENDEDOR', $cod_vendedor, ALFA, 10, OBRIGATORIO)); 56 | $layout->adiciona(new Campo(8, 'DUN DO PRODUTO', $dun_protudo, ALFA, 14, OBRIGATORIO)); 57 | $layout->adiciona(new Campo(9, 'QUANTIDADE VENDIDA', $qntd_vendida, ALFA, 10, OBRIGATORIO)); 58 | $layout->adiciona(new Campo(10, 'VALOR FATURADO', $vlr_faturado, ALFA, 8.2, OBRIGATORIO)); 59 | 60 | $conta_vendas++; 61 | 62 | $linha = $layout->gera_linha(); 63 | 64 | // Gera linha conforme o layout 65 | return $linha; 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /app/Procter/Vendedores.php: -------------------------------------------------------------------------------- 1 | | 10 | * | | 11 | * | Programa...: Vendedores.php | 12 | * | | 13 | * | Autor......: Helder | 14 | * | | 15 | * | Criação....: 26-06-2018 | 16 | * | | 17 | * | Objetivo...: Formatar registros conforme Layout PROCTER/Vendedores | 18 | * | | 19 | * | Layout EDI.: | 20 | * | | 21 | * +-----------------------------------------------------------------------+ 22 | * | Versões....: | 23 | * | | 24 | * | | 25 | * | | 26 | * +-----------------------------------------------------------------------+ 27 | */ 28 | 29 | namespace App\Procter; 30 | 31 | use App\Layout; 32 | use App\Campo; 33 | 34 | class Vendedores 35 | { 36 | public $conta_vendedores; 37 | 38 | public function registro_vendedores($sap_mae, $sap_filial, $cod_vendedor, $nome_vendedor, $cod_supervisor, $nome_supervisor) 39 | { 40 | $conta_vendedores = 0; 41 | 42 | $layout = new Layout(); 43 | 44 | // CAMPO: ORDEM, DESCRIÇÃO, CONTEUDO, TIPO N/A, TAMANHO, OBRIGATORIO 45 | $layout->adiciona(new Campo(1, 'COD SAP MAE', $sap_mae, ALFA, 15, OBRIGATORIO)); 46 | $layout->adiciona(new Campo(2, 'COD SAP FILIAL', $sap_filial, ALFA, 15, OBRIGATORIO)); 47 | $layout->adiciona(new Campo(3, 'SETOR/CODIGO DO VENDEDOR', $cod_vendedor, ALFA, 10, OBRIGATORIO)); 48 | $layout->adiciona(new Campo(4, 'NOME DO VENDEDOR', $nome_vendedor, ALFA, 50, OBRIGATORIO)); 49 | $layout->adiciona(new Campo(5, 'CODIGO DO SUPERVISOR', $cod_supervisor, ALFA, 10, OBRIGATORIO)); 50 | $layout->adiciona(new Campo(6, 'NOME DO SUPERVISOR', $nome_supervisor, ALFA, 50, OBRIGATORIO)); 51 | 52 | $conta_vendedores++; 53 | 54 | $linha = $layout->gera_linha(); 55 | 56 | // Gera linha conforme o layout 57 | return $linha; 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /arquivos/.directory: -------------------------------------------------------------------------------- 1 | [Dolphin] 2 | SortOrder=1 3 | SortRole=modificationtime 4 | Timestamp=2018,9,23,10,25,28 5 | Version=4 6 | ViewMode=1 7 | -------------------------------------------------------------------------------- /arquivos/BLZ_STOR_NC_10908082005.txt: -------------------------------------------------------------------------------- 1 | 2001050255;2930298340;CPF07610028327;TRANSPORTADORA BCA;ATACADO ALIMENTAR;RUA ABC, 123;ABCDEF;FEDCBA;MG;19107-322;35 9986423591;123;12; -------------------------------------------------------------------------------- /arquivos/BZL_FACTSINV_NC_10908092005.txt: -------------------------------------------------------------------------------- 1 | 2001050255;2930298340;17501001274891;999999.999;999999.999;09/13/2018; -------------------------------------------------------------------------------- /arquivos/BZL_FACT_NC_10908092005.txt: -------------------------------------------------------------------------------- 1 | 2001050255;2930298340;1234567890;FAC;13/09/2018;CPF98564483594;1234567890;1549678SD546;1000000000;540.00; -------------------------------------------------------------------------------- /arquivos/BZL_PROD_NC_10908092005.txt: -------------------------------------------------------------------------------- 1 | 2001050255;2930298340;13/09/2018;123;10;6; -------------------------------------------------------------------------------- /arquivos/BZL_SREP_NC_10908092005.txt: -------------------------------------------------------------------------------- 1 | 2001050255;2930298340;1234567890;ABCDE DE FG HIJK;0987654321;KJIH GF ED EDCBA; -------------------------------------------------------------------------------- /arquivos/ESTOQUE_00000000_20150701.txt: -------------------------------------------------------------------------------- 1 | H42021016 2 | D420210167896007540600 203147 ABS INTERNO INTIMUS SUPER C/8 000000027170,830000000000000,00000000000000,0000000027170,83 -------------------------------------------------------------------------------- /arquivos/KC.txt: -------------------------------------------------------------------------------- 1 | H42021016 2 | D420210167896007540600 203147 ABS INTERNO INTIMUS SUPER C/8 000000027170,83000000000000000000000000000000000000027170,83 -------------------------------------------------------------------------------- /arquivos/SELLOUT_CodigoFIA_AAAAMMDD.txt: -------------------------------------------------------------------------------- 1 | H420210162018/09/26 2 | D420219311609 1619 SUPERMERCADOS VARANDAS LTDA 49949472000184 49949472000184 AVENIDA SENADOR PINHEIRO MACHADO, 643 11075003SP CAMPO GRANDE SANTOS 32396380 BR JOSE INALDO 163 LG003 R.A. JOSEFA ANGELICA DE SOUZA NASCIMENTO 10692 7896007540662 000120000000000471000000000003,9300BRL2017/06/152017/06/15F513652 UN 000000000000001000000000000001UN 0000000000000010000000000000012017/06/152017/06/16 2617189783335170620002548000188550010005136521984613761 -------------------------------------------------------------------------------- /arquivos/conemb.txt: -------------------------------------------------------------------------------- 1 | 00012345 54321 1007180714CON50DDMMSSS 2 | 520CON50DDMMSSS 3 | 52112123123000112TRANSPORTADORA 4 | 522ABCDEF ABCDEABCDEF 11223333C12123123000112121231230001211212312300011212123123000112121231230001129999 MGABC123 ABCDEF123456 ABCDEF123456 ABCDEF123456 ABCDEF123456 ABCDEF 123456789ABCDE 1123581321 123456789ABCDEF ABCDEABCDEF BR08 C1ISABCDEF SMGMGMG 5 | 5230006,2000006,30000006,400000006,4000000000000013,20000000000013,20000000000013,20000000000013,20000000000013,20000000000013,20000000000013,20000000000013,20000000000013,20000000000013,20000000000013,200A00000000013,2000010000000000013,200100000000013,2003,20000000000013,20000000000013,2003,20000000000013,20000000000013,200Z23ICM1 6 | 524121231230001121234567891231122333300000000013,2000006,2000006,30000006,400000006,40000ABCDEF123456 123456789 123456789 123456789 123456789 S1S1234MGABCDEF 7 | 52512123123000112TRANSPORTADORA1 12312345678912123123000112TRANSPORTADORA2 12312345678912123123000112TRANSPORTADORA3 123123456789ABCDEF ABC 123456789 12123123000112 8 | 524TRANSPORTADORA 12123123000112ABCDEF123456 RUA ABC, 123 ABCDEF ABCDEFGH 122233344222222222MG 11922222222 9 | 529099900000000013,200 10 | -------------------------------------------------------------------------------- /arquivos/doccob.txt: -------------------------------------------------------------------------------- 1 | 00012345 54321 1007180714COB502906001 2 | 550COBRA501007001 3 | 55112123123000112TRANSPORTADORA ACME 4 | 55212345678900001000012345610072018311220180000000031,2300BCO0200000000000000100311220180000000003,120000237BRADESCO 0514300006706648 I000000201818 320180985711223897234597834598723498571122018 311465245624360 5 | 5530000000013,1200123000000000013,12000000000013,1200123000000000013,12000000000013,1200123000000000013,12000000000013,1200 6 | 5551234567890001 123456 0000000031,230010072018000000000123450000000005432100011122233344MGMGMG422619 Z2548946248636 65559444684684 4446416387998 22244874963418 N 7 | 55632111223344511223344123451200000001112223300111222333444CARGA1 CARGA1 11223344AAABBBCCC AAABBBCCCDDD11223344S 8 | 55911111234567890,1200 9 | -------------------------------------------------------------------------------- /arquivos/notfis.txt: -------------------------------------------------------------------------------- 1 | 00012345 54321 1007180714NOT50DDMMSSS 2 | 500COBRA501007001 3 | 501COBRA501007001 12123123000112---------------------------------------------RUA ABC, 123 CBA ABCDE ABCDE EDCBA MG 28082018111155555555555 4 | 502TRANSPORTADORA ACME 12123123000112RUA ABC, 123 CBA ABCDE ABCDE EDCBA MG 55555555555 111 5 | 503TRANSPORTADORA ACME 12123123000112------------------------------RUA ABC, 123 CBA ABCDE ABCDE EDCBA MG 5555555555 1234111 1C 6 | 5041234567890 12123123000112---------------RUA ABC, 123 CBA ABCDE ABCDE EDCBA MG 5555555555 1234111 2C 7 | 505ABC12345678928082018ABCDE ABCDE ABCDE 112C28082018ABCD1234 S1S1234MGSABCD1234 01111222333444555 1122233344555 ABCD1234 ABCD1234 ABCD1234 42808201816002808201816010112233441554466879 ABCD1234 I 8 | 506123,1200123,13000123,130000006,400000006,40000SS00000000013,20000000000013,20000000000013,20000000000013,20000000000013,20000000000013,20000000000013,20000000000013,20000000000013,20000000000013,20000000000013,20000000000013,20000000000013,20000000000013,20000000000013,200000000013,200000000013,200000000013,200 9 | 5070006,2000006,30000006,400000006,4000000000000013,20000000000013,20000000000013,20000000000013,20000000000013,20000000000013,20000000000013,20000000000013,20000000000013,20000000000013,20000000000013,2003,20000000000013,200200000000013,2003,20000000000013,20000000000013,2003,20000000000013,20000000000013,200ABCABCDMG 10 | 508Marcasmarcas 1523 1546 11 | 50912123123000111ABCD 12311111111112123123000112BACD 12322222222212123123000113CABD 123333333333ABCD 123AB1123581321 12123123000112 12 | 51100055500FARDOS 5556664 NOME 12560000000000000001236400123548MARCAMARCAS 5556 15 5449 13 | 513RAZAO 12123123000112---------------RUA ABC ABCD CBA 123456789123456789MG 553333333 14 | 514RAZAO 12123123000112---------------RUA ABC ABCD CBA 123456789123456789MG 55112345678 DOCA 15 | 515RAZAO 12123123000112---------------RUA ABC ABCD CBA 123456789123456789MG 112333333333 16 | 5190000123456789000000123456789000000123456789000000012355 17 | -------------------------------------------------------------------------------- /arquivos/ocoren.txt: -------------------------------------------------------------------------------- 1 | 00012345 54321 1007180714OCO50DDMM999 2 | 540OCORR50DDMM999 3 | 54112123123000112TRANSPORTADORA ACME 4 | 5420121231230011212312345678912331082018160001555566644SDA 1223334444 1223334444 1223334444 ABCDE 123AB123ABCDE 1123ABABCDE31082018160031082018160031082018160131082018160212123123000112123123456789 5 | 543ABCDEFGHIJKLM ABCDEFGHIJKLM ABCDEFGHIJKLM 6 | 5440006,2000006,200ABCDE ABCDE 7 | 5450121231230011112123123000113ABCDE ABCDEABCDE 8 | 5491234 9 | -------------------------------------------------------------------------------- /composer.json: -------------------------------------------------------------------------------- 1 | 2 | { 3 | "name": "php-edi", 4 | "description": "Gerar EDI para vários fornecedores", 5 | "authors": [ 6 | { 7 | "name": "Helder", 8 | "email": "helder.afonso.de.morais@gmail.com" 9 | }, 10 | { 11 | "name": "Sidnei", 12 | "email": "sidnei@gmail.com" 13 | } 14 | ], 15 | "require": { 16 | "php": ">=7" 17 | }, 18 | "autoload": { 19 | "psr-4": { 20 | "App\\" : "app/" 21 | } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /composer.lock: -------------------------------------------------------------------------------- 1 | { 2 | "_readme": [ 3 | "This file locks the dependencies of your project to a known state", 4 | "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", 5 | "This file is @generated automatically" 6 | ], 7 | "content-hash": "c56598ff3058aabe052b01c47c7370fb", 8 | "packages": [], 9 | "packages-dev": [], 10 | "aliases": [], 11 | "minimum-stability": "stable", 12 | "stability-flags": [], 13 | "prefer-stable": false, 14 | "prefer-lowest": false, 15 | "platform": { 16 | "php": ">=7" 17 | }, 18 | "platform-dev": [] 19 | } 20 | -------------------------------------------------------------------------------- /dados/KimberlyClark.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 42021016 4 | 7896007540600 5 | 203147 6 | ABS INTERNO INTIMUS SUPER C/8 7 | 27170,83 8 | 0,0 9 | 0,0 10 | 27170,83 11 | 12 | 2018/09/26 13 | 42021931 14 | 1609 15 | 1619 16 | SUPERMERCADOS VARANDAS LTDA 17 | 49949472000184 18 | 49949472000184 19 | AVENIDA SENADOR PINHEIRO MACHADO, 643 20 | 11075003 21 | SP 22 | CAMPO GRANDE 23 | SANTOS 24 | 32396380 25 | BR 26 | JOSE INALDO 27 | 163 28 | 29 | LG003 30 | R.A. JOSEFA ANGELICA DE SOUZA NASCIMENTO 31 | 10692 32 | 7896007540662 33 | 34 | 12 35 | 471 36 | 3,93 37 | BRL 38 | 2017/06/15 39 | 2017/06/15 40 | F 41 | 513652 42 | UN 43 | 000000000000001 44 | 1 45 | UN 46 | 000000000000001 47 | 000000000000001 48 | 2017/06/15 49 | 2017/06/16 50 | 51 | 26171897833 52 | 35170620002548000188550010005136521984613761 53 | 54 | 55 | -------------------------------------------------------------------------------- /dados/Pernod.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | H 4 | VENDA11 5 | 00000000000000 6 | 7 | D 8 | 00000000000000 9 | 000000000000000000 10 | AAAAMMDD 11 | 00000000000000000000 12 | 12457832659825 13 | 25.33 14 | 15.28 15 | 50 16 | lkjkljljkl 17 | A 18 | 37880000 19 | 1245788956235 20 | AAAAMM 21 | DD 22 | P 23 | 4.25 24 | 4444 25 | 26 | 27 | H 28 | Estoq11 29 | 00000000000000 30 | AAAAMMDD 31 | 32 | 39 | 40 | 41 | 42 | 43 | -------------------------------------------------------------------------------- /dados/conemb.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 12345 4 | 54321 5 | 100718 6 | 0714 7 | CON50DDMMSSS 8 | 9 | 10 | CON50DDMMSSS 11 | 12 | 12123123000112 13 | TRANSPORTADORA 14 | 15 | 16 | ABCDEF 17 | ABCDE 18 | ABCDEF 19 | 11223333 20 | C 21 | 12123123000112 22 | 12123123000121 23 | 12123123000112 24 | 12123123000112 25 | 12123123000112 26 | 9999 27 | MGABC123 28 | ABCDEF123456 29 | ABCDEF123456 30 | ABCDEF123456 31 | ABCDEF123456 32 | ABCDEF 33 | 123456789ABCDE 34 | 1123581321 35 | 123456789 36 | ABCDEF 37 | ABCDE 38 | ABCDEF 39 | BR08 40 | C 41 | 1 42 | I 43 | S 44 | ABCDEF 45 | S 46 | MG 47 | MG 48 | MG 49 | 50 | 51 | 6,2 52 | 6,3 53 | 6,4 54 | 6,4 55 | 13,2 56 | 13,2 57 | 13,2 58 | 13,2 59 | 13,2 60 | 13,2 61 | 13,2 62 | 13,2 63 | 13,2 64 | 13,2 65 | 13,2 66 | A 67 | 13,2 68 | 1 69 | 13,2 70 | 1 71 | 13,2 72 | 3,2 73 | 13,2 74 | 13,2 75 | 3,2 76 | 13,2 77 | 13,2 78 | Z23 79 | ICM1 80 | 81 | 82 | 12123123000112 83 | 123456789 84 | 123 85 | 11223333 86 | 13,2 87 | 6,2 88 | 6,3 89 | 6,4 90 | 6,4 91 | ABCDEF123456 92 | 123456789 93 | 123456789 94 | 123456789 95 | 123456789 96 | S 97 | 1 98 | S 99 | 1234 100 | MG 101 | ABCDEF 102 | 103 | 104 | 12123123000112 105 | TRANSPORTADORA1 106 | 123 107 | 123456789 108 | 12123123000112 109 | TRANSPORTADORA2 110 | 123 111 | 123456789 112 | 12123123000112 113 | TRANSPORTADORA3 114 | 123 115 | 123456789 116 | ABCDEF 117 | ABC 118 | 123456789 119 | 12123123000112 120 | 121 | 122 | TRANSPORTADORA 123 | 12123123000112 124 | ABCDEF123456 125 | RUA ABC, 123 126 | ABCDEF 127 | ABCDEFGH 128 | 122233344 129 | 222222222 130 | MG 131 | 11922222222 132 | 133 | 134 | 999 135 | 13,2 136 | 137 | 138 | 139 | -------------------------------------------------------------------------------- /dados/doccob.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 12345 4 | 54321 5 | 100718 6 | 0714 7 | COBRA501007001 8 | 9 | 10 | COBRA501007001 11 | 12123123000112 12 | TRANSPORTADORA ACME 13 | 14 | 1234567890 15 | 0 16 | 001 17 | 123456 18 | 10072018 19 | 31122018 20 | 31,23 21 | BCO 22 | 2 23 | 1 24 | 31122018 25 | 3,12 26 | 237 27 | BRADESCO 28 | 0514 29 | 3 30 | 670664 31 | 8 32 | I 33 | 2018 34 | 18 35 | 32018 36 | 98571122 37 | 3897234597834598723498571122018 38 | 311465245624360 39 | 40 | 13,12 41 | 123 42 | 13,12 43 | 13,12 44 | 123 45 | 13,12 46 | 13,12 47 | 123 48 | 13,12 49 | 13,12 50 | 51 | 52 | 321 53 | 112233445 54 | 11223344 55 | 12345.12 56 | 111222.33 57 | 111222333444 58 | CARGA1 59 | CARGA1 60 | 11223344AAABBBCCC 61 | AAABBBCCCDDD11223344 62 | S 63 | 64 | 65 | 66 | 1234567890 67 | 001 68 | 123456 69 | 31,23 70 | 10072018 71 | 12345 72 | 54321 73 | 11122233344 74 | MG 75 | MG 76 | MG 77 | 422619 78 | Z2 79 | 548946248636 80 | 65559444684684 81 | 4446416387998 82 | 22244874963418 83 | N 84 | 85 | 86 | 1111 87 | 1234567890,12 88 | 89 | 90 | 91 | -------------------------------------------------------------------------------- /dados/notfis.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 12345 4 | 54321 5 | 100718 6 | 0714 7 | NOT501007001 8 | 9 | 10 | COBRA501007001 11 | 12123123000112 12 | TRANSPORTADORA ACME 13 | --------------- 14 | --------------- 15 | --------------- 16 | RUA ABC, 123 17 | CBA 18 | ABCDE 19 | ABCDE 20 | EDCBA 21 | MG 22 | 28082018 23 | 1111 24 | 55555555555 25 | 26 | TRANSPORTADORA ACME 27 | 12123123000112 28 | RUA ABC, 123 29 | CBA 30 | ABCDE 31 | ABCDE 32 | EDCBA 33 | MG 34 | 55555555555 35 | 111 36 | 37 | 38 | TRANSPORTADORA ACME 39 | 12123123000112 40 | --------------- 41 | --------------- 42 | RUA ABC, 123 43 | CBA 44 | ABCDE 45 | ABCDE 46 | EDCBA 47 | MG 48 | 5555555555 49 | 1234 50 | 111 51 | 1 52 | C 53 | 54 | 55 | 1234567890 56 | 12123123000112 57 | --------------- 58 | RUA ABC, 123 59 | CBA 60 | ABCDE 61 | ABCDE 62 | EDCBA 63 | MG 64 | 5555555555 65 | 1234 66 | 111 67 | 2 68 | C 69 | 70 | 71 | ABC 72 | 123456789 73 | 28082018 74 | ABCDE 75 | ABCDE 76 | ABCDE 77 | 1 78 | 1 79 | 2 80 | C 81 | 28082018 82 | ABCD1234 83 | S 84 | 1 85 | S 86 | 1234 87 | MG 88 | S 89 | ABCD1234 90 | 01 91 | 111222333444555 92 | 1122233344555 93 | ABCD1234 94 | ABCD1234 95 | ABCD1234 96 | 4 97 | 28082018 98 | 1600 99 | 28082018 100 | 1601 101 | 11223344 102 | 1554466879 103 | ABCD1234 104 | I 105 | 106 | 107 | 123,12 108 | 123,13 109 | 123,13 110 | 6,4 111 | 6,4 112 | S 113 | S 114 | 13,2 115 | 13,2 116 | 13,2 117 | 13,2 118 | 13,2 119 | 13,2 120 | 13,2 121 | 13,2 122 | 13,2 123 | 13,2 124 | 13,2 125 | 13,2 126 | 13,2 127 | 13,2 128 | 13,2 129 | 13,2 130 | 13,2 131 | 13,2 132 | 133 | 134 | 6,2 135 | 6,3 136 | 6,4 137 | 6,4 138 | 13,2 139 | 13,2 140 | 13,2 141 | 13,2 142 | 13,2 143 | 13,2 144 | 13,2 145 | 13,2 146 | 13,2 147 | 13,2 148 | 13,2 149 | 3,2 150 | 13,2 151 | 2 152 | 13,2 153 | 3,2 154 | 13,2 155 | 13,2 156 | 3,2 157 | 13,2 158 | 13,2 159 | ABC 160 | ABCD 161 | MG 162 | 163 | 164 | Marcasmarcas 165 | 1523 166 | 1546 167 | 168 | 169 | 12123123000111 170 | ABCD 171 | 123 172 | 111111111 173 | 12123123000112 174 | BACD 175 | 123 176 | 222222222 177 | 12123123000113 178 | CABD 179 | 123 180 | 333333333 181 | ABCD 182 | 123AB 183 | 1123581321 184 | 12123123000112 185 | 186 | 187 | 555 188 | FARDOS 189 | 5556664 190 | NOME 191 | 1256 192 | 12364 193 | 123548 194 | MARCAMARCAS 195 | 5556 196 | 15 197 | 5449 198 | 199 | 200 | RAZAO 201 | 12123123000112 202 | --------------- 203 | RUA ABC 204 | ABCD 205 | CBA 206 | 123456789 207 | 123456789 208 | MG 209 | 553333333 210 | 211 | 212 | RAZAO 213 | 12123123000112 214 | --------------- 215 | RUA ABC 216 | ABCD 217 | CBA 218 | 123456789 219 | 123456789 220 | MG 221 | 55112345678 222 | DOCA 223 | 224 | 225 | RAZAO 226 | 12123123000112 227 | --------------- 228 | RUA ABC 229 | ABCD 230 | CBA 231 | 123456789 232 | 123456789 233 | MG 234 | 112333333333 235 | 236 | 237 | 123456789 238 | 123456789 239 | 123456789 240 | 12355 241 | 242 | 243 | 244 | -------------------------------------------------------------------------------- /dados/ocoren.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 12345 4 | 54321 5 | 100718 6 | 0714 7 | NOT501007001 8 | 9 | 10 | OCORR50DDMM999 11 | 12123123000112 12 | TRANSPORTADORA ACME 13 | 14 | 1212312300112 15 | 123 16 | 123456789 17 | 123 18 | 31082018 19 | 1600 20 | 01 21 | 555566644SDA 22 | 1223334444 23 | 1223334444 24 | 1223334444 25 | ABCDE 26 | 123AB 27 | 123ABCDE 28 | 1 29 | 123AB 30 | ABCDE 31 | 31082018 32 | 1600 33 | 31082018 34 | 1600 35 | 31082018 36 | 1601 37 | 31082018 38 | 1602 39 | 12123123000112 40 | 123 41 | 123456789 42 | 43 | 44 | ABCDEFGHIJKLM 45 | ABCDEFGHIJKLM 46 | ABCDEFGHIJKLM 47 | 48 | 49 | 6,2 50 | 6,2 51 | ABCDE 52 | ABCDE 53 | 54 | 55 | 1212312300111 56 | 12123123000113 57 | ABCDE 58 | ABCDE 59 | ABCDE 60 | 61 | 62 | 1234 63 | 64 | 65 | 66 | -------------------------------------------------------------------------------- /dados/procter.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 2001050255 5 | 2930298340 6 | 07610028327 7 | TRANSPORTADORA BCA 8 | ATACADO ALIMENTAR 9 | RUA ABC, 123 10 | ABCDEF 11 | FEDCBA 12 | MG 13 | 19107-322 14 | 35 9986423591 15 | 123 16 | 12 17 | 18 | 19 | 2001050255 20 | 2930298340 21 | 1234567890 22 | ABCDE DE FG HIJK 23 | 0987654321 24 | KJIH GF ED EDCBA 25 | 26 | 27 | 2001050255 28 | 2930298340 29 | 1234567890 30 | FAC 31 | 13/09/2018 32 | 98564483594 33 | 1234567890 34 | 1549678SD546 35 | 1000000000 36 | 540.00 37 | 38 | 39 | 2001050255 40 | 2930298340 41 | 13/09/2018 42 | 123 43 | 10 44 | 6 45 | 46 | 47 | 2001050255 48 | 2930298340 49 | 17501001274891 50 | 999999.999 51 | 999999.999 52 | 09/13/2018 53 | 54 | -------------------------------------------------------------------------------- /layouts/kc/Layout FIA Estoque_FINAL.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/helderam/php-edi/c1c2569ca1ed24bb05b10f2df61584da2351a38e/layouts/kc/Layout FIA Estoque_FINAL.pdf -------------------------------------------------------------------------------- /layouts/kc/Layout FIA.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/helderam/php-edi/c1c2569ca1ed24bb05b10f2df61584da2351a38e/layouts/kc/Layout FIA.pdf -------------------------------------------------------------------------------- /layouts/proceda/DOCCOB-50.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/helderam/php-edi/c1c2569ca1ed24bb05b10f2df61584da2351a38e/layouts/proceda/DOCCOB-50.pdf -------------------------------------------------------------------------------- /layouts/procter/EDI PROCTER GAMBLE.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/helderam/php-edi/c1c2569ca1ed24bb05b10f2df61584da2351a38e/layouts/procter/EDI PROCTER GAMBLE.pdf -------------------------------------------------------------------------------- /teste.php: -------------------------------------------------------------------------------- 1 |