Skip to content

Commit d606ef8

Browse files
authored
docs: Add docs on how to modify transactions. (#48)
1 parent c59a360 commit d606ef8

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

README.md

+24
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,30 @@ Will produce:
8080

8181
![added-transaction](https://github.com/bvanelli/actualpy/blob/main/docs/static/added-transaction.png?raw=true)
8282

83+
## Updating existing transactions
84+
85+
You may also update transactions using the SQLModel directly, you just need to make sure to commit the results at the
86+
end:
87+
88+
```python
89+
from actual import Actual
90+
from actual.queries import get_transactions
91+
92+
93+
with Actual(base_url="http://localhost:5006", password="mypass", file="My budget") as actual:
94+
for transaction in get_transactions(actual.session):
95+
# change the transactions notes
96+
if transaction.notes is not None and "my pattern" in transaction.notes:
97+
transaction.notes = transaction.notes + " my suffix!"
98+
# commit your changes!
99+
actual.commit()
100+
101+
```
102+
103+
> **WARNING:** You can also modify the relationships, for example the `transaction.payee.name`, but you to be aware that
104+
> this payee might be used for more than one transaction. Whenever the relationship is anything but 1:1, you have to
105+
> track the changes already done to prevent modifying a field twice.
106+
83107
## Generating backups
84108

85109
You can use actualpy to generate regular backups of your server files. Here is a script that will backup your server

0 commit comments

Comments
 (0)