Costflow Syntax v0.3: Formula

We just released Costflow Syntax v0.3. The most important feature in v0.3 is Formula. Costflow is designed for making plain text accounting easier, Formula is designed for making create patterned Costflow entries easier.

Many accounting transactions have some patterns. For example, the subscriptions of Spotify / Netflix / 1Password (same accounts, same amounts), or Uber / AWS fees (same accounts, different amounts), or pay for dinner with the same credit card. All these transactions can be easier with Formula.

With the help of Formula, you can create a transaction entry with one keyword, even with an emoji.

Formula flowchart

How to use Formula?

Formula Config

Like replacement, a config is needed before start using formula.

The formula config is in key: value format. The key is the formula name (can’t be a command name), the value is the content to parse with Costflow Syntax. Some variables are allowed in the value. The variable should be wrapped in double curly braces. The variables allowed in current version:

  • amount: the first number in the input. You can use some basic math operations with the amount, e.g. amount * 0.8;
  • pre: the original input excludes the formula name;

More variables will be supported in future versions.

As it showed on Formula flowchart image, Costflow will first convert the formula based on its config, then parse the value with Costflow Syntax all over again. So the value should follow Costflow Syntax too.

Some Formula config examples we mentioned earlier.

  "formula": {
    "aws": "@AWS {{ amount }} USD visa > aws",
    "cashback": "Airline Cash Back {{ amount }} visa > {{ amount * 0.95 }} expenseFlight + {{ amount * 0.05 }} incomeCashback",
    "netflix": "@Netflix 15.99 USD visa > netflix",
    "split": "Dinner {{ amount }} visa > food + rx + ry",
    "spotify": "@Spotify 14.99 USD visa > spotify",
    "uber": "@Uber {{ amount }} USD visa > uber",
    "rent": "Rent {{ amount }} USD visa > rent",
    "v2f": "{{ pre }} visa > food",
    "☕️": "@Leplays ☕️ {{ amount }}  Liabilities:CreditCard:Visa > Expenses:Coffee"

Use Config

When we finish the config, we can use Formula in Costflow products. The command of Formula is f, and you can trigger it like this: f keyword .... For providing a better experience, the command symbol f can be omitted if the keyword is not one of Costflow Syntax commands.

For example, we create a config for AWS: {"aws": "@AWS {{ amount }} USD visa > aws"}, we can send f aws 60 or just aws 60 to use this formula.

The keywords of Formula can be emoji, such as ☕️ / 🍕 / 🍔 / 🍣. It may not save your time, but it can provide more fun for bookkeeping, that’s for sure.

You can get more information on our Docs site.

The Formula is supported on Costflow CLI, Costflow Playground and Costflow Hub now.

Leave a Reply

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