Skip to content

Commit

Permalink
minor refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
Sha-yol committed Nov 11, 2024
1 parent 4522c2d commit bf398ac
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions strategies/sw_balance.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ def create_transactions(self, exp: Expense, myshare: ExpenseUser, data: list[str
txns['paid'] = paid_txn

balance_txn = paid_txn.copy()
balance = myshare.getNetBalance()
if float(balance) != 0: # I owe or am owed; balance txn needed
balance = float(myshare.getNetBalance())
if balance != 0: # I owe or am owed; balance txn needed
txns['balance'] = balance_txn
if float(balance) > 0: # I am owed; difference credited to balance account
if balance > 0: # I am owed; difference credited to balance account
balance_txn['source_name'] = self._sw_balance_account + " balancer"
balance_txn['destination_name'] = self._sw_balance_account
balance_txn['type'] = 'deposit'
Expand All @@ -30,5 +30,5 @@ def create_transactions(self, exp: Expense, myshare: ExpenseUser, data: list[str
balance_txn['destination_name'] = paid_txn['destination_name']
balance_txn['type'] = "withdrawal"
balance_txn['description'] = f"Balance transfer for: {paid_txn['description']}"
balance_txn = self._apply_transaction_amount(balance_txn, exp, -float(balance))
balance_txn = self._apply_transaction_amount(balance_txn, exp, -balance)
return list(txns.values())

0 comments on commit bf398ac

Please sign in to comment.