Class: Elibri::ONIX::Release_3_0::Price
- Inherits:
-
Object
- Object
- Elibri::ONIX::Release_3_0::Price
- Includes:
- HashId
- Defined in:
- lib/elibri_onix/onix_3_0/price.rb
Constant Summary collapse
- ATTRIBUTES =
[ :type, :minimum_order_quantity, :amount, :currency_code, :printed_on_product, :position_on_product, :tax_type, :tax_rate_percent, :vat ]
- RELATIONS =
[]
Constants included from HashId
HashId::SKIPPED_2, HashId::SKIPPED_ATTRIBS
Instance Attribute Summary collapse
-
#amount ⇒ Object
Returns the value of attribute amount.
-
#currency_code ⇒ Object
Returns the value of attribute currency_code.
-
#minimum_order_quantity ⇒ Object
Returns the value of attribute minimum_order_quantity.
-
#position_on_product ⇒ Object
Returns the value of attribute position_on_product.
-
#printed_on_product ⇒ Object
Returns the value of attribute printed_on_product.
-
#tax_rate_percent ⇒ Object
Returns the value of attribute tax_rate_percent.
-
#tax_type ⇒ Object
Returns the value of attribute tax_type.
-
#to_xml ⇒ Object
Returns the value of attribute to_xml.
-
#type ⇒ Object
Returns the value of attribute type.
Instance Method Summary collapse
-
#initialize(data) ⇒ Price
constructor
A new instance of Price.
- #printed_on_product? ⇒ Boolean
- #vat ⇒ Object
Methods included from HashId
Constructor Details
#initialize(data) ⇒ Price
Returns a new instance of Price.
26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/elibri_onix/onix_3_0/price.rb', line 26 def initialize(data) @to_xml = data.to_s @type = data.at_css('PriceType').try(:text) @minimum_order_quantity = data.at_css('MinimumOrderQuantity').try(:text).try(:to_i) @amount = BigDecimal(data.at_css('PriceAmount').try(:text)) @currency_code = data.at_css('CurrencyCode').try(:text) @printed_on_product = data.at_css('PrintedOnProduct').try(:text) @position_on_product = data.at_css('PositionOnProduct').try(:text) if data.at_css('Tax') @tax_type = data.at_css('Tax').at_css('TaxType').try(:text) @tax_rate_percent = data.at_css('Tax').at_css('TaxRatePercent').text.to_i if data.at_css('Tax').at_css('TaxRatePercent') end end |
Instance Attribute Details
#amount ⇒ Object
Returns the value of attribute amount.
23 24 25 |
# File 'lib/elibri_onix/onix_3_0/price.rb', line 23 def amount @amount end |
#currency_code ⇒ Object
Returns the value of attribute currency_code.
23 24 25 |
# File 'lib/elibri_onix/onix_3_0/price.rb', line 23 def currency_code @currency_code end |
#minimum_order_quantity ⇒ Object
Returns the value of attribute minimum_order_quantity.
23 24 25 |
# File 'lib/elibri_onix/onix_3_0/price.rb', line 23 def minimum_order_quantity @minimum_order_quantity end |
#position_on_product ⇒ Object
Returns the value of attribute position_on_product.
23 24 25 |
# File 'lib/elibri_onix/onix_3_0/price.rb', line 23 def position_on_product @position_on_product end |
#printed_on_product ⇒ Object
Returns the value of attribute printed_on_product.
23 24 25 |
# File 'lib/elibri_onix/onix_3_0/price.rb', line 23 def printed_on_product @printed_on_product end |
#tax_rate_percent ⇒ Object
Returns the value of attribute tax_rate_percent.
23 24 25 |
# File 'lib/elibri_onix/onix_3_0/price.rb', line 23 def tax_rate_percent @tax_rate_percent end |
#tax_type ⇒ Object
Returns the value of attribute tax_type.
23 24 25 |
# File 'lib/elibri_onix/onix_3_0/price.rb', line 23 def tax_type @tax_type end |
#to_xml ⇒ Object
Returns the value of attribute to_xml.
23 24 25 |
# File 'lib/elibri_onix/onix_3_0/price.rb', line 23 def to_xml @to_xml end |
#type ⇒ Object
Returns the value of attribute type.
23 24 25 |
# File 'lib/elibri_onix/onix_3_0/price.rb', line 23 def type @type end |
Instance Method Details
#printed_on_product? ⇒ Boolean
40 41 42 |
# File 'lib/elibri_onix/onix_3_0/price.rb', line 40 def printed_on_product? @printed_on_product == "02" end |
#vat ⇒ Object
45 46 47 |
# File 'lib/elibri_onix/onix_3_0/price.rb', line 45 def vat @tax_type == Elibri::ONIX::Dict::Release_3_0::TaxType::VAT ? @tax_rate_percent : nil end |