Sha256: efeff43840e19a5084708b8218f1f85ef88b5afa360aec46d67b6e3d4eb696d7

Contents?: true

Size: 856 Bytes

Versions: 4

Compression:

Stored size: 856 Bytes

Contents

module Spree
  class ShippingRate < ActiveRecord::Base
    belongs_to :shipment, class_name: 'Spree::Shipment'
    belongs_to :shipping_method, class_name: 'Spree::ShippingMethod'

    attr_accessible :id, :shipping_method, :shipment,
                    :name, :cost, :selected, :shipping_method_id

    scope :frontend, -> { includes(:shipping_method).where(ShippingMethod.on_frontend_query) }
    scope :backend, -> { includes(:shipping_method).where(ShippingMethod.on_backend_query) }

    delegate :order, :currency, to: :shipment
    delegate :name, to: :shipping_method

    def display_price
      if Spree::Config[:shipment_inc_vat]
        price = (1 + Spree::TaxRate.default) * cost
      else
        price = cost
      end

      Spree::Money.new(price, { currency: currency })
    end
    alias_method :display_cost, :display_price
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
spree_core-2.0.7 app/models/spree/shipping_rate.rb
spree_core-2.0.6 app/models/spree/shipping_rate.rb
spree_core-2.0.5 app/models/spree/shipping_rate.rb
spree_core-2.0.4 app/models/spree/shipping_rate.rb