Class: Nfcom::Models::Total

Inherits:
Object
  • Object
show all
Defined in:
lib/nfcom/models/total.rb

Overview

Representa os valores totalizadores da NF-COM

Esta classe agrega todos os valores da nota fiscal, incluindo valores de serviços, descontos, impostos e o valor total da nota.

Responsabilidades:

  • Armazenar os valores totalizadores da nota

  • Calcular o valor total da NF-COM

  • Manter valores de impostos (preenchidos externamente ou derivados)

Observações importantes:

  • Esta classe NÃO calcula impostos por regra fiscal

  • ICMS, PIS e COFINS devem ser informados pela camada de tributação

  • O Total apenas consolida os valores

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attributes = {}) ⇒ Total

Returns a new instance of Total.



28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/nfcom/models/total.rb', line 28

def initialize(attributes = {})
  @valor_desconto = 0.0
  @valor_outras_despesas = 0.0
  @icms_base_calculo = 0.0
  @icms_valor = 0.0
  @icms_desonerado = 0.0
  @fcp_valor = 0.0
  @pis_valor = 0.0
  @cofins_valor = 0.0
  @funttel_valor = 0.0
  @fust_valor = 0.0
  @pis_retido = 0.0
  @cofins_retido = 0.0
  @csll_retido = 0.0
  @irrf_retido = 0.0

  attributes.each do |key, value|
    send("#{key}=", value) if respond_to?("#{key}=")
  end
end

Instance Attribute Details

#cofins_retidoObject

Returns the value of attribute cofins_retido.



21
22
23
# File 'lib/nfcom/models/total.rb', line 21

def cofins_retido
  @cofins_retido
end

#cofins_valorObject

Returns the value of attribute cofins_valor.



21
22
23
# File 'lib/nfcom/models/total.rb', line 21

def cofins_valor
  @cofins_valor
end

#csll_retidoObject

Returns the value of attribute csll_retido.



21
22
23
# File 'lib/nfcom/models/total.rb', line 21

def csll_retido
  @csll_retido
end

#fcp_valorObject

Returns the value of attribute fcp_valor.



21
22
23
# File 'lib/nfcom/models/total.rb', line 21

def fcp_valor
  @fcp_valor
end

#funttel_valorObject

Returns the value of attribute funttel_valor.



21
22
23
# File 'lib/nfcom/models/total.rb', line 21

def funttel_valor
  @funttel_valor
end

#fust_valorObject

Returns the value of attribute fust_valor.



21
22
23
# File 'lib/nfcom/models/total.rb', line 21

def fust_valor
  @fust_valor
end

#icms_base_calculoObject

Returns the value of attribute icms_base_calculo.



21
22
23
# File 'lib/nfcom/models/total.rb', line 21

def icms_base_calculo
  @icms_base_calculo
end

#icms_desoneradoObject

Returns the value of attribute icms_desonerado.



21
22
23
# File 'lib/nfcom/models/total.rb', line 21

def icms_desonerado
  @icms_desonerado
end

#icms_valorObject

Returns the value of attribute icms_valor.



21
22
23
# File 'lib/nfcom/models/total.rb', line 21

def icms_valor
  @icms_valor
end

#irrf_retidoObject

Returns the value of attribute irrf_retido.



21
22
23
# File 'lib/nfcom/models/total.rb', line 21

def irrf_retido
  @irrf_retido
end

#pis_retidoObject

Returns the value of attribute pis_retido.



21
22
23
# File 'lib/nfcom/models/total.rb', line 21

def pis_retido
  @pis_retido
end

#pis_valorObject

Returns the value of attribute pis_valor.



21
22
23
# File 'lib/nfcom/models/total.rb', line 21

def pis_valor
  @pis_valor
end

#valor_descontoObject

Returns the value of attribute valor_desconto.



21
22
23
# File 'lib/nfcom/models/total.rb', line 21

def valor_desconto
  @valor_desconto
end

#valor_outras_despesasObject

Returns the value of attribute valor_outras_despesas.



21
22
23
# File 'lib/nfcom/models/total.rb', line 21

def valor_outras_despesas
  @valor_outras_despesas
end

#valor_servicosObject

Returns the value of attribute valor_servicos.



21
22
23
# File 'lib/nfcom/models/total.rb', line 21

def valor_servicos
  @valor_servicos
end

#valor_totalObject

Returns the value of attribute valor_total.



21
22
23
# File 'lib/nfcom/models/total.rb', line 21

def valor_total
  @valor_total
end

Instance Method Details

#calcular_totalObject



49
50
51
52
53
# File 'lib/nfcom/models/total.rb', line 49

def calcular_total
  @valor_total = valor_servicos.to_f -
                 valor_desconto.to_f +
                 valor_outras_despesas.to_f
end

#valor_liquidoObject



55
56
57
# File 'lib/nfcom/models/total.rb', line 55

def valor_liquido
  valor_total.to_f
end