br_danfe 0.7.5 → 0.7.6

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
- SHA1:
3
- metadata.gz: be0d6e9558d5b847f53c00cade4b70ddb70ad4a0
4
- data.tar.gz: d8bc73c774cc349271de9ea30a0dce444da770de
2
+ SHA256:
3
+ metadata.gz: e797a591ec546eec11cfbc4c29dbfa70150e923f9bac9783fa780208627534b5
4
+ data.tar.gz: 7e7874ef1ecab1a069a94776ca52f3f716e8b94c1ecb9a16198dfaf7557dccf0
5
5
  SHA512:
6
- metadata.gz: cbe1f22e327d37ca9407ef1694cfb9bfce6ff7975cc06e74ad8cc97c39689dafd7937fe5dbe9386738f7b66e2ed85b3e3a8ea1ddb297b397603d41b090795069
7
- data.tar.gz: ba71d07555ab5cc042d9e1e47593ac824d03cdfc21a2f61e74b142ded20e10ed2261682b4c572b82048ee8bb7ecdffd026b7955749c47eca0960e76f079550f8
6
+ metadata.gz: 445cd9a8904be6c4af9b646554541f6ac4d4b3f7a848c923ec32c1d758512a9c5cff528b16fb23e6832aaa35db0f2e7a6824d03019c9cc0b4de3a2cb74392292
7
+ data.tar.gz: 740084d68b2a60cac9258cd5d070ff64db8ec050936daa900d078812dfd468981d46c362ccea5b51114cbceaea7f0662f03f6501f9e77ba8050de1357b912dac
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- br_danfe (0.7.5)
4
+ br_danfe (0.7.6)
5
5
  barby (= 0.5.1)
6
6
  br_documents (>= 0.0.15)
7
7
  i18n (= 0.8.6)
@@ -105,6 +105,7 @@ 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
109
  ICMS:
109
110
  CST: "CST"
110
111
  vBC: "BC ICMS"
@@ -9,39 +9,52 @@ module BrDanfe
9
9
  xprod = "#{@det.css('prod/xProd').text}"
10
10
 
11
11
  xprod += infAdProd if has_infAdProd?
12
- xprod += fci if has_fci?
13
- xprod += st if has_st?
12
+ xprod += fci if fci?
13
+ xprod += st if st?
14
+ xprod += fcp if fcp?
14
15
 
15
16
  xprod
16
17
  end
17
18
 
18
19
  private
19
- def has_infAdProd?
20
- !@det.css("infAdProd").text.empty?
21
- end
22
20
 
23
- def has_fci?
24
- !@det.css("prod/nFCI").text.empty?
21
+ def infAdProd
22
+ "\n#{@det.css('infAdProd').text}"
25
23
  end
26
24
 
27
- def has_st?
28
- @det.css("ICMS/*/vBCST").text.to_i > 0
25
+ def has_infAdProd?
26
+ !@det.css("infAdProd").text.empty?
29
27
  end
30
28
 
31
- def infAdProd
32
- "\n" + @det.css("infAdProd").text
29
+ def fci
30
+ "\n#{I18n.t('danfe.det.prod.xProdFCI',
31
+ nFCI: @det.css('prod/nFCI').text)}"
33
32
  end
34
33
 
35
- def fci
36
- "\n" + I18n.t("danfe.det.prod.xProdFCI", nFCI: @det.css('prod/nFCI').text)
34
+ def fci?
35
+ !@det.css('prod/nFCI').text.empty?
37
36
  end
38
37
 
39
38
  def st
