Created
September 30, 2018 00:19
-
-
Save joegaudet/2dba38b2e994db60d41582d9ab7bc146 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Invoice | |
%w(sender_details recipient_details).each do |method| | |
define_method method do | |
attributes[method] | |
end | |
end | |
%w(total_amount tax_amount).each do |meth| | |
define_method("#{meth}=") do |value| | |
currency_config = Invoicing::CurrencyValue::CURRENCIES[currency] || Invoicing::CurrencyValue::CURRENCIES[area.currency] | |
super( | |
BigDecimal(value).round( | |
currency_config[:digits], | |
Money.rounding_mode | |
) | |
) | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment