-
Notifications
You must be signed in to change notification settings - Fork 10
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
reconcile_transaction() somehow breaks the "rules" functionality on actual #68
Comments
I understand your use case, maybe adding a run_rules on commit would be enough, but it's not optimal because this API tries to mimic adding entries via frontend, and if you add a transaction via frontend, no rule will be run (as far as I could test). Wouldn't something like this work for you? from actual import Actual
from datetime import datetime
import decimal
from actual.queries import get_accounts, reconcile_transaction, get_ruleset
csv_data = [["Date", "Payee", "Notes", "Category", "Amount", "Cleared", "imported_ID"]]
URL_ACTUAL = "http://localhost:5006"
PASSWORD_ACTUAL = "mypass"
FILE_ACTUAL = "CSV Importer"
with Actual(base_url=URL_ACTUAL, password=PASSWORD_ACTUAL, file=FILE_ACTUAL) as actual:
accounts = get_accounts(actual.session)
ruleset = get_ruleset(actual.session)
added_transactions = []
for account in accounts:
for row in csv_data:
# here, we define the basic information from the file
date, payee, notes, category, amount, cleared, imported_ID = (
datetime.strptime(row[0], "%Y-%m-%d").date(), # transform to date
row[1],
row[2],
row[3],
decimal.Decimal(row[4]),
row[5] == "Cleared",
row[6],
)
t = reconcile_transaction(
actual.session,
date,
account,
payee,
notes,
category,
amount,
imported_ID,
cleared=cleared,
imported_payee=payee,
already_matched=added_transactions,
)
actual.session.flush() # flush to load the ids and relationships
ruleset.run(t) # run the rule here
added_transactions.append(t)
actual.commit() |
It worked now! Appreciate your help! |
Caught a new bug, now it's when running ruleset.run(t). The code example is basically the same as you sent above. This raised due to scheduled transactions. Ir only happens then the date from a transaction "t" is equal a trasaction added by a schedule. When I delete the schedule, it stops the error:
This raised due to " imported payee - any option - name " rule. Deleting the rule, stops the error:
|
Do your schedule happens to have an end date? Could you share how it is defined? |
I generated a new release, could you update and check if it still fails? |
Hello @tcpr1, thanks for your last message, I could finally reproduce the reason why it was crashing. Turns out I was comparing the wrong cutoff date when resolving the before weekend mode. It should be fixed in the soon to be released version 0.5.1. |
No more errors! |
Checks
Reproducible example
Log output
No response
Issue description
I am using reconcile_transaction() to import bank data into Actual.
Everything seems to be working fine, but the "rules" funcionality to rename payees do not work.
One thing I also noticed is when I import .ofx or .csv inside Actual, the payee name gets bolded, but it is not the case for the payees names of imported transactions through this API.
Expected behavior
After actual.commit() the newly created transactions should be renamed based on Actual rules automatically.
Installed versions
The text was updated successfully, but these errors were encountered: