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

Allow creating transactions without payee #89

Merged
merged 3 commits into from
Oct 26, 2024
Merged

Conversation

nyukhalov
Copy link
Contributor

Overview

actualpy fails to create a transaction without a payee.

When a default (payee='') payee value is used, actualpy searches for a payee with an empty name and expects to find only one such payee. Actual Budget uses special payees to represent transfers between accounts. Such payees always have an empty name. If a budget has more than one transfer payee, create_transaction will fail because get_or_create_payee will find multiple payees with empty names and fail validation.

When a None payee value is passed, create_transaction succeeds, but then Actual errors because of a invalid payee (I haven't captured the exact error, but you can easily reproduce this but calling create_transaction(..., payee=None)) and then editing this transaction in Actual.

Solution

This proposal adds support for the None payee value in create_transaction.
When a None value is passed, the implementation does not attempt to create a payee, and passes None as a payee_id in create_transaction_from_ids.

The proposed implementation should be backward compatible.

Copy link

codecov bot commented Oct 24, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 97.67%. Comparing base (68d640d) to head (0a6c0a7).
Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main      #89   +/-   ##
=======================================
  Coverage   97.67%   97.67%           
=======================================
  Files          16       16           
  Lines        2194     2196    +2     
=======================================
+ Hits         2143     2145    +2     
  Misses         51       51           

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

@bvanelli
Copy link
Owner

Thanks for the PR, actually I don't know why I've set the payee to an empty string initially... I tried on the UI and it's apparently setting it to none, but I guess it was to overcome this issue with the payees linked to the accounts, but your solution is better.

I'll check if all tests run when changing the default and I'll merge it.

@bvanelli bvanelli merged commit 2c89c52 into bvanelli:main Oct 26, 2024
8 checks passed
@bvanelli
Copy link
Owner

Thanks, it's now merged. The default has also been changed to None because that is the frontend default.

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.

2 participants