Class: MercadoPublicoCl::POItem

Inherits:
Data
  • Object
show all
Defined in:
lib/mercado_publico_cl/value_objects/purchase_order_item.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#buyer_specificationObject (readonly)

Returns the value of attribute buyer_specification

Returns:

  • (Object)

    the current value of buyer_specification



4
5
6
# File 'lib/mercado_publico_cl/value_objects/purchase_order_item.rb', line 4

def buyer_specification
  @buyer_specification
end

#categoryObject (readonly)

Returns the value of attribute category

Returns:

  • (Object)

    the current value of category



4
5
6
# File 'lib/mercado_publico_cl/value_objects/purchase_order_item.rb', line 4

def category
  @category
end

#category_codeObject (readonly)

Returns the value of attribute category_code

Returns:

  • (Object)

    the current value of category_code



4
5
6
# File 'lib/mercado_publico_cl/value_objects/purchase_order_item.rb', line 4

def category_code
  @category_code
end

#correlativeObject (readonly)

Returns the value of attribute correlative

Returns:

  • (Object)

    the current value of correlative



4
5
6
# File 'lib/mercado_publico_cl/value_objects/purchase_order_item.rb', line 4

def correlative
  @correlative
end

#currencyObject (readonly)

Returns the value of attribute currency

Returns:

  • (Object)

    the current value of currency



4
5
6
# File 'lib/mercado_publico_cl/value_objects/purchase_order_item.rb', line 4

def currency
  @currency
end

#currency_codeObject (readonly)

Returns the value of attribute currency_code

Returns:

  • (Object)

    the current value of currency_code



4
5
6
# File 'lib/mercado_publico_cl/value_objects/purchase_order_item.rb', line 4

def currency_code
  @currency_code
end

#product_codeObject (readonly)

Returns the value of attribute product_code

Returns:

  • (Object)

    the current value of product_code



4
5
6
# File 'lib/mercado_publico_cl/value_objects/purchase_order_item.rb', line 4

def product_code
  @product_code
end

#product_nameObject (readonly)

Returns the value of attribute product_name

Returns:

  • (Object)

    the current value of product_name



4
5
6
# File 'lib/mercado_publico_cl/value_objects/purchase_order_item.rb', line 4

def product_name
  @product_name
end

#quantityObject (readonly)

Returns the value of attribute quantity

Returns:

  • (Object)

    the current value of quantity



4
5
6
# File 'lib/mercado_publico_cl/value_objects/purchase_order_item.rb', line 4

def quantity
  @quantity
end

#rawObject (readonly)

Returns the value of attribute raw

Returns:

  • (Object)

    the current value of raw



4
5
6
# File 'lib/mercado_publico_cl/value_objects/purchase_order_item.rb', line 4

def raw
  @raw
end

#supplier_specificationObject (readonly)

Returns the value of attribute supplier_specification

Returns:

  • (Object)

    the current value of supplier_specification



4
5
6
# File 'lib/mercado_publico_cl/value_objects/purchase_order_item.rb', line 4

def supplier_specification
  @supplier_specification
end

#totalObject (readonly)

Returns the value of attribute total

Returns:

  • (Object)

    the current value of total



4
5
6
# File 'lib/mercado_publico_cl/value_objects/purchase_order_item.rb', line 4

def total
  @total
end

#total_chargesObject (readonly)

Returns the value of attribute total_charges

Returns:

  • (Object)

    the current value of total_charges



4
5
6
# File 'lib/mercado_publico_cl/value_objects/purchase_order_item.rb', line 4

def total_charges
  @total_charges
end

#total_discountsObject (readonly)

Returns the value of attribute total_discounts

Returns:

  • (Object)

    the current value of total_discounts



4
5
6
# File 'lib/mercado_publico_cl/value_objects/purchase_order_item.rb', line 4

def total_discounts
  @total_discounts
end

#total_taxesObject (readonly)

Returns the value of attribute total_taxes

Returns:

  • (Object)

    the current value of total_taxes



4
5
6
# File 'lib/mercado_publico_cl/value_objects/purchase_order_item.rb', line 4

def total_taxes
  @total_taxes
end

#unitObject (readonly)

Returns the value of attribute unit

Returns:

  • (Object)

    the current value of unit



4
5
6
# File 'lib/mercado_publico_cl/value_objects/purchase_order_item.rb', line 4

def unit
  @unit
end

#unit_priceObject (readonly)

Returns the value of attribute unit_price

Returns:

  • (Object)

    the current value of unit_price



4
5
6
# File 'lib/mercado_publico_cl/value_objects/purchase_order_item.rb', line 4

def unit_price
  @unit_price
end

Class Method Details

.from_payload(raw) ⇒ Object



23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/mercado_publico_cl/value_objects/purchase_order_item.rb', line 23

def self.from_payload(raw)
  return nil if raw.nil?

  currency_code = raw["Moneda"]
  new(
    correlative: Resources::Base.to_int(raw["Correlativo"]),
    category_code: Resources::Base.to_int(raw["CodigoCategoria"]),
    category: raw["Categoria"],
    product_code: Resources::Base.to_int(raw["CodigoProducto"]),
    product_name: raw["Producto"] || raw["NombreProducto"],
    buyer_specification: raw["EspecificacionComprador"],
    supplier_specification: raw["EspecificacionProveedor"],
    quantity: Resources::Base.to_float(raw["Cantidad"]),
    unit: raw["Unidad"] || raw["UnidadMedida"],
    currency: Enums::Currency.to_symbol(currency_code),
    currency_code: currency_code,
    unit_price: Resources::Base.to_float(raw["PrecioNeto"]),
    total_charges: Resources::Base.to_float(raw["TotalCargos"]),
    total_discounts: Resources::Base.to_float(raw["TotalDescuentos"]),
    total_taxes: Resources::Base.to_float(raw["TotalImpuestos"]),
    total: Resources::Base.to_float(raw["Total"]),
    raw: raw
  )
end

Instance Method Details

#inspectObject Also known as: to_s



48
49
50
# File 'lib/mercado_publico_cl/value_objects/purchase_order_item.rb', line 48

def inspect
  "#<POItem ##{correlative} product=#{product_name.inspect} qty=#{quantity} unit_price=#{unit_price}>"
end