mock_dfe 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +12 -0
- data/.rspec +3 -0
- data/.travis.yml +5 -0
- data/Gemfile +6 -0
- data/Gemfile.lock +47 -0
- data/LICENSE.txt +21 -0
- data/README.md +45 -0
- data/Rakefile +6 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/lib/mock_dfe.rb +25 -0
- data/lib/mock_dfe/dfes/nfe_400.rb +34 -0
- data/lib/mock_dfe/mock_dfe.rb +33 -0
- data/lib/mock_dfe/templates/nfe_4.00.json.erb +222 -0
- data/lib/mock_dfe/templates/nfe_4.00.xml.erb +25 -0
- data/lib/mock_dfe/version.rb +3 -0
- data/mock_dfe.gemspec +32 -0
- metadata +151 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: e8a4a2109aa89085f679b98f2540dcd086682f4b2b5e93a2dcf5a52aa03e9316
|
4
|
+
data.tar.gz: be5e444b0f3fefd635ced48fa286303397b6fce28d11e0a8974eda96beac6f2b
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 0a2b9cb451197068c4981bc26d4a29fe11698cc7a8d2ff2f430d8a486234f8ef0c35fe11ac4f75ce64b8891f63fcebb30dd2addff113b0941f69f666a5ff9be0
|
7
|
+
data.tar.gz: e76ae9674a713dc74ac620bf68f8cd5a331a93ec92607b9bed456d71b4e20e53e098dddd993928ac38924e77150787d9134318c99304a4a1c2ec37103d6d2430
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,47 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
mock_dfe (0.1.1)
|
5
|
+
cpf_cnpj (~> 0.2.0)
|
6
|
+
faker (~> 1.9, >= 1.9.0)
|
7
|
+
|
8
|
+
GEM
|
9
|
+
remote: https://rubygems.org/
|
10
|
+
specs:
|
11
|
+
concurrent-ruby (1.1.5)
|
12
|
+
cpf_cnpj (0.2.1)
|
13
|
+
diff-lcs (1.3)
|
14
|
+
faker (1.9.3)
|
15
|
+
i18n (>= 0.7)
|
16
|
+
i18n (1.6.0)
|
17
|
+
concurrent-ruby (~> 1.0)
|
18
|
+
mini_portile2 (2.4.0)
|
19
|
+
nokogiri (1.10.1)
|
20
|
+
mini_portile2 (~> 2.4.0)
|
21
|
+
rake (10.5.0)
|
22
|
+
rspec (3.8.0)
|
23
|
+
rspec-core (~> 3.8.0)
|
24
|
+
rspec-expectations (~> 3.8.0)
|
25
|
+
rspec-mocks (~> 3.8.0)
|
26
|
+
rspec-core (3.8.0)
|
27
|
+
rspec-support (~> 3.8.0)
|
28
|
+
rspec-expectations (3.8.2)
|
29
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
30
|
+
rspec-support (~> 3.8.0)
|
31
|
+
rspec-mocks (3.8.0)
|
32
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
33
|
+
rspec-support (~> 3.8.0)
|
34
|
+
rspec-support (3.8.0)
|
35
|
+
|
36
|
+
PLATFORMS
|
37
|
+
ruby
|
38
|
+
|
39
|
+
DEPENDENCIES
|
40
|
+
bundler (~> 1.16)
|
41
|
+
mock_dfe!
|
42
|
+
nokogiri (~> 1.8)
|
43
|
+
rake (~> 10.0)
|
44
|
+
rspec (~> 3.0)
|
45
|
+
|
46
|
+
BUNDLED WITH
|
47
|
+
1.16.2
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2019 TODO: Write your name
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,45 @@
|
|
1
|
+
# MockDfe
|
2
|
+
|
3
|
+
Generates XML examples of different Brazilian tax documents with random data.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
gem 'mock_dfe', :git => 'https://github.com/taxweb/mock_dfe.git', :branch => 'master'
|
11
|
+
```
|
12
|
+
|
13
|
+
And then execute:
|
14
|
+
|
15
|
+
$ bundle
|
16
|
+
|
17
|
+
## Usage
|
18
|
+
|
19
|
+
```
|
20
|
+
require 'mock_dfe'
|
21
|
+
MockDfe::Nfe.render #=> "Renders last version of NFe"
|
22
|
+
MockDfe::Nfe.render('4.00') #=> "Renders NFe version 4.00"
|
23
|
+
```
|
24
|
+
**Currently Available Documents and versions:**
|
25
|
+
|DFe|Version|
|
26
|
+
|:---:|:---:|
|
27
|
+
|NFe |4.00 |
|
28
|
+
## Development
|
29
|
+
|
30
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
31
|
+
|
32
|
+
### Todo:
|
33
|
+
- [ ] Add other DFe's and its versions (Nfe 1.00, Cte, NFSe...)
|
34
|
+
- [ ] Possibility of sending any params that will overwrite the randomly generated ones
|
35
|
+
|
36
|
+
\* Do NOT forget to add tests update the documentation for every new development
|
37
|
+
|
38
|
+
|
39
|
+
## Contributing
|
40
|
+
|
41
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/taxweb/mock_dfe.
|
42
|
+
|
43
|
+
## License
|
44
|
+
|
45
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "mock_dfe"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start(__FILE__)
|
data/bin/setup
ADDED
data/lib/mock_dfe.rb
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
require 'json'
|
2
|
+
require 'faker'
|
3
|
+
require 'cpf_cnpj'
|
4
|
+
require 'erb'
|
5
|
+
|
6
|
+
Dir["#{File.expand_path("../../", __FILE__)}/lib/mock_dfe/dfes/*.rb"].each { |file| require file }
|
7
|
+
|
8
|
+
require_relative 'mock_dfe/version'
|
9
|
+
require_relative 'mock_dfe/mock_dfe'
|
10
|
+
|
11
|
+
# method injection on the class Hash
|
12
|
+
class Hash
|
13
|
+
def to_xml
|
14
|
+
map do |k, v|
|
15
|
+
text = Hash === v ? v.to_xml : v
|
16
|
+
"<%s>%s</%s>" % [k, text, k] unless k[0] == '_'
|
17
|
+
end.join
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
COD_DA_UF = { RO: 11, AC: 12, AM: 13, RR: 14, PA: 15, AP: 16,
|
22
|
+
TO: 17, MA: 21, PI: 22, CE: 23, RN: 24, PB: 25,
|
23
|
+
PE: 26, AL: 27, SE: 28, BA: 29, MG: 31, ES: 32,
|
24
|
+
RJ: 33, SP: 35, PR: 41, SC: 42, RS: 43, MS: 50,
|
25
|
+
MT: 51, GO: 52, DF: 53 }.freeze
|
@@ -0,0 +1,34 @@
|
|
1
|
+
# template for NFe 4.00
|
2
|
+
class Nfe400
|
3
|
+
attr_reader :emit_date, :cUF, :AAMM, :CNPJ, :mod, :serie, :nNF, :tpEmis, :cNF, :cDV, :chave
|
4
|
+
|
5
|
+
def initialize
|
6
|
+
@emit_date = DateTime.parse(Faker::Date.backward(1825).to_s)
|
7
|
+
@cUF = COD_DA_UF.values.sample
|
8
|
+
@AAMM = @emit_date.strftime('%y%m')
|
9
|
+
@CNPJ = CNPJ.generate
|
10
|
+
@mod = '55'
|
11
|
+
@serie = '002'
|
12
|
+
@nNF = Faker::Number.between(1, 999_999_999).to_s.rjust(9, '0')
|
13
|
+
@tpEmis = '1'
|
14
|
+
@cNF = Faker::Number.number(8)
|
15
|
+
chave_sem_cdv = "#{@cUF}#{@AAMM}#{@CNPJ}#{@mod}#{@serie}#{@nNF}#{@tpEmis}#{@cNF}"
|
16
|
+
@cDV = calculate_cdv(chave_sem_cdv)
|
17
|
+
@chave = "#{chave_sem_cdv}#{@cDV}"
|
18
|
+
end
|
19
|
+
|
20
|
+
def calculate_cdv(chave)
|
21
|
+
soma = 0
|
22
|
+
multiplicador = 2
|
23
|
+
|
24
|
+
[*0..42].reverse_each do |i|
|
25
|
+
soma += (chave[i].to_i * multiplicador)
|
26
|
+
multiplicador += 1
|
27
|
+
multiplicador = 2 if multiplicador > 9
|
28
|
+
end
|
29
|
+
resto = soma % 11
|
30
|
+
digito_verificador = 11 - resto
|
31
|
+
digito_verificador = 0 if digito_verificador >= 10
|
32
|
+
digito_verificador
|
33
|
+
end
|
34
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
module MockDfe
|
2
|
+
class Nfe
|
3
|
+
class << self
|
4
|
+
def render(version = 'default')
|
5
|
+
template = render_template(version)
|
6
|
+
generate_xml(template)
|
7
|
+
end
|
8
|
+
|
9
|
+
private
|
10
|
+
|
11
|
+
def render_template(version)
|
12
|
+
case version
|
13
|
+
when '4.00', 'default'
|
14
|
+
@key_fields = Nfe400.new
|
15
|
+
json_erb = File.read("#{File.expand_path("../../", __FILE__)}/mock_dfe/templates/nfe_4.00.json.erb")
|
16
|
+
else
|
17
|
+
raise "There are no templates for NFe #{version}."
|
18
|
+
end
|
19
|
+
load_erb(json_erb)
|
20
|
+
end
|
21
|
+
|
22
|
+
def generate_xml(template)
|
23
|
+
@params = JSON.parse(template)
|
24
|
+
xml = File.read("#{File.expand_path("../../", __FILE__)}/mock_dfe/templates/nfe_4.00.xml.erb")
|
25
|
+
load_erb(xml)
|
26
|
+
end
|
27
|
+
|
28
|
+
def load_erb(template)
|
29
|
+
ERB.new(template).result(binding)
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,222 @@
|
|
1
|
+
{
|
2
|
+
"nfeProc": {
|
3
|
+
"NFe": {
|
4
|
+
"infNFe": {
|
5
|
+
"ide": {
|
6
|
+
"cUF": "<%= @key_fields.cUF %>",
|
7
|
+
"cNF": "<%= @key_fields.cNF %>",
|
8
|
+
"natOp": "<%= Faker::Lorem.sentence %>",
|
9
|
+
"mod": "<%= @key_fields.mod %>",
|
10
|
+
"serie": "<%= @key_fields.serie %>",
|
11
|
+
"nNF": "<%= @key_fields.nNF %>",
|
12
|
+
"dhEmi": "<%= @key_fields.emit_date%>",
|
13
|
+
"dhSaiEnt": "<%= @key_fields.emit_date%>",
|
14
|
+
"tpNF": "<%= Faker::Number.digit %>",
|
15
|
+
"idDest": "<%= Faker::Number.digit %>",
|
16
|
+
"cMunFG": "<%= Faker::Number.number(7) %>",
|
17
|
+
"tpImp": "<%= Faker::Number.digit %>",
|
18
|
+
"tpEmis": "<%= @key_fields.tpEmis %>",
|
19
|
+
"cDV": "<%= @key_fields.cDV %>",
|
20
|
+
"tpAmb": "<%= Faker::Number.digit %>",
|
21
|
+
"finNFe": "<%= Faker::Number.digit %>",
|
22
|
+
"indFinal": "<%= Faker::Number.digit %>",
|
23
|
+
"indPres": "<%= Faker::Number.digit %>",
|
24
|
+
"procEmi": "<%= Faker::Number.digit %>",
|
25
|
+
"verProc": "<%= Faker::Lorem.word %>"
|
26
|
+
},
|
27
|
+
"emit": {
|
28
|
+
<% nome = Faker::Company.name %>
|
29
|
+
"CNPJ": "<%= @key_fields.CNPJ %>",
|
30
|
+
"xNome": "<%= nome %>",
|
31
|
+
"xFant": "<%= nome %>",
|
32
|
+
"enderEmit": {
|
33
|
+
"xLgr": "<%= Faker::Address.street_name %>",
|
34
|
+
"nro": "<%= Faker::Number.number(3) %>",
|
35
|
+
"xBairro": "<%= Faker::Address.community %>>",
|
36
|
+
"cMun": "<%= Faker::Number.number(7) %>",
|
37
|
+
"xMun": "<%= Faker::Address.city %>",
|
38
|
+
"UF": "<%= Faker::Address.state_abbr %>",
|
39
|
+
"CEP": "<%= Faker::Number.number(8) %>",
|
40
|
+
"cPais": "<%= Faker::Number.number(4) %>",
|
41
|
+
"xPais": "<%= Faker::Address.country %>",
|
42
|
+
"fone": "<%= Faker::Number.number(10) %>"
|
43
|
+
},
|
44
|
+
"IE": "<%= Faker::Number.number(8) %>",
|
45
|
+
"CRT": "<%= Faker::Number.digit %>"
|
46
|
+
},
|
47
|
+
"dest": {
|
48
|
+
<% nome = Faker::Company.name %>
|
49
|
+
"CNPJ": "<% CNPJ.generate %>",
|
50
|
+
"xNome": "<%= nome %>",
|
51
|
+
"enderDest": {
|
52
|
+
"xLgr": "<%= Faker::Address.street_name %>",
|
53
|
+
"nro": "<%= Faker::Number.number(3) %>",
|
54
|
+
"xBairro": "<%= Faker::Address.community %>>",
|
55
|
+
"cMun": "<%= Faker::Number.number(7) %>",
|
56
|
+
"xMun": "<%= Faker::Address.city %>",
|
57
|
+
"UF": "<%= Faker::Address.state_abbr %>",
|
58
|
+
"CEP": "<%= Faker::Number.number(8) %>",
|
59
|
+
"cPais": "<%= Faker::Number.number(4) %>",
|
60
|
+
"xPais": "<%= Faker::Address.country %>",
|
61
|
+
"fone": "<%= Faker::Number.number(10) %>"
|
62
|
+
},
|
63
|
+
"indIEDest": "<%= Faker::Number.digit %>",
|
64
|
+
"IE": "<%= Faker::Number.number(8) %>",
|
65
|
+
"email": "<%= Faker::Internet.email %>"
|
66
|
+
},
|
67
|
+
"det": {
|
68
|
+
"prod": {
|
69
|
+
"cProd": "<%= Faker::Number.number(6) %>",
|
70
|
+
"cEAN": "<%= Faker::Lorem.sentence %>",
|
71
|
+
"xProd": "<%= Faker::Lorem.sentence %>",
|
72
|
+
"NCM": "<%= Faker::Number.number(8) %>",
|
73
|
+
"CEST": "<%= Faker::Number.number(7) %>",
|
74
|
+
"CFOP": "<%= Faker::Number.number(4) %>",
|
75
|
+
"uCom": "<%= Faker::Lorem.characters(2).upcase %>",
|
76
|
+
"qCom": "<%= Faker::Number.decimal(1, 4) %>",
|
77
|
+
"vUnCom": "<%= Faker::Number.decimal(4, 10) %>",
|
78
|
+
"vProd": "<%= Faker::Number.decimal(4, 2) %>",
|
79
|
+
"cEANTrib": "<%= Faker::Lorem.words(2).join(' ') %>",
|
80
|
+
"uTrib": "<%= Faker::Lorem.characters(2).upcase %>",
|
81
|
+
"qTrib": "<%= Faker::Number.decimal(1, 4) %>",
|
82
|
+
"vUnTrib": "<%= Faker::Number.positive %>",
|
83
|
+
"indTot": "<%= Faker::Number.digit %>",
|
84
|
+
"nFCI": "<%= Faker::Lorem.sentence %>",
|
85
|
+
"comb": {
|
86
|
+
"cProdANP": "<%= Faker::Number.number(9) %>",
|
87
|
+
"descANP": "<%= Faker::Lorem.word %>",
|
88
|
+
"qTemp": "<%= Faker::Number.decimal(1, 4) %>",
|
89
|
+
"UFCons": "<%= Faker::Address.state_abbr %>"
|
90
|
+
}
|
91
|
+
},
|
92
|
+
"imposto": {
|
93
|
+
"vTotTrib": "<%= Faker::Number.decimal(4, 2) %>",
|
94
|
+
"ICMS": {
|
95
|
+
"ICMS00": {
|
96
|
+
"orig": "<%= Faker::Number.digit %>",
|
97
|
+
"CST": "<%= Faker::Number.number(2) %>",
|
98
|
+
"modBC": "<%= Faker::Number.digit %>",
|
99
|
+
"vBC": "<%= Faker::Number.decimal(4, 2) %>",
|
100
|
+
"pICMS": "<%= Faker::Number.decimal(2) %>",
|
101
|
+
"vICMS": "<%= Faker::Number.decimal(4, 2) %>",
|
102
|
+
"pFCP": "<%= Faker::Number.decimal(1, 2) %>",
|
103
|
+
"vFCP": "<%= Faker::Number.decimal(3, 2) %>"
|
104
|
+
}
|
105
|
+
},
|
106
|
+
"IPI": {
|
107
|
+
"cEnq": "<%= Faker::Number.number(3) %>",
|
108
|
+
"IPITrib": {
|
109
|
+
"CST": "<%= Faker::Number.number(2) %>",
|
110
|
+
"vBC": "<%= Faker::Number.decimal(1, 2) %>",
|
111
|
+
"pIPI": "<%= Faker::Number.decimal(1, 2) %>",
|
112
|
+
"vIPI": "<%= Faker::Number.decimal(1, 2) %>"
|
113
|
+
}
|
114
|
+
},
|
115
|
+
"PIS": {
|
116
|
+
"PISAliq": {
|
117
|
+
"CST": "<%= Faker::Number.number(2) %>",
|
118
|
+
"vBC": "<%= Faker::Number.decimal(4, 2) %>",
|
119
|
+
"pPIS": "<%= Faker::Number.decimal(1, 2) %>",
|
120
|
+
"vPIS": "<%= Faker::Number.decimal(3, 2) %>"
|
121
|
+
}
|
122
|
+
},
|
123
|
+
"COFINS": {
|
124
|
+
"COFINSAliq": {
|
125
|
+
"CST": "<%= Faker::Number.number(2) %>",
|
126
|
+
"vBC": "<%= Faker::Number.decimal(4, 2) %>",
|
127
|
+
"pCOFINS": "<%= Faker::Number.decimal(1, 2) %>",
|
128
|
+
"vCOFINS": "<%= Faker::Number.decimal(3, 2) %>"
|
129
|
+
}
|
130
|
+
}
|
131
|
+
},
|
132
|
+
"infAdProd": "<%= Faker::Lorem.paragraph %>",
|
133
|
+
"_nItem": "1"
|
134
|
+
},
|
135
|
+
"total": {
|
136
|
+
"ICMSTot": {
|
137
|
+
"vBC": "<%= Faker::Number.decimal(4, 2) %>",
|
138
|
+
"vICMS": "<%= Faker::Number.decimal(4, 2) %>",
|
139
|
+
"vICMSDeson": "<%= Faker::Number.decimal(1, 2) %>",
|
140
|
+
"vFCP": "<%= Faker::Number.decimal(3, 2) %>",
|
141
|
+
"vBCST": "<%= Faker::Number.decimal(1, 2) %>",
|
142
|
+
"vST": "<%= Faker::Number.decimal(1, 2) %>",
|
143
|
+
"vFCPST": "<%= Faker::Number.decimal(1, 2) %>",
|
144
|
+
"vFCPSTRet": "<%= Faker::Number.decimal(1, 2) %>",
|
145
|
+
"vProd": "<%= Faker::Number.decimal(4, 2) %>",
|
146
|
+
"vFrete": "<%= Faker::Number.decimal(1, 2) %>",
|
147
|
+
"vSeg": "<%= Faker::Number.decimal(1, 2) %>",
|
148
|
+
"vDesc": "<%= Faker::Number.decimal(1, 2) %>",
|
149
|
+
"vII": "<%= Faker::Number.decimal(1, 2) %>",
|
150
|
+
"vIPI": "<%= Faker::Number.decimal(1, 2) %>",
|
151
|
+
"vIPIDevol": "<%= Faker::Number.decimal(1, 2) %>",
|
152
|
+
"vPIS": "<%= Faker::Number.decimal(3, 2) %>",
|
153
|
+
"vCOFINS": "<%= Faker::Number.decimal(3, 2) %>",
|
154
|
+
"vOutro": "<%= Faker::Number.decimal(1, 2) %>",
|
155
|
+
"vNF": "<%= Faker::Number.decimal(4, 2) %>",
|
156
|
+
"vTotTrib": "<%= Faker::Number.decimal(4, 2) %>"
|
157
|
+
}
|
158
|
+
},
|
159
|
+
"transp": {
|
160
|
+
"modFrete": "<%= Faker::Number.digit %>",
|
161
|
+
"transporta": {
|
162
|
+
"CNPJ": "<%= @key_fields.CNPJ %>",
|
163
|
+
"xNome": "<%= Faker::Company.name %>",
|
164
|
+
"IE": "<%= Faker::Number.number(8) %>",
|
165
|
+
"xEnder": "<%= Faker::Address.street_address %>",
|
166
|
+
"xMun": "<%= Faker::Address.city %>",
|
167
|
+
"UF": "<%= Faker::Address.state_abbr %>"
|
168
|
+
},
|
169
|
+
"vol": {
|
170
|
+
"qVol": "<%= Faker::Number.digit %>",
|
171
|
+
"esp": "VOLUME",
|
172
|
+
"nVol": "<%= Faker::Number.digit %>",
|
173
|
+
"pesoL": "<%= Faker::Number.decimal(3) %>",
|
174
|
+
"pesoB": "<%= Faker::Number.decimal(3) %>"
|
175
|
+
}
|
176
|
+
},
|
177
|
+
"cobr": {
|
178
|
+
"fat": {
|
179
|
+
"nFat": "<%= Faker::Number.number(6) %>",
|
180
|
+
"vOrig": "<%= Faker::Number.decimal(4, 2) %>",
|
181
|
+
"vDesc": "<%= Faker::Number.decimal(1, 2) %>",
|
182
|
+
"vLiq": "<%= Faker::Number.decimal(4, 2) %>"
|
183
|
+
},
|
184
|
+
"dup": {
|
185
|
+
"nDup": "<%= Faker::Number.number(3) %>",
|
186
|
+
"dVenc": "<%= Faker::Date.backward(1825).strftime('%Y-%m-%d') %>",
|
187
|
+
"vDup": "<%= Faker::Number.decimal(4, 2) %>"
|
188
|
+
}
|
189
|
+
},
|
190
|
+
"pag": {
|
191
|
+
"detPag": {
|
192
|
+
"tPag": "<%= Faker::Number.number(2) %>",
|
193
|
+
"vPag": "<%= Faker::Number.decimal(4, 2) %>"
|
194
|
+
}
|
195
|
+
},
|
196
|
+
"infAdic": {
|
197
|
+
"infAdFisco": "<%= Faker::Lorem.sentence %>",
|
198
|
+
"infCpl": "<%= Faker::Lorem.paragraph %>"
|
199
|
+
},
|
200
|
+
"_Id": "NFe<%=@key_fields.chave%>",
|
201
|
+
"_versao": "4.00"
|
202
|
+
},
|
203
|
+
"_xmlns": "http://www.portalfiscal.inf.br/nfe"
|
204
|
+
},
|
205
|
+
"protNFe": {
|
206
|
+
"infProt": {
|
207
|
+
"tpAmb": "<%= Faker::Number.digit %>",
|
208
|
+
"verAplic": "<%= Faker::Lorem.characters(16).upcase %>",
|
209
|
+
"chNFe": "<%= @key_fields.chave %>",
|
210
|
+
"dhRecbto": "2019-01-28T12:02:56-02:00",
|
211
|
+
"nProt": "<%= Faker::Number.number(15) %>",
|
212
|
+
"digVal": "<%= Faker::Lorem.characters(29) %>",
|
213
|
+
"cStat": "<%= Faker::Number.number(3) %>",
|
214
|
+
"xMotivo": "Autorizado o uso da NF-e"
|
215
|
+
},
|
216
|
+
"_xmlns": "http://www.portalfiscal.inf.br/nfe",
|
217
|
+
"_versao": "4.00"
|
218
|
+
},
|
219
|
+
"_xmlns": "http://www.portalfiscal.inf.br/nfe",
|
220
|
+
"_versao": "4.00"
|
221
|
+
}
|
222
|
+
}
|
@@ -0,0 +1,25 @@
|
|
1
|
+
<nfeProc versao="<%= @params["nfeProc"]["_versao"] %>" xmlns="<%= @params["nfeProc"]["_xmlns"] %>">
|
2
|
+
<NFe xmlns="<%= @params["nfeProc"]["NFe"]["_xmlns"] %>">
|
3
|
+
<% inf_nfe = @params["nfeProc"]["NFe"]["infNFe"]%>
|
4
|
+
<infNFe Id="<%= inf_nfe["_Id"] %>" versao="<%= inf_nfe["_versao"]%>">
|
5
|
+
<ide> <%= inf_nfe["ide"].to_xml %> </ide>
|
6
|
+
<emit> <%= inf_nfe["emit"].to_xml %> </emit>
|
7
|
+
<dest> <%= inf_nfe["dest"].to_xml %> </dest>
|
8
|
+
<det nItem="<%= inf_nfe["det"]["_nItem"] %>" >
|
9
|
+
<%det = inf_nfe["det"] %>
|
10
|
+
<prod> <%= det["prod"].to_xml %> </prod>
|
11
|
+
<imposto> <%= det["imposto"].to_xml %> </imposto>
|
12
|
+
<infAdProd> <%= det["infAdProd"] %> </infAdProd>
|
13
|
+
</det>
|
14
|
+
<total> <%= inf_nfe["total"].to_xml %> </total>
|
15
|
+
<transp> <%= inf_nfe["transp"].to_xml %> </transp>
|
16
|
+
<cobr> <%= inf_nfe["cobr"].to_xml %> </cobr>
|
17
|
+
<pag> <%= inf_nfe["pag"].to_xml %> </pag>
|
18
|
+
<infAdic> <%= inf_nfe["infAdic"].to_xml %> </infAdic>
|
19
|
+
</infNFe>
|
20
|
+
</NFe>
|
21
|
+
<% prot_nfe = @params["nfeProc"]["protNFe"]%>
|
22
|
+
<protNFe versao="<%= prot_nfe["_versao"]%>" xmlns="<%= prot_nfe["_xmlns"]%>">
|
23
|
+
<%= prot_nfe.to_xml %>
|
24
|
+
</protNFe>
|
25
|
+
</nfeProc>
|
data/mock_dfe.gemspec
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
|
2
|
+
lib = File.expand_path("../lib", __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require "mock_dfe/version"
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "mock_dfe"
|
8
|
+
spec.version = MockDfe::VERSION
|
9
|
+
spec.authors = ["Carlos Palha"]
|
10
|
+
spec.email = ["carlao_epalha@hotmail.com"]
|
11
|
+
|
12
|
+
spec.summary = %q{Generates Mock DFe data.}
|
13
|
+
spec.description = %q{Generates Xml examples of different Brazilian tax documents. }
|
14
|
+
spec.homepage = "https://github.com/taxweb/mock_dfe"
|
15
|
+
spec.license = "MIT"
|
16
|
+
|
17
|
+
# Specify which files should be added to the gem when it is released.
|
18
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
19
|
+
spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
|
20
|
+
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
21
|
+
end
|
22
|
+
spec.bindir = "exe"
|
23
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
24
|
+
spec.require_paths = ["lib"]
|
25
|
+
|
26
|
+
spec.add_development_dependency "bundler", "~> 1.16"
|
27
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
28
|
+
spec.add_development_dependency "rspec", "~> 3.0"
|
29
|
+
spec.add_development_dependency 'nokogiri', '~> 1.8'
|
30
|
+
spec.add_runtime_dependency 'faker', '~> 1.9', '>= 1.9.0'
|
31
|
+
spec.add_dependency 'cpf_cnpj', '~> 0.2.0'
|
32
|
+
end
|
metadata
ADDED
@@ -0,0 +1,151 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: mock_dfe
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Carlos Palha
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2019-03-20 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.16'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.16'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rspec
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '3.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '3.0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: nokogiri
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '1.8'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '1.8'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: faker
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '1.9'
|
76
|
+
- - ">="
|
77
|
+
- !ruby/object:Gem::Version
|
78
|
+
version: 1.9.0
|
79
|
+
type: :runtime
|
80
|
+
prerelease: false
|
81
|
+
version_requirements: !ruby/object:Gem::Requirement
|
82
|
+
requirements:
|
83
|
+
- - "~>"
|
84
|
+
- !ruby/object:Gem::Version
|
85
|
+
version: '1.9'
|
86
|
+
- - ">="
|
87
|
+
- !ruby/object:Gem::Version
|
88
|
+
version: 1.9.0
|
89
|
+
- !ruby/object:Gem::Dependency
|
90
|
+
name: cpf_cnpj
|
91
|
+
requirement: !ruby/object:Gem::Requirement
|
92
|
+
requirements:
|
93
|
+
- - "~>"
|
94
|
+
- !ruby/object:Gem::Version
|
95
|
+
version: 0.2.0
|
96
|
+
type: :runtime
|
97
|
+
prerelease: false
|
98
|
+
version_requirements: !ruby/object:Gem::Requirement
|
99
|
+
requirements:
|
100
|
+
- - "~>"
|
101
|
+
- !ruby/object:Gem::Version
|
102
|
+
version: 0.2.0
|
103
|
+
description: 'Generates Xml examples of different Brazilian tax documents. '
|
104
|
+
email:
|
105
|
+
- carlao_epalha@hotmail.com
|
106
|
+
executables: []
|
107
|
+
extensions: []
|
108
|
+
extra_rdoc_files: []
|
109
|
+
files:
|
110
|
+
- ".gitignore"
|
111
|
+
- ".rspec"
|
112
|
+
- ".travis.yml"
|
113
|
+
- Gemfile
|
114
|
+
- Gemfile.lock
|
115
|
+
- LICENSE.txt
|
116
|
+
- README.md
|
117
|
+
- Rakefile
|
118
|
+
- bin/console
|
119
|
+
- bin/setup
|
120
|
+
- lib/mock_dfe.rb
|
121
|
+
- lib/mock_dfe/dfes/nfe_400.rb
|
122
|
+
- lib/mock_dfe/mock_dfe.rb
|
123
|
+
- lib/mock_dfe/templates/nfe_4.00.json.erb
|
124
|
+
- lib/mock_dfe/templates/nfe_4.00.xml.erb
|
125
|
+
- lib/mock_dfe/version.rb
|
126
|
+
- mock_dfe.gemspec
|
127
|
+
homepage: https://github.com/taxweb/mock_dfe
|
128
|
+
licenses:
|
129
|
+
- MIT
|
130
|
+
metadata: {}
|
131
|
+
post_install_message:
|
132
|
+
rdoc_options: []
|
133
|
+
require_paths:
|
134
|
+
- lib
|
135
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
136
|
+
requirements:
|
137
|
+
- - ">="
|
138
|
+
- !ruby/object:Gem::Version
|
139
|
+
version: '0'
|
140
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
141
|
+
requirements:
|
142
|
+
- - ">="
|
143
|
+
- !ruby/object:Gem::Version
|
144
|
+
version: '0'
|
145
|
+
requirements: []
|
146
|
+
rubyforge_project:
|
147
|
+
rubygems_version: 2.7.3
|
148
|
+
signing_key:
|
149
|
+
specification_version: 4
|
150
|
+
summary: Generates Mock DFe data.
|
151
|
+
test_files: []
|