Turn-based Budget (Civ Inspired Budget Redux)

Turn-based Budget (Civ Inspired Budget Redux)

Some recent additions to the Tap system got me thinking about an exciting project I came across years ago.

Seven years ago, to be exact, I ran into a post on Hacker News about a budget tool based on the Sid Meier's Civilization cashflow system built by a programmer by the name Alex Reckler.

I'm a huge fan of Civ games and also happen to build bookkeeping systems. Needless to say I was hooked.

At the time, I was heavily invested in a totally different system, and wasn’t ready for a new one. -- But the turn-based system Alex developed was inspiring.

Keeping a budget, doing the books and analyzing finances is usually considered dull work. But, in Civ it's fun -- why can't it be fun IRL? I think it can.

Alex found an experience (the in-game Civ resource system) where managing finances is engaging and enjoyable, then translated that experience into something usable for himself and others.

So why am I bringing this up years later? Recently, a Tap user shared with me their  budgeting system implementing Beans and the Tap API. It is like a classic envelope budgeting system with a few unique characteristics.

The creator asked if Tap Formulas could support some new functions to make their system even easier. Hell yeah it can!

In the process of developing those functions I realized: Tap has every component necessary to create something pretty close to the feature-set of Alex's system! I had to try building it.

Here's how it works:

Step one: You need to set up some Spells.

  • Recurring notes to log fixed-cost transactions that occur on a schedule (monthly, weekly, daily)
  • Reminder that sends a summary of your finances
  • And another reminder that requests input of daily transaction you'd like to track

Note: you can also input transactions from your bank account via a CSV. Right now, Tap only supports a generic CSV, but we can make a custom importer for your bank. Get in touch at hello@tatatap.com

Another note: I'm about to start using some Tap-specific terminology, mainly related to beans. If you're unfamiliar with beans  you can check out the explanation page. Or just keep reading, , they may become clear throughout this post.

Beans look like this

+"Salary":4232.88

In short, they are a sign + or - followed by a symbol "Salary", followed by a number :4232.88

This adds or subtracts that number from the specified symbol. Tap keeps track of the value of all the beans and can recall them using formulas.

Step Two: Set up the environment.

We're going to put all these notes in a folder called "/books", that way it's isolated from the rest of our content. In addition we’ll tag all recurring transactions “recurring” this will become clear in the bonus section below.

Create a note with your current balance using a bean. I chose to call it "Checking Account". You can call them whatever you want.

/books

Beginning Balance

+"Checking Account":4520.77

Step three: create a monthly recurring note with all transactions that happen once a month.

It might look something like this:

/books

#recurring

-"Rent":2250
-"Internet":99.50
-"Netflix":12.99
-"Dropbox":10.99

...

Step two (b): create a monthly recurring note with all transactions that happen once a week

/books

#recurring

+"Salary":1876.22
-"Child care":533

Step two(c): Daily expenses.

/books

#recurring

-"Train ticket":14.83

At this point we have an automatic tally of all fixed cost and repeating transactions. These transactions will get recorded on their respective schedules.

Step three: When you have one-off expenses or income these can be input by saving a note:

/books

-"Dentist":381.29

Next, we are going to set up a Spell that lets us know our current cash on hand. Create a reminder spell in the communication method you prefer: email, SMS, Telegram.

In the message body we'll include a formula to calculate our current financial standing. Something like this:


$$("What I've got")(bean - "/books")

$$("Spent so far this month")
  (bean-
    -
    "/books"
    -
    (change-time (time now) start-of month)
    (time now))
    
$$("Net this month")
  (bean
    -
    "/books"
    -
    (change-time (time now) start-of month)
    (time now))

This will send us a daily message in our preferred communication channel that looks like this:

There's a lot going on in the above reminder. Let's break it down. I chose to include three formulas, "What I've got", "Spent so far this month" and "Net this month".

The first is the simplest. It says: get the net value of all beans in the "/books" folder. Because we set up the initial "Checking Account" bean, assuming we log all our transactions, this formula should continue to report our current balance.

$$("What I've got")(bean - "/books")

The bean function takes up to five arguments: bean name, folder, tag list, start date and end date

The second function says: get the total outgoing amount for all beans in the "/books" folder starting at the beginning of the current month and ending today.

$$("Spent so far this month")
  (bean-
    -
    "/books"
    -
    (change-time (time now) start-of month)
    (time now))

Notice on the second function it's using the bean- function, which means it will only total outgoing beans (or the ones that start with a "-"). Other than that the only difference is we're specifying a start and end time.

The start time is a little complicated because we need to get the start of the current month. To do this there is a function called change-time. change-time takes both a time input and serveral keywords, namely: “start-of” and “month”. This way we can specify exactly how we want the time to change. What we end up with is (change-time (time now) start-of month). This translates to: change the time of now to the start of that month, whatever month (time now) happens to be.

The next formula is just a variation on the second. It says: get the net value of all the beans in the "/books" folder for the current month. As you can see the only difference is we're using the bean function instead of the bean- function.

Now that everything is set up it will just keep on running. If you need to change any of the monthly, weekly or daily transactions you can modify the spell and all recurring notes going forward will include the new transactions.

Bonus Formula

One of the cool things about Alex’s post was the “Magic Number” concept. The magic number represents, in his words: “how much I would be making if I could cryogenically freeze myself and somehow continue to get a paycheck and pay bills.“

There are a few ways we could get this number. One simple option is to run a calculation on the recurring transactions that happened last month. The downside to this approach is that it will take a month before there’s useful information, but the plus side is it will stay up to date without any intervention.

Here’s the formula:

$$("Magic Number")
  (/ (bean
       -
       "/books"
       "recurring"
       (change-time
         (subtract-time (time note) months 1)
         start-of month)
       (change-time
         (subtract-time (time note) months 1)
         end-of month)) 30)

In plain english this formula says: retrieve the total value of beans in the “/books” folder with the “recurring” tag starting on the first of last month and ending on the last day of last month – divide all that by 30.

What now?

The system outlined above is just a sketch of what's possible using Tap.

Here are a few things that could make that system even more useful:

  • Implement double-entry for all recurring transactions.
  • Set up a reminder to prompt yourself to input the days expenses
  • Regularly import your bank transactions from CSV to beans
  • Set up a tagging system for transaction categories

Let me know if you're interested in any of the above topics or others and maybe it could be the topic of a future post.