Skip to content

Instantly share code, notes, and snippets.

@hkilis
Last active July 27, 2018 07:44
Show Gist options
  • Save hkilis/9df1e83e85dce7e9764129859ed1cfdb to your computer and use it in GitHub Desktop.
Save hkilis/9df1e83e85dce7e9764129859ed1cfdb to your computer and use it in GitHub Desktop.
BRAND_RATING_FACTOR = {:high => 1.1, :low => 0.9}
PRICING_REFRENCE = {15 => 0.75, 25 => 0.775, 50 => 0.8, 75 => 0.825, 100 => 0.85, 200 => 0.875, 400 => 0.9, 600 => 0.925}
price_reference = 99
product_database_shipping_cost = 50
brand_rating = 'high'
def get_pricing_ceil(price)
PRICING_REFRENCE.find {|key, _| price < key}.try(:last) || 0.95
end
price_original = price_suggestion = (price_reference - product_database_shipping_cost * get_pricing_ceil(price_reference)) * BRAND_RATING_FACTOR.fetch(brand_rating.to_sym, 1)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment