Sha256: 14ae1b25abf6fe6eeb591a238c0b2daaa179448ca3160ecd6d3832ce305bb471
Contents?: true
Size: 676 Bytes
Versions: 12
Compression:
Stored size: 676 Bytes
Contents
module MuckCommerce module CurrencyMethods # Assumes a field named amount def amount_dollars= val self.amount = dollars_to_cents(val) end # Assumes a field named amount def amount_dollars cents_to_dollars(self.amount) end # Assumes a field named amount # Get the order amount as a formatted currency instead of as cents. def amount_price format_currency(self.amount) end protected def format_currency(val) format("%.2f", cents_to_dollars(val)) end def cents_to_dollars(val) val * 0.01 end def dollars_to_cents(val) val * 100 end end end
Version data entries
12 entries across 12 versions & 1 rubygems