dfe-taxweb 0.1.6 → 0.1.8

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 7dfd3421bd1352da0283e6f30d27248b71b8d972
4
- data.tar.gz: de16da6ca8d3a84c45ff8c983b0e9a3f4cfef496
3
+ metadata.gz: 04578d76f2e2874c717a6516be650500ff59d932
4
+ data.tar.gz: 8551007d00921f82180aa3bb7f1381d0f0744659
5
5
  SHA512:
6
- metadata.gz: c3875372eaa0119b60fabb1ed7162499bdd6fbce2bf32fb80e9afccea8f839ba84f397f5a5a29f193a7d95fd4e28b9e42a01a22d44b0fdd373417d3744027d93
7
- data.tar.gz: f107d6237c372b526d4fd0878a38656106f6224094163182fcdaac4c76b87728adb5cbfb4a5d74f19860dad71d86b64ebd6580449ee3fbc2bb153690536d4772
6
+ metadata.gz: a0516763eb2fedcfc853b8934d928c1f28d2c6d8dcbe117437e329b201aa0fd55c52c991ce97d9374ce246cdaa266c906c4fee403c73becd9e47c6d8b012fa66
7
+ data.tar.gz: 37fe93c6574b989dc9cac0ae8f27f4efba3551ab8fb8dfdf0ac8a7e147a6301561ca8acde43f14017adee8c887ed6652ffcb2736321f9034617e8c449d07d860
@@ -41,6 +41,7 @@ module DfeTaxweb
41
41
  dhCont: inf_nfe.atributo('ide.dhCont'),
42
42
  xJust: inf_nfe.atributo('ide.xJust'),
43
43
  vNF: inf_nfe.atributo('total.ICMSTot.vNF'),
44
+ indConsumidorFinal: (inf_nfe.atributo('ide.indFinal') == '1' ? 'S' : 'N'),
44
45
  emitente: emitente,
45
46
  destinatario: destinatario,
46
47
  retirada: retirada,
@@ -55,6 +56,8 @@ module DfeTaxweb
55
56
  def emitente
56
57
  emit = inf_nfe.atributo('emit')
57
58
  endereco = endereco(emit.atributo('enderEmit'))
