mirror of
https://github.com/Growstuff/growstuff.git
synced 2026-05-14 11:15:48 -04:00
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.
29 lines
675 B
Ruby
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
|
|
|