Sha256: 4c230c87146b7aedfabdaa7881336b2da36f36a38c9c2e0bb2493e6e661de7d0

Contents?: true

Size: 1.98 KB

Versions: 9

Compression:

Stored size: 1.98 KB

Contents

module Centaman
  class Object::TicketType < Centaman::Object
    attr_reader :price, :discount
    attr_accessor :quantity

    def price
      @price ||= begin
        p = price_including_tax / (1 + tax_percentage / 100)
        p = p + discount
        p.round(2)
      end
    end

    def discount
      @discount ||= Centaman::Service::TicketType::DISCOUNT
    end

    def adult?
      age_group == "adult"
    end

    # rubocop:disable Metrics/MethodLength
    def attributes
      [
        Centaman::Attribute.new(
          centaman_key: "TicketId",
          app_key: :id,
          type: :integer
        ),
        Centaman::Attribute.new(
          centaman_key: "TicketDescription",
          app_key: :description,
          type: :string
        ),
        Centaman::Attribute.new(
          centaman_key: "TicketPrice",
          app_key: :price_including_tax,
          type: :float
        ),
        Centaman::Attribute.new(
          centaman_key: "TicketBookingFee",
          app_key: :booking_fee,
          type: :float
        ),
        Centaman::Attribute.new(
          centaman_key: "TicketFeeItemId",
          app_key: :fee_item_id,
          type: :integer
        ),
        Centaman::Attribute.new(
          centaman_key: "DepositPercentage",
          app_key: :deposit_percentage,
          type: :float
        ),
        Centaman::Attribute.new(
          centaman_key: "IsTaxInclusive",
          app_key: :is_tax_inclusive,
          type: :boolean
        ),
        Centaman::Attribute.new(
          centaman_key: "TaxPercentage",
          app_key: :tax_percentage,
          type: :float
        ),
        Centaman::Attribute.new(
          centaman_key: "TicketDescription",
          app_key: :age_group,
          type: :age_group
        ),
        Centaman::Attribute.new(
          centaman_key: "TicketDescription",
          app_key: :display_age_group,
          type: :display_age_group
        ),
      ]
    end
    # rubocop:enable Metrics/MethodLength
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
centaman-0.1.8 lib/centaman/object/ticket_type.rb
centaman-0.1.7 lib/centaman/object/ticket_type.rb
centaman-0.1.6 lib/centaman/object/ticket_type.rb
centaman-0.1.5 lib/centaman/object/ticket_type.rb
centaman-0.1.4 lib/centaman/object/ticket_type.rb
centaman-0.1.3 lib/centaman/object/ticket_type.rb
centaman-0.1.2 lib/centaman/object/ticket_type.rb
centaman-0.1.1 lib/centaman/object/ticket_type.rb
centaman-0.1.0 lib/centaman/object/ticket_type.rb