Skip to content
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

feat: Add budget balance and filter for budget in get_transactions #91

Merged
merged 1 commit into from
Oct 28, 2024

Conversation

bvanelli
Copy link
Owner

@bvanelli bvanelli commented Oct 26, 2024

Allows you to check the balance for your budget, as well as retrieve the transactions for each budget.

I did try to create transactions directly as a budget property, but that runs into different issues:

  • Creating the relationship is quite hard since we have to compare an integer from the budget in the form 202410, with an integer in the transactions table in the form 20241005. This makes the "safe" relationship harder to achieve. - When using instead a property, the sqlalchemy session is used instead of the sqlmodel session. It's probably not safe either since we have to convert the result first to the correct models, and I don't know if they would work 100%.

I instead included the budget filter in the get_transactions instead.
For example:

...
budget = get_budget(actual.session, datetime.date.today(), "Food")
print(f"Available to spend is: {budget.get_amount()}")
print(f"Already spent is: {budget.balance}")

For me prints:

Available to spend is: 30
Already spent is: -35

And frontend shows:

image

Closes #90

Copy link

codecov bot commented Oct 26, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 97.69%. Comparing base (2c89c52) to head (475beef).
Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main      #91      +/-   ##
==========================================
+ Coverage   97.67%   97.69%   +0.01%     
==========================================
  Files          16       16              
  Lines        2196     2213      +17     
==========================================
+ Hits         2145     2162      +17     
  Misses         51       51              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link

@raiyni raiyni left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems good with my testing

@bvanelli bvanelli merged commit 4921908 into main Oct 28, 2024
8 checks passed
@bvanelli bvanelli deleted the 90-scoped-budget-balance branch October 28, 2024 06:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Category from budgets should be scoped to the filtered month
2 participants