Class: Nfe::Product
- Inherits:
-
Object
- Object
- Nfe::Product
- Defined in:
- lib/nfe_reader/product.rb
Overview
Detalhamento de Produtos e Serviços da NF-e
Instance Attribute Summary collapse
-
#amount ⇒ Object
readonly
Returns the value of attribute amount.
-
#amount_sale ⇒ Object
readonly
Returns the value of attribute amount_sale.
-
#armament ⇒ Object
readonly
Returns the value of attribute armament.
-
#cfop ⇒ Object
readonly
Returns the value of attribute cfop.
-
#demand_item ⇒ Object
readonly
Returns the value of attribute demand_item.
-
#demand_number ⇒ Object
readonly
Returns the value of attribute demand_number.
-
#discount ⇒ Object
readonly
Returns the value of attribute discount.
-
#ean ⇒ Object
readonly
Returns the value of attribute ean.
-
#exportation ⇒ Object
readonly
Returns the value of attribute exportation.
-
#freight ⇒ Object
readonly
Returns the value of attribute freight.
-
#fuel ⇒ Object
readonly
Returns the value of attribute fuel.
-
#gtin ⇒ Object
readonly
Returns the value of attribute gtin.
-
#icms ⇒ Object
readonly
Returns the value of attribute icms.
-
#importation ⇒ Object
readonly
Returns the value of attribute importation.
-
#importation_tax ⇒ Object
readonly
Returns the value of attribute importation_tax.
-
#insurance ⇒ Object
readonly
Returns the value of attribute insurance.
-
#ipi ⇒ Object
readonly
Returns the value of attribute ipi.
-
#ipi_exception ⇒ Object
readonly
Returns the value of attribute ipi_exception.
-
#kind ⇒ Object
readonly
Returns the value of attribute kind.
-
#ncm ⇒ Object
readonly
Returns the value of attribute ncm.
-
#number ⇒ Object
readonly
Returns the value of attribute number.
-
#other_value ⇒ Object
readonly
Returns the value of attribute other_value.
-
#pis ⇒ Object
readonly
Returns the value of attribute pis.
-
#product ⇒ Object
readonly
Returns the value of attribute product.
-
#product_code ⇒ Object
readonly
Returns the value of attribute product_code.
-
#total ⇒ Object
readonly
Returns the value of attribute total.
-
#unit ⇒ Object
readonly
Returns the value of attribute unit.
-
#unit_sale ⇒ Object
readonly
Returns the value of attribute unit_sale.
-
#value ⇒ Object
readonly
Returns the value of attribute value.
-
#value_sale ⇒ Object
readonly
Returns the value of attribute value_sale.
Instance Method Summary collapse
- #create_resource(klass, attrs = {}) ⇒ Object
- #create_resources(klass, attrs = {}) ⇒ Object
-
#initialize(attrs = {}) ⇒ Product
constructor
Fields Values.
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)
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 |
# File 'lib/nfe_reader/product.rb', line 17 def initialize(attrs = {}) @number = attrs[:nItem] if attrs[:prod] @product_code = attrs[:prod][:cProd] @product = 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(Nfe::Importation, attrs[:prod][:DI]) end @armament = create_resources(Nfe::Armament, attrs[:arma]) if attrs[:arma] @medicament = create_resources(Nfe::Medicament, attrs[:med]) if attrs[:med] @fuel = Nfe::Fuel.new(attrs[:comb]) if attrs[:comb] @vehicle = Nfe::Vehicle.new(attrs[:veicProd]) if attrs[:veicProd] @exportation = create_resources(Nfe::Exportation, attrs[:detExport]) if attrs[:imposto] @icms = create_resources(Nfe::Icms, attrs[:imposto][:ICMS]) @cofins = create_resources(Nfe::Cofins, attrs[:imposto][:COFINS]) @pis = create_resources(Nfe::Pis, attrs[:imposto][:PIS]) @importation_tax = create_resource(Nfe::ImportationTax, attrs[:imposto][:II]) @ipi = create_resource(Nfe::Ipi, attrs[:imposto][:IPI]) @pis_st = create_resource(Nfe::PisSt, attrs[:imposto][:PISST]) @cofins_st = create_resource(Nfe::CofinsSt, attrs[:imposto][:COFINSST]) @issqn = create_resource(Nfe::Issqn, attrs[:imposto][:ISSQN]) end end |
Instance Attribute Details
#amount ⇒ Object (readonly)
Returns the value of attribute amount.
5 6 7 |
# File 'lib/nfe_reader/product.rb', line 5 def amount @amount end |
#amount_sale ⇒ Object (readonly)
Returns the value of attribute amount_sale.
5 6 7 |
# File 'lib/nfe_reader/product.rb', line 5 def amount_sale @amount_sale end |
#armament ⇒ Object (readonly)
Returns the value of attribute armament.
5 6 7 |
# File 'lib/nfe_reader/product.rb', line 5 def armament @armament end |
#cfop ⇒ Object (readonly)
Returns the value of attribute cfop.
5 6 7 |
# File 'lib/nfe_reader/product.rb', line 5 def cfop @cfop end |
#demand_item ⇒ Object (readonly)
Returns the value of attribute demand_item.
5 6 7 |
# File 'lib/nfe_reader/product.rb', line 5 def demand_item @demand_item end |
#demand_number ⇒ Object (readonly)
Returns the value of attribute demand_number.
5 6 7 |
# File 'lib/nfe_reader/product.rb', line 5 def demand_number @demand_number end |
#discount ⇒ Object (readonly)
Returns the value of attribute discount.
5 6 7 |
# File 'lib/nfe_reader/product.rb', line 5 def discount @discount end |
#ean ⇒ Object (readonly)
Returns the value of attribute ean.
5 6 7 |
# File 'lib/nfe_reader/product.rb', line 5 def ean @ean end |
#exportation ⇒ Object (readonly)
Returns the value of attribute exportation.
5 6 7 |
# File 'lib/nfe_reader/product.rb', line 5 def exportation @exportation end |
#freight ⇒ Object (readonly)
Returns the value of attribute freight.
5 6 7 |
# File 'lib/nfe_reader/product.rb', line 5 def freight @freight end |
#fuel ⇒ Object (readonly)
Returns the value of attribute fuel.
5 6 7 |
# File 'lib/nfe_reader/product.rb', line 5 def fuel @fuel end |
#gtin ⇒ Object (readonly)
Returns the value of attribute gtin.
5 6 7 |
# File 'lib/nfe_reader/product.rb', line 5 def gtin @gtin end |
#icms ⇒ Object (readonly)
Returns the value of attribute icms.
5 6 7 |
# File 'lib/nfe_reader/product.rb', line 5 def icms @icms end |
#importation ⇒ Object (readonly)
Returns the value of attribute importation.
5 6 7 |
# File 'lib/nfe_reader/product.rb', line 5 def importation @importation end |
#importation_tax ⇒ Object (readonly)
Returns the value of attribute importation_tax.
5 6 7 |
# File 'lib/nfe_reader/product.rb', line 5 def importation_tax @importation_tax end |
#insurance ⇒ Object (readonly)
Returns the value of attribute insurance.
5 6 7 |
# File 'lib/nfe_reader/product.rb', line 5 def insurance @insurance end |
#ipi ⇒ Object (readonly)
Returns the value of attribute ipi.
5 6 7 |
# File 'lib/nfe_reader/product.rb', line 5 def ipi @ipi end |
#ipi_exception ⇒ Object (readonly)
Returns the value of attribute ipi_exception.
5 6 7 |
# File 'lib/nfe_reader/product.rb', line 5 def ipi_exception @ipi_exception end |
#kind ⇒ Object (readonly)
Returns the value of attribute kind.
5 6 7 |
# File 'lib/nfe_reader/product.rb', line 5 def kind @kind end |
#ncm ⇒ Object (readonly)
Returns the value of attribute ncm.
5 6 7 |
# File 'lib/nfe_reader/product.rb', line 5 def ncm @ncm end |
#number ⇒ Object (readonly)
Returns the value of attribute number.
5 6 7 |
# File 'lib/nfe_reader/product.rb', line 5 def number @number end |
#other_value ⇒ Object (readonly)
Returns the value of attribute other_value.
5 6 7 |
# File 'lib/nfe_reader/product.rb', line 5 def other_value @other_value end |
#pis ⇒ Object (readonly)
Returns the value of attribute pis.
5 6 7 |
# File 'lib/nfe_reader/product.rb', line 5 def pis @pis end |
#product ⇒ Object (readonly)
Returns the value of attribute product.
5 6 7 |
# File 'lib/nfe_reader/product.rb', line 5 def product @product end |
#product_code ⇒ Object (readonly)
Returns the value of attribute product_code.
5 6 7 |
# File 'lib/nfe_reader/product.rb', line 5 def product_code @product_code end |
#total ⇒ Object (readonly)
Returns the value of attribute total.
5 6 7 |
# File 'lib/nfe_reader/product.rb', line 5 def total @total end |
#unit ⇒ Object (readonly)
Returns the value of attribute unit.
5 6 7 |
# File 'lib/nfe_reader/product.rb', line 5 def unit @unit end |
#unit_sale ⇒ Object (readonly)
Returns the value of attribute unit_sale.
5 6 7 |
# File 'lib/nfe_reader/product.rb', line 5 def unit_sale @unit_sale end |
#value ⇒ Object (readonly)
Returns the value of attribute value.
5 6 7 |
# File 'lib/nfe_reader/product.rb', line 5 def value @value end |
#value_sale ⇒ Object (readonly)
Returns the value of attribute value_sale.
5 6 7 |
# File 'lib/nfe_reader/product.rb', line 5 def value_sale @value_sale end |
Instance Method Details
#create_resource(klass, attrs = {}) ⇒ Object
73 74 75 76 |
# File 'lib/nfe_reader/product.rb', line 73 def create_resource(klass, attrs = {}) return unless attrs klass.new(attrs) end |
#create_resources(klass, attrs = {}) ⇒ Object
78 79 80 81 82 83 84 85 86 87 88 |
# File 'lib/nfe_reader/product.rb', line 78 def create_resources(klass, attrs = {}) resources = [] return resources unless attrs attrs.each do |a| resources << klass.new(a.last) end resources end |