nfe_reader 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (80) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +23 -0
  3. data/Gemfile +4 -0
  4. data/LICENSE.txt +22 -0
  5. data/README.md +38 -0
  6. data/Rakefile +13 -0
  7. data/lib/nfe_reader/authorization.rb +12 -0
  8. data/lib/nfe_reader/carrier.rb +16 -0
  9. data/lib/nfe_reader/collection/duplicate.rb +12 -0
  10. data/lib/nfe_reader/collection.rb +34 -0
  11. data/lib/nfe_reader/customer.rb +62 -0
  12. data/lib/nfe_reader/delivery.rb +20 -0
  13. data/lib/nfe_reader/document.rb +73 -0
  14. data/lib/nfe_reader/export.rb +12 -0
  15. data/lib/nfe_reader/fiscal.rb +33 -0
  16. data/lib/nfe_reader/header.rb +129 -0
  17. data/lib/nfe_reader/information.rb +38 -0
  18. data/lib/nfe_reader/product/armament.rb +22 -0
  19. data/lib/nfe_reader/product/cane.rb +42 -0
  20. data/lib/nfe_reader/product/exportation.rb +20 -0
  21. data/lib/nfe_reader/product/fuel.rb +18 -0
  22. data/lib/nfe_reader/product/importation.rb +49 -0
  23. data/lib/nfe_reader/product/medicament.rb +19 -0
  24. data/lib/nfe_reader/product/vehicle.rb +117 -0
  25. data/lib/nfe_reader/product.rb +90 -0
  26. data/lib/nfe_reader/provider.rb +43 -0
  27. data/lib/nfe_reader/purchase.rb +14 -0
  28. data/lib/nfe_reader/removal.rb +20 -0
  29. data/lib/nfe_reader/taxation/cofins.rb +43 -0
  30. data/lib/nfe_reader/taxation/cofins_st.rb +19 -0
  31. data/lib/nfe_reader/taxation/icms.rb +86 -0
  32. data/lib/nfe_reader/taxation/importation_tax.rb +17 -0
  33. data/lib/nfe_reader/taxation/ipi.rb +41 -0
  34. data/lib/nfe_reader/taxation/issqn.rb +22 -0
  35. data/lib/nfe_reader/taxation/pis.rb +42 -0
  36. data/lib/nfe_reader/taxation/pis_st.rb +19 -0
  37. data/lib/nfe_reader/total.rb +76 -0
  38. data/lib/nfe_reader/transport.rb +97 -0
  39. data/lib/nfe_reader/version.rb +5 -0
  40. data/lib/nfe_reader.rb +129 -0
  41. data/lib/nokogiri_hash.rb +60 -0
  42. data/nfe-reader.gemspec +24 -0
  43. data/test/files/sample-nfe.xml +234 -0
  44. data/test/files/sample2-nfe.xml +192 -0
  45. data/test/nfe_reader/authorization_test.rb +22 -0
  46. data/test/nfe_reader/cane_test.rb +71 -0
  47. data/test/nfe_reader/carrier_test.rb +46 -0
  48. data/test/nfe_reader/collection/duplicate_test.rb +27 -0
  49. data/test/nfe_reader/collection_test.rb +78 -0
  50. data/test/nfe_reader/customer_test.rb +133 -0
  51. data/test/nfe_reader/delivery_test.rb +57 -0
  52. data/test/nfe_reader/document_test.rb +113 -0
  53. data/test/nfe_reader/export_test.rb +22 -0
  54. data/test/nfe_reader/fiscal_test.rb +67 -0
  55. data/test/nfe_reader/header_test.rb +135 -0
  56. data/test/nfe_reader/information_test.rb +37 -0
  57. data/test/nfe_reader/product/armament_test.rb +32 -0
  58. data/test/nfe_reader/product/exportation_test.rb +34 -0
  59. data/test/nfe_reader/product/fuel_test.rb +44 -0
  60. data/test/nfe_reader/product/importation_test.rb +64 -0
  61. data/test/nfe_reader/product/medicament_test.rb +37 -0
  62. data/test/nfe_reader/product/vehicle_test.rb +133 -0
  63. data/test/nfe_reader/product_test.rb +125 -0
  64. data/test/nfe_reader/provider_test.rb +155 -0
  65. data/test/nfe_reader/purchase_test.rb +27 -0
  66. data/test/nfe_reader/removal_test.rb +57 -0
  67. data/test/nfe_reader/taxation/cofins_st_test.rb +37 -0
  68. data/test/nfe_reader/taxation/cofins_test.rb +42 -0
  69. data/test/nfe_reader/taxation/icms_test.rb +122 -0
  70. data/test/nfe_reader/taxation/importation_tax_test.rb +32 -0
  71. data/test/nfe_reader/taxation/ipi_test.rb +78 -0
  72. data/test/nfe_reader/taxation/issqn_test.rb +42 -0
  73. data/test/nfe_reader/taxation/pis_st_test.rb +37 -0
  74. data/test/nfe_reader/taxation/pis_test.rb +42 -0
  75. data/test/nfe_reader/total_test.rb +148 -0
  76. data/test/nfe_reader/transport_test.rb +172 -0
  77. data/test/nfe_reader_test.rb +125 -0
  78. data/test/nokogiri_test.rb +27 -0
  79. data/test/test_helper.rb +13 -0
  80. metadata +201 -0
