dfe-taxweb 0.1.1 → 0.1.3
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 +4 -4
- data/lib/dfe_taxweb.rb +10 -0
- data/lib/dfe_taxweb/atributo.rb +18 -0
- data/lib/dfe_taxweb/atributos.rb +62 -0
- data/lib/dfe_taxweb/atributos.yml +301 -0
- data/lib/dfe_taxweb/version.rb +1 -1
- data/spec/dfe_taxweb_spec.rb +22 -0
- metadata +5 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d3c7857560dc471203389cbf1ce05b9833aeeda2
|
4
|
+
data.tar.gz: a7591433bf9198494a27b3c0c286e5d1ccc78c58
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 36d4664a455d62168e3ed872a7b2107a67248adf76d181010592594ba637a6694850398d7237aaa342ec076841458fc50cca5e04be83686d0a4437f06fef2f63
|
7
|
+
data.tar.gz: 73b8810146393f041f9f8b7b4dc5f044f7b482beb7bf5a0400dfb07e1d6b9b2b36c650c5a5411b9676f40fdce1b0e518349d7eb0634b13d2a04f817aeb2271ab
|
data/lib/dfe_taxweb.rb
CHANGED
@@ -2,6 +2,8 @@
|
|
2
2
|
require 'active_support/core_ext/hash'
|
3
3
|
require 'active_support/core_ext/enumerable'
|
4
4
|
|
5
|
+
require 'dfe_taxweb/atributo'
|
6
|
+
require 'dfe_taxweb/atributos'
|
5
7
|
require 'dfe_taxweb/conjunto'
|
6
8
|
require 'dfe_taxweb/nfe'
|
7
9
|
|
@@ -11,4 +13,12 @@ module DfeTaxweb
|
|
11
13
|
DfeTaxweb::Nfe.new xml_or_hash
|
12
14
|
end
|
13
15
|
|
16
|
+
def self.atributo(path, hash=nil)
|
17
|
+
DfeTaxweb::Atributos.instance.atributo(path, hash)
|
18
|
+
end
|
19
|
+
|
20
|
+
def self.atributos
|
21
|
+
DfeTaxweb::Atributos.instance
|
22
|
+
end
|
23
|
+
|
14
24
|
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
module DfeTaxweb
|
2
|
+
class Atributo
|
3
|
+
attr_accessor :titulo, :descricao
|
4
|
+
attr_reader :caminho
|
5
|
+
|
6
|
+
def initialize(atributos, caminho='')
|
7
|
+
@caminho = caminho
|
8
|
+
atributos.each do |k, v|
|
9
|
+
begin
|
10
|
+
self.send(:"#{k}=", v)
|
11
|
+
rescue NoMethodError => e
|
12
|
+
# self.class.send(:attr_accessor, k)
|
13
|
+
# retry
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,62 @@
|
|
1
|
+
require 'singleton'
|
2
|
+
require 'yaml'
|
3
|
+
|
4
|
+
module DfeTaxweb
|
5
|
+
class Atributos
|
6
|
+
include Singleton
|
7
|
+
|
8
|
+
attr_reader :atributos_hash, :atributos_list, :atributos_object
|
9
|
+
|
10
|
+
def initialize
|
11
|
+
atributos_h = YAML.load(File.read(File.join(__dir__, 'atributos.yml')))
|
12
|
+
@atributos_hash = atributos_h['documento'].deep_symbolize_keys || {}
|
13
|
+
end
|
14
|
+
|
15
|
+
def lista
|
16
|
+
@atributos_list ||= tree_to_list(@atributos_hash)
|
17
|
+
end
|
18
|
+
|
19
|
+
def colecao
|
20
|
+
@atributos_object ||= lista.map do |atributo_path|
|
21
|
+
atributo(atributo_path)
|
22
|
+
end.compact
|
23
|
+
end
|
24
|
+
|
25
|
+
def atributo(path, conjunto=nil)
|
26
|
+
conjunto = @atributos_hash if conjunto.nil?
|
27
|
+
attrs = path.split(".").inject(conjunto) do |item, key|
|
28
|
+
next if item.nil?
|
29
|
+
if key =~ /\[\d+\]/
|
30
|
+
item[key.sub(/\[\d+\]/, '').to_sym][key[/\[(\d+)\]/, 1].to_i]
|
31
|
+
else
|
32
|
+
item[key.to_sym]
|
33
|
+
end
|
34
|
+
end
|
35
|
+
DfeTaxweb::Atributo.new(attrs, path)
|
36
|
+
end
|
37
|
+
|
38
|
+
private
|
39
|
+
def tree_to_list(hash, parent='')
|
40
|
+
if hash.is_a?(Array)
|
41
|
+
hash.map {|a| tree_to_list(a, parent)}.flatten.compact
|
42
|
+
elsif hash.is_a?(Hash)
|
43
|
+
hash.map do |key, attrs|
|
44
|
+
extra_attributes = attrs.except(:titulo, :descricao) #YML
|
45
|
+
if extra_attributes.present?
|
46
|
+
normalized_parent = normalize_parent_key(parent, key)
|
47
|
+
tree_to_list(extra_attributes, normalized_parent)
|
48
|
+
else
|
49
|
+
tree_to_list(key, parent)
|
50
|
+
end
|
51
|
+
end.flatten.compact
|
52
|
+
else
|
53
|
+
normalize_parent_key(parent, hash)
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
def normalize_parent_key(parent, key)
|
58
|
+
parent.present? ? "#{parent}.#{key}" : "#{key}"
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
end
|
@@ -0,0 +1,301 @@
|
|
1
|
+
pessoa: &pessoa
|
2
|
+
cnpj:
|
3
|
+
titulo: "CNPJ"
|
4
|
+
descricao: ""
|
5
|
+
cpf:
|
6
|
+
titulo: "CPF"
|
7
|
+
descricao: ""
|
8
|
+
nome:
|
9
|
+
titulo: "Nome"
|
10
|
+
descricao: ""
|
11
|
+
xFant:
|
12
|
+
titulo: "Nome Fantasia"
|
13
|
+
descricao: ""
|
14
|
+
inscricaoEstadual:
|
15
|
+
titulo: "Inscrição Estadual"
|
16
|
+
descricao: ""
|
17
|
+
IEST:
|
18
|
+
titulo: "Inscrição Estadual ST"
|
19
|
+
descricao: ""
|
20
|
+
inscricaoMunicipal:
|
21
|
+
titulo: "Inscrição Municipal"
|
22
|
+
descricao: ""
|
23
|
+
cdAtividadeEconomica:
|
24
|
+
titulo: "CNAE"
|
25
|
+
descricao: ""
|
26
|
+
contribuinteICMS:
|
27
|
+
titulo: "Contribuinte ICMS?"
|
28
|
+
descricao: ""
|
29
|
+
contribuinteIPI:
|
30
|
+
titulo: "Contribuinte IPI?"
|
31
|
+
descricao: ""
|
32
|
+
contribuinteST:
|
33
|
+
titulo: "Contribuinte ST?"
|
34
|
+
descricao: ""
|
35
|
+
contribuinteISS:
|
36
|
+
titulo: "Contribuinte ISS?"
|
37
|
+
descricao: ""
|
38
|
+
contribuintePIS:
|
39
|
+
titulo: "Contribuinte PIS?"
|
40
|
+
descricao: ""
|
41
|
+
contribuinteCOFINS:
|
42
|
+
titulo: "Contribuinte COFINS?"
|
43
|
+
descricao: ""
|
44
|
+
contribuinteII:
|
45
|
+
titulo: "Contribuinte II?"
|
46
|
+
descricao: ""
|
47
|
+
simplesNac:
|
48
|
+
titulo: "Simples Nacional?"
|
49
|
+
descricao: ""
|
50
|
+
xLgr:
|
51
|
+
titulo: "Logradouro"
|
52
|
+
descricao: ""
|
53
|
+
Nro:
|
54
|
+
titulo: "Número"
|
55
|
+
descricao: ""
|
56
|
+
xCpl:
|
57
|
+
titulo: "Complemento"
|
58
|
+
descricao: ""
|
59
|
+
xBairro:
|
60
|
+
titulo: "Bairro"
|
61
|
+
descricao: ""
|
62
|
+
cdMunicipio:
|
63
|
+
titulo: "Cód. Município"
|
64
|
+
descricao: ""
|
65
|
+
xMun:
|
66
|
+
titulo: "Município"
|
67
|
+
descricao: ""
|
68
|
+
uf:
|
69
|
+
titulo: "UF"
|
70
|
+
descricao: ""
|
71
|
+
cep:
|
72
|
+
titulo: "CEP"
|
73
|
+
descricao: ""
|
74
|
+
cdPais:
|
75
|
+
titulo: "Cód. País"
|
76
|
+
descricao: ""
|
77
|
+
xPais:
|
78
|
+
titulo: "País"
|
79
|
+
descricao: ""
|
80
|
+
fone:
|
81
|
+
titulo: "Telefone"
|
82
|
+
descricao: ""
|
83
|
+
documento:
|
84
|
+
idDocFiscal:
|
85
|
+
titulo: "ID Documento Fiscal"
|
86
|
+
descricao: ""
|
87
|
+
natOp:
|
88
|
+
titulo: "Natureza da Operação"
|
89
|
+
descricao: ""
|
90
|
+
tipoPagto:
|
91
|
+
titulo: "Tipo de Pagamento"
|
92
|
+
descricao: ""
|
93
|
+
modelo:
|
94
|
+
titulo: "Modelo"
|
95
|
+
descricao: ""
|
96
|
+
serie:
|
97
|
+
titulo: "Série"
|
98
|
+
descricao: ""
|
99
|
+
numero:
|
100
|
+
titulo: "Número"
|
101
|
+
descricao: ""
|
102
|
+
dtEmissao:
|
103
|
+
titulo: "Data de Emissão"
|
104
|
+
descricao: ""
|
105
|
+
dtES:
|
106
|
+
titulo: "dtES"
|
107
|
+
descricao: ""
|
108
|
+
dtPagto:
|
109
|
+
titulo: "dtPagto"
|
110
|
+
descricao: ""
|
111
|
+
cMunFG:
|
112
|
+
titulo: "cMunFG"
|
113
|
+
descricao: ""
|
114
|
+
refNFP:
|
115
|
+
titulo: "refNFP"
|
116
|
+
descricao: ""
|
117
|
+
refCTE:
|
118
|
+
titulo: "refCTE"
|
119
|
+
descricao: ""
|
120
|
+
refECF:
|
121
|
+
titulo: "refECF"
|
122
|
+
descricao: ""
|
123
|
+
tpImp:
|
124
|
+
titulo: "tpImp"
|
125
|
+
descricao: ""
|
126
|
+
tpEmis:
|
127
|
+
titulo: "tpEmis"
|
128
|
+
descricao: ""
|
129
|
+
cDV:
|
130
|
+
titulo: "cDV"
|
131
|
+
descricao: ""
|
132
|
+
tpAmb:
|
133
|
+
titulo: "Tipo de Ambiente"
|
134
|
+
descricao: ""
|
135
|
+
finNFe:
|
136
|
+
titulo: "Finalidade NF-e"
|
137
|
+
descricao: ""
|
138
|
+
procEmi:
|
139
|
+
titulo: "tpAmb"
|
140
|
+
descricao: ""
|
141
|
+
verProc:
|
142
|
+
titulo: "verProc"
|
143
|
+
descricao: ""
|
144
|
+
dhCont:
|
145
|
+
titulo: "dhCont"
|
146
|
+
descricao: ""
|
147
|
+
xJust:
|
148
|
+
titulo: "xJust"
|
149
|
+
descricao: ""
|
150
|
+
vNF:
|
151
|
+
titulo: "Valor NF-e"
|
152
|
+
descricao: ""
|
153
|
+
emitente:
|
154
|
+
titulo: "Emitente"
|
155
|
+
descricao: ""
|
156
|
+
<<: *pessoa
|
157
|
+
destinatario:
|
158
|
+
titulo: "Destinatário"
|
159
|
+
descricao: ""
|
160
|
+
<<: *pessoa
|
161
|
+
retirada:
|
162
|
+
titulo: "Retirada"
|
163
|
+
descricao: ""
|
164
|
+
entrega:
|
165
|
+
titulo: "Entrega"
|
166
|
+
descricao: ""
|
167
|
+
itensDocFiscal:
|
168
|
+
titulo: "Itens do Documento Fiscal"
|
169
|
+
descricao: ""
|
170
|
+
cdCSTICMS:
|
171
|
+
titulo: "cdCSTICMS"
|
172
|
+
descricao: ""
|
173
|
+
cdCSTIPI:
|
174
|
+
titulo: "cdCSTIPI"
|
175
|
+
descricao: ""
|
176
|
+
cdCSTPIS:
|
177
|
+
titulo: "cdCSTPIS"
|
178
|
+
descricao: ""
|
179
|
+
cdCSTCOFINS:
|
180
|
+
titulo: "cdCSTCOFINS"
|
181
|
+
descricao: ""
|
182
|
+
cdItemDocFiscal:
|
183
|
+
titulo: "cdItemDocFiscal"
|
184
|
+
descricao: ""
|
185
|
+
cdCfop:
|
186
|
+
titulo: "Código CFOP"
|
187
|
+
descricao: ""
|
188
|
+
unidade:
|
189
|
+
titulo: "unidade"
|
190
|
+
descricao: ""
|
191
|
+
qtItemDocFiscal:
|
192
|
+
titulo: "qtItemDocFiscal"
|
193
|
+
descricao: ""
|
194
|
+
vlUnitario:
|
195
|
+
titulo: "vlUnitario"
|
196
|
+
descricao: ""
|
197
|
+
vlTotalCI:
|
198
|
+
titulo: "vlTotalCI"
|
199
|
+
descricao: ""
|
200
|
+
vlTotal:
|
201
|
+
titulo: "vlTotal"
|
202
|
+
descricao: ""
|
203
|
+
qtTributariaUnidade:
|
204
|
+
titulo: "qtTributariaUnidade"
|
205
|
+
descricao: ""
|
206
|
+
qtTributaria:
|
207
|
+
titulo: "qtTributaria"
|
208
|
+
descricao: ""
|
209
|
+
vUnTrib:
|
210
|
+
titulo: "vUnTrib"
|
211
|
+
descricao: ""
|
212
|
+
vlFrete:
|
213
|
+
titulo: "vlFrete"
|
214
|
+
descricao: ""
|
215
|
+
vlSeguro:
|
216
|
+
titulo: "vlSeguro"
|
217
|
+
descricao: ""
|
218
|
+
vlDesconto:
|
219
|
+
titulo: "vlDesconto"
|
220
|
+
descricao: ""
|
221
|
+
vlOda:
|
222
|
+
titulo: "vlOda"
|
223
|
+
descricao: ""
|
224
|
+
DI:
|
225
|
+
titulo: "DI"
|
226
|
+
descricao: ""
|
227
|
+
xPed:
|
228
|
+
titulo: "xPed"
|
229
|
+
descricao: ""
|
230
|
+
nItemPed:
|
231
|
+
titulo: "nItemPed"
|
232
|
+
descricao: ""
|
233
|
+
cdClassificacao:
|
234
|
+
titulo: "cdClassificacao"
|
235
|
+
descricao: ""
|
236
|
+
deduzCFOP:
|
237
|
+
titulo: "deduzCFOP"
|
238
|
+
descricao: ""
|
239
|
+
deduzCSTICMS:
|
240
|
+
titulo: "deduzCSTICMS"
|
241
|
+
descricao: ""
|
242
|
+
deduzCSTPIS:
|
243
|
+
titulo: "deduzCSTPIS"
|
244
|
+
descricao: ""
|
245
|
+
deduzCSTCOFINS:
|
246
|
+
titulo: "deduzCSTCOFINS"
|
247
|
+
descricao: ""
|
248
|
+
deduzCSTIPI:
|
249
|
+
titulo: "deduzCSTIPI"
|
250
|
+
descricao: ""
|
251
|
+
prodItem:
|
252
|
+
titulo: "Produto"
|
253
|
+
descricao: ""
|
254
|
+
indTot:
|
255
|
+
titulo: "indTot"
|
256
|
+
descricao: ""
|
257
|
+
cEANTrib:
|
258
|
+
titulo: "cEANTrib"
|
259
|
+
descricao: ""
|
260
|
+
codigo:
|
261
|
+
titulo: "codigo"
|
262
|
+
descricao: ""
|
263
|
+
EAN:
|
264
|
+
titulo: "EAN"
|
265
|
+
descricao: ""
|
266
|
+
descricao:
|
267
|
+
titulo: "descricao"
|
268
|
+
descricao: ""
|
269
|
+
NCM:
|
270
|
+
titulo: "NCM"
|
271
|
+
descricao: ""
|
272
|
+
CEST:
|
273
|
+
titulo: "CEST"
|
274
|
+
descricao: ""
|
275
|
+
exTIPI:
|
276
|
+
titulo: "exTIPI"
|
277
|
+
descricao: ""
|
278
|
+
cdOrigem:
|
279
|
+
titulo: "cdOrigem"
|
280
|
+
descricao: ""
|
281
|
+
aplicacao:
|
282
|
+
titulo: "aplicacao"
|
283
|
+
descricao: ""
|
284
|
+
fabricacao:
|
285
|
+
titulo: "fabricacao"
|
286
|
+
descricao: ""
|
287
|
+
enquadramentos:
|
288
|
+
titulo: "Enquadramentos"
|
289
|
+
descricao: ""
|
290
|
+
tipoOperacao:
|
291
|
+
titulo: "Tipo de Operação"
|
292
|
+
descricao: ""
|
293
|
+
tpDocFiscal:
|
294
|
+
titulo: "Tipo de Documento Fiscal"
|
295
|
+
descricao: ""
|
296
|
+
naturezaOperacao:
|
297
|
+
titulo: "Natureza da Operação"
|
298
|
+
descricao: ""
|
299
|
+
tpCalculo:
|
300
|
+
titulo: "tpCalculo"
|
301
|
+
descricao: ""
|
data/lib/dfe_taxweb/version.rb
CHANGED
data/spec/dfe_taxweb_spec.rb
CHANGED
@@ -15,4 +15,26 @@ describe DfeTaxweb do
|
|
15
15
|
end
|
16
16
|
end
|
17
17
|
|
18
|
+
describe ".atributo" do
|
19
|
+
subject { described_class.atributo('emitente.cnpj') }
|
20
|
+
|
21
|
+
it "retorna uma instância de DfeTaxweb::Atributo com o conteúdo do cnpj do emitente" do
|
22
|
+
expect(subject).to be_a(DfeTaxweb::Atributo)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
describe ".atributos" do
|
27
|
+
subject { described_class.atributos}
|
28
|
+
|
29
|
+
it "retorna uma nova instância de DfeTaxweb::Nfe" do
|
30
|
+
expect(subject).to be_a(DfeTaxweb::Atributos)
|
31
|
+
end
|
32
|
+
|
33
|
+
it "retorna uma nova instância de DfeTaxweb::Nfe" do
|
34
|
+
emitente = subject.atributo('emitente')
|
35
|
+
expect(emitente).to be_a(DfeTaxweb::Atributo)
|
36
|
+
expect(emitente.titulo).to be_a(String)
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
18
40
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dfe-taxweb
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Bruno Porto
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-10-
|
11
|
+
date: 2017-10-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -81,6 +81,9 @@ extra_rdoc_files: []
|
|
81
81
|
files:
|
82
82
|
- lib/dfe-taxweb.rb
|
83
83
|
- lib/dfe_taxweb.rb
|
84
|
+
- lib/dfe_taxweb/atributo.rb
|
85
|
+
- lib/dfe_taxweb/atributos.rb
|
86
|
+
- lib/dfe_taxweb/atributos.yml
|
84
87
|
- lib/dfe_taxweb/conjunto.rb
|
85
88
|
- lib/dfe_taxweb/nfe.rb
|
86
89
|
- lib/dfe_taxweb/version.rb
|