sefazp 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: ff6d8bd9e74ab1c906ada601b477ec595795f458
4
+ data.tar.gz: cb69bd71efe73c50ad50aa1ec2bdd075f6073403
5
+ SHA512:
6
+ metadata.gz: 5087bdafe4794efd86b70772e123494af7491888df2346d37f6aefbdfe2776f97f61f08da5932df834ee8eec602160aea0fd813a0e495e7b7978369468bb4915
7
+ data.tar.gz: e3b07ff226c06747ff7596b8e7205e3ae71d260605e681e9043c68e1a55b0c75d1aae77b411bb1919fb9bd2500529b7deea1410a43a85939d44afa83cd863140
data/.gitignore ADDED
@@ -0,0 +1,25 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
18
+ *.bundle
19
+ *.so
20
+ *.o
21
+ *.a
22
+ mkmf.log
23
+ .ruby-gemset
24
+ .ruby-version
25
+
data/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in sefazp.gemspec
4
+ gemspec
5
+
6
+ gem 'rspec'
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2015 Alexei Telles
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,29 @@
1
+ # Sefazp
2
+
3
+ TODO: Write a gem description
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'sefazp'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install sefazp
18
+
19
+ ## Usage
20
+
21
+ TODO: Write usage instructions here
22
+
23
+ ## Contributing
24
+
25
+ 1. Fork it ( https://github.com/[my-github-username]/sefazp/fork )
26
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
27
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
28
+ 4. Push to the branch (`git push origin my-new-feature`)
29
+ 5. Create a new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,9 @@
1
+ require "bundler/gem_tasks"
2
+
3
+ require "rspec/core/rake_task"
4
+
5
+ RSpec::Core::RakeTask.new("spec")
6
+
7
+ task :default => :spec
8
+
9
+
data/lib/sefazp/cte.rb ADDED
@@ -0,0 +1,154 @@
1
+ class Cte
2
+ def initialize(xml_content)
3
+ @xml_content = xml_content
4
+ end
5
+
6
+ def parse
7
+ begin
8
+ frete = nil
9
+ pedagio = nil
10
+ outros = nil
11
+ nfe_keys = Array.new
12
+ doc = REXML::Document.new(@xml_content)
13
+ municipio_do_emitente = doc.elements["cteProc/CTe/infCte/emit/enderEmit/cMun"].get_text
14
+ municipio_do_remetente = doc.elements["cteProc/CTe/infCte/rem/enderReme/cMun"].get_text
15
+ municipio_do_destinatario = doc.elements["cteProc/CTe/infCte/dest/enderDest/cMun"].get_text
16
+ municipio_de_origem = doc.elements["cteProc/CTe/infCte/ide/cMunIni"].get_text
17
+ municipio_de_destino = doc.elements["cteProc/CTe/infCte/ide/cMunFim"].get_text
18
+ municipio_de_emissao = doc.elements["cteProc/CTe/infCte/ide/cMunEnv"].get_text
19
+ numero = doc.elements["cteProc/CTe/infCte/ide/nCT"].get_text
20
+ serie = doc.elements["cteProc/CTe/infCte/ide/serie"].get_text
21
+ chave_de_acesso = doc.elements["cteProc/CTe/infCte"].attributes["Id"]
22
+ tipo_do_cte = doc.elements["cteProc/CTe/infCte/ide/tpCTe"].get_text
23
+ tipo_do_servico = doc.elements["cteProc/CTe/infCte/ide/tpServ"].get_text
24
+ tomador_do_servico = doc.elements["cteProc/CTe/infCte/ide/toma03/toma"].get_text
25
+ forma_de_pagamento = doc.elements["cteProc/CTe/infCte/ide/forPag"].get_text
26
+ codigo_do_cfop = doc.elements["cteProc/CTe/infCte/ide/CFOP"].get_text
27
+ descricao_do_cfop = doc.elements["cteProc/CTe/infCte/ide/natOp"].get_text
28
+ cnpj_do_emitente = doc.elements["cteProc/CTe/infCte/emit/CNPJ"].get_text
29
+ inscricao_estadual_do_emitente = doc.elements["cteProc/CTe/infCte/emit/IE"].get_text
30
+ nome_do_emitente = doc.elements["cteProc/CTe/infCte/emit/xNome"].get_text
31
+ nome_fantasia_do_emitente = doc.elements["cteProc/CTe/infCte/emit/xFant"].get_text
32
+ logradouro_do_emitente = doc.elements["cteProc/CTe/infCte/emit/enderEmit/xLgr"].get_text
33
+ numero_do_emitente = doc.elements["cteProc/CTe/infCte/emit/enderEmit/nro"].get_text
34
+ bairro_do_emitente = doc.elements["cteProc/CTe/infCte/emit/enderEmit/xBairro"].get_text
35
+ cep_do_emitente = doc.elements["cteProc/CTe/infCte/emit/enderEmit/CEP"].get_text
36
+ cnpj_do_remetente = doc.elements["cteProc/CTe/infCte/rem/CNPJ"].get_text
37
+ inscricao_estadual_do_remetente = doc.elements["cteProc/CTe/infCte/rem/IE"].get_text
38
+ nome_do_remetente = doc.elements["cteProc/CTe/infCte/rem/xNome"].get_text
39
+ logradouro_do_remetente = doc.elements["cteProc/CTe/infCte/rem/enderReme/xLgr"].get_text
40
+ numero_do_remetente = doc.elements["cteProc/CTe/infCte/rem/enderReme/nro"].get_text
41
+ bairro_do_remetente = doc.elements["cteProc/CTe/infCte/rem/enderReme/xBairro"].get_text
42
+ cep_do_remetente = doc.elements["cteProc/CTe/infCte/rem/enderReme/CEP"].get_text
43
+ cnpj_do_destinatario = doc.elements["cteProc/CTe/infCte/dest/CNPJ"].get_text
44
+ inscricao_estadual_do_destinatario = doc.elements["cteProc/CTe/infCte/dest/IE"].get_text
45
+ nome_do_destinatario = doc.elements["cteProc/CTe/infCte/dest/xNome"].get_text
46
+ logradouro_do_destinatario = doc.elements["cteProc/CTe/infCte/dest/enderDest/xLgr"].get_text
47
+ numero_do_destinatario = doc.elements["cteProc/CTe/infCte/dest/enderDest/nro"].get_text
48
+ bairro_do_destinatario = doc.elements["cteProc/CTe/infCte/dest/enderDest/xBairro"].get_text
49
+ cep_do_destinatario = doc.elements["cteProc/CTe/infCte/dest/enderDest/CEP"].get_text
50
+ produto_predominante = doc.elements["cteProc/CTe/infCte/infCTeNorm/infCarga/proPred"].get_text
51
+ unidade_de_medida = doc.elements["cteProc/CTe/infCte/infCTeNorm/infCarga/infQ/tpMed"].get_text
52
+ quantidade = doc.elements["cteProc/CTe/infCte/infCTeNorm/infCarga/infQ/qCarga"].get_text
53
+ valor_da_mercadoria = doc.elements["cteProc/CTe/infCte/infCTeNorm/infCarga/vCarga"].get_text
54
+ responsavel = doc.elements["cteProc/CTe/infCte/infCTeNorm/seg/respSeg"].get_text
55
+ valor_total = doc.elements["cteProc/CTe/infCte/vPrest/vTPrest"].get_text
56
+ valor_a_receber = doc.elements["cteProc/CTe/infCte/vPrest/vRec"].get_text
57
+ base_de_calculo = doc.elements["cteProc/CTe/infCte/imp/ICMS/ICMS00/vBC"].get_text
58
+ aliquota_icms = doc.elements["cteProc/CTe/infCte/imp/ICMS/ICMS00/pICMS"].get_text
59
+ valor_icms = doc.elements["cteProc/CTe/infCte/imp/ICMS/ICMS00/vICMS"].get_text
60
+ lotacao = doc.elements["cteProc/CTe/infCte/infCTeNorm/infModal/rodo/lota"].get_text
61
+ data_prevista_de_entrega = doc.elements["cteProc/CTe/infCte/infCTeNorm/infModal/rodo/dPrev"].get_text
62
+ tipo_do_veiculo = doc.elements["cteProc/CTe/infCte/infCTeNorm/infModal/rodo/veic/tpVeic"].get_text
63
+ placa_do_veiculo = doc.elements["cteProc/CTe/infCte/infCTeNorm/infModal/rodo/veic/placa"].get_text
64
+ uf_do_veiculo = doc.elements["cteProc/CTe/infCte/infCTeNorm/infModal/rodo/veic/UF"].get_text
65
+ renavan_do_veiculo = doc.elements["cteProc/CTe/infCte/infCTeNorm/infModal/rodo/veic/RENAVAM"].get_text
66
+ tara_em_kg_do_veiculo = doc.elements["cteProc/CTe/infCte/infCTeNorm/infModal/rodo/veic/tara"].get_text.to_s
67
+ capacidade_em_kg_do_veiculo = doc.elements["cteProc/CTe/infCte/infCTeNorm/infModal/rodo/veic/capKG"].get_text
68
+ capacidade_em_m3_do_veiculo = doc.elements["cteProc/CTe/infCte/infCTeNorm/infModal/rodo/veic/capM3"].get_text
69
+ nome_do_motorista = doc.elements["cteProc/CTe/infCte/infCTeNorm/infModal/rodo/moto/xNome"].get_text
70
+ cpf_do_motorista = doc.elements["cteProc/CTe/infCte/infCTeNorm/infModal/rodo/moto/CPF"].get_text
71
+ rntrc = doc.elements["cteProc/CTe/infCte/infCTeNorm/infModal/rodo/RNTRC"].get_text
72
+ doc.get_elements("cteProc/CTe/infCte/vPrest/Comp").each do |comp|
73
+ if comp.elements["xNome"].get_text.to_s == "FRETE VALOR"
74
+ frete = comp.elements["vComp"].get_text
75
+ elsif comp.elements["xNome"].get_text.to_s == "PEDAGIO"
76
+ pedagio = comp.elements["vComp"].get_text
77
+ elsif comp.elements["xNome"].get_text.to_s == "OUTROS"
78
+ outros = comp.elements["vComp"].get_text
79
+ end
80
+ end
81
+ doc.get_elements("cteProc/CTe/infCte/infCTeNorm/infDoc/infNFe").each do |key|
82
+ nfe_keys << key.elements["chave"].get_text
83
+ end
84
+
85
+ return {
86
+ municipio_do_emitente: municipio_do_emitente,
87
+ municipio_do_remetente: municipio_do_remetente,
88
+ municipio_do_destinatario: municipio_do_destinatario,
89
+ municipio_de_origem: municipio_de_origem,
90
+ municipio_de_destino: municipio_de_destino,
91
+ municipio_de_emissao: municipio_de_emissao,
92
+ numero: numero,
93
+ serie: serie,
94
+ chave_de_acesso: chave_de_acesso,
95
+ tipo_do_cte: tipo_do_cte,
96
+ tipo_do_servico: tipo_do_servico,
97
+ tomador_do_servico: tomador_do_servico,
98
+ forma_de_pagamento: forma_de_pagamento,
99
+ codigo_do_cfop: codigo_do_cfop,
100
+ descricao_do_cfop: descricao_do_cfop,
101
+ cnpj_do_emitente: cnpj_do_emitente,
102
+ inscricao_estadual_do_emitente: inscricao_estadual_do_emitente,
103
+ nome_do_emitente: nome_do_emitente,
104
+ nome_fantasia_do_emitente: nome_fantasia_do_emitente,
105
+ logradouro_do_emitente: logradouro_do_emitente,
106
+ numero_do_emitente: numero_do_emitente,
107
+ bairro_do_emitente: bairro_do_emitente,
108
+ cep_do_emitente: cep_do_emitente,
109
+ cnpj_do_remetente: cnpj_do_remetente,
110
+ inscricao_estadual_do_remetente: inscricao_estadual_do_remetente,
111
+ nome_do_remetente: nome_do_remetente,
112
+ logradouro_do_remetente: logradouro_do_remetente,
113
+ numero_do_remetente: numero_do_remetente,
114
+ bairro_do_remetente: bairro_do_remetente,
115
+ cep_do_remetente: cep_do_remetente,
116
+ cnpj_do_destinatario: cnpj_do_destinatario,
117
+ inscricao_estadual_do_destinatario: inscricao_estadual_do_destinatario,
118
+ nome_do_destinatario: nome_do_destinatario,
119
+ logradouro_do_destinatario: logradouro_do_destinatario,
120
+ numero_do_destinatario: numero_do_destinatario,
121
+ bairro_do_destinatario: bairro_do_destinatario,
122
+ cep_do_destinatario: cep_do_destinatario,
123
+ produto_predominante: produto_predominante,
124
+ unidade_de_medida: unidade_de_medida,
125
+ quantidade: quantidade,
126
+ valor_da_mercadoria: valor_da_mercadoria,
127
+ responsavel: responsavel,
128
+ valor_total: valor_total,
129
+ valor_a_receber: valor_a_receber,
130
+ base_de_calculo: base_de_calculo,
131
+ aliquota_icms: aliquota_icms,
132
+ valor_icms: valor_icms,
133
+ lotacao: lotacao,
134
+ data_prevista_de_entrega: data_prevista_de_entrega,
135
+ tipo_do_veiculo: tipo_do_veiculo,
136
+ placa_do_veiculo: placa_do_veiculo,
137
+ uf_do_veiculo: uf_do_veiculo,
138
+ renavan_do_veiculo: renavan_do_veiculo,
139
+ tara_em_kg_do_veiculo: tara_em_kg_do_veiculo,
140
+ capacidade_em_kg_do_veiculo: capacidade_em_kg_do_veiculo,
141
+ capacidade_em_m3_do_veiculo: capacidade_em_m3_do_veiculo,
142
+ nome_do_motorista: nome_do_motorista,
143
+ cpf_do_motorista: cpf_do_motorista,
144
+ rntrc: rntrc,
145
+ frete: frete,
146
+ pedagio: pedagio,
147
+ outros: outros,
148
+ nfe_keys: nfe_keys
149
+ }
150
+ rescue
151
+ return nil
152
+ end
153
+ end
154
+ end
@@ -0,0 +1,3 @@
1
+ module Sefazp
2
+ VERSION = "0.0.1"
3
+ end
data/lib/sefazp.rb ADDED
@@ -0,0 +1,11 @@
1
+ require "sefazp/version"
2
+ require "sefazp/cte"
3
+ require "rexml/document"
4
+
5
+ module Sefazp
6
+ extend self
7
+
8
+ def parse_cte(xml_content)
9
+ Cte.new(xml_content).parse
10
+ end
11
+ end
data/sefazp.gemspec ADDED
@@ -0,0 +1,23 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'sefazp/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "sefazp"
8
+ spec.version = Sefazp::VERSION
9
+ spec.authors = ["Alexei Telles"]
10
+ spec.email = ["alexeitsb@gmail.com"]
11
+ spec.summary = "Transforma seus arquivos xml de MDFe, CTe e NFe em um Hash contendo as informações mais importantes"
12
+ spec.description = ""
13
+ spec.homepage = ""
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0")
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_development_dependency "bundler", "~> 1.6"
22
+ spec.add_development_dependency "rake"
23
+ end
@@ -0,0 +1,42 @@
1
+ <?xml version="1.0" encoding="utf-8"?><cteProc xmlns="http://www.portalfiscal.inf.br/cte" versao="2.00"><CTe xmlns="http://www.portalfiscal.inf.br/cte"><infCte versao="2.00" Id="CTe35150110663500000167570020000154241000000014"><ide><cUF>35</cUF><cCT>00000001</cCT><CFOP>6353</CFOP><natOp>ESTABELECIMENTO COMERCIAL</natOp><forPag>0</forPag><mod>57</mod><serie>2</serie><nCT>15424</nCT><dhEmi>2015-01-20T12:49:33</dhEmi><tpImp>1</tpImp><tpEmis>1</tpEmis><cDV>4</cDV><tpAmb>1</tpAmb><tpCTe>0</tpCTe><procEmi>0</procEmi><verProc>TrustFiles</verProc><cMunEnv>3505708</cMunEnv><xMunEnv>BARUERI</xMunEnv><UFEnv>SP</UFEnv><modal>01</modal><tpServ>0</tpServ><cMunIni>3106200</cMunIni><xMunIni>BELO HORIZONTE</xMunIni><UFIni>MG</UFIni><cMunFim>3529401</cMunFim><xMunFim>MAUA</xMunFim><UFFim>SP</UFFim><retira>1</retira><toma03><toma>0</toma></toma03></ide><emit><CNPJ>10663500000167</CNPJ><IE>714107634116</IE><xNome>ARELLANO VOSS TRANSPORTES LTDA.</xNome><xFant>AVT - BARUERI - DAY BRASIL 1</xFant><enderEmit><xLgr>RUA SANTA CRUZ</xLgr><nro>481</nro><xCpl>1</xCpl><xBairro>BARRA FUNDA</xBairro><cMun>3556701</cMun><xMun>VINHEDO</xMun><CEP>13280000</CEP><UF>SP</UF><fone>1938262557</fone></enderEmit></emit><rem><CNPJ>49327943000384</CNPJ><IE>0623502100062</IE><xNome>DAY BRASIL S/A</xNome><enderReme><xLgr>R CALDAS DA RAINHA</xLgr><nro>1359</nro><xBairro>SAO FRANCISCO</xBairro><cMun>3106200</cMun><xMun>BELO HORIZONTE</xMun><CEP>31255180</CEP><UF>MG</UF></enderReme></rem><dest><CNPJ>00023779000160</CNPJ><IE>442195903117</IE><xNome>POLYSISTEM IMP E EXP DE POLICARBONATO LT</xNome><enderDest><xLgr>RUA RINALDO CHIAROTTI</xLgr><nro>491</nro><xBairro>SERTAOZINHO</xBairro><cMun>3529401</cMun><xMun>MAUA</xMun><CEP>09372060</CEP><UF>SP</UF></enderDest></dest><vPrest><vTPrest>370.68</vTPrest><vRec>370.68</vRec><Comp><xNome>FRETE VALOR</xNome><vComp>370.68</vComp></Comp><Comp><xNome>PEDAGIO</xNome><vComp>0.00</vComp></Comp><Comp><xNome>OUTROS</xNome><vComp>0.00</vComp></Comp></vPrest><imp><ICMS><ICMS00><CST>00</CST><vBC>370.68</vBC><pICMS>12.00</pICMS><vICMS>44.48</vICMS></ICMS00></ICMS></imp><infCTeNorm><infCarga><vCarga>45677.25</vCarga><proPred>VARIOS</proPred><infQ><cUnid>03</cUnid><tpMed>PECAS</tpMed><qCarga>225</qCarga></infQ></infCarga><infDoc><infNFe><chave>31150149327943000384550010000318811007008823</chave></infNFe></infDoc><seg><respSeg>0</respSeg></seg><infModal versaoModal="2.00"><rodo xmlns="http://www.portalfiscal.inf.br/cte"><RNTRC>46072566</RNTRC><dPrev>2015-01-21</dPrev><lota>1</lota><veic><RENAVAM>00547274670</RENAVAM><placa>EWJ1042</placa><tara>15750</tara><capKG>0</capKG><capM3>0</capM3><tpProp>T</tpProp><tpVeic>0</tpVeic><tpRod>00</tpRod><tpCar>00</tpCar><UF>SP</UF></veic><moto><xNome>CELIO OLIVEIRA SANTOS</xNome><CPF>12403654892</CPF></moto></rodo></infModal></infCTeNorm></infCte><Signature xmlns="http://www.w3.org/2000/09/xmldsig#"><SignedInfo><CanonicalizationMethod Algorithm="http://www.w3.org/TR/2001/REC-xml-c14n-20010315" /><SignatureMethod Algorithm="http://www.w3.org/2000/09/xmldsig#rsa-sha1" /><Reference URI="#CTe35150110663500000167570020000154241000000014"><Transforms><Transform Algorithm="http://www.w3.org/2000/09/xmldsig#enveloped-signature" /><Transform Algorithm="http://www.w3.org/TR/2001/REC-xml-c14n-20010315" /></Transforms><DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1" /><DigestValue>C4YffkZGUL6B+9h5wWR2d6ArlyU=</DigestValue></Reference></SignedInfo><SignatureValue>FU8bUyGktjyh9HTdyrJ+sUXCGFDzprK8DCYLDtcJdnFdfIN2CwWVm8KSTq06ZbE6L8daQWt0Vjgk
2
+ lcN2hHsSXAOJjxexku9l/ADXQmJOeDjVNswMxBTeTyNyxTk3+DINOmbgU67bBy9rAtbfWrlOn+Lv
3
+ AVEsZXyqbB4PriTEiZlXna+sObqILgx+ORM1K5vTST6mWk8sBcYRXox+xFJmfbTyj4r7lOWPnAhI
4
+ QB4jgtVBFfirhqLj6bk/lr8GB0dJj0BuB1xHhtLCPolakjSxhkOSq76E/sb3zhWqu1+1iQzUBEgo
5
+ W45D3iypc1F93yDOpJKsZOGcI3Rg+TbGzb0dXg==</SignatureValue><KeyInfo><X509Data><X509Certificate>MIIITDCCBjSgAwIBAgIQVMKJrzUVOm63L2nEvhQkmDANBgkqhkiG9w0BAQsFADB1MQswCQYDVQQG
6
+ EwJCUjETMB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1NJ
32
+ TkNPUl9SRkJfRzQucDdjMCgGCCsGAQUFBzABhhxodHRwOi8vb2NzcC5jZXJ0aXNpZ24uY29tLmJy
33
+ MA0GCSqGSIb3DQEBCwUAA4ICAQBItjeA56R5172Co53/OPvvFTVE6drmlk4vqMMaOT6Zeoz1phlq
34
+ LCdQzi4jSnOsho4zLLeJ/2CC7JMMg33OGbvEqIKLNT4FuleOb9IxUZZBsLtWG352hMAMsbg+l4P4
35
+ zHOWISpZZCHccKxhD0OupDinXkP/zgRoeBQyfGtJUSSsyyu5jeiYy0CFoR4VVCDB1NPnR+FPfhF3
36
+ uUuX6TSgk3yltvI4FHNbH6qKFQ32IkafLmMFVHoZ1uM2eXMOThsXxhjviACic5xaGFOOb7BcqnMP
37
+ Hkx/8egPOk2EAXSSz1pT/qB4BCzZaF7Ahd5HGvOETjq9t3OwXSi8WEz3D1rWKZZdgf5XYzkNrcNA
38
+ u4EQA8Y+moOJ4DycWmF2sCuBlSLNda2cgdCj1EDOVZsWCMFc+IgawX1H86FHNx1JC0TXWIcktSPv
39
+ YtOHuc54KbFoY2y4XOIZeoSLj53a4YJDdSfaMui5cenczgZ/zD875jlg3RJPHH+UpepzIx5jOLBB
40
+ NCvxaY3YDylqyW2zz33ex7X52I17+LZxGllLI8IMwhf6eGyF+xt9/q/vqyK4sv2OQTt6kC1pXWlL
41
+ Es+qYAiqGiqUoqC/oxBjRvRqbQe6TXA34qwQpYfa9Lhls4VdyzOp7KxG+O7HzSe5p3LIxQO8MkMp
42
+ AW3/O4DfCnPIjswwV99/kQLsTQ==</X509Certificate></X509Data></KeyInfo></Signature></CTe><protCTe versao="2.00"><infProt><tpAmb>1</tpAmb><verAplic>SP-CTe-13-01-2015</verAplic><chCTe>35150110663500000167570020000154241000000014</chCTe><dhRecbto>2015-01-20T12:52:05</dhRecbto><nProt>135150464744660</nProt><digVal>C4YffkZGUL6B+9h5wWR2d6ArlyU=</digVal><cStat>100</cStat><xMotivo>Autorizado o uso do CT-e</xMotivo></infProt></protCTe></cteProc>
@@ -0,0 +1,10 @@
1
+ require "spec_helper"
2
+
3
+ describe Sefazp do
4
+ let(:cte_xml_content) { File.open("spec/fixtures/cte.xml", "r") }
5
+
6
+ it "should parse a cte" do
7
+ expect(Sefazp.parse_cte(cte_xml_content)).to eq({ :municipio_do_emitente=>"3556701", :municipio_do_remetente=>"3106200", :municipio_do_destinatario=>"3529401", :municipio_de_origem=>"3106200", :municipio_de_destino=>"3529401", :municipio_de_emissao=>"3505708", :numero=>"15424", :serie=>"2", :chave_de_acesso=>"CTe35150110663500000167570020000154241000000014", :tipo_do_cte=>"0", :tipo_do_servico=>"0", :tomador_do_servico=>"0", :forma_de_pagamento=>"0", :codigo_do_cfop=>"6353", :descricao_do_cfop=>"ESTABELECIMENTO COMERCIAL", :cnpj_do_emitente=>"10663500000167", :inscricao_estadual_do_emitente=>"714107634116", :nome_do_emitente=>"ARELLANO VOSS TRANSPORTES LTDA.", :nome_fantasia_do_emitente=>"AVT - BARUERI - DAY BRASIL 1", :logradouro_do_emitente=>"RUA SANTA CRUZ", :numero_do_emitente=>"481", :bairro_do_emitente=>"BARRA FUNDA", :cep_do_emitente=>"13280000", :cnpj_do_remetente=>"49327943000384", :inscricao_estadual_do_remetente=>"0623502100062", :nome_do_remetente=>"DAY BRASIL S/A", :logradouro_do_remetente=>"R CALDAS DA RAINHA", :numero_do_remetente=>"1359", :bairro_do_remetente=>"SAO FRANCISCO", :cep_do_remetente=>"31255180", :cnpj_do_destinatario=>"00023779000160", :inscricao_estadual_do_destinatario=>"442195903117", :nome_do_destinatario=>"POLYSISTEM IMP E EXP DE POLICARBONATO LT", :logradouro_do_destinatario=>"RUA RINALDO CHIAROTTI", :numero_do_destinatario=>"491", :bairro_do_destinatario=>"SERTAOZINHO", :cep_do_destinatario=>"09372060", :produto_predominante=>"VARIOS", :unidade_de_medida=>"PECAS", :quantidade=>"225", :valor_da_mercadoria=>"45677.25", :responsavel=>"0", :valor_total=>"370.68", :valor_a_receber=>"370.68", :base_de_calculo=>"370.68", :aliquota_icms=>"12.00", :valor_icms=>"44.48", :lotacao=>"1", :data_prevista_de_entrega=>"2015-01-21", :tipo_do_veiculo=>"0", :placa_do_veiculo=>"EWJ1042", :uf_do_veiculo=>"SP", :renavan_do_veiculo=>"00547274670", :tara_em_kg_do_veiculo=>"15750", :capacidade_em_kg_do_veiculo=>"0", :capacidade_em_m3_do_veiculo=>"0", :nome_do_motorista=>"CELIO OLIVEIRA SANTOS", :cpf_do_motorista=>"12403654892", :rntrc=>"46072566", :frete=>"370.68", :pedagio=>"0.00", :outros=>"0.00", :nfe_keys=>["31150149327943000384550010000318811007008823"] })
8
+ end
9
+
10
+ end
@@ -0,0 +1,8 @@
1
+ require 'rubygems'
2
+ require 'bundler/setup'
3
+ # our gem
4
+ require 'sefazp'
5
+
6
+ RSpec.configure do |config|
7
+
8
+ end
metadata ADDED
@@ -0,0 +1,88 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: sefazp
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Alexei Telles
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-02-10 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.6'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.6'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ description: ''
42
+ email:
43
+ - alexeitsb@gmail.com
44
+ executables: []
45
+ extensions: []
46
+ extra_rdoc_files: []
47
+ files:
48
+ - ".gitignore"
49
+ - Gemfile
50
+ - LICENSE.txt
51
+ - README.md
52
+ - Rakefile
53
+ - lib/sefazp.rb
54
+ - lib/sefazp/cte.rb
55
+ - lib/sefazp/version.rb
56
+ - sefazp.gemspec
57
+ - spec/fixtures/cte.xml
58
+ - spec/sefazp_spec.rb
59
+ - spec/spec_helper.rb
60
+ homepage: ''
61
+ licenses:
62
+ - MIT
63
+ metadata: {}
64
+ post_install_message:
65
+ rdoc_options: []
66
+ require_paths:
67
+ - lib
68
+ required_ruby_version: !ruby/object:Gem::Requirement
69
+ requirements:
70
+ - - ">="
71
+ - !ruby/object:Gem::Version
72
+ version: '0'
73
+ required_rubygems_version: !ruby/object:Gem::Requirement
74
+ requirements:
75
+ - - ">="
76
+ - !ruby/object:Gem::Version
77
+ version: '0'
78
+ requirements: []
79
+ rubyforge_project:
80
+ rubygems_version: 2.2.2
81
+ signing_key:
82
+ specification_version: 4
83
+ summary: Transforma seus arquivos xml de MDFe, CTe e NFe em um Hash contendo as informações
84
+ mais importantes
85
+ test_files:
86
+ - spec/fixtures/cte.xml
87
+ - spec/sefazp_spec.rb
88
+ - spec/spec_helper.rb