Class: Nfe::Reader::Product

Inherits:
Object
  • Object
show all
Includes:
AttributeHelper, CreatorHelper
Defined in:
lib/nfe_reader/product.rb

Overview

Detalhamento de Produtos e Serviços da NF-e

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from CreatorHelper

#create_resource, #create_resources, #to_array

Methods included from AttributeHelper

#attributes, #attributes_to_hash

Constructor Details

#initialize(attrs = {}) ⇒ Product

Fields Values

indTot: 0 - o valor do item (vProd) compõe o valor total da NF-e (vProd)

1 - o valor do item (vProd) não compõe o valor total da NF-e (vProd) (v2.0)


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/product.rb', line 22

def initialize(attrs = {})
  @number = attrs[:nItem]
  
  if attrs[:prod]
    @code = attrs[:prod][:cProd]
    @name = attrs[:prod][:xProd]
    @ean = attrs[:prod][:cEAN]
    @ncm = attrs[:prod][:NCM]
    
    # Sale
    @cfop = attrs[:prod][:CFOP]
    @unit_sale = attrs[:prod][:uCom]
    @amount_sale = attrs[:prod][:qCom]
    @value_sale = attrs[:prod][:vUnCom]
    @total = attrs[:prod][:vProd]

    # Numero do Pedido de Compra
    @demand_number = attrs[:prod][:xPed]
    # Item do Pedido de Compra
    @demand_item = attrs[:prod][:nItemPed]

    # GTIN (Global Trade ItemNumber)
    @gtin = attrs[:prod][:cEANTrib]
    
    @unit = attrs[:prod][:uTrib]
    @amount = attrs[:prod][:qTrib]
    @value = attrs[:prod][:vUnTrib]
    @kind = attrs[:prod][:indTot]
    @ipi_exception = attrs[:prod][:EXTIPI]
    @freight = attrs[:prod][:vFrete]
    @insurance = attrs[:prod][:vSeg]
    @discount = attrs[:prod][:vDesc]
    @other_value = attrs[:prod][:vOutro]
    
    @importation = create_resource(Importation, attrs[:prod][:DI])
  end

  @fuel    = Fuel.new(attrs[:comb]) if attrs[:comb]
  @vehicle = Vehicle.new(attrs[:veicProd]) if attrs[:veicProd]
  
  @armament   = create_resources(Armament, attrs[:arma])  if attrs[:arma]
  @medicament = create_resources(Medicament, attrs[:med]) if attrs[:med]

  @exportation = create_resources(Exportation, attrs[:detExport])

  if attrs[:imposto]
    @icms   = create_resources(Icms, attrs[:imposto][:ICMS])
    @cofins = create_resources(Cofins, attrs[:imposto][:COFINS])
    @pis    = create_resources(Pis, attrs[:imposto][:PIS])
    
    @importation_tax = create_resource(ImportationTax, attrs[:imposto][:II])
    @ipi = create_resource(Ipi, attrs[:imposto][:IPI])
    @pis_st = create_resource(PisSt, attrs[:imposto][:PISST])
    @cofins_st = create_resource(CofinsSt, attrs[:imposto][:COFINSST])
    @issqn = create_resource(Issqn, attrs[:imposto][:ISSQN])
  end
end

Instance Attribute Details

#amountObject (readonly)

Returns the value of attribute amount.



9
10
11
# File 'lib/nfe_reader/product.rb', line 9

def amount
  @amount
end

#amount_saleObject (readonly)

Returns the value of attribute amount_sale.



9
10
11
# File 'lib/nfe_reader/product.rb', line 9

def amount_sale
  @amount_sale
end

#armamentObject (readonly)

Returns the value of attribute armament.



9
10
11
# File 'lib/nfe_reader/product.rb', line 9

def armament
  @armament
end

#cfopObject (readonly)

Returns the value of attribute cfop.



9
10
11
# File 'lib/nfe_reader/product.rb', line 9

def cfop
  @cfop
end

#codeObject (readonly)

Returns the value of attribute code.



9
10
11
# File 'lib/nfe_reader/product.rb', line 9

def code
  @code
end

#cofinsObject (readonly)

Returns the value of attribute cofins.



9
10
11
# File 'lib/nfe_reader/product.rb', line 9

def cofins
  @cofins
end

#cofins_stObject (readonly)

Returns the value of attribute cofins_st.



9
10
11
# File 'lib/nfe_reader/product.rb', line 9

def cofins_st
  @cofins_st
end

#demand_itemObject (readonly)

Returns the value of attribute demand_item.



9
10
11
# File 'lib/nfe_reader/product.rb', line 9

def demand_item
  @demand_item
end

#demand_numberObject (readonly)

Returns the value of attribute demand_number.