@@ -0,0 +1,192 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <nfeProc xmlns="http://www.portalfiscal.inf.br/nfe" versao="2.00">
3
+ <NFe xmlns="http://www.portalfiscal.inf.br/nfe">
4
+ <infNFe versao="2.00" Id="NFe12300384950081649000148500001000001310002342">
5
+ <ide>
6
+ <cUF>42</cUF>
7
+ <cNF>00000000</cNF>
8
+ <natOp>Venda de Merc. Recebida ou Adq. De Terc.</natOp>
9
+ <indPag>1</indPag>
10
+ <mod>55</mod>
11
+ <serie>1</serie>
12
+ <nNF>1000</nNF>
13
+ <dEmi>2000-01-01</dEmi>
14
+ <dSaiEnt>2000-01-01</dSaiEnt>
15
+ <hSaiEnt>12:00:00</hSaiEnt>
16
+ <tpNF>1</tpNF>
17
+ <cMunFG>4218202</cMunFG>
18
+ <tpImp>1</tpImp>
19
+ <tpEmis>1</tpEmis>
20
+ <cDV>2</cDV>
21
+ <tpAmb>1</tpAmb>
22
+ <finNFe>1</finNFe>
23
+ <procEmi>0</procEmi>
24
+ <verProc>Software 1.0</verProc>
25
+ </ide>
26
+ <emit>
27
+ <CNPJ>10302227000145</CNPJ>
28
+ <xNome>FORNECEDOR</xNome>
29
+ <enderEmit>
30
+ <xLgr>RUA, 51</xLgr>
31
+ <nro>0</nro>
32
+ <xBairro>BAIRRO</xBairro>
33
+ <cMun>4218202</cMun>
34
+ <xMun>TIMBÓ</xMun>
35
+ <UF>SC</UF>
36
+ <CEP>89120000</CEP>
37
+ <cPais>1058</cPais>
38
+ <fone>4755555555</fone>
39
+ </enderEmit>
40
+ <IE>111111111</IE>
41
+ <CRT>1</CRT>
42
+ </emit>
43
+ <dest>
44
+ <CNPJ>35718645000149</CNPJ>
45
+ <xNome>CLIENTE</xNome>
46
+ <enderDest>
47
+ <xLgr>RUA</xLgr>
48
+ <nro>0</nro>
49
+ <xBairro>BAIRRO</xBairro>
50
+ <cMun>4214805</cMun>
51
+ <xMun>RIO DO SUL</xMun>
52
+ <UF>SC</UF>
53
+ <CEP>89160000</CEP>
54
+ <cPais>1058</cPais>
55
+ <xPais>BRASIL</xPais>
56
+ <fone>4700000000</fone>
57
+ </enderDest>
58
+ <IE>252322746</IE>
59
+ <email>email@cliente.com.br</email>
60
+ </dest>
61
+ <det nItem="1">
62
+ <prod>
63
+ <cProd>000001</cProd>
64
+ <cEAN />
65
+ <xProd>Produto 1</xProd>
66
+ <NCM>00000000</NCM>
67
+ <CFOP>5102</CFOP>
68
+ <uCom>Pr</uCom>
69
+ <qCom>2.0000</qCom>
70
+ <vUnCom>34.7000000000</vUnCom>
71
+ <vProd>138.80</vProd>
72
+ <cEANTrib />
73
+ <uTrib>Pr</uTrib>
74
+ <qTrib>4.0000</qTrib>
75
+ <vUnTrib>34.7000000000</vUnTrib>
76
+ <indTot>1</indTot>
77
+ </prod>
78
+ <imposto>
79
+ <ICMS>
80
+ <ICMSSN102>
81
+ <orig>0</orig>
82
+ <CSOSN>102</CSOSN>
83
+ </ICMSSN102>
84
+ </ICMS>
85
+ <PIS>
86
+ <PISOutr>
87
+ <CST>99</CST>
88
+ <vBC>0.00</vBC>
89
+ <pPIS>0.00</pPIS>
90
+ <vPIS>0.00</vPIS>
91
+ </PISOutr>
92
+ </PIS>
93
+ <COFINS>
94
+ <COFINSOutr>
95
+ <CST>99</CST>
96
+ <vBC>0.00</vBC>
97
+ <pCOFINS>0.00</pCOFINS>
98
+ <vCOFINS>0.00</vCOFINS>
99
+ </COFINSOutr>
100
+ </COFINS>
101
+ </imposto>
102
+ </det>
103
+ <total>
104
+ <ICMSTot>
105
+ <vBC>0.00</vBC>
106
+ <vICMS>0.00</vICMS>
107
+ <vBCST>0.00</vBCST>
108
+ <vST>0.00</vST>
109
+ <vProd>138.80</vProd>
110
+ <vFrete>0.00</vFrete>
111
+ <vSeg>0.00</vSeg>
112
+ <vDesc>0.00</vDesc>
113
+ <vII>0.00</vII>
114
+ <vIPI>0.00</vIPI>
115
+ <vPIS>0.00</vPIS>
116
+ <vCOFINS>0.00</vCOFINS>
117
+ <vOutro>0.00</vOutro>
118
+ <vNF>138.80</vNF>
119
+ </ICMSTot>
120
+ <retTrib />
121
+ </total>
122
+ <transp>
123
+ <modFrete>0</modFrete>
124
+ <transporta>
125
+ <CNPJ>74793624000140</CNPJ>
126
+ <xNome>TRANSPORTADORA</xNome>
127
+ <IE>111111111</IE>
128
+ <xEnder>RUA</xEnder>
129
+ <xMun>TIMBÓ</xMun>
130
+ <UF>SC</UF>
131
+ </transporta>
132
+ <veicTransp>
133
+ <placa>AAA0000</placa>
134
+ <UF>SC</UF>
135
+ </veicTransp>
136
+ </transp>
137
+ <cobr>
138
+ <fat>
139
+ <nFat>0001</nFat>
140
+ <vOrig>138.80</vOrig>
141
+ <vLiq>138.80.17</vLiq>
142
+ </fat>
143
+ <dup>
144
+ <nDup>001</nDup>
145
+ <dVenc>2000-02-01</dVenc>
146
+ <vDup>138.80</vDup>
147
+ </dup>
148
+ </cobr>
149
+ <infAdic>
150
+ <infAdFisco>
151
+ INFORMACAO ADICIONAL
152
+ </infAdFisco>
153
+ </infAdic>
154
+ </infNFe>
155
+ <Signature xmlns="http://www.w3.org/2000/09/xmldsig#">
156
+ <SignedInfo>
157
+ <CanonicalizationMethod Algorithm="http://www.w3.org/TR/2001/REC-xml-c14n-20010315" />
158
+ <SignatureMethod Algorithm="http://www.w3.org/2000/09/xmldsig#rsa-sha1" />
159
+ <Reference URI="#NFe12300384950081649000148500001000001310002342">
160
+ <Transforms>
161
+ <Transform Algorithm="http://www.w3.org/2000/09/xmldsig#enveloped-signature" />
162
+ <Transform Algorithm="http://www.w3.org/TR/2001/REC-xml-c14n-20010315" />
163
+ </Transforms>
164
+ <DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1" />
165
+ <DigestValue>ait7e07Xf0nkqcQTCIcOIVVZCrw=</DigestValue>
166
+ </Reference>
167
+ </SignedInfo>
168
+ <SignatureValue>
169
+ rDoxl0n4MhfLwAJq4pmfnb4Il+USPndfz0v+6vxyQhZEORlXoBgst7GneJ550M9gBDHuKlitn8TE28wE7bPS3ttAvcEtqHfN6iIiBYVXR3RqoRVFOEVPhxZwYAs4M3rlzYiCMBzQ8iJPAv2+2OORlJ5foYCDmIHOCvOFc/aFOms2fHoR8O/uUXfHB0ElN55jorqLZom2MSgnMwd0iblKVqndnEMnCM2zvpm4lL9HGFm+lkzWvjy96zO/HKkZ5FBWWdDsUThevpUVOHRHQ48MqsExvUjiFIMZeZDRS7Y/RS/cVGNknuoZ8x3NX/RtMkRsTOuQ4OnkmcU2nvturCXPdg==
170
+ </SignatureValue>
171
+ <KeyInfo>
172
+ <X509Data>
173
+ <X509Certificate>
174
+ MIIIPjCCBiagAwIBAgIQdamExIOY/iVppDltpM5cDDANBgkqhkiG9w0BAQsFADB4MQswCQYDVQQGEwJCUjETMBEGA1UEChMKSUNQLUJyYXNpbDE2MDQGA1UECxMtU2VjcmV0YXJpYSBkYSBSZWNlaXRhIEZlZGVyYWwgZG8gQnJhc2lsIC0gUkZCMRwwGgYDVQQDExNBQyBDZXJ0aXNpZ24gUkZCIEc0MB4XDTEzMDcwNTAwMDAwMFoXDTE0MDcwNDIzNTk1OVowgecxCzAJBgNVBAYTAkJSMRMwEQYDVQQKFApJQ1AtQnJhc2lsMQswCQYDVQQIEwJTQzEOMAwGA1UEBxQFVElNQk8xNjA0BgNVBAsULVNlY3JldGFyaWEgZGEgUmVjZWl0YSBGZWRlcmFsIGRvIEJyYXNpbCAtIFJGQjEWMBQGA1UECxQNUkZCIGUtQ05QSiBBMTEiMCAGA1UECxQZQXV0ZW50aWNhZG8gcG9yIEFSIENOQiBDRjEyMDAGA1UEAxMpUkVOQVRBIFJPRURFUiBKQUNPQlNFTiB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z8wlDorGrzzC/oOYtt3T1ETvEXo4iPIZ7dwVkCv8Rs5IGbTGrJoRnaV/PGHLIlrFaKfOtat51n4HX+ebAFK+ZvabbHNsnwpnZJbuNBV/P7BLttNV0M2BC/WNtTsxor0mTho2Kiz5VOqUpqnyBWqfJApMFJnuF0=
175
+ </X509Certificate>
176
+ </X509Data>
177
+ </KeyInfo>
178
+ </Signature>
179
+ </NFe>
180
+ <protNFe versao="2.00">
181
+ <infProt Id="ID100000481241129" xmlns="http://www.portalfiscal.inf.br/nfe">
182
+ <tpAmb>1</tpAmb>
183
+ <verAplic>SVRS2000101120000</verAplic>
184
+ <chNFe>12300384950081649000148500001000001310002342</chNFe>
185
+ <dhRecbto>2000-01-01T12:00:00</dhRecbto>
186
+ <nProt>100000481241129</nProt>
187
+ <digVal>aklOQ0184NjoeaqCIRT01927Crf=</digVal>
188
+ <cStat>100</cStat>
189
+ <xMotivo>Autorizado o uso da NF-e</xMotivo>
190
+ </infProt>
191
+ </protNFe>
192
+ </nfeProc>
@@ -0,0 +1,22 @@
1
+ require File.expand_path("../../test_helper", __FILE__)
2
+
3
+ describe Nfe::Authorization do
4
+ def nfe_hash
5
+ {
6
+ autXML: {
7
+ CNPJ: '99819146000120',
8
+ CPF: '64046757655'
9
+ }
10
+ }
11
+ end
12
+
13
+ let(:authorization) { Nfe::Authorization.new(nfe_hash[:autXML]) }
14
+
15
+ it '#cnpj' do
16
+ authorization.cnpj.must_equal '99819146000120'
17
+ end
18
+
19
+ it '#cpf' do
20
+ authorization.cpf.must_equal '64046757655'
21
+ end
22
+ end
@@ -0,0 +1,71 @@
1
+ require File.expand_path("../../test_helper", __FILE__)
2
+
3
+ describe Nfe::Cane do
4
+ def nfe_hash
5
+ {
6
+ cana: {
7
+ safra: '2000',
8
+ ref: '01/2000',
9
+ qTotMes: '100000',
10
+ qTotAnt: '90000',
11
+ qTotGer: '110000',
12
+ vFor: '5000',
13
+ vTotDed: '2000',
14
+ vLiqFor: '3000',
15
+
16
+ forDia: [
17
+ { dia: '01', qtde: '1000' },
18
+ { dia: '10', qtde: '3000' }
19
+ ],
20
+
21
+ deduc: [
22
+ { xDed: "Deduction 1", vDed: '10.00' },
23
+ { xDed: "Deduction 2", vDed: '300.00' }
24
+ ],
25
+
26
+ }
27
+ }
28
+ end
29
+
30
+ let(:cane) { Nfe::Cane.new(nfe_hash[:cana]) }
31
+
32
+ it '#harvest' do
33
+ cane.harvest.must_equal '2000'
34
+ end
35
+
36
+ it '#month' do
37
+ cane.month.must_equal '01/2000'
38
+ end
39
+
40
+ it '#month_amount' do
41
+ cane.month_amount.must_equal '100000'
42
+ end
43
+
44
+ it '#previous_amount' do
45
+ cane.previous_amount.must_equal '90000'
46
+ end
47
+
48
+ it '#amount' do
49
+ cane.amount.must_equal '110000'
50
+ end
51
+
52
+ it '#value' do
53
+ cane.value.must_equal '5000'
54
+ end
55
+
56
+ it '#deduction_value' do
57
+ cane.deduction_value.must_equal '2000'
58
+ end
59
+
60
+ it '#net_value' do
61
+ cane.net_value.must_equal '3000'
62
+ end
63
+
64
+ it '#days' do
65
+ cane.days.must_equal [['01', '1000'], ['10', '3000']]
66
+ end
67
+
68
+ it '#deductions' do
69
+ cane.deductions.must_equal [['Deduction 1', '10.00'], ['Deduction 2', '300.00']]
70
+ end
71
+ end
@@ -0,0 +1,46 @@
1
+ require File.expand_path("../../test_helper", __FILE__)
2
+
3
+ describe Nfe::Carrier do
4
+ def nfe_hash
5
+ {
6
+ transp: {
7
+ CNPJ: '99819146000120',
8
+ xNome: 'Carrier',
9
+ IE: '15786913',
10
+ xEnder: 'Address',
11
+ xMun: 'City',
12
+ UF: 'ST'
13
+ }
14
+ }
15
+ end
16
+
17
+ let(:carrier) { Nfe::Carrier.new(nfe_hash[:transp]) }
18
+
19
+ it '#cnpj' do
20
+ carrier.cnpj.must_equal '99819146000120'
21
+ end
22
+
23
+ it '#cpf' do
24
+ carrier.cpf.must_be_nil
25
+ end
26
+
27
+ it '#name' do
28
+ carrier.name.must_equal 'Carrier'
29
+ end
30
+
31
+ it '#ie' do
32
+ carrier.ie.must_equal '15786913'
33
+ end
34
+
35
+ it '#address' do
36
+ carrier.address.must_equal 'Address'
37
+ end
38
+
39
+ it '#city' do
40
+ carrier.city.must_equal 'City'
41
+ end
42
+
43
+ it '#state' do
44
+ carrier.state.must_equal 'ST'
45
+ end
46
+ end
@@ -0,0 +1,27 @@
1
+ require File.expand_path("../../../test_helper", __FILE__)
2
+
3
+ describe Nfe::Duplicate do
4
+ def nfe_hash
5
+ {
6
+ duplicate: {
7
+ nDup: '1',
8
+ dVenc: '01/01/2000',
9
+ vDup: '50.00'
10
+ }
11
+ }
12
+ end
13
+
14
+ let(:duplicate) { Nfe::Duplicate.new(nfe_hash[:duplicate]) }
15
+
16
+ it '#number' do
17
+ duplicate.number.must_equal '1'
18
+ end
19
+
20
+ it '#expiration' do
21
+ duplicate.expiration.must_equal '01/01/2000'
22
+ end
23
+
24
+ it '#value' do
25
+ duplicate.value.must_equal '50.00'
26
+ end
27
+ end
@@ -0,0 +1,78 @@
1
+ require File.expand_path("../../test_helper", __FILE__)
2
+
3
+ describe Nfe::Collection do
4
+ def nfe_hash
5
+ {
6
+ collection: {
7
+ fat:{
8
+ nFat: '1000',
9
+ vOrig: '1500.00',
10
+ vDesc: '0.00',
11
+ vLiq: '1500.00'
12
+ },
13
+ dup: {
14
+ nDup: '1',
15
+ dVenc: '01/01/2000',
16
+ vDup: '1500.00'
17
+ }
18
+ }
19
+ }
20
+ end
21
+
22
+ def collection_hash
23
+ {
24
+ collection: {
25
+ fat:{
26
+ nFat: '1000',
27
+ vOrig: '1500.00',
28
+ vDesc: '0.00',
29
+ vLiq: '1500.00'
30
+ },
31
+ dup: [
32
+ {
33
+ nDup: '1',
34
+ dVenc: '01/01/2000',
35
+ vDup: '750.00'
36
+ },
37
+ {
38
+ nDup: '2',
39
+ dVenc: '01/01/2000',
40
+ vDup: '750.00'
41
+ }
42
+ ]
43
+ }
44
+ }
45
+ end
46
+
47
+ let(:collection) { Nfe::Collection.new(nfe_hash[:collection]) }
48
+
49
+ describe 'One duplicate' do
50
+ it '#number' do
51
+ collection.number.must_equal '1000'
52
+ end
53
+
54
+ it '#value' do
55
+ collection.value.must_equal '1500.00'
56
+ end
57
+
58
+ it '#descont' do
59
+ collection.descont.must_equal '0.00'
60
+ end
61
+
62
+ it '#value_net' do
63
+ collection.value_net.must_equal '1500.00'
64
+ end
65
+
66
+ it '#duplicates' do
67
+ collection.duplicates.size.must_equal 1
68
+ end
69
+ end
70
+
71
+ describe 'Two duplicate' do
72
+ let(:collection) { Nfe::Collection.new(collection_hash[:collection]) }
73
+
74
+ it '#duplicates' do
75
+ collection.duplicates.size.must_equal 2
76
+ end
77
+ end
78
+ end
@@ -0,0 +1,133 @@
1
+ require File.expand_path("../../test_helper", __FILE__)
2
+
3
+ describe Nfe::Customer do
4
+ def customer_hash
5
+ {
6
+ dest: {
7
+ CNPJ: '99819146000120',
8
+ CPF: '64046757655',
9
+ xNome: 'Customer',
10
+ IE: '15786913',
11
+ email: 'customer@test.mail',
12
+ ISUF: '1234567890',
13
+ idEstrangeiro: '10021312198423',
14
+ enderDest: {
15
+ fone: '55 5555-5555',
16
+ xLgr: 'Green Street',
17
+ nro: '123',
18
+ xBairro: 'Neighborhood',
19
+ cMun: '1246',
20
+ xMun: 'City',
21
+ UF: 'ST',
22
+ cPais: '1058',
23
+ xPais: 'Brazil'
24
+ }
25
+ }
26
+ }
27
+ end
28
+
29
+ describe 'with address' do
30
+ let(:customer) { Nfe::Customer.new(customer_hash[:dest]) }
31
+
32
+ it '#foreign_code' do
33
+ customer.foreign_code.must_equal '10021312198423'
34
+ end
35
+
36
+ it '#cnpj' do
37
+ customer.cnpj.must_equal '99819146000120'
38
+ end
39
+
40
+ it '#cpf' do
41
+ customer.cpf.must_equal '64046757655'
42
+ end
43
+
44
+ it '#name' do
45
+ customer.name.must_equal 'Customer'
46
+ end
47
+
48
+ it '#state_registration' do
49
+ customer.state_registration.must_equal '15786913'
50
+ end
51
+
52
+ it '#email' do
53
+ customer.email.must_equal 'customer@test.mail'
54
+ end
55
+
56
+ it '#suframa' do
57
+ customer.suframa.must_equal '1234567890'
58
+ end
59
+
60
+ it '#phone' do
61
+ customer.phone.must_equal '55 5555-5555'
62
+ end
63
+
64
+ it '#number' do
65
+ customer.number.must_equal '123'
66
+ end
67
+
68
+ it '#address' do
69
+ customer.address.must_equal 'Green Street'
70
+ end
71
+ it '#neighborhood' do
72
+ customer.neighborhood.must_equal 'Neighborhood'
73
+ end
74
+
75
+ it '#city_code' do
76
+ customer.city_code.must_equal '1246'
77
+ end
78
+
79
+ it '#city' do
80
+ customer.city.must_equal 'City'
81
+ end
82
+
83
+ it '#state' do
84
+ customer.state.must_equal 'ST'
85
+ end
86
+
87
+ it '#country_code' do
88
+ customer.country_code.must_equal '1058'
89
+ end
90
+
91
+ it '#country' do
92
+ customer.country.must_equal 'Brazil'
93
+ end
94
+ end
95
+
96
+ describe 'without address' do
97
+ let(:customer) { Nfe::Customer.new }
98
+ it '#phone' do
99
+ customer.number.must_be_nil
100
+ end
101
+
102
+ it '#number' do
103
+ customer.number.must_be_nil
104
+ end
105
+
106
+ it '#address' do
107
+ customer.address.must_be_nil
108
+ end
109
+ it '#neighborhood' do
110
+ customer.neighborhood.must_be_nil
111
+ end
112
+
113
+ it '#city_code' do
114
+ customer.city_code.must_be_nil
115
+ end
116
+
117
+ it '#city' do
118
+ customer.city.must_be_nil
119
+ end
120
+
121
+ it '#state' do
122
+ customer.state.must_be_nil
123
+ end
124
+
125
+ it '#country_code' do
126
+ customer.country_code.must_be_nil
127
+ end
128
+
129
+ it '#country' do
130
+ customer.country.must_be_nil
131
+ end
132
+ end
133
+ end
@@ -0,0 +1,57 @@
1
+ require File.expand_path("../../test_helper", __FILE__)
2
+
3
+ describe Nfe::Delivery do
4
+ def nfe_hash
5
+ {
6
+ entrega: {
7
+ CNPJ: '99819146000120',
8
+ CPF: '64046757655',
9
+ xLgr: 'Street',
10
+ nro: '157',
11
+ xCpl: 'Address',
12
+ xBairro: 'Neighborhood',
13
+ xMun: 'City',
14
+ cMun: '1234',
15
+ UF: 'ST',
16
+ }
17
+ }
18
+ end
19
+
20
+ let(:delivery) { Nfe::Delivery.new(nfe_hash[:entrega]) }
21
+
22
+ it '#cnpj' do
23
+ delivery.cnpj.must_equal '99819146000120'
24
+ end
25
+
26
+ it '#cpf' do
27
+ delivery.cpf.must_equal '64046757655'
28
+ end
29
+
30
+ it '#address' do
31
+ delivery.address.must_equal 'Street'
32
+ end
33
+
34
+ it '#number' do
35
+ delivery.number.must_equal '157'
36
+ end
37
+
38
+ it '#complement' do
39
+ delivery.complement.must_equal 'Address'
40
+ end
41
+
42
+ it '#neighborhood' do
43
+ delivery.neighborhood.must_equal 'Neighborhood'
44
+ end
45
+
46
+ it '#city_code' do
47
+ delivery.city_code.must_equal '1234'
48
+ end
49
+
50
+ it '#city' do
51
+ delivery.city.must_equal 'City'
52
+ end
53
+
54
+ it '#state' do
55
+ delivery.state.must_equal 'ST'
56
+ end
57
+ end