Module: Custom::PriceHelper
- Included in:
- Lib::Boats::RentPricePerSeason, Lib::Boats::SalePrice
- Defined in:
- app/helpers/custom/price_helper.rb
Instance Method Summary collapse
Instance Method Details
#price_discount(object, attr) ⇒ Object
6 7 8 9 10 11 12 13 14 |
# File 'app/helpers/custom/price_helper.rb', line 6 def price_discount(object, attr) price = object.attributes[currency_attribute_name(attr)] discount = object.attributes["#{attr}_discount"] return '' if price.nil? return price if discount.nil? price - (price / 100 * discount) end |
#price_format(object, attr, options = {}) ⇒ Object
18 19 20 21 22 23 24 25 26 27 |
# File 'app/helpers/custom/price_helper.rb', line 18 def price_format(object, attr, = {}) price = [:discounted] ? price_discount(object, attr) : object.attributes[currency_attribute_name(attr, [:currency])] return '' if price.blank? unit = currency_symbol [:currency] price = number_to_currency(price, unit: unit).to_s price = price + [:postfix] if [:postfix] price = [:prefix] + price if [:prefix] price end |