class FbaFeeCalculator::FbaFeeCalculation
Attributes
amazon_referral_fee[R]
category[R]
cost_subtotal[R]
cubic_feet[R]
dimensional_weight[R]
dimensions[R]
fulfillment_cost_subtotal[R]
is_media[R]
margin_impact[R]
monthly_storage[R]
order_handling[R]
outbound_shipping_weight[R]
packaging_weight[R]
pick_and_pack[R]
price[R]
revenue_subtotal[R]
size_category[R]
size_tier[R]
variable_closing_fee[R]
weight[R]
weight_handling[R]
Public Class Methods
new(price, category, weight, dimensions)
click to toggle source
# File lib/fba_fee_calculator/fba_fee_calculation.rb, line 16 def initialize(price, category, weight, dimensions) @price = price @category = category @weight = weight @dimensions = dimensions @fba_fees = FbaFees.new end
Public Instance Methods
calculate!()
click to toggle source
# File lib/fba_fee_calculator/fba_fee_calculation.rb, line 24 def calculate! return unless valid? calculate_is_media calculate_size_category calculate_size_tier calculate_cubic_feet calculate_dimensional_weight calculate_packaging_weight calculate_outbound_shipping_weight calculate_revenue_subtotal calculate_amazon_referral_fee calculate_variable_closing_fee calculate_order_handling calculate_pick_and_pack calculate_weight_handling calculate_monthly_storage calculate_fulfillment_cost_subtotal calculate_cost_subtotal calculate_margin_impact self end
Private Instance Methods
calculate_amazon_referral_fee()
click to toggle source
# File lib/fba_fee_calculator/fba_fee_calculation.rb, line 82 def calculate_amazon_referral_fee @amazon_referral_fee = @fba_fees.get_amazon_referral_fee(category, price) end
calculate_cost_subtotal()
click to toggle source
# File lib/fba_fee_calculator/fba_fee_calculation.rb, line 110 def calculate_cost_subtotal @cost_subtotal = ((@fulfillment_cost_subtotal + @amazon_referral_fee + @variable_closing_fee) * -1).round(2) end
calculate_cubic_feet()
click to toggle source
# File lib/fba_fee_calculator/fba_fee_calculation.rb, line 62 def calculate_cubic_feet @cubic_feet = @fba_fees.get_cubic_feet(dimensions) end
calculate_dimensional_weight()
click to toggle source
# File lib/fba_fee_calculator/fba_fee_calculation.rb, line 66 def calculate_dimensional_weight @dimensional_weight = @fba_fees.get_dimensional_weight(dimensions) end
calculate_fulfillment_cost_subtotal()
click to toggle source
# File lib/fba_fee_calculator/fba_fee_calculation.rb, line 106 def calculate_fulfillment_cost_subtotal @fulfillment_cost_subtotal = (@order_handling + @pick_and_pack + @weight_handling + @monthly_storage).round(2) end
calculate_is_media()
click to toggle source
# File lib/fba_fee_calculator/fba_fee_calculation.rb, line 50 def calculate_is_media @is_media = @fba_fees.is_media?(category) end
calculate_margin_impact()
click to toggle source
# File lib/fba_fee_calculator/fba_fee_calculation.rb, line 114 def calculate_margin_impact @margin_impact = (@price + @cost_subtotal).round(2) end
calculate_monthly_storage()
click to toggle source
# File lib/fba_fee_calculator/fba_fee_calculation.rb, line 102 def calculate_monthly_storage @monthly_storage = @fba_fees.get_monthly_storage(size_category, cubic_feet) end
calculate_order_handling()
click to toggle source
# File lib/fba_fee_calculator/fba_fee_calculation.rb, line 90 def calculate_order_handling @order_handling = @fba_fees.get_order_handling(size_category, price) end
calculate_outbound_shipping_weight()
click to toggle source
# File lib/fba_fee_calculator/fba_fee_calculation.rb, line 74 def calculate_outbound_shipping_weight @outbound_shipping_weight = @fba_fees.get_outbound_shipping_weight(size_tier, weight, packaging_weight, dimensional_weight) end
calculate_packaging_weight()
click to toggle source
# File lib/fba_fee_calculator/fba_fee_calculation.rb, line 70 def calculate_packaging_weight @packaging_weight = @fba_fees.get_packaging_weight(size_category, is_media) end
calculate_pick_and_pack()
click to toggle source
# File lib/fba_fee_calculator/fba_fee_calculation.rb, line 94 def calculate_pick_and_pack @pick_and_pack = @fba_fees.get_pick_and_pack(size_tier) end
calculate_revenue_subtotal()
click to toggle source
# File lib/fba_fee_calculator/fba_fee_calculation.rb, line 78 def calculate_revenue_subtotal @revenue_subtotal = price end
calculate_size_category()
click to toggle source
# File lib/fba_fee_calculator/fba_fee_calculation.rb, line 54 def calculate_size_category @size_category = @fba_fees.get_standard_or_oversize(dimensions, weight) end
calculate_size_tier()
click to toggle source
# File lib/fba_fee_calculator/fba_fee_calculation.rb, line 58 def calculate_size_tier @size_tier = @fba_fees.get_size_tier(size_category, weight, dimensions, is_media) end
calculate_variable_closing_fee()
click to toggle source
# File lib/fba_fee_calculator/fba_fee_calculation.rb, line 86 def calculate_variable_closing_fee @variable_closing_fee = @fba_fees.get_variable_closing_fee(category, is_media) end
calculate_weight_handling()
click to toggle source
# File lib/fba_fee_calculator/fba_fee_calculation.rb, line 98 def calculate_weight_handling @weight_handling = @fba_fees.get_weight_handling(size_tier, outbound_shipping_weight, is_media) end
valid_dimensions()
click to toggle source
# File lib/fba_fee_calculator/fba_fee_calculation.rb, line 118 def valid_dimensions errs = [] if dimensions.length != 3 errs << "must have 3 parts (width, height, depth)" end dimensions.each do |dimension| if dimension.to_f <= 0 errs << "must contain all positive, numeric values" end end errs.uniq.each do |err| errors.add(:dimensions, err) end end