br_danfe 0.7.7 → 0.8.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2e1f4f292bdbde6c761b111ff0dec61b4d9de9f8dc63880ce20e4a08a7db1568
4
- data.tar.gz: c003eb4a660ca9211ff3fc3440757f60290ad64f5285cf9a17ae42045fb4ab0b
3
+ metadata.gz: dbfc9d821dc664401714b3611cfc696aa2b569b2f8aeaa11469511c27bff85f0
4
+ data.tar.gz: 14218c179db89c175265117bebd5332a8110a92a3fa5722631ac54f74d8f4849
5
5
  SHA512:
6
- metadata.gz: 768f790b05abc78e00af3304db2a51678e4c3fb7432291b5e8207af2bd61c09d2a287c906598f94e91d7eddda97bd14099e70161303dc81dc55547c1efb76a42
7
- data.tar.gz: '01788ddf78bc372eff580b8cbdc66ccf32e0db8bc90bf296090495491398d662bd4932d3831329d381998c9bc2f262f16fd2161b523686243dbf5f1df70bbef1'
6
+ metadata.gz: 9b9024776b1b7f0a7302bed95c225254c55086c5df53d35ae75ef50a8f79c6f1fe36d2c65173ec426004fe3d7692d23626f6d8ea9b3875505c17073b627a3e53
7
+ data.tar.gz: 1c6e82f74f8f3a29f07a0a5eaf718ccdac50bb82893fa5f5c2dc10209f25ae1295b5512c82f7a6d0e51e2a32d7a32c1eaf0f83c107357c77051944af4a85741e
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- br_danfe (0.7.7)
4
+ br_danfe (0.8.0)
5
5
  barby (= 0.5.1)
6
6
  br_documents (>= 0.0.15)
7
7
  i18n (= 0.8.6)
@@ -84,4 +84,4 @@ DEPENDENCIES
84
84
  simplecov-html (= 0.10.1)
85
85
 
86
86
  BUNDLED WITH
87
- 1.17.2
87
+ 1.16.3
@@ -105,7 +105,9 @@ pt-BR:
105
105
  vProd: "VL TOTAL"
106
106
  xProdST: "ST: MVA: %{pMVAST}% * Alíq: %{pICMSST}% * BC: %{vBCST} * Vlr: %{vICMSST}"
107
107
  xProdFCI: "FCI: %{nFCI}"
108
- xProdFCP: "FCP: Alíq: %{pFCP}% * Vlr: %{vFCP}"
108
+ xProdFCP: "FCP: Base: %{vBCFCP} * Alíq: %{pFCP}% * Vlr: %{vFCP}"
109
+ xProdFCPICMS00: "FCP: Alíq: %{pFCP}% * Vlr: %{vFCP}"
110
+ xProdFCPST: "FCP ST: Base: %{vBCFCPST} * Alíq: %{pFCPST}% * Vlr: %{vFCPST}"
109
111
  ICMS:
110
112
  CST: "CST"
111
113
  vBC: "BC ICMS"
@@ -10,8 +10,9 @@ module BrDanfe
10
10
 
11
11
  xprod += infAdProd if has_infAdProd?
12
12
  xprod += fci if fci?
13
- xprod += st if st?
13
+ xprod += icms_st if icms_st?
14
14
  xprod += fcp if fcp?
15
+ xprod += fcp_st if fcp_st?
15
16
 
16
17
  xprod
17
18
  end
@@ -35,7 +36,7 @@ module BrDanfe
35
36
  !@det.css('prod/nFCI').text.empty?
36
37
  end
37
38
 
38
- def st
39
+ def icms_st
39
40
  "\n#{I18n.t('danfe.det.prod.xProdST',
40
41
  pMVAST: Helper.numerify(@det.css('ICMS/*/pMVAST').text),
41
42
  pICMSST: Helper.numerify(@det.css('ICMS/*/pICMSST').text),
@@ -43,18 +44,44 @@ module BrDanfe
43
44
  vICMSST: Helper.numerify(@det.css('ICMS/*/vICMSST').text))}"
44
45
  end
45
46
 
46
- def st?
47
- @det.css("ICMS/*/vBCST").text.to_i > 0
47
+ def icms_st?
48
+ @det.css('ICMS/*/vBCST').text.to_i > 0
49
+ end
50
+
51
+ def fcp?
52
+ @det.css('ICMS/*/vFCP').text.to_i > 0
48
53
  end
49
54
 
50
55
  def fcp
51
- "\n#{I18n.t('danfe.det.prod.xProdFCP',
56
+ icms00? ? fcp_for_icms00 : fcp_complete
57
+ end
58
+
59
+ def icms00?
60
+ @det.at_css('ICMS00')
61
+ end
62
+
63
+ def fcp_for_icms00
64
+ "\n#{I18n.t('danfe.det.prod.xProdFCPICMS00',
52
65
  vFCP: Helper.numerify(@det.css('ICMS00/vFCP').text),
53
66
  pFCP: Helper.numerify(@det.css('ICMS00/pFCP').text))}"
54
67
  end
55
68
 
