Class: ShippingRate

Inherits:
ActiveRecord::Base
  • Object
show all
Includes:
ActionView::Helpers::NumberHelper
Defined in:
app/models/shipping_rate.rb

Overview

Schema Information

Table name: shipping_rates

id                    :integer(4)      not null, primary key
shipping_method_id    :integer(4)      not null
rate                  :decimal(8, 2)   default(0.0), not null
shipping_rate_type_id :integer(4)      not null
shipping_category_id  :integer(4)      not null
minimum_charge        :decimal(8, 2)   default(0.0), not null
position              :integer(4)
active                :boolean(1)      default(TRUE)
created_at            :datetime
updated_at            :datetime

Constant Summary

MONTHLY_BILLING_RATE_ID =
1

Instance Method Summary (collapse)

Instance Method Details

- (Boolean) individual?

determines if the shippng rate should be calculated individually

Parameters:

  • (none)

Returns:

  • (Boolean)


43
44
45
# File 'app/models/shipping_rate.rb', line 43

def individual?
  shipping_rate_type_id == ShippingRateType::INDIVIDUAL_ID
end

- (String) name

the shipping method name, shipping zone and sub_name ex. '3 to 5 day UPS, International, Individual - 5.50'

Parameters:

  • (none)

Returns:

  • (String)


52
53
54
# File 'app/models/shipping_rate.rb', line 52

def name
  [shipping_method.name, shipping_method.shipping_zone.name, sub_name].join(', ')
end

- (String) name_rate_min

the shipping method name, and $$$ rate ex. '3 to 5 day UPS - $5.50'

Parameters:

  • (none)

Returns:

  • (String)


70
71
72
# File 'app/models/shipping_rate.rb', line 70

def name_rate_min
  [name_with_rate, "(min order => #{minimum_charge})" ].join(' ')
end

- (String) name_with_rate

the shipping method name, and $$$ rate ex. '3 to 5 day UPS - $5.50'

Parameters:

  • (none)

Returns:

  • (String)


79
80
81
# File 'app/models/shipping_rate.rb', line 79

def name_with_rate
  [shipping_method.name, charge_amount].compact.join(' - ')
end

- (String) sub_name

the shipping rate type and $$$ rate separated by ' - ' ex. 'Individual - 5.50'

Parameters:

  • (none)

Returns:

  • (String)


61
62
63
# File 'app/models/shipping_rate.rb', line 61

def sub_name
  '(' + [shipping_rate_type.name, rate ].join(' - ') + ')'
end