Class: FE::Document::Item
- Inherits:
-
Object
- Object
- FE::Document::Item
- Includes:
- ActiveModel::Validations
- Defined in:
- lib/facturacr/document/item.rb
Constant Summary collapse
- UNITS =
%w[Sp m kg s A K mol cd m² m³ m/s m/s² 1/m kg/m³ A/m² A/m mol/m³ cd/m² 1 rad sr Hz N Pa J W C V F Ω S Wb T H °C lm lx Bq Gy Sv kat Pa·s N·m N/m rad/s rad/s² W/m² J/K J/(kg·K) J/kg W/(m·K) J/m³ V/m C/m³ C/m² F/m H/m J/mol J/(mol·K) C/kg Gy/s W/sr W/(m²·sr) kat/m³ min h d º ´ ´´ L t Np B eV u ua Unid Gal g Km ln cm mL mm Oz Otros].freeze
- CODE_TYPES =
{ '01' => 'Código del producto del vendedor', '02' => 'Código del producto del comprador', '03' => 'Código del producto asignado por la industria', '04' => 'Código uso interno', '99' => 'Otros' }.freeze
Instance Attribute Summary collapse
-
#code ⇒ Object
Returns the value of attribute code.
-
#code_type ⇒ Object
Returns the value of attribute code_type.
-
#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.
-
#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.
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/facturacr/document/item.rb', line 34 def initialize(args = {}) @line_number = args[:line_number] @code_type = args[:code_type].presence || '01' @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.
18 19 20 |
# File 'lib/facturacr/document/item.rb', line 18 def code @code end |
#code_type ⇒ Object
Returns the value of attribute code_type.
18 19 20 |
# File 'lib/facturacr/document/item.rb', line 18 def code_type @code_type end |
#description ⇒ Object
Returns the value of attribute description.
18 19 20 |
# File 'lib/facturacr/document/item.rb', line 18 def description @description end |
#discount ⇒ Object
Returns the value of attribute discount.
18 19 20 |
# File 'lib/facturacr/document/item.rb', line 18 def discount @discount end |
#discount_reason ⇒ Object
Returns the value of attribute discount_reason.
18 19 20 |
# File 'lib/facturacr/document/item.rb', line 18 def discount_reason @discount_reason end |
#line_number ⇒ Object
Returns the value of attribute line_number.
18 19 20 |
# File 'lib/facturacr/document/item.rb', line 18 def line_number @line_number end |
#net_total ⇒ Object
Returns the value of attribute net_total.
18 19 20 |
# File 'lib/facturacr/document/item.rb', line 18 def net_total @net_total end |
#quantity ⇒ Object
Returns the value of attribute quantity.
18 19 20 |
# File 'lib/facturacr/document/item.rb', line 18 def quantity @quantity end |
#subtotal ⇒ Object
Returns the value of attribute subtotal.
18 19 20 |
# File 'lib/facturacr/document/item.rb', line 18 def subtotal @subtotal end |
#taxes ⇒ Object
Returns the value of attribute taxes.
18 19 20 |
# File 'lib/facturacr/document/item.rb', line 18 def taxes @taxes end |
#total ⇒ Object
Returns the value of attribute total.
18 19 20 |
# File 'lib/facturacr/document/item.rb', line 18 def total @total end |
#unit ⇒ Object
Returns the value of attribute unit.
18 19 20 |
# File 'lib/facturacr/document/item.rb', line 18 def unit @unit end |
#unit_price ⇒ Object
Returns the value of attribute unit_price.
18 19 20 |
# File 'lib/facturacr/document/item.rb', line 18 def unit_price @unit_price end |
Instance Method Details
#build_xml(node) ⇒ Object
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 |
# File 'lib/facturacr/document/item.rb', line 50 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 @code_type x2.Codigo @code end end x.Cantidad @quantity x.UnidadMedida @unit x.Detalle @description x.PrecioUnitario @unit_price x.MontoTotal @total x.MontoDescuento @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 |