2015-09-08 13:25:54 +00:00
|
|
|
module TransactionsHelper
|
2015-09-08 18:45:32 +00:00
|
|
|
def get_transaction_peer(transaction, user)
|
|
|
|
return transaction.creditor if user == transaction.debtor
|
|
|
|
return transaction.debtor if user == transaction.creditor
|
|
|
|
end
|
|
|
|
|
|
|
|
def amount_in_perspective(transaction, user)
|
|
|
|
return -transaction.amount if user == transaction.debtor
|
|
|
|
return transaction.amount if user == transaction.creditor
|
|
|
|
end
|
2015-09-08 13:25:54 +00:00
|
|
|
end
|