class Centaman::Object::Extra
Attributes
booking_time_id[R]
quantity[RW]
Public Instance Methods
after_init(args = {})
click to toggle source
# File lib/centaman/object/extra.rb, line 6 def after_init(args = {}) @quantity = 0 @booking_time_id = args.fetch(:booking_time_id, nil) end
attributes()
click to toggle source
rubocop:disable Metrics/MethodLength
# File lib/centaman/object/extra.rb, line 38 def attributes [ Centaman::Attribute.new( centaman_key: 'ExtraId', app_key: :id, type: :integer ), Centaman::Attribute.new( centaman_key: 'ExtraDescription', app_key: :extra_description, type: :string ), Centaman::Attribute.new( centaman_key: 'ExtraPrice', app_key: :price_including_tax, type: :float ), Centaman::Attribute.new( centaman_key: 'DepositPercentage', app_key: :deposit_percentage, type: :float ), Centaman::Attribute.new( centaman_key: 'IsTaxInclusive', app_key: :tax_inclusive, type: :boolean ), Centaman::Attribute.new( centaman_key: 'TaxPercentage', app_key: :tax_percentage, type: :float ) ] end
calculate_price_before_tax()
click to toggle source
# File lib/centaman/object/extra.rb, line 15 def calculate_price_before_tax p = price_including_tax / (1 + tax_percentage / 100) p.round(2) end
description()
click to toggle source
# File lib/centaman/object/extra.rb, line 32 def description @extra_description.gsub!('Bar Package Cocktail Cruises', 'Bar Package') @description = @extra_description end
json()
click to toggle source
# File lib/centaman/object/extra.rb, line 20 def json { id: id, description: description, quantity: quantity, price: price, deposit_percentage: deposit_percentage, tax_inclusive: tax_inclusive, tax_percentage: tax_percentage } end
price()
click to toggle source
# File lib/centaman/object/extra.rb, line 11 def price @price ||= tax_inclusive ? calculate_price_before_tax : price_including_tax end