Change MoneyMove model #2

Merged
bilal.catic merged 2 commits from implement-new-logic-for-ledger-update into master 2020-05-20 16:49:30 +02:00
Showing only changes of commit 3cc8cb7d85 - Show all commits

View File

@@ -32,18 +32,9 @@ class MoneyMove < ApplicationRecord
end
end
def old_desc(params)
if params[:description].present?
"#{params[:description]} - "
else
''
end
end
def create_move_from(params)
to_homie_name = Homie.find(params[:to_homie_id]).name
added_desc = "[To: #{to_homie_name}]"
new_desc = "#{old_desc(params)}#{added_desc}"
new_desc = "[#{to_homie_name}] #{params[:description]}".lstrip
MoneyMove.new(
homie_id: params[:from_homie_id],
amount: -params[:amount].to_d,
@@ -52,8 +43,7 @@ class MoneyMove < ApplicationRecord
end
def create_move_to(params)
added_desc = "[From: #{from_source_name(params)}]"
new_desc = "#{old_desc(params)}#{added_desc}"
new_desc = "[#{from_source_name(params)}] #{params[:description]}".lstrip
MoneyMove.new(
homie_id: params[:to_homie_id],
amount: params[:amount].to_d,