Class: Elibri::ONIX::Release_3_0::Price

Inherits:
Object
  • Object
show all
Defined in:
lib/elibri_onix/onix_3_0/price.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(data) ⇒ Price

Returns a new instance of Price.



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/elibri_onix/onix_3_0/price.rb', line 10

def initialize(data)
  @to_xml = data.to_s
  @type = data.at_css('PriceType')&.text
  @price_qualifier = data.at_css("PriceQualifier")&.text
  @minimum_order_quantity = data.at_css('MinimumOrderQuantity')&.text&.to_i
  @amount = BigDecimal(data.at_css('PriceAmount')&.text)
  @currency_code = data.at_css('CurrencyCode')&.text
  @printed_on_product = data.at_css('PrintedOnProduct')&.text
  @position_on_product = data.at_css('PositionOnProduct')&.text
  if data.at_css('Tax')
    @tax_type = data.at_css('Tax').at_css('TaxType')&.text
    @tax_rate_percent = data.at_css('Tax').at_css('TaxRatePercent').text.to_i if data.at_css('Tax').at_css('TaxRatePercent')
  end
  @price_constraint_limits = data.css("PriceConstraintLimit").map { |pc| PriceConstraintLimit.new(pc) }
  if pi = data.at_css("PriceIdentifier")
    @price_identifier = PriceIdentifier.new(pi)
  end
end

Instance Attribute Details

#amountObject

Returns the value of attribute amount.



7
8
9
# File 'lib/elibri_onix/onix_3_0/price.rb', line 7

def amount
  @amount
end

#currency_codeObject

Returns the value of attribute currency_code.



7
8
9
# File 'lib/elibri_onix/onix_3_0/price.rb', line 7

def currency_code
  @currency_code
end

#minimum_order_quantityObject

Returns the value of attribute minimum_order_quantity.



7
8
9
# File 'lib/elibri_onix/onix_3_0/price.rb', line 7

def minimum_order_quantity
  @minimum_order_quantity
end

#position_on_productObject

Returns the value of attribute position_on_product.



7
8
9
# File 'lib/elibri_onix/onix_3_0/price.rb', line 7

def position_on_product
  @position_on_product
end

#price_constraint_limitsObject

Returns the value of attribute price_constraint_limits.



7
8
9
# File 'lib/elibri_onix/onix_3_0/price.rb', line 7

def price_constraint_limits
  @price_constraint_limits
end

#price_identifierObject

Returns the value of attribute price_identifier.



7
8
9
# File 'lib/elibri_onix/onix_3_0/price.rb', line 7

def price_identifier
  @price_identifier
end

#price_qualifierObject

Returns the value of attribute price_qualifier.



7
8
9
# File 'lib/elibri_onix/onix_3_0/price.rb', line 7

def price_qualifier
  @price_qualifier
end

#printed_on_productObject

Returns the value of attribute printed_on_product.



7
8
9
# File 'lib/elibri_onix/onix_3_0/price.rb', line 7

def printed_on_product
  @printed_on_product
end

#tax_rate_percentObject

Returns the value of attribute tax_rate_percent.



7
8
9
# File 'lib/elibri_onix/onix_3_0/price.rb', line 7

def tax_rate_percent
  @tax_rate_percent
end

#tax_typeObject

Returns the value of attribute tax_type.



7
8
9
# File 'lib/elibri_onix/onix_3_0/price.rb', line 7

def tax_type
  @tax_type
end

#to_xmlObject

Returns the value of attribute to_xml.



7
8
9
# File 'lib/elibri_onix/onix_3_0/price.rb', line 7

def to_xml
  @to_xml
end

#typeObject

Returns the value of attribute type.



7
8
9
# File 'lib/elibri_onix/onix_3_0/price.rb', line 7

def type
  @type
end

Instance Method Details

#printed_on_product?Boolean

Returns:

  • (Boolean)


29
30
31
# File 'lib/elibri_onix/onix_3_0/price.rb', line 29

def printed_on_product?
  @printed_on_product == "02"
end

#vatObject



34
35
36
# File 'lib/elibri_onix/onix_3_0/price.rb', line 34

def vat
  @tax_type == Elibri::ONIX::Dict::Release_3_0::TaxType::VAT ? @tax_rate_percent : nil
end