Managing short-term lending with two-way YNAB

This post explains the reason behind my latest personal project, YNAB Debt Sync.

Shortly after I started using YNAB I ran into a problem. How was I meant to borrow cash from —or spot cash to— family and friends? The first few times a friend asked me to spot them some cash to pay for lunch or a beer, I just assigned it to whatever category the activity was related to. That posed a problem though, I wasn't actually spending that money on that category, so my budget wasn't truly reflecting my spending. In any case, I'd (hopefully) be getting that money back the next time I saw them.

The solution I came up with was to create a category for each person. If I loaned a person 5€, I'd create an outflow transaction and assign it to that person's category. Starting from a zero balance, the category would show a -5€ balance, meaning they owed me that amount.

If, another day, I borrowed 7€ from them, I'd record two cash transactions. One inflow of 7€ assigned to that person's category, which would update the balance to +2€ (i.e. I owe them money). The other transaction would be an outflow of 7€, assigned to whatever category made sense (e.g. Lunch), decreasing that category's balance. This way my budget would be accurate, as I had actually spent 7€ on lunch. As the two transactions have the same amount, but are opposites of each other (inflow vs. outflow), the balance for my cash account would remain unchanged (usually close to zero, in this case :)

To avoid any outstanding loans subtracting from my "available to budget" amount when the loans span two months, for example if I were to borrow money on the last Sunday of a month and I wouldn't be able to repay until the following Sunday, I "turned the arrow right", as mentioned by this post on YNAB's forums.

This was great for a while. I could lend and borrow money for short periods of time while being confident my actual spending categories were accurate, and also keeping track of how much I (or they!) owed.

Then I managed to convince some of these friends and family to use YNAB. Suddenly, my budget wasn't the sole source of information. I started being a bit lazier when recording money I borrowed; I knew the lender would record the transaction to ensure their budget was up-to-date. The opposite also happened, if I loaned somebody some money, they knew I'd record it and chase them after it. Especially with family, where loans are quite frequent.

It got to the point where, when checking my category balances against the other people's budgets, quite often one or two categories would be out of sync. We'd then have to manually go through both budgets' transactions and look for the missing ones, which was boring and time-consuming. Wanting to see if I could automate the process, I dug through YNAB's budget files and realised it was possible. Being a bit of an enterprising individual, I wrote YNAB Debt Sync.


The YNAB link uses my referral code, which gives you a $6 discount if you buy a licence, and $6 for me.

This system is similar to YNAB's own recommendation for loans, except creating a category per person instead of per loan and not budgeting for the categories, just taking advantage of "turning the arrow right" to keep a running total. Luckily this type of situation happens with a small group of people, so I only have a few categories. For cases when there are lots of different people involved, the strategy of having a catch-all category and using the memo field for the person's name, described in the YNAB forum post, is more manageable.

While writing this post I realised this system is basically a reinvention of double-entry bookkeeping. For every loan (credit) transaction in one person's budget there is a matching, opposite,  borrow (debit) transaction in the other person's budget. Tallying up the transactions in each budget should result in the same balance; one tally will be positive and the other will be negative. If the budgets don't tally up to a mirrored balance, there is a mistake somewhere; either missing transaction(s) or mistyped amount(s).

Note that, due to "turning the arrow right" and not budgeting the loan categories, it's possible to have enough outstanding loans that could wreak havoc with your cash flow if you're not at Rule 4 yet.


About johnny

Computers have interested me since I can remember and conveniently I studied computer science. I also enjoy performing in a local amateur theatre group and cycling. This is where I post solutions to problems I've had in the office or any other project, hopefully clearly enough to refer back to in the future.
This entry was posted in Uncategorized. Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *


You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>