Package: ynab-split-budget
ynab-split-budgetThis 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 YNABCreate a checking account for the cost sharing in both YNAB budgets.Create a personal access token for both budgets as describedhereInstall library from PyPIpipinstallynab-split-budgetCreate configCreate a configdictwith 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 tohttps://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 IDshttps://app.ynab.com/<budget_id>/accounts/<account_id>Possible colors for the flag value arered,orange,yellow,green,blueandpurpleAlternatively 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>Usage1. Create a transactionCreate 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@xfor 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 functionalityfromynabsplitbudgetimportYnabSplitBudget# initialize from config dictynab_split_budget=YnabSplitBudget(config=CONFIG,user='<user_name>')# or alternatively from yamlynab_split_budget=YnabSplitBudget.from_yaml(path='path/to/config.yaml',user='<user_name')ynab_split_budget.split_transactions()3. Clear the newly split transactionUsing 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 functionalityBy 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 asinceargument to the function with a value fromdatetime.dateynab_split_budget.insert_complements()Advanced UsageCheck BalancesAdditionally you can check if the cleared balances in both accounts match. If they don't match you will get back aBalancesDontMatchError which also gives you the two values of the balances.ynab_split_budget.raise_on_balances_off()Delete Orphaned ComplementsIf 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 asinceargument to the function with a value fromdatetime.dateynab_split_budget.delete_orphaned_complements()Show LogsThe library logs information about the result of the methods on the 'INFO' level. If you want to see these logs import
the logging module and set in to the levelINFO. You can also access the logger for advanced configuration via theloggerattribute of yourYnabSplitBudgetinstance.importlogginglogging.basicConfig(level='INFO')Run via bash commandsYou can run this package also from bash with the following commands$python-mynabsplitbudget-c<path/config.yaml#user_name>-s|--split-transactions
$python-mynabsplitbudget-c<path/config.yaml#user_name>-i|--insert-complements[-d|--since-date"YYYY-mm-dd"]$python-mynabsplitbudget-c<path/config.yaml#user_name>-b|--check-balancesDevelopmentRead theCONTRIBUTING.mdfile.