Sha256: 97b8b0a9dedd45d91d9a27aa62c03b0ee96d8a17da90c1d7f095003603279257

Contents?: true

Size: 1.02 KB

Versions: 15

Compression:

Stored size: 1.02 KB

Contents

module Shoppe
  class DeliveryServicePrice < ActiveRecord::Base

    # Set the table name
    self.table_name = 'shoppe_delivery_service_prices'
  
    include Shoppe::AssociatedCountries
  
    # The delivery service which this price belongs to
    belongs_to :delivery_service, :class_name => 'Shoppe::DeliveryService'
    
    # The tax rate which should be applied
    belongs_to :tax_rate, :class_name => "Shoppe::TaxRate"
    
    # Validations
    validates :code, :presence => true
    validates :price, :numericality => true
    validates :cost_price, :numericality => true, :allow_blank => true
    validates :min_weight, :numericality => true
    validates :max_weight, :numericality => true
  
    # All prices ordered by their price ascending
    scope :ordered, -> { order(:price => :asc) }
    
    # All prices which are suitable for the weight passed.
    #
    # @param weight [BigDecimal] the weight of the order
    scope :for_weight, -> weight { where("min_weight <= ? AND max_weight >= ?", weight, weight) }
  
  end
end

Version data entries

15 entries across 15 versions & 3 rubygems

Version Path
shoppe-1.1.1 app/models/shoppe/delivery_service_price.rb
shoppe-1.1.0 app/models/shoppe/delivery_service_price.rb
shoppe-1.0.9 app/models/shoppe/delivery_service_price.rb
shoppe-1.0.8 app/models/shoppe/delivery_service_price.rb
kylekthompson-shoppe-1.0.7 app/models/shoppe/delivery_service_price.rb
shoppe-1.0.7 app/models/shoppe/delivery_service_price.rb
shoppe-1.0.6 app/models/shoppe/delivery_service_price.rb
shoppe-paypal-1.1.0 vendor/bundle/ruby/2.1.0/gems/shoppe-1.0.5/app/models/shoppe/delivery_service_price.rb
shoppe-1.0.5 app/models/shoppe/delivery_service_price.rb
shoppe-1.0.3 app/models/shoppe/delivery_service_price.rb
shoppe-1.0.2 app/models/shoppe/delivery_service_price.rb
shoppe-1.0.1 app/models/shoppe/delivery_service_price.rb
shoppe-1.0.0 app/models/shoppe/delivery_service_price.rb
shoppe-0.0.21 app/models/shoppe/delivery_service_price.rb
shoppe-0.0.20 app/models/shoppe/delivery_service_price.rb