56
- def fcp?
57
- @det.css("ICMS00/vFCP").text.to_i > 0
69
+ def fcp_complete
70
+ "\n#{I18n.t('danfe.det.prod.xProdFCP',
71
+ vBCFCP: Helper.numerify(@det.css('ICMS/*/vBCFCP').text),
72
+ vFCP: Helper.numerify(@det.css('ICMS/*/vFCP').text),
73
+ pFCP: Helper.numerify(@det.css('ICMS/*/pFCP').text))}"
74
+ end
75
+
76
+ def fcp_st?
77
+ @det.css('ICMS/*/vFCPST').text.to_i > 0
78
+ end
79
+
80
+ def fcp_st
81
+ "\n#{I18n.t('danfe.det.prod.xProdFCPST',
82
+ vBCFCPST: Helper.numerify(@det.css('ICMS/*/vBCFCPST').text),
83
+ pFCPST: Helper.numerify(@det.css('ICMS/*/pFCPST').text),
84
+ vFCPST: Helper.numerify(@det.css('ICMS/*/vFCPST').text))}"
58
85
  end
59
86
  end
60
87
  end
@@ -1,3 +1,3 @@
1
1
  module BrDanfe
2
- VERSION = '0.7.7'.freeze
2
+ VERSION = '0.8.0'.freeze
3
3
  end
@@ -88,7 +88,7 @@ describe BrDanfe::DanfeLib::Xprod do
88
88
  end
89
89
  end
90
90
 
91
- context "when have FCP" do
91
+ context "when have FCP on ICMS00 tag" do
92
92
  let(:xml_fcp) do
93
93
  xml = <<-eos
94
94
  <det nItem="1">
@@ -97,9 +97,11 @@ describe BrDanfe::DanfeLib::Xprod do
97
97
  </prod>
98
98
  <imposto>
99
99
  <vTotTrib>23.56</vTotTrib>
100
- <ICMS00>
101
- <vFCP>4.71</vFCP>
102
- <pFCP>2.00</pFCP>
100
+ <ICMS>
101
+ <ICMS00>
102
+ <vFCP>4.71</vFCP>
103
+ <pFCP>2.00</pFCP>
104
+ </ICMS00>
103
105
  </ICMS>
104
106
  </imposto>
105
107
  </det>
@@ -136,10 +138,10 @@ describe BrDanfe::DanfeLib::Xprod do
136
138
  <pICMSST>17.00</pICMSST>
137
139
  <vICMSST>29.28</vICMSST>
138
140
  </ICMSSN202>
139
- </ICMS>
140
- <ICMS00>
141
- <vFCP>4.71</vFCP>
142
- <pFCP>2.00</pFCP>
141
+ <ICMS00>
142
+ <vFCP>4.71</vFCP>
143
+ <pFCP>2.00</pFCP>
144
+ </ICMS00>
143
145
  </ICMS>
144
146
  </imposto>
145
147
  <infAdProd>Informações adicionais do produto</infAdProd>
@@ -165,5 +167,73 @@ describe BrDanfe::DanfeLib::Xprod do
165
167
  expect(subject.render).to eq expected
166
168
  end
167
169
  end
170
+
171
+ context "when FCP is not in a ICMS00 tag" do
172
+ let(:xml_fcp) do
173
+ xml = <<-eos
174
+ <det nItem="1">
175
+ <prod>
176
+ <xProd>MONITOR DE ARCO ELETRICO</xProd>
177
+ </prod>
178
+ <imposto>
179
+ <vTotTrib>23.56</vTotTrib>
180
+ <ICMS>
181
+ <ICMS10>
182
+ <vBCFCP>235.50</vBCFCP>
183
+ <vFCP>4.71</vFCP>
184
+ <pFCP>2.00</pFCP>
185
+ </ICMS10>
186
+ </ICMS>
187
+ </imposto>
188
+ </det>
189
+ eos
190
+
191
+ Nokogiri::XML(xml)
192
+ end
193
+
194
+ subject { BrDanfe::DanfeLib::Xprod.new(xml_fcp) }
195
+
196
+ it "returns product + FCP" do
197
+ expected = "MONITOR DE ARCO ELETRICO"
198
+ expected += "\n"
199
+ expected += "FCP: Base: 235,50 * Alíq: 2,00% * Vlr: 4,71"
200
+
201
+ expect(subject.render).to eq expected
202
+ end
203
+ end
204
+
205
+ context "when have FCP ST" do
206
+ let(:xml_fcp) do
207
+ xml = <<-eos
208
+ <det nItem="1">
209
+ <prod>
210
+ <xProd>MONITOR DE ARCO ELETRICO</xProd>
211
+ </prod>
212
+ <imposto>
213
+ <vTotTrib>23.56</vTotTrib>
214
+ <ICMS>
215
+ <ICMS30>
216
+ <vBCFCPST>235.50</vBCFCPST>
217
+ <vFCPST>4.71</vFCPST>
218
+ <pFCPST>2.00</pFCPST>
219
+ </ICMS30>
220
+ </ICMS>
221
+ </imposto>
222
+ </det>
223
+ eos
224
+
225
+ Nokogiri::XML(xml)
226
+ end
227
+
228
+ subject { BrDanfe::DanfeLib::Xprod.new(xml_fcp) }
229
+
230
+ it "returns product + FCP" do
231
+ expected = "MONITOR DE ARCO ELETRICO"
232
+ expected += "\n"
233
+ expected += "FCP ST: Base: 235,50 * Alíq: 2,00% * Vlr: 4,71"
234
+
235
+ expect(subject.render).to eq expected
236
+ end
237
+ end
168
238
  end
169
239
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: br_danfe
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.7
4
+ version: 0.8.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - ASSEINFO
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-01-30 00:00:00.000000000 Z
11
+ date: 2019-03-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: barby