-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Debt tracker #23
Debt tracker #23
Conversation
This was a long branch - when merging, can squash to make history neater. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for the continued contribution, this is great! A couple comments, nothing major. Looks good!
Handle it as one of the arguments to applyExpenseAmountToTransaction
Make a deposit to the SW balance account of amount "balance" when an expense entails people owe me money, instead of a transfer from the paying account to the SW balance, which doesn't make sense.
If type is "deposit", the asset account is the *destination*, not the *source*.
If I payed nothing on an expense, don't make a transaction from my real accounts, only from the balance account.
fd037ad
to
4fb84d5
Compare
explicitly handle expenses where I paid nothing but I still owe something, and the edge case where an expense was recorded but I paid my whole share.
Remove ability to pass ExpenseUser to get amount, pass amount explicitly. Rename method to clarify usage.
Also, some tests seem to be failing. Mind taking a look? (A missing argument, and a decimal 0)
|
Correctly use mock_apply_transaction_amount
I'm not why the automatic tests failed, but they passed on my machine after the latest commits. |
The tests are good now, the pipeline fails due to permissions, but if you open it, it does show the test results (not sure if you would have permissions for that too). |
Let me think about it a bit. I remember going down the split transaction
route and rejecting it, but not why.
I think I didn't want to treat it as an expense account - it made more
sense to think of it as an asset account, and then it can get counted in
your net worth. I think you can't count an expense account in your net
worth.
…On Wed, Nov 13, 2024, 10:54 Adyanth Hosavalike ***@***.***> wrote:
***@***.**** commented on this pull request.
------------------------------
In strategies/sw_balance.py
<#23 (comment)>
:
> + self._sw_balance_account = sw_balance_account
+ self._apply_transaction_amount = apply_transaction_amount
+
+ def create_transactions(self, exp: Expense, myshare: ExpenseUser, data: list[str]) -> list[dict]:
+ txns = {}
+ paid_txn = self._get_expense_transaction_body(exp, myshare, data)
+ paid_txn = self._apply_transaction_amount(paid_txn, exp, myshare.getPaidShare())
+ if float(paid_txn['amount']) != 0: # I paid; payment txn needed
+ txns['paid'] = paid_txn
+
+ balance_txn = paid_txn.copy()
+ balance = float(myshare.getNetBalance())
+ if balance != 0: # I owe or am owed; balance txn needed
+ txns['balance'] = balance_txn
+ if balance > 0: # I am owed; difference credited to balance account
+ balance_txn['source_name'] = self._sw_balance_account + " balancer"
My bank statement would show 10 going to the grocery store, not 4 to the
store and 6 to another account.
Would you say correctly representing this warrants a new Firefly account
(the balancer account) to be created? Would this be an asset/revenue or an
expense account that deposits money into the asset account? You could make
use of the split transaction to generate something like this where it
correctly shows it as part of a single transaction.
Screenshot.2024-11-13.at.2.21.31.PM.png (view on web)
<https://github.com/user-attachments/assets/1dbe0f9c-d8c9-49f9-a50c-6c01ad880763>
I am good to merge this as is if you think this is the best approach. My
only concern in creating yet another account that might not technically be
needed.
—
Reply to this email directly, view it on GitHub
<#23 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AHU22SVXVRX6PLF76XTAKUL2AMHTXAVCNFSM6AAAAABRPEYF5OVHI2DSMVQWIX3LMV43YUDVNRWFEZLROVSXG5CSMV3GSZLXHMZDIMZSGMZTMMBRGU>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
Partially solves #9 - adds the splitwise balance functionality.
When processing SW expenses, adds a withdrawal transaction from the paying account for the full amount payed, and adds a deposit to the SW balance account.
If processing an expense payed by others - only add a withdrawal transaction from the SW balance account.
Feature is implemented using strategy design pattern - a feature switch in the .env file determines whether to use the simple strategy or the SW balance strategy for transaction handling.
main.py
changes are minor, does not contain SW balance logic - almost all in thestrategies/sw_balance.py
file.Waiting for comments and review :)