40
- "\n" + I18n.t("danfe.det.prod.xProdST",
39
+ "\n#{I18n.t('danfe.det.prod.xProdST',
41
40
  pMVAST: Helper.numerify(@det.css('ICMS/*/pMVAST').text),
42
41
  pICMSST: Helper.numerify(@det.css('ICMS/*/pICMSST').text),
43
42
  vBCST: Helper.numerify(@det.css('ICMS/*/vBCST').text),
44
- vICMSST: Helper.numerify(@det.css('ICMS/*/vICMSST').text))
43
+ vICMSST: Helper.numerify(@det.css('ICMS/*/vICMSST').text))}"
44
+ end
45
+
46
+ def st?
47
+ @det.css("ICMS/*/vBCST").text.to_i > 0
48
+ end
49
+
50
+ def fcp
51
+ "\n#{I18n.t('danfe.det.prod.xProdFCP',
52
+ vFCP: Helper.numerify(@det.css('ICMS00/vFCP').text),
53
+ pFCP: Helper.numerify(@det.css('ICMS00/pFCP').text))}"
54
+ end
55
+
56
+ def fcp?
57
+ @det.css("ICMS00/vFCP").text.to_i > 0
45
58
  end
46
59
  end
47
60
  end
@@ -1,3 +1,3 @@
1
1
  module BrDanfe
2
- VERSION = '0.7.5'.freeze
2
+ VERSION = '0.7.6'.freeze
3
3
  end
@@ -88,7 +88,38 @@ describe BrDanfe::DanfeLib::Xprod do
88
88
  end
89
89
  end
90
90
 
91
- context "when have FCI + ST + infAdProd" do
91
+ context "when have FCP" do
92
+ let(:xml_fcp) do
93
+ xml = <<-eos
94
+ <det nItem="1">
95
+ <prod>
96
+ <xProd>MONITOR DE ARCO ELETRICO</xProd>
97
+ </prod>
98
+ <imposto>
99
+ <vTotTrib>23.56</vTotTrib>
100
+ <ICMS00>
101
+ <vFCP>4.71</vFCP>
102
+ <pFCP>2.00</pFCP>
103
+ </ICMS>
104
+ </imposto>
105
+ </det>
106
+ eos
107
+
108
+ Nokogiri::XML(xml)
109
+ end
110
+
111
+ subject { BrDanfe::DanfeLib::Xprod.new(xml_fcp) }
112
+
113
+ it "returns product + FCP" do
114
+ expected = "MONITOR DE ARCO ELETRICO"
115
+ expected += "\n"
116
+ expected += "FCP: Alíq: 2,00% * Vlr: 4,71"
117
+
118
+ expect(subject.render).to eq expected
119
+ end
120
+ end
121
+
122
+ context "when have FCI + ST + infAdProd + FCP" do
92
123
  let(:xml_IFC_ST_infAdProd) do
93
124
  xml = <<-eos
94
125
  <det nItem="1">
@@ -106,6 +137,10 @@ describe BrDanfe::DanfeLib::Xprod do
106
137
  <vICMSST>29.28</vICMSST>
107
138
  </ICMSSN202>
108
139
  </ICMS>
140
+ <ICMS00>
141
+ <vFCP>4.71</vFCP>
142
+ <pFCP>2.00</pFCP>
143
+ </ICMS>
109
144
  </imposto>
110
145
  <infAdProd>Informações adicionais do produto</infAdProd>
111
146
  </det>
@@ -124,6 +159,8 @@ describe BrDanfe::DanfeLib::Xprod do
124
159
  expected +="FCI: 12232531-74B2-4FDD-87A6-CF0AD3E55386"
125
160
  expected += "\n"
126
161
  expected += "ST: MVA: 56,00% * Alíq: 17,00% * BC: 479,82 * Vlr: 29,28"
162
+ expected += "\n"
163
+ expected += "FCP: Alíq: 2,00% * Vlr: 4,71"
127
164
 
128
165
  expect(subject.render).to eq expected
129
166
  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.5
4
+ version: 0.7.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - ASSEINFO
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-09-04 00:00:00.000000000 Z
11
+ date: 2018-09-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: barby
@@ -368,7 +368,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
368
368
  version: '0'
369
369
  requirements: []
370
370
  rubyforge_project:
371
- rubygems_version: 2.4.5.4
371
+ rubygems_version: 2.7.6
372
372
  signing_key:
373
373
  specification_version: 4
374
374
  summary: DANFE pdf generator for Brazilian invoices.