Sha256: f52d72c749c11c7ca07315fcad6f811bb7358a24f161080be2d637efc7d32df4

Contents?: true

Size: 797 Bytes

Versions: 1

Compression:

Stored size: 797 Bytes

Contents

module Shoppe
  class DeliveryServicePrice < ActiveRecord::Base

    # Set the table name
    self.table_name = 'shoppe_delivery_service_prices'
  
    # Tax rates are associated with countries
    include Shoppe::AssociatedCountries
  
    # Relationships
    belongs_to :delivery_service, :class_name => 'Shoppe::DeliveryService'
    belongs_to :tax_rate, :class_name => "Shoppe::TaxRate"
  
    # Validations
    validates :price, :numericality => true
    validates :cost_price, :numericality => true, :allow_blank => true
    validates :min_weight, :numericality => true
    validates :max_weight, :numericality => true
  
    # Scopes
    scope :ordered, -> { order('price asc')}
    scope :for_weight, -> weight { where("min_weight <= ? AND max_weight >= ?", weight, weight) }
  
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
shoppe-0.0.15 app/models/shoppe/delivery_service_price.rb