59
+ cnae = emit.atributo('CNAE')
60
+ contribuinte_ipi = cnae && cnae =~ /^[123]/ ? 'S' : 'N'
58
61
  {
59
62
  cnpj: emit.atributo('CNPJ'),
60
63
  cpf: emit.atributo('CPF'),
@@ -63,9 +66,9 @@ module DfeTaxweb
63
66
  inscricaoEstadual: emit.atributo('IE'),
64
67
  IEST: emit.atributo('IEST'),
65
68
  inscricaoMunicipal: emit.atributo('IM'),
66
- cdAtividadeEconomica: emit.atributo('CNAE'),
69
+ cdAtividadeEconomica: cnae,
67
70
  contribuinteICMS: emit.atributo('IE') ? 'S' : 'N',
68
- # contribuinteIPI: emit.atributo('IE') ? 'S' : 'N',
71
+ contribuinteIPI: contribuinte_ipi,
69
72
  contribuinteST: emit.atributo('IEST') ? 'S' : 'N',
70
73
  contribuinteISS: emit.atributo('IM') ? 'S' : 'N',
71
74
  contribuintePIS: emit.atributo('CNPJ') ? 'S' : 'N',
@@ -83,8 +86,7 @@ module DfeTaxweb
83
86
  cpf: dest.atributo('CPF'),
84
87
  nome: dest.atributo('xNome'),
85
88
  inscricaoEstadual: dest.atributo('IE'),
86
- contribuinteICMS: dest.atributo('IE') ? 'S' : 'N',
87
- # contribuinteIPI: dest.atributo('IE') ? 'S' : 'N',
89
+ contribuinteICMS: dest_contribuinte_icms?,
88
90
  contribuintePIS: dest.atributo('CNPJ') ? 'S' : 'N',
89
91
  contribuinteCOFINS: dest.atributo('CNPJ') ? 'S' : 'N',
90
92
  contribuinteII: 'S',
@@ -449,6 +451,17 @@ module DfeTaxweb
449
451
  item.atributo('prod.qTrib')
450
452
  end
451
453
 
454
+ def dest_contribuinte_icms?
455
+ case inf_nfe.atributo('ide.indIEDest').to_s
456
+ when '1'
457
+ 'S'
458
+ when '2', '9'
459
+ 'N'
460
+ else
461
+ !!inf_nfe.atributo('dest.IE') ? 'S' : 'N'
462
+ end
463
+ end
464
+
452
465
  private
453
466
  def inf_nfe
454
467
  @inf_nfe ||= nfe.atributo('nfeProc.NFe.infNFe') ||
@@ -1,3 +1,3 @@
1
1
  module DfeTaxweb
2
- VERSION = '0.1.6'
2
+ VERSION = '0.1.8'
3
3
  end
@@ -38,14 +38,14 @@ describe DfeTaxweb::Nfe do
38
38
  expect(subject).to receive(:itens).and_return([])
39
39
  documento = subject.mapear_documento
40
40
  expect(documento).to be_a(Hash)
41
- expect(documento.keys.sort).to eq([:destinatario, :emitente, :entrega, :itensDocFiscal, :naturezaOperacao, :retirada, :tpDocFiscal].sort)
41
+ expect(documento.keys.sort).to eq([:destinatario, :emitente, :entrega, :indConsumidorFinal, :itensDocFiscal, :naturezaOperacao, :retirada, :tpDocFiscal].sort)
42
42
  end
43
43
  end
44
44
 
45
45
  describe "#emitente" do
46
46
  it "retorna o hash de emitente" do
47
47
  expect(subject).to receive(:endereco).and_return({})
48
- expect(subject.emitente.keys.sort).to eq([:contribuinteCOFINS, :contribuinteICMS, :contribuinteII, :contribuinteISS, :contribuintePIS, :contribuinteST, :simplesNac].sort)
48
+ expect(subject.emitente.keys.sort).to eq([:contribuinteCOFINS, :contribuinteICMS, :contribuinteII, :contribuinteIPI, :contribuinteISS, :contribuintePIS, :contribuinteST, :simplesNac].sort)
49
49
  end
50
50
  end
51
51
 
@@ -557,4 +557,33 @@ describe DfeTaxweb::Nfe do
557
557
  end
558
558
  end
559
559
 
560
+ describe "#dest_contribuinte_icms?" do
561
+ let(:inf_nfe){DfeTaxweb::Conjunto.new({})}
562
+ before(:each){allow(subject).to receive(:inf_nfe).and_return(inf_nfe)}
563
+ context 'é contribuinte' do
564
+ it "caso ide.indIEDest=1" do
565
+ expect(inf_nfe).to receive(:atributo).with('ide.indIEDest').and_return(1)
566
+ expect(subject.dest_contribuinte_icms?).to eq('S')
567
+ end
568
+ it "caso ide.indIEDest não seja 1, 2 ou 9 mas tenha IE" do
569
+ expect(inf_nfe).to receive(:atributo).with('ide.indIEDest').and_return(3)
570
+ expect(inf_nfe).to receive(:atributo).with('dest.IE').and_return('123')
571
+ expect(subject.dest_contribuinte_icms?).to eq('S')
572
+ end
573
+ end
574
+ context 'não é contribuinte' do
575
+ it "caso ide.indIEDest=2 ou 9" do
576
+ expect(inf_nfe).to receive(:atributo).with('ide.indIEDest').and_return(2)
577
+ expect(subject.dest_contribuinte_icms?).to eq('N')
578
+ expect(inf_nfe).to receive(:atributo).with('ide.indIEDest').and_return(9)
579
+ expect(subject.dest_contribuinte_icms?).to eq('N')
580
+ end
581
+ it "caso ide.indIEDest não seja 1, 2 ou 9 e não tenha IE" do
582
+ expect(inf_nfe).to receive(:atributo).with('ide.indIEDest').and_return(3)
583
+ expect(inf_nfe).to receive(:atributo).with('dest.IE').and_return(nil)
584
+ expect(subject.dest_contribuinte_icms?).to eq('N')
585
+ end
586
+ end
587
+ end
588
+
560
589
  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.6
4
+ version: 0.1.8
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-25 00:00:00.000000000 Z
11
+ date: 2018-03-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -72,6 +72,20 @@ dependencies:
72
72
  - - "~>"
73
73
  - !ruby/object:Gem::Version
74
74
  version: '1.1'
75
+ - !ruby/object:Gem::Dependency
76
+ name: rspec_junit_formatter
77
+ requirement: !ruby/object:Gem::Requirement
78
+ requirements:
79
+ - - "~>"
80
+ - !ruby/object:Gem::Version
81
+ version: '0.1'
82
+ type: :development
83
+ prerelease: false
84
+ version_requirements: !ruby/object:Gem::Requirement
85
+ requirements:
86
+ - - "~>"
87
+ - !ruby/object:Gem::Version
88
+ version: '0.1'
75
89
  description: Biblioteca Documento Fiscal TaxWeb. Conversão de NFe para DFe-TaxWeb
76
90
  email:
77
91
  - brunotporto@gmail.com