Skip to main content

Library to split and share You Need A Budget (YNAB) transactions between two budgets

Project description

ynab-split-budget

GitHub Release Github Release Monthly downloads

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.

"Buy Me A Coffee"

Preparations in YNAB

  1. Create a checking account for the cost sharing in both YNAB budgets.
  2. Create a personal access token for both budgets as described here

Install library from PyPI

pip install ynab-split-budget

Usage

1. Create a transaction

Create a transaction in the budget and add a specific flag color for the splits. The transaction needs to be cleared in order to be considered by this library. 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 library

Initialize the library by creating two User instances and pass them as user and partner to the constructor of the main class. For the flag_color set the value used marking the transaction earlier. Possible color values are red, orange, yellow, green, blue and purple. The id of the budget and of the account can be found going to https://app.ynab.com/ and opening 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>. The User object can be optionally initialized from a YAML file using the from_yaml() classmethod.

from ynabsplitbudget import YnabSplitBudget, User

user = User(name='<name>', token='<token>', budget_id='<budget_id>', 
            account_id='<account_id', flag_color='<flag_color>')

partner = User(name='<name>', token='<token>', budget_id='<budget_id>', 
               account_id='<account_id', flag_color='<flag_color>')

split_budget = YnabSplitBudget(user=user, partner=partner)

3. Split transactions

Call the split() method of the instance. It will split flagged transactions in the budget into a subtransaction with the original category and a transfer to the split account. By default, the transfer transactions will show up as uncleared in the split account. The optional clear parameter allows to automatically clear the transactions in the split account. The function returns the updated transactions after applying the split.

split_budget.split()

4. Push new splits to partner split account

Calling the push() function will insert new transactions from user split account into split account of partner to keep both accounts in sync. By default, the function will compare and insert transactions of the last 30 days. Optionally it takes a since parameter in the form of datetime.date to set a timeframe different from 30 days.

split_budget.push()

Advanced Usage

Check Balances

The raise_on_balances_off() function compares the cleared balances in both split accounts. If they don't match it will raise a BalancesDontMatch error which includes the values of the balances.

split_budget.raise_on_balances_off()

Delete Orphaned Complements

The delete_orphans() function deletes orphaned transactions in the partner split account, which don't have a corresponding transaction in the user split account any more. It does return a list with the deleted transactions. By default, the function compares transactions of the last 30 days. Optionally it takes a since parameter in the form of datetime.date to set a timeframe different from 30 days.

split_budget.delete_orphans()

Reconcile split account

The reconcile() function allows to reconcile the split account. It does check if the balances match before reconciling and will an BalancesDontMatch error if they don't.

split_budget.reconcile()

Show Logs

The library logs information about the result of the methods at the 'INFO' level. The logs can be made visible by importing the logging module and set it to the level INFO. The logger itself can also be accessed via the logger attribute of the instance.

import logging

logging.basicConfig(level='INFO')

Run via bash

You can run this library also from bash with the following basic structure

$ python -m ynabsplitbudget -u <path/user.yaml> -p <path/partner.yaml> --split

For a complete list of available bash options please use

$ python -m ynabsplitbudget -h | -- help

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ynab_split_budget-1.0.0.tar.gz (23.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

ynab_split_budget-1.0.0-py3-none-any.whl (25.6 kB view details)

Uploaded Python 3

File details

Details for the file ynab_split_budget-1.0.0.tar.gz.

File metadata

  • Download URL: ynab_split_budget-1.0.0.tar.gz
  • Upload date:
  • Size: 23.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.2 CPython/3.12.3 Linux/6.5.0-1018-azure

File hashes

Hashes for ynab_split_budget-1.0.0.tar.gz
Algorithm Hash digest
SHA256 c1c994c34b169e3778efca7dc9b22dfdc001f68c34f55c7f7128a69cf9219080
MD5 c535b695fa14d971e6dac7a2f9e2824b
BLAKE2b-256 e89e7e3ea61c6b9832635e167fbab642d391b129aa998ca27e4730a6043b9bac

See more details on using hashes here.

File details

Details for the file ynab_split_budget-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: ynab_split_budget-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 25.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.2 CPython/3.12.3 Linux/6.5.0-1018-azure

File hashes

Hashes for ynab_split_budget-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 9ec39c4692d7d7086405d0607f3ed8b8dcd376cfb17bb5f5ec2c342ef3b9b305
MD5 6b9d61e0e0984ebeb3d7cd0801c8119e
BLAKE2b-256 064299d7eeb2e8b27e81c9397f6baa85c8b74b6007f337ff2b453808d4d8e7d7

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page