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

Add support for running and inserting rules #12

Merged
merged 6 commits into from
May 6, 2024

Conversation

bvanelli
Copy link
Owner

@bvanelli bvanelli commented May 6, 2024

  • Introduce Rule and RuleSet for creating new rules and running existing rules on the local database.
  • Refactor some parts of the code to make the API naming more uniform
  • Update database model to include the custom reports

Here is one example rule adding with frontend result:

import datetime

from actual import Actual
from actual.queries import create_rule
from actual.rules import (
    Action,
    Condition,
    ConditionType,
    Rule,
)


with Actual("http://localhost:5006", password="mypass", file="My Finances") as actual:
    action = Action(field="cleared", value=1)
    condition = Condition(field="date", op=ConditionType.IS_APPROX, value=datetime.date(2024, 1, 2))
    rule = Rule(conditions=[condition], actions=[action], operation="all", stage="pre")
    created_rule = create_rule(actual.session, rule)
    actual.commit()

Result:

image

Closes #11

@bvanelli bvanelli merged commit dd7aad2 into main May 6, 2024
4 checks passed
@bvanelli bvanelli deleted the refactor/organize-code-a-bit branch May 6, 2024 20:15
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.

Add support for running rules offline
1 participant