Prevent transaction amount with commas to give wrong results

This commit is contained in:
benji 2015-09-10 16:15:17 +02:00
parent e593d0fda0
commit ec5e556dde

View file

@ -40,8 +40,13 @@ class TransactionsController < ApplicationController
debtor: User.find_by(name: t[:debtor]) || User.zeus,
creditor: User.find_by(name: t[:creditor]) || User.zeus,
issuer: current_client || current_user,
amount: (t[:euros].to_f*100 + t[:cents].to_f).to_i,
amount: (float(t[:euros]) * 100 + float(t[:cents])).to_i,
message: t[:message]
}
end
def float arg
if arg.is_a? String then arg.sub!(',', '.') end
arg.to_f
end
end