Library to split and share You Need A Budget (YNAB) transactions between two budgets
Project description
ynab-split-budget
This library enables cost sharing across two YNAB budgets. It requires two dedicated accounts in each budget to which each budget owner can transfer amounts from their own budget. Each transfer is considered as its opposite in the other account.
Preparations in YNAB
- Create a checking account for the cost sharing in both YNAB budgets.
- Create a personal access token for both budgets as described here
Install library from PyPI
pip install ynab-split-budget
Create config
Create a config dict with the below structure.
CONFIG = {
'<user_name>': {
'budget': '<budget_id>',
'account': '<account_id>',
'token': '<ynab_token>',
'flag': '<color>'},
'<partner_name>': {
'budget': '<budget_id>',
'account': '<account_id>',
'token': '<ynab_token>',
'flag': '<color>'}
}
You can find the ID of the budget and of the account if you go to https://app.ynab.com/ and open the target account by
clicking on the name on the left hand side menu. The URL does now contain both IDs
https://app.ynab.com/<budget_id>/accounts/<account_id>
Possible colors for the flag value are red, orange, yellow, green, blue and purple
Alternatively you can save the config in a yaml file with the below structure and provide the path to the library when initializing
<user_name>:
token: <ynab_token>
budget: <budget_id>
account: <account_id>
flag: <color>
<partner_name>:
token: <ynab_token>
budget: <budget_id>
account: <account_id>
flag: <color>
Usage
1. Create a transaction
Create a transaction in your budget and add the defined color flag. Only cleared transactions will be considered.
By default, the transaction will be split in half, but you can specify a different split by adding
@x% for percentage or @x for specific amount in the memo of the transaction. The amount you specify
in this split will be transferred to your sharing account. You can also create a plain transfer to the shared account
which will be completely allocated to the partner account.
2. Initialize and run the split functionality
from ynabsplitbudget import YnabSplitBudget
# initialize from config dict
ynab_split_budget = YnabSplitBudget(config=CONFIG, user='<user_name>')
# or alternatively from yaml
ynab_split_budget = YnabSplitBudget.from_yaml(path='path/to/config.yaml', user='<user_name')
ynab_split_budget.split_transactions()
3. Clear the newly split transaction
Using the YNAB web interface go to your split account and clear the newly split transaction over there. This can currently not be automated as YNAB API can't clear split transactions at this point in time.
4. Run the insert functionality
By default the library will compare and insert transactions of the last 30 days. If you would like to do it for a
different timeframe you can provide a since argument to the function with a value from datetime.date
ynab_split_budget.insert_complements()
Advanced Usage
Check Balances
Additionally you can check if the cleared balances in both accounts match. If they don't match you will get back a
BalancesDontMatch Error which also gives you the two values of the balances.
ynab_split_budget.raise_on_balances_off()
Delete Orphaned Complements
If you delete a transaction in your share account you can use this function to delete the respective complement on your
partners shared account. It does return a list with the deleted transactions. By default the library will compare
transactions of the last 30 days. If you would like to do it for a different timeframe you can provide a since
argument to the function with a value from datetime.date
ynab_split_budget.delete_orphaned_complements()
Run via bash commands
You can run this package also from bash with the following commands
$ python -m ynabsplitbudget -c <path/config.yaml#user_name> -s | --split-transactions
$ python -m ynabsplitbudget -c <path/config.yaml#user_name> -i | --insert-complements [-d | --since-date "YYYY-mm-dd"]
$ python -m ynabsplitbudget -c <path/config.yaml#user_name> -b | --check-balances
Development
Read the CONTRIBUTING.md file.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file ynab_split_budget-0.6.1.tar.gz.
File metadata
- Download URL: ynab_split_budget-0.6.1.tar.gz
- Upload date:
- Size: 22.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.1 CPython/3.12.2 Linux/6.2.0-1019-azure
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
14f695a7a57a41b3854b129537f17e6ea2b74a20bc695bd4022fb4acba7b5f9c
|
|
| MD5 |
f2aa1542417a98fd290bef4fa77561a7
|
|
| BLAKE2b-256 |
0fe1d66c7f4820ec86e5874e60585967d09952e9dd4e660ba300d37ba0332f48
|
File details
Details for the file ynab_split_budget-0.6.1-py3-none-any.whl.
File metadata
- Download URL: ynab_split_budget-0.6.1-py3-none-any.whl
- Upload date:
- Size: 24.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.1 CPython/3.12.2 Linux/6.2.0-1019-azure
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
59bddf9fdcd9c807473770be91f1ec709528a19ed3e9dbd75ad2af7235102634
|
|
| MD5 |
43f5f155384eea5c60cb7c7f68f50db8
|
|
| BLAKE2b-256 |
afc77a38cd39c1032d3cf3086c25b8bef277aaa914b274c32ca984cfdfbade14
|