9
10
11
# File 'lib/nfe_reader/product.rb', line 9

def demand_number
  @demand_number
end

#discountObject (readonly)

Returns the value of attribute discount.



9
10
11
# File 'lib/nfe_reader/product.rb', line 9

def discount
  @discount
end

#eanObject (readonly)

Returns the value of attribute ean.



9
10
11
# File 'lib/nfe_reader/product.rb', line 9

def ean
  @ean
end

#exportationObject (readonly)

Returns the value of attribute exportation.



9
10
11
# File 'lib/nfe_reader/product.rb', line 9

def exportation
  @exportation
end

#freightObject (readonly)

Returns the value of attribute freight.



9
10
11
# File 'lib/nfe_reader/product.rb', line 9

def freight
  @freight
end

#fuelObject (readonly)

Returns the value of attribute fuel.



9
10
11
# File 'lib/nfe_reader/product.rb', line 9

def fuel
  @fuel
end

#gtinObject (readonly)

Returns the value of attribute gtin.



9
10
11
# File 'lib/nfe_reader/product.rb', line 9

def gtin
  @gtin
end

#icmsObject (readonly)

Returns the value of attribute icms.



9
10
11
# File 'lib/nfe_reader/product.rb', line 9

def icms
  @icms
end

#importationObject (readonly)

Returns the value of attribute importation.



9
10
11
# File 'lib/nfe_reader/product.rb', line 9

def importation
  @importation
end

#importation_taxObject (readonly)

Returns the value of attribute importation_tax.



9
10
11
# File 'lib/nfe_reader/product.rb', line 9

def importation_tax
  @importation_tax
end

#insuranceObject (readonly)

Returns the value of attribute insurance.



9
10
11
# File 'lib/nfe_reader/product.rb', line 9

def insurance
  @insurance
end

#ipiObject (readonly)

Returns the value of attribute ipi.



9
10
11
# File 'lib/nfe_reader/product.rb', line 9

def ipi
  @ipi
end

#ipi_exceptionObject (readonly)

Returns the value of attribute ipi_exception.



9
10
11
# File 'lib/nfe_reader/product.rb', line 9

def ipi_exception
  @ipi_exception
end

#issqnObject (readonly)

Returns the value of attribute issqn.



9
10
11
# File 'lib/nfe_reader/product.rb', line 9

def issqn
  @issqn
end

#kindObject (readonly)

Returns the value of attribute kind.



9
10
11
# File 'lib/nfe_reader/product.rb', line 9

def kind
  @kind
end

#medicamentObject (readonly)

Returns the value of attribute medicament.



9
10
11
# File 'lib/nfe_reader/product.rb', line 9

def medicament
  @medicament
end

#nameObject (readonly)

Returns the value of attribute name.



9
10
11
# File 'lib/nfe_reader/product.rb', line 9

def name
  @name
end

#ncmObject (readonly)

Returns the value of attribute ncm.



9
10
11
# File 'lib/nfe_reader/product.rb', line 9

def ncm
  @ncm
end

#numberObject (readonly)

Returns the value of attribute number.



9
10
11
# File 'lib/nfe_reader/product.rb', line 9

def number
  @number
end

#other_valueObject (readonly)

Returns the value of attribute other_value.



9
10
11
# File 'lib/nfe_reader/product.rb', line 9

def other_value
  @other_value
end

#pisObject (readonly)

Returns the value of attribute pis.



9
10
11
# File 'lib/nfe_reader/product.rb', line 9

def pis
  @pis
end

#pis_stObject (readonly)

Returns the value of attribute pis_st.



9
10
11
# File 'lib/nfe_reader/product.rb', line 9

def pis_st
  @pis_st
end

#totalObject (readonly)

Returns the value of attribute total.



9
10
11
# File 'lib/nfe_reader/product.rb', line 9

def total
  @total
end

#unitObject (readonly)

Returns the value of attribute unit.



9
10
11
# File 'lib/nfe_reader/product.rb', line 9

def unit
  @unit
end

#unit_saleObject (readonly)

Returns the value of attribute unit_sale.



9
10
11
# File 'lib/nfe_reader/product.rb', line 9

def unit_sale
  @unit_sale
end

#valueObject (readonly)

Returns the value of attribute value.



9
10
11
# File 'lib/nfe_reader/product.rb', line 9

def value
  @value
end

#value_saleObject (readonly)

Returns the value of attribute value_sale.



9
10
11
# File 'lib/nfe_reader/product.rb', line 9

def value_sale
  @value_sale
end

#vehicleObject (readonly)

Returns the value of attribute vehicle.



9
10
11
# File 'lib/nfe_reader/product.rb', line 9

def vehicle
  @vehicle
end