Queries
queries
Functions:
-
get_transactions–Returns a list of all available transactions, sorted by date in descending order.
-
match_transaction–Matches a transaction with another transaction based on the fuzzy matching.
-
create_transaction_from_ids–Internal method to generate a transaction from ids instead of objects.
-
create_transaction–Creates a transaction from the provided input.
-
set_transaction_payee–Sets a payee safely by checking if this payee is a transfer. If it is, then the transfer will be created.
-
normalize_payee–Normalizes the payees to make sure they are consistent across imports.
-
reconcile_transaction–Matches the transaction to an existing transaction using fuzzy matching.
-
create_splits–Creates a transaction with splits based on the list of transactions.
-
create_split–Creates a transaction split based on the parent transaction.
-
get_category_groups–Returns a list of all available category groups.
-
create_category_group–Creates a new category with the group name
name. -
get_or_create_category_group–Gets or create the category group, if not found with
name. -
get_categories–Returns a list of all available categories.
-
create_category–Creates a new category with the
nameandgroup_name. If the group is not existing, it will also be created. -
get_tag–Gets one individual tag based on an exact match of the name.
-
get_tags–Get all tags stored on the Actual database using a name or description pattern.
-
create_tag–Creates a new tag with the
nameanddescription. Name should not be provided with the hashtag. -
get_category–Gets an existing category by name, returns
Noneif not found. Deleted payees are excluded from the search. -
get_or_create_category–Gets or create the category, if not found with
name. -
get_accounts–Returns a list of all available accounts.
-
get_payees–Returns a list of all available payees.
-
get_payee–Gets an existing payee by name, returns
Noneif not found. Deleted payees are excluded from the search. -
create_payee–Creates a new payee with the desired name.
-
get_or_create_payee–Gets an existing payee by name, and if it does not exist, creates a new one.
-
create_account–Creates a new account with the name and balance.
-
get_account–Gets an account with the desired name, otherwise returns
None. Deleted accounts are excluded from the search. -
get_or_create_account–Gets or create the account, if not found with
name. The initial balance will be set to0. -
get_budgets–Returns a list of all available budgets.
-
get_budget–Gets an existing budget by category name, returns
Noneif not found. -
create_budget–Gets an existing budget based on the month and category. If it already exists, the amount will be replaced by
-
get_budgeted_balance–Returns the budgeted balance under the category for the individual month, not taking into account accumulated value.
-
get_accumulated_budgeted_balance–Returns the budgeted balance as shown by the Actual UI under the category.
-
get_held_budget–Gets the budget held for a budget month from the database.
-
create_transfer–Creates a transfer of money between two accounts. The amount is provided as a positive value.
-
get_rules–Returns a list of all available rules.
-
get_ruleset–Returns a list of all available rules, but as a rule set that can be used to be applied to existing transactions.
-
create_rule–Creates a rule based on the conditions and actions defined on the input rule. The rule can be ordered to run
-
get_schedules–Returns a list of all available schedules, automatically filtering completed schedules.
-
create_schedule–Create a schedule database object based on the parameters.
-
create_schedule_config–Created a recurring config for the schedule.
-
get_or_create_clock–Loads the HULC Clock from the database that tells the client from when the messages should be retrieved.
-
get_preferences–Loads the preference list from the database.
-
get_or_create_preference–Loads the preference list from the database. If the key is missing, a new one is created, otherwise it's updated.
-
get_preference–Gets an existing preference by key name, returns
Noneif not found.
get_transactions
get_transactions(
s: Session,
start_date: date | None = None,
end_date: date | None = None,
notes: str | None = None,
account: Accounts | str | None = None,
category: Categories | str | None = None,
is_parent: bool = False,
include_deleted: bool = False,
budget: ZeroBudgets | None = None,
cleared: bool | None = None,
payee: Payees | str | None = None,
amount: Decimal | float | int | None = None,
transfer: bool | None = None,
off_budget: bool | None = None,
) -> Sequence[Transactions]
Returns a list of all available transactions, sorted by date in descending order.
Parameters:
-
(sSession) –Session from the Actual local database.
-
(start_datedate | None, default:None) –Optional start date for the transaction period (inclusive)
-
(end_datedate | None, default:None) –optional end date for the transaction period (exclusive)
-
(notesstr | None, default:None) –optional notes filter for the transactions. This looks for a case-insensitive pattern rather than for the exact match, i.e. 'foo' would match 'Foo Bar'.
-
(accountAccounts | str | None, default:None) –Optional account (either Account object or Account name) filter for the transactions.
-
(categoryCategories | str | None, default:None) –Optional category (either Category object or Category name) filter for the transactions.
-
(is_parentbool, default:False) –Optional boolean flag to indicate if a transaction is a parent. Parent transactions are either single transactions or the main transaction with the
Transactions.splitsproperty. The default is to return all individual splits, and the parent can be retrieved by theTransactions.parentproperty. -
(include_deletedbool, default:False) –Includes deleted transactions from the search.
-
(budgetZeroBudgets | None, default:None) –Optional budget filter for the transactions. The budget range and category will be used to filter the final results. **Usually not used together with the
start_dateandend_datefilters, as they might hide results. -
(clearedbool | None, default:None) –Optional cleared filter for the transactions. Defaults to None, meaning both cleared and non-cleared transactions are included.
-
(payeePayees | str | None, default:None) –Optional payee filter for the transactions. If provided, only transactions with a matching payee are returned. Returns an empty list if no matches are found. By default, it returns all transactions.
-
(amountDecimal | float | int | None, default:None) –Optional amount filter for the transactions. If provided, only transactions with a matching amount are returned. Returns an empty list if no matches are found. By default, it returns all transactions.
-
(transferbool | None, default:None) –Optional transfer filter for the transactions. If True, only transactions which are transfers between two accounts are returned. When False, no transfers are returned. By default, it returns all transactions.
-
(off_budgetbool | None, default:None) –Optional off-budget filter for the transactions. If True, only transactions from off-budget accounts are returned. If False, only transactions from on-budget accounts are returned. By default (None), returns all transactions regardless of budget status.
Returns:
-
Sequence[Transactions]–List of transactions with
account,categoryandpayeepreloaded.
Source code in actual/queries.py
123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 | |
match_transaction
match_transaction(
s: Session,
date: date,
account: str | Accounts,
payee: str | Payees | None = None,
amount: Decimal | float | int = 0,
imported_id: str | None = None,
already_matched: list[Transactions] | None = None,
) -> Transactions | None
Matches a transaction with another transaction based on the fuzzy matching.
Described at reconcileTransactions. The matches, from strongest to the weakest are defined as follows:
- The strongest match will be the
imported_id(orfinancial_id), - The transaction with the same exact amount and around the same date (7 days), with the same payee (closest first).
- The transaction with the same exact amount and around the same date (7 days, closest first).
Source code in actual/queries.py
create_transaction_from_ids
create_transaction_from_ids(
s: Session,
date: date,
account_id: str,
payee_id: str | None,
notes: str | None,
category_id: str | None = None,
amount: Decimal | float = 0,
imported_id: str | None = None,
cleared: bool = False,
imported_payee: str | None = None,
process_payee: bool = True,
) -> Transactions
Internal method to generate a transaction from ids instead of objects.
Source code in actual/queries.py
create_transaction
create_transaction(
s: Session,
date: date,
account: str | Accounts,
payee: str | Payees | None = None,
notes: str | None = "",
category: str | Categories | None = None,
amount: Decimal | float | int = 0,
imported_id: str | None = None,
cleared: bool = False,
imported_payee: str | None = None,
) -> Transactions
Creates a transaction from the provided input.
Parameters:
-
(sSession) –Session from the Actual local database.
-
(datedate) –Date of the transaction.
-
(accountstr | Accounts) –Either account name or account object (via
get_accountorget_accounts). Will not be auto-created if missing. -
(payeestr | Payees | None, default:None) –Optional name of the payee from the transaction. Will be created if missing.
-
(notesstr | None, default:'') –Optional description for the transaction.
-
(categorystr | Categories | None, default:None) –Optional category for the transaction. Will be created if not existing.
-
(amountDecimal | float | int, default:0) –Amount of the transaction. Positive indicates that the account balance will go up (deposit), and negative that the account balance will go down (payment)
-
(imported_idstr | None, default:None) –unique id of the imported transaction. This is often provided if the transaction comes from a third-party system that contains unique ids (i.e., via bank sync).
-
(clearedbool, default:False) –Visual indication that the transaction is in both your budget and in your account statement, and they match.
-
(imported_payeestr | None, default:None) –Known internally as imported_description, this is the original name of the payee, when importing data and before running rules.
Returns:
-
Transactions–The generated transaction object.
Source code in actual/queries.py
set_transaction_payee
set_transaction_payee(
s: Session,
transaction: Transactions,
payee: Payees | str | None,
) -> None
Sets a payee safely by checking if this payee is a transfer. If it is, then the transfer will be created.
This is necessary since the payee can be set to a "transfer id", which references an account. When this happens, the transaction will be marked as a transfer between the two accounts, and a new transaction will need to be created on the other account, with the negative amount.
Parameters:
-
(sSession) –Session from the Actual local database.
-
(transactionTransactions) –Transaction to exchange the payee.
-
(payeePayees | str | None) –Object or unique id of the payee to be set. Must be existing
Source code in actual/queries.py
normalize_payee
normalize_payee(
payee_name: str | None, raw_payee_name: bool = False
) -> str
Normalizes the payees to make sure they are consistent across imports.
Done according to the source code found at the official source code
To make sure that the payees are consistent across the imports, an example string like 'MY PAYEE ' turns into
'My Payee', as well as 'My PaYeE'. Those are considered to be the same payee.
Parameters:
-
(payee_namestr | None) –The original payee name to be normalized.
-
(raw_payee_namebool, default:False) –If the original payee name should be used instead. If the payee provided consists of spaces or an empty string, it will still be assigned to
None.
Returns:
-
str–The normalized payee name.
Source code in actual/queries.py
reconcile_transaction
reconcile_transaction(
s: Session,
date: date,
account: str | Accounts,
payee: str | Payees | None = None,
notes: str | None = None,
category: str | Categories | None = None,
amount: Decimal | float | int = 0,
imported_id: str | None = None,
cleared: bool | None = None,
imported_payee: str | None = None,
update_existing: bool = True,
already_matched: list[Transactions] | None = None,
) -> Transactions
Matches the transaction to an existing transaction using fuzzy matching.
Parameters:
-
(sSession) –Session from the Actual local database.
-
(datedate) –Date of the transaction.
-
(accountstr | Accounts) –Either account name or account object (via
get_accountorget_accounts). Will not be auto-created if missing. -
(payeestr | Payees | None, default:None) –Name of the payee from the transaction. Will be created if missing.
-
(notesstr | None, default:None) –Optional description for the transaction.
-
(categorystr | Categories | None, default:None) –Optional category for the transaction. Will be created if not existing.
-
(amountDecimal | float | int, default:0) –Amount of the transaction. Positive indicates that the account balance will go up (deposit), and negative that the account balance will go down (payment)
-
(imported_idstr | None, default:None) –unique id of the imported transaction. This is often provided if the transaction comes from a third-party system that contains unique ids (i.e., via bank sync).
-
(clearedbool | None, default:None) –This is a visual indication that the transaction is in both your budget and in your account statement, and they match.
-
(imported_payeestr | None, default:None) –Known internally as imported_description, this is the original name of the payee, when importing data and before running rules.
-
(update_existingbool, default:True) –If the transaction should be updated to the provided properties, if a match is found.
-
(already_matchedlist[Transactions] | None, default:None) –List of the transactions that were already matched. When importing a list of transactions, this would prevent transactions with the exact same (date, amount) to be assigned as duplicates.
Returns:
-
Transactions–The generated or matched transaction object.
Source code in actual/queries.py
create_splits
create_splits(
s: Session,
transactions: Sequence[Transactions],
payee: str | Payees | None = None,
notes: str = "",
) -> Transactions
Creates a transaction with splits based on the list of transactions.
The total amount will be evaluated as the sum of the individual amounts. All dates must be set to the same value.
Parameters:
-
(sSession) –Session from the Actual local database.
-
(transactionsSequence[Transactions]) –List of transactions that will be added to the splits.
-
(payeestr | Payees | None, default:None) –(Deprecated) Name or object of the payee from the transaction. Ignored for all purposes, since only the child transactions have a payee.
-
(notesstr, default:'') –Optional description for the transaction.
Returns:
-
Transactions–The generated transaction object for the parent transaction.
Source code in actual/queries.py
create_split
create_split(
s: Session,
transaction: Transactions,
amount: float | Decimal,
) -> Transactions
Creates a transaction split based on the parent transaction.
This is the opposite of create_splits, that joins all transactions as one big transaction. When using this method, you need to make sure all splits that you add to a transaction are then valid.
Parameters:
-
(sSession) –Session from the Actual local database.
-
(transactionTransactions) –Parent transaction to the split you want to create.
-
(amountfloat | Decimal) –Amount of the split.
Returns:
-
Transactions–The generated transaction object for the split transaction.
Source code in actual/queries.py
get_category_groups
get_category_groups(
s: Session,
name: str | None = None,
include_deleted: bool = False,
is_income: bool | None = None,
)
Returns a list of all available category groups.
Parameters:
-
(sSession) –Session from the Actual local database.
-
(namestr | None, default:None) –Pattern name of the category group, case-insensitive.
-
(include_deletedbool, default:False) –Includes all category groups deleted via frontend. They would not show normally.
-
(is_incomebool | None, default:None) –If set, it will filter by the
is_incomeproperty of the category.
Returns:
-
–
List of category groups with
categoriesalready loaded.
Source code in actual/queries.py
create_category_group
create_category_group(
s: Session, name: str
) -> CategoryGroups
Creates a new category with the group name name.
Make sure you avoid creating payees with duplicate names, as it makes it difficult to find them without knowing the unique id beforehand.
Source code in actual/queries.py
get_or_create_category_group
get_or_create_category_group(
s: Session, name: str
) -> CategoryGroups
Gets or create the category group, if not found with name.
Deleted category groups are excluded from the search.
Source code in actual/queries.py
get_categories
get_categories(
s: Session,
name: str | None = None,
include_deleted: bool = False,
is_income: bool | None = None,
) -> Sequence[Categories]
Returns a list of all available categories.
Parameters:
-
(sSession) –Session from the Actual local database.
-
(namestr | None, default:None) –Pattern name of the category, case-insensitive.
-
(include_deletedbool, default:False) –Includes all categories deleted via frontend. They would not show normally.
-
(is_incomebool | None, default:None) –If set, it will filter by the
is_incomeproperty of the category.
Returns:
-
Sequence[Categories]–List of categories with
transactionsalready loaded.
Source code in actual/queries.py
create_category
create_category(
s: Session, name: str, group_name: str | None = None
) -> Categories
Creates a new category with the name and group_name. If the group is not existing, it will also be created.
Make sure you avoid creating categories with duplicate names, as it makes it difficult to find them without knowing the unique id beforehand. The exception is to have them in separate group names, but you then need to provide the group name to the method also.
If a group name is not provided, the default 'Usual Expenses' will be picked.
Source code in actual/queries.py
get_tag
Gets one individual tag based on an exact match of the name.
get_tags
get_tags(
s: Session,
name: str | None = None,
description: str | None = None,
include_deleted: bool = False,
) -> Sequence[Tags]
Get all tags stored on the Actual database using a name or description pattern.
Parameters:
-
(sSession) –Session from the Actual local database.
-
(namestr | None, default:None) –Pattern name of the tag name, case-insensitive.
-
(descriptionstr | None, default:None) –Pattern name of the tag description, case-insensitive.
-
(include_deletedbool, default:False) –Includes all tags which were deleted via frontend. They would not show normally.
Source code in actual/queries.py
create_tag
create_tag(
s: Session,
name: str,
description: str | None = None,
color: str = "#690CB0",
) -> Tags
Creates a new tag with the name and description. Name should not be provided with the hashtag.
The name will be the tag used inside the transaction. You can use this tag afterward by setting the
notes of a transaction. If your tag is called 'foo', you can append '#foo' to the transaction notes.
The color of the tag can be provided as hexadecimal (i.e. '#690CB0' for purple or '#1976D2' for blue).
Source code in actual/queries.py
get_category
get_category(
s: Session,
name: str | Categories,
group_name: str | None = None,
strict_group: bool = False,
) -> Categories | None
Gets an existing category by name, returns None if not found. Deleted payees are excluded from the search.
Source code in actual/queries.py
get_or_create_category
get_or_create_category(
s: Session,
name: str | Categories,
group_name: str | None = None,
strict_group: bool = False,
) -> Categories
Gets or create the category, if not found with name.
If the category already exists, but in a different group, but the category name is still unique, it will be
returned, unless strict_group is set to True.
If a group name is not provided, the default 'Usual Expenses' will be picked.
Source code in actual/queries.py
get_accounts
get_accounts(
s: Session,
name: str | None = None,
include_deleted: bool = False,
closed: bool | None = None,
off_budget: bool | None = None,
) -> Sequence[Accounts]
Returns a list of all available accounts.
Parameters:
-
(sSession) –Session from the Actual local database.
-
(namestr | None, default:None) –Pattern name of the payee, case-insensitive.
-
(include_deletedbool, default:False) –Includes all payees deleted via frontend. They would not show normally.
-
(closedbool | None, default:None) –Optional closed filter; Defaults to None (includes open and closed accounts).
-
(off_budgetbool | None, default:None) –Optional off_budget filter; Defaults to None (includes off and on budget accounts).
Returns:
Source code in actual/queries.py
get_payees
get_payees(
s: Session,
name: str | None = None,
include_deleted: bool = False,
) -> Sequence[Payees]
Returns a list of all available payees.
Parameters:
-
(sSession) –Session from the Actual local database.
-
(namestr | None, default:None) –Pattern name of the payee, case-insensitive.
-
(include_deletedbool, default:False) –Includes all payees deleted via frontend. They would not show normally.
Returns:
Source code in actual/queries.py
get_payee
Gets an existing payee by name, returns None if not found. Deleted payees are excluded from the search.
Source code in actual/queries.py
create_payee
Creates a new payee with the desired name.
Make sure you avoid creating payees with duplicate names, as it makes it difficult to find them without knowing the unique id beforehand.
Source code in actual/queries.py
get_or_create_payee
Gets an existing payee by name, and if it does not exist, creates a new one.
If the payee is created twice, this method will fail with a database error.
Source code in actual/queries.py
create_account
create_account(
s: Session,
name: str,
initial_balance: Decimal | float = Decimal(0),
off_budget: bool = False,
) -> Accounts
Creates a new account with the name and balance.
Make sure you avoid creating accounts with duplicate names, as it makes it difficult to find them without knowing the unique id beforehand.
Source code in actual/queries.py
get_account
Gets an account with the desired name, otherwise returns None. Deleted accounts are excluded from the search.
Source code in actual/queries.py
get_or_create_account
Gets or create the account, if not found with name. The initial balance will be set to 0.
Source code in actual/queries.py
get_budgets
get_budgets(
s: Session,
month: date | None = None,
category: str | Categories | None = None,
) -> Sequence[BaseBudgets]
Returns a list of all available budgets.
The object type returned will be either ZeroBudgets or ReflectBudgets, depending on the type of budget selected globally. The budget options are:
- Envelope budgeting (default): ZeroBudgets
- Tracking budgeting: ReflectBudgets
Parameters:
-
(sSession) –Session from the Actual local database.
-
(monthdate | None, default:None) –Month to get budgets for, as a date for that month. Use
datetime.date.today()if you want the budget for the current month. -
(categorystr | Categories | None, default:None) –The category to filter for the budget. By default, the query looks for all budgets.
Returns:
-
Sequence[BaseBudgets]–List of budgets. It's important to note that budgets will only exist if they are actively set beforehand. When the frontend shows a budget as 0.00, it might not be returned by this method.
Source code in actual/queries.py
get_budget
get_budget(
s: Session, month: date, category: str | Categories
) -> BaseBudgets | None
Gets an existing budget by category name, returns None if not found.
Parameters:
-
(sSession) –Session from the Actual local database.
-
(monthdate) –Month to get budgets for, as a date for that month. Use
datetime.date.today()if you want the budget for the current month. -
(categorystr | Categories) –Category to filter for the budget.
Returns:
-
BaseBudgets | None–Returns the budget matching the month and category. If not found, returns
None. If the budget is not set via frontend, it will show as 0.00, but this function will still returnNone.
Source code in actual/queries.py
create_budget
create_budget(
s: Session,
month: date,
category: str | Categories,
amount: Decimal | float | int = 0.0,
carryover: bool | None = None,
) -> BaseBudgets
Gets an existing budget based on the month and category. If it already exists, the amount will be replaced by the new amount.
Parameters:
-
(sSession) –Session from the Actual local database.
-
(monthdate) –Month to get budgets for, as a date for that month. Use
datetime.date.today()if you want the budget for the current month. -
(categorystr | Categories) –Category to filter for the budget.
-
(amountDecimal | float | int, default:0.0) –Amount for the budget.
-
(carryoverbool | None, default:None) –If set to
True, the budget will carry the negative balances over to the next month. By default, no value is actively set, and the database will set it toFalse.
Returns:
-
BaseBudgets–Return budget matching the month and category, and assigns the amount to the budget. If not found, creates a new budget.
Source code in actual/queries.py
get_budgeted_balance
Returns the budgeted balance under the category for the individual month, not taking into account accumulated value.
If you want a function that consideres the accumulated value in case of an envelope budget, check the get_accumulated_budgeted_balance.
Parameters:
-
(sSession) –Session from the Actual local database.
-
(monthdate) –Month to get budgets for, as a date for that month. Use
datetime.date.today()if you want the budget for the current month. -
(categorystr | Categories) –Category to filter for the budget.
Returns:
-
Decimal–A decimal representing the budget real balance for the category.
Source code in actual/queries.py
get_accumulated_budgeted_balance
Returns the budgeted balance as shown by the Actual UI under the category.
This is calculated by summing all considered budget values and subtracting all transactions for them.
When using envelope budget, this value will accumulate with each consecutive month that your spending is
greater than your budget. If this value goes under 0.00, your budget is reset for the next month, unless the
carryover flag is set on the budget. In this case, the balance will be held for the next month.
When using tracking budget, only the current month is considered for savings, so no previous values will carry over.
Parameters:
-
(sSession) –Session from the Actual local database.
-
(monthdate) –Month to get budgets for, as a date for that month. Use
datetime.date.today()if you want the budget for the current month. -
(categorystr | Categories) –Category to filter for the budget.
Returns:
-
Decimal–A decimal representing the budget real balance for the category. This is evaluated by adding all previous leftover budgets that have a value greater than 0.
Source code in actual/queries.py
get_held_budget
get_held_budget(
s: Session, month: date
) -> ZeroBudgetMonths | None
Gets the budget held for a budget month from the database.
The held budget only applies to envelope budgeting.
Parameters:
-
(sSession) –Session from the Actual local database.
-
(monthdate) –Month to get budgets for, as a date for that month. Use
datetime.date.today()if you want the current month.
Returns:
-
ZeroBudgetMonths | None–Returns the held budget object.
Source code in actual/queries.py
create_transfer
create_transfer(
s: Session,
date: date,
source_account: str | Accounts,
dest_account: str | Accounts,
amount: Decimal | int | float,
notes: str | None = None,
) -> tuple[Transactions, Transactions]
Creates a transfer of money between two accounts. The amount is provided as a positive value.
Parameters:
-
(sSession) –Session from the Actual local database.
-
(datedate) –Date of the transfer.
-
(source_accountstr | Accounts) –Account that will transfer the money and reduce its balance.
-
(dest_accountstr | Accounts) –Account that will receive the money and increase its balance.
-
(amountDecimal | int | float) –Amount, as a positive decimal, to be transferred.
-
(notesstr | None, default:None) –Additional description for the transfer.
Returns:
-
tuple[Transactions, Transactions]–Tuple containing both transactions, as one is created per account. The transactions would be cross-referenced by their
transferred_id.
Source code in actual/queries.py
get_rules
get_rules(
s: Session, include_deleted: bool = False
) -> Sequence[Rules]
Returns a list of all available rules.
Parameters:
-
(sSession) –Session from the Actual local database.
-
(include_deletedbool, default:False) –Includes all payees deleted via frontend. They would not show normally.
Returns:
Source code in actual/queries.py
get_ruleset
Returns a list of all available rules, but as a rule set that can be used to be applied to existing transactions.
Parameters:
-
(sSession) –Session from the Actual local database.
Returns:
-
RuleSet–RuleSet object that contains all rules and can be either.
Source code in actual/queries.py
create_rule
Creates a rule based on the conditions and actions defined on the input rule. The rule can be ordered to run immediately, running the action for all entries that match the conditions on insertion.
Parameters:
-
(sSession) –Session from the Actual local database.
-
(ruleRule) –A constructed Rule object. The rule format and data types are validated on the constructor but the data itself is not. Make sure that, if you reference uuids, that they exist.
-
(run_immediatelybool, default:False) –If the run should run for all transactions on insert, defaults to
False.
Returns:
-
Rules–Rule database object created.
Source code in actual/queries.py
get_schedules
get_schedules(
s: Session,
name: str | None = None,
include_deleted: bool = False,
include_completed: bool = False,
) -> Sequence[Schedules]
Returns a list of all available schedules, automatically filtering completed schedules.
Parameters:
-
(sSession) –Session from the Actual local database.
-
(namestr | None, default:None) –Pattern name of the payee, case-insensitive.
-
(include_deletedbool, default:False) –Includes all payees deleted via frontend. They would not show normally.
-
(include_completedbool, default:False) –Includes all schedules that have been completed. They are also shown as hidden on the frontend.
Returns:
Source code in actual/queries.py
create_schedule
create_schedule(
s: Session,
date: date | datetime | Schedule,
amount: (
Decimal
| float
| tuple[Decimal, Decimal]
| tuple[float, float]
),
amount_operation: Literal[
"is", "isapprox", "isbetween"
] = "isapprox",
name: str | None = None,
payee: str | Payees | None = None,
account: str | Accounts | None = None,
posts_transaction: bool = False,
) -> Schedules
Create a schedule database object based on the parameters.
Parameters:
-
(sSession) –Session from the Actual local database.
-
(datedate | datetime | Schedule) –Date of the schedule (if it only happens once) or Schedule object, that can be initialized more easily with the helper create_schedule_config.
-
(amountDecimal | float | tuple[Decimal, Decimal] | tuple[float, float]) –Amount that the scheduled transaction will have. Provide only one number, except if the amount uses an
isbetweeninamount_operation, in this case num1 and 2 should be provided as a tuple(num1, num2), wherenum1 < num2. -
(amount_operationLiteral['is', 'isapprox', 'isbetween'], default:'isapprox') –Controls how amount is interpreted. Set this value to
iswhen your schedule always matches a fixed amount. By default,isapproxwill be used, and the amount will be treated as an estimate and will match transactions that are plus/minus 7.5% of the amount entered. When usingisbetween, make sure that the amount is provided as a tuple (num1, num2), wherenum1 < num2. -
(namestr | None, default:None) –Not mandatory. Schedule names must be unique.
-
(payeestr | Payees | None, default:None) –Optional; will default to
None. -
(accountstr | Accounts | None, default:None) –Optional; will default to
None. -
(posts_transactionbool, default:False) –Whether the schedule should auto-post transactions on your behalf. Defaults to false.
Returns:
-
Schedules–Rule database object created.
Source code in actual/queries.py
1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 | |
create_schedule_config
create_schedule_config(
start: date | datetime,
end_mode: (
EndMode
| Literal["never", "on_date", "after_n_occurrences"]
| str
) = NEVER,
end_occurrences: int | None = None,
end_date: date | datetime | None = None,
interval: int = 1,
frequency: (
Frequency
| Literal["daily", "weekly", "monthly", "yearly"]
| str
) = MONTHLY,
patterns: list[Pattern] | None = None,
skip_weekend: bool = False,
weekend_solve_mode: (
WeekendSolveMode | Literal["before", "after"] | str
) = AFTER,
) -> Schedule
Created a recurring config for the schedule.
This configuration indicates how the schedule runs. It is an alternative way of creating a schedule (instead of the simple start date and frequency option) that can be configured quite
For the date fields, if a datetime is provided, only the truncated value will be used.
Parameters:
-
(startdate | datetime) –The date indicating the start date of the recurrence.
-
(end_modeEndMode | Literal['never', 'on_date', 'after_n_occurrences'] | str, default:NEVER) –Specifies how the recurrence ends: never ends, after a number of occurrences, or on a specific date.
-
(end_occurrencesint | None, default:None) –Used when
end_modeis'after_n_occurrences'. Indicates how many times it should repeat. -
(end_datedate | datetime | None, default:None) –Used when
end_modeis'on_date'. The date object indicating when the recurrence should end. -
(intervalint, default:1) –The interval at which the recurrence happens. Defaults to
1if omitted. -
(frequencyFrequency | Literal['daily', 'weekly', 'monthly', 'yearly'] | str, default:MONTHLY) –How often the schedule repeats.
-
(patternslist[Pattern] | None, default:None) –Optional patterns to control specific dates for recurrence (e.g., certain weekdays or month days).
-
(skip_weekendbool, default:False) –If true, skips weekends when calculating recurrence dates. This option can be further configured with the
weekend_solve_modeparameter. -
(weekend_solve_modeWeekendSolveMode | Literal['before', 'after'] | str, default:AFTER) –If a calculated date falls on a weekend and
skip_weekendis true, this controls whether the date moves to the before or after weekday.
Returns:
-
Schedule–Schedule object (not database object) that can be used to create a schedule via create_schedule.
Source code in actual/queries.py
1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 | |
get_or_create_clock
get_or_create_clock(
s: Session, client: HULC_Client | None = None
) -> MessagesClock
Loads the HULC Clock from the database that tells the client from when the messages should be retrieved.
See the original implementation.
If the clock is not existing, it will be created based on the passed client. If the client is missing, an empty client is created. If the clock was already existing, the timestamp will only be overwritten if a client is provided, otherwise the original value will be returned.
Parameters:
-
(sSession) –Session from the Actual local database.
-
(clientHULC_Client | None, default:None) –HULC Client object.
Returns:
-
MessagesClock–The message clock object.
Source code in actual/queries.py
get_preferences
get_preferences(s: Session) -> Sequence[Preferences]
Loads the preference list from the database.
Parameters:
-
(sSession) –Session from the Actual local database.
Returns:
-
Sequence[Preferences]–List of preferences.
Source code in actual/queries.py
get_or_create_preference
Loads the preference list from the database. If the key is missing, a new one is created, otherwise it's updated.
Parameters:
-
(sSession) –Session from the Actual local database.
-
(keystr) –Key of the preference.
-
(valuestr) –Value of the preference.
Returns:
-
Preferences–The preference object.
Source code in actual/queries.py
get_preference
get_preference(s: Session, key: str) -> Preferences | None
Gets an existing preference by key name, returns None if not found.
Parameters:
-
(sSession) –Session from the Actual local database.
-
(keystr) –Preference name.
Returns:
-
Preferences | None–Preference matching the key provided. If not found, returns
None.