accept and use custom settle value

This commit is contained in:
Bilal
2020-10-05 14:25:42 +03:00
parent 6a6f650538
commit 04abd4be78
3 changed files with 6 additions and 5 deletions

View File

@@ -12,8 +12,8 @@ class Homie < ApplicationRecord
end
end
def settle
total = MoneyMove.where(homie_id: id).all.sum(:amount)
def settle(amount)
total = amount.nil? ? MoneyMove.where(homie_id: id).all.sum(:amount) : amount
all_money_moves = MoneyMove.where(homie_id: id).all
transaction do
@@ -22,7 +22,7 @@ class Homie < ApplicationRecord
MoneyMove.create_settle_record(id, total)
end
true
rescue StandardError => e
rescue StandardError
false
end
end