Files
growstuff/app/helpers/application_helper.rb
Lucy e674a6572e Added conversion links for recommended prices.
The paragraphs were getting a bit verbose so we shortened the link
text as well. Added an additional test to make sure the link is
working here too.
2013-07-03 13:22:07 +01:00

29 lines
675 B
Ruby

module ApplicationHelper
def price_in_dollars(price)
return sprintf('%.2f', price / 100.0)
end
# 999 cents becomes 9.99 AUD -- for products/orders/etc
def price_with_currency(price)
return sprintf('%.2f %s', price / 100.0,
Growstuff::Application.config.currency)
end
def parse_date(str)
str ||= '' # Date.parse barfs on nil
return str == '' ? nil : Date.parse(str)
end
def forex_link(price)
pid = price_in_dollars(price)
currency = Growstuff::Application.config.currency
link = "http://www.wolframalpha.com/input/?i=#{pid}+#{currency}"
return link_to "(convert)",
link,
:target => "_blank"
end
end