diff --git a/lib/king_dta/booking.rb b/lib/king_dta/booking.rb index b6bfcea..9e91f67 100644 --- a/lib/king_dta/booking.rb +++ b/lib/king_dta/booking.rb @@ -24,9 +24,9 @@ def initialize( account, value, text=nil, account_key=nil, currency="EUR" ) end @currency = currency if value.is_a?(String) - value = BigDecimal.new value.sub(',', '.') + value = big_decimal value.sub(',', '.') elsif value.is_a?(Numeric) - value = BigDecimal.new value.to_s + value = big_decimal value.to_s else raise Exception.new("Gimme a value as a String or Numeric. You gave me a #{value.class}") end @@ -46,6 +46,10 @@ def text=(text) @text = convert_text( text ) end + def big_decimal(val) + BigDecimal.try(:new, val) || BigDecimal(val) + end + def pos?; @pos end end #class Buchung