Method: NfeReader::Total#initialize

Defined in:
lib/nfe_reader/total.rb

#initialize(attrs = {}) ⇒ Total

Returns a new instance of Total.



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
# File 'lib/nfe_reader/total.rb', line 12

def initialize(attrs = {})
  # Impostos
  if attrs[:ICMSTot]
    # Base ICMS
    @icms_base = attrs[:ICMSTot][:vBC]
    # Valor ICMS
    @icms = attrs[:ICMSTot][:vICMS]
    # Base ICMS ST
    @st_base = attrs[:ICMSTot][:vBCST]
    # Valor ICMS ST
    @st = attrs[:ICMSTot][:vST]
    # Total de Produtos
    @product = attrs[:ICMSTot][:vProd]
    # Total de Frete
    @freight = attrs[:ICMSTot][:vFrete]
    # Total de Seguro
    @insurance = attrs[:ICMSTot][:vSeg]
    # Total de Desconto
    @descount = attrs[:ICMSTot][:vDesc]
    # Total de Imposto de Importacao
    @ii = attrs[:ICMSTot][:vII]
    # Total de IPI
    @ipi = attrs[:ICMSTot][:vIPI]
    # Total de PIS
    @pis = attrs[:ICMSTot][:vPIS]
    # Total de COFINS
    @cofins = attrs[:ICMSTot][:vCOFINS]
    # Total de Outros
    @another = attrs[:ICMSTot][:vOutro]
    # Total NFe
    @total = attrs[:ICMSTot][:vNF]
    # Total NFe
    @tax = attrs[:ICMSTot][:vTotTrib]
  end

  # Servicos
  if attrs[:ISSQNtot]
    # Valor do Servico
    @service_value = attrs[:ISSQNtot][:vServ]
    # Base de calculo do Servico
    @service_base = attrs[:ISSQNtot][:vBC]
    # ISS do Servico
    @service_iss = attrs[:ISSQNtot][:vISS]
    # Pis do Servico
    @service_pis = attrs[:ISSQNtot][:vPIS]
    # Cofins do Servico
    @service_cofins = attrs[:ISSQNtot][:vCOFINS]
  end

  # Retencoes
  if attrs[:retTrib]
    # Retencao de PIS
    @retention_pis = attrs[:retTrib][:vRetPIS]
    # Retencao de COFINS
    @retention_cofins = attrs[:retTrib][:vRetCOFINS]
    # Retencao de CSLL
    @retention_csll = attrs[:retTrib][:vRetCSLL]
    # Base de Retencao do IRRF 
    @retention_irrf_base = attrs[:retTrib][:vBCIRRF]
    # Valor de Retencao do IRRF
    @retention_irrf = attrs[:retTrib][:vIRRF]
    # Base de Retencao da Previdencia
    @retention_foresight_base = attrs[:retTrib][:vBCRetPrev]
    # Valor de Retencao da Previdencia
    @retention_foresight = attrs[:retTrib][:vRetPrev]
  end
end