Class: FE::Document::Item
- Inherits:
-
Object
- Object
- FE::Document::Item
- Includes:
- ActiveModel::Validations
- Defined in:
- lib/facturacr/document/item.rb
Instance Attribute Summary collapse
-
#code ⇒ Object
Returns the value of attribute code.
-
#description ⇒ Object
Returns the value of attribute description.
-
#discount ⇒ Object
Returns the value of attribute discount.
-
#discount_reason ⇒ Object
Returns the value of attribute discount_reason.
-
#exoneration ⇒ Object
Returns the value of attribute exoneration.
-
#line_number ⇒ Object
Returns the value of attribute line_number.
-
#net_total ⇒ Object
Returns the value of attribute net_total.
-
#quantity ⇒ Object
Returns the value of attribute quantity.
-
#subtotal ⇒ Object
Returns the value of attribute subtotal.
-
#taxes ⇒ Object
Returns the value of attribute taxes.
-
#total ⇒ Object
Returns the value of attribute total.
-
#unit ⇒ Object
Returns the value of attribute unit.
-
#unit_price ⇒ Object
Returns the value of attribute unit_price.
Instance Method Summary collapse
- #build_xml(node) ⇒ Object
-
#initialize(args = {}) ⇒ Item
constructor
A new instance of Item.
Constructor Details
#initialize(args = {}) ⇒ Item
Returns a new instance of Item.
21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/facturacr/document/item.rb', line 21 def initialize(args={}) @line_number = args[:line_number] @code = args[:code] @quantity = args[:quantity] @unit = args[:unit] @description = args[:description] @unit_price = args[:unit_price] @total = args[:total] @discount = args[:discount] @discount_reason = args[:discount_reason] @subtotal = args[:subtotal] @taxes = args[:taxes] || [] @net_total = args[:net_total] end |
Instance Attribute Details
#code ⇒ Object
Returns the value of attribute code.
6 7 8 |
# File 'lib/facturacr/document/item.rb', line 6 def code @code end |
#description ⇒ Object
Returns the value of attribute description.
6 7 8 |
# File 'lib/facturacr/document/item.rb', line 6 def description @description end |
#discount ⇒ Object
Returns the value of attribute discount.
6 7 8 |
# File 'lib/facturacr/document/item.rb', line 6 def discount @discount end |
#discount_reason ⇒ Object
Returns the value of attribute discount_reason.
6 7 8 |
# File 'lib/facturacr/document/item.rb', line 6 def discount_reason @discount_reason end |
#exoneration ⇒ Object
Returns the value of attribute exoneration.
6 7 8 |
# File 'lib/facturacr/document/item.rb', line 6 def exoneration @exoneration end |
#line_number ⇒ Object
Returns the value of attribute line_number.
6 7 8 |
# File 'lib/facturacr/document/item.rb', line 6 def line_number @line_number end |
#net_total ⇒ Object
Returns the value of attribute net_total.
6 7 8 |
# File 'lib/facturacr/document/item.rb', line 6 def net_total @net_total end |
#quantity ⇒ Object
Returns the value of attribute quantity.
6 7 8 |
# File 'lib/facturacr/document/item.rb', line 6 def quantity @quantity end |
#subtotal ⇒ Object
Returns the value of attribute subtotal.
6 7 8 |
# File 'lib/facturacr/document/item.rb', line 6 def subtotal @subtotal end |
#taxes ⇒ Object
Returns the value of attribute taxes.
6 7 8 |
# File 'lib/facturacr/document/item.rb', line 6 def taxes @taxes end |
#total ⇒ Object
Returns the value of attribute total.
6 7 8 |
# File 'lib/facturacr/document/item.rb', line 6 def total @total end |
#unit ⇒ Object
Returns the value of attribute unit.
6 7 8 |
# File 'lib/facturacr/document/item.rb', line 6 def unit @unit end |
#unit_price ⇒ Object
Returns the value of attribute unit_price.
6 7 8 |
# File 'lib/facturacr/document/item.rb', line 6 def unit_price @unit_price end |
Instance Method Details
#build_xml(node) ⇒ Object
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 |
# File 'lib/facturacr/document/item.rb', line 36 def build_xml(node) raise "Item invalid: #{errors.}" unless valid? node = Nokogiri::XML::Builder.new if node.nil? node.LineaDetalle do |x| x.NumeroLinea @line_number if @code.present? x.Codigo do |x2| x2.Tipo "01" x2.Codigo @code end end x.Cantidad @quantity x.UnidadMedida @unit x.Detalle @description x.PrecioUnitario @unit_price x.MontoTotal @total x.Discount @discount if @discount.present? x.NaturalezaDescuento @discount_reason if @discount_reason.present? x.SubTotal @subtotal @taxes.each do |tax| tax.build_xml(x) end if @exoneration.present? @exoneration.build_xml(x) end x.MontoTotalLinea @net_total end end |