actualbudget / actualbudget/actual

[Feedback] Rule action templating

Open
#3,606 67 comments 21 reactions 0 assignees View on GitHub
experimental feature rules
Dominant language
TypeScript
Stars
28.7k
Forks
3k
Avg merge
2d 11h
Merged PRs (30d)
65

Description

Rule action templating allows rules to dynamically set fields based on transaction data.

To enable the feature - head over to experimental features and toggle the rule action templating feature flag. Next, go to the "rules" page and set up a new rule.

To use it, click the icon on the right hand side of the input box to toggle from "text" to "template" mode:
Text mode:
![image](https://github.com/user-attachments/assets/e97e241e-945f-4a75-9d03-ce8927f09262)
Template mode:
![image](https://github.com/user-attachments/assets/03bf8625-f582-4267-80af-dbe59886ea11)

Then enter your template. For example, the below will replace the notes field with the VAT paid (standard VAT is 20% in the uk)
![image](https://github.com/user-attachments/assets/07b870c6-40e4-4d88-96d8-b7aa0d11c077)

At the moment, templating is supported for setting:
- notes
- date
- amount
- cleared (although no boolean helper functions are currently supported)

Full list of available helper functions:
- `regex value regex replacement`
- `add num1 num2 ...`
- `sub num1 num2 ...`
- `div num1 num2 ...`
- `mul num1 num2 ...`
- `mod num1 num2 ...`
- `floor num`
- `ceil num`
- `round num`
- `abs num`
- `min num1 num2 ...`
- `max num1 num2 ...`
- `fixed num1 num2`
- `day date`
- `month date`
- `year date`
- `format date format`
- `debug value` (logs to console)
- `replace value pattern replacement` mimics js replace. When pattern is not as `/regex/flags` it just uses raw value as opposed to `{{regex ...`
- `replaceAll value pattern replacement` mimics js replaceAll
- `addDays date days` add x days to the day
- `subDays date days`
- `addWeeks date weeks`
- `subWeeks date weeks`
- `addMonths date months`
- `subMonths date months`
- `addYears date years`
- `subYears date years`
- `setDay date day` Overflows are handled, 0 will set to last day of month before
- `concat args..` joins all arguments together

Full list of available variables that can be used
- `today (date)`
- `account (id)`
- `amount (number)`
- remember this is stored _without_ the decimal place. ie. £152 will be `15200`. `{{div amount 100}}` can be used to convert back
- `cleared (boolean)`
- `date (date)`
- `error (?)`
- `imported_id (id)`
- `imported_payee (string)`
- `is_child (boolean)`
- `is_parent (boolean)`
- `notes (string)`
- `parent_id (id)`
- `payee (id)`
- `reconciled (boolean)`
- `schedule (id)`
- `sort_order (number)`
- `starting_balance_flag (boolean)`
- `tombstone (boolean)`
- `transfer_id (id)`
---
Feel free to share your ideas, bug reports and feedback below.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.