-
Notifications
You must be signed in to change notification settings - Fork 162
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add docs for rule action templating experimental feature (#632)
Closes #480 Feedback issue for the reference actualbudget/actual#3606 This is a starting point for a more fleshed out version, adding examples in the future would be good
- Loading branch information
Showing
4 changed files
with
101 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
# Rule Action Templating | ||
|
||
:::warning | ||
This is an **experimental feature**. That means we’re still working on finishing it. There may be bugs, missing functionality or incomplete documentation, and we may decide to remove the feature in a future release. If you have any feedback, please [open an issue](https://github.com/actualbudget/actual/issues) or post a message in the Discord. | ||
::: | ||
:::warning | ||
All functionality described here may not be available in the latest stable release. Use the `edge` images for the latest implementation. | ||
::: | ||
|
||
Rule action templating allows rules to dynamically set fields based on transaction data via meta programming inside the rule. | ||
|
||
Setting the following fields with a rule template is currently supported: | ||
- notes | ||
- date | ||
- amount | ||
- payee (name) | ||
- cleared (although no boolean helper functions are currently supported) | ||
|
||
Actual uses [handlebars](https://handlebarsjs.com/) under the hood to process the rule templates. You can find more in depth information about how this works in [their guide](https://handlebarsjs.com/guide). | ||
|
||
## Using rule action templating | ||
You can toggle between the normal and template input modes by clicking the icon to the right of the action input box. | ||
|
||
 | ||
|
||
When the template input mode is active you can type your template into the input box as below. This example removes the string " 12345" from an imported payee and sets the payee to this new value. | ||
|
||
 | ||
|
||
## Variables | ||
|
||
| Variable | Type | Notes | | ||
|-----------------------|---------|-----------------------------------------------------------------------------------------------------------------| | ||
| today | date | Today's date | | ||
| account | id | | | ||
| date | date | | | ||
| payee | id | | | ||
| imported_payee | string | | | ||
| notes | string | | | ||
| amount | number | This is stored without the decimal place. ie. 152 will be 15200. {{div amount 100}} can be used to convert back | | ||
| cleared | boolean | | | ||
| reconciled | boolean | | | ||
| imported_id | id | ID of the transaction provided from an import source (eg. bank sync/QFX) | | ||
| is_child | boolean | Flag for children in a split transaction | | ||
| is_parent | boolean | Flag for the parent of a split transaction | | ||
| parent_id | id | Set if is_child = true | | ||
| schedule | id | | | ||
| starting_balance_flag | boolean | Set if the transaction is a starting balance transaction | | ||
| transfer_id | id | | | ||
|
||
## Functions | ||
### Mathematical | ||
|
||
| Function | Arguments | Notes | | ||
|----------|---------------------|-------| | ||
| add | number1, number2... | | | ||
| sub | number1, number2... | | | ||
| div | number1, number2... | | | ||
| mul | number1, number2... | | | ||
| mod | number1, number2... | | | ||
| floor | number | | | ||
| ceil | number | | | ||
| round | number | | | ||
| abs | number | | | ||
| min | number1, number2... | | | ||
| max | number1, number2... | | | ||
| fixed | number1, number2... | | | ||
|
||
### Text | ||
|
||
| Function | Arguments | Notes | | ||
|------------|-----------------------------|------------------------------------------------------------------------------------------------------------| | ||
| regex | value, regex, replacement | | | ||
| 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. When pattern is not as /regex/flags it just uses raw value as opposed to {{regex ... | | ||
| concat | values... | Joins all arguments together | | ||
|
||
### Date | ||
|
||
| Function | Arguments | Notes | | ||
|-----------|--------------|---------------------------------------------------------------| | ||
| addDays | date, number | | | ||
| subDays | date, number | | | ||
| addWeeks | date, number | | | ||
| subWeeks | date, number | | | ||
| addMonths | date, number | | | ||
| subMonths | date, number | | | ||
| addYears | date, number | | | ||
| subYears | date, number | | | ||
| setDay | date, day | Overflows are handled, 0 will set to last day of month before | | ||
| day | date | Extract the day from a date | | ||
| month | date | Extract the month from a date | | ||
| year | date | Extract the year from a date | | ||
| format | date, format | | | ||
|
||
### Other | ||
|
||
| Function | Arguments | Notes | | ||
|----------|-----------|---------------------------------------------------------| | ||
| debug | any | Prints the arguments to the browser development console | |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.