formula plugin for a personal finance tw: help in getting values with macros

127 views
Skip to first unread message

manuar...@gmail.com

unread,
Apr 1, 2018, 1:45:31 PM4/1/18
to TiddlyWiki
hello everyone,

so, I'm making a tiddlywiki to keep track of expenses, incomes and such, using gentag and formula plugins.

Now, the structure would be something like this (just an example):

* accounts
**bank
**cash
*expenses
**car
**mortgage
* incomes
**work
**teeth selling

Each transactions would be a tiddler with the fields: from, to, value.

Every book will have a type field, for example bank would have "account". work "incomes" and so on.


So, if I want to know the value of all the money in my bank, I could just use the formula widget by doing so, and it works alright:

<$formula formula="sum([[bank]listed[to]get[value]]) - (sum([[bank]listed[from]get[value]])) + sum([all[current]get[initialvalue]])" precision=3/>

The problem arises in two points:

1: if I want a general formula that I can use for every tiddler and just paste it as a macro. This is what I've tried so far:


\define accountValue()

<$formula formula="sum([$(book)$listed[to]get[value]]) - (sum([$(book)$listed[from]get[value]])) + sum([all[current]get[initialvalue]])" precision=3/>
\end

<$set name=book value=<<currentTiddler>>>
<<accountValue>>
</$set>

This only considers the initialvalue field, no in and outs.

2. I would then like to get all the value of all the accounts, let's say bank and cash, so I tried to put the first formula widget in a "totalvalue" field, and to call it from an "account" tiddler, like so:

<$formula formula="sum([[accounts]listed[type]get[totalvalue]])/">

but I only get an error

CompileError: invalid operand "sum([[accounts]listed[type]get[totalvalue]])/"


So... frankly, there is something I'm missing, but I've been working on it for 3 days now, trying to understand what's the issue, making a macro in a macro in a macro calling different variables with set widget, but no good.


I hope I managed to explain myself, I would greatly appreciate any help, of course once done it will go in my github with the other tiddlywikis!


All the best and have a nice day

Message has been deleted

Jed Carty

unread,
Apr 1, 2018, 3:07:41 PM4/1/18
to TiddlyWiki
I am not sure if it is the problem or a typo here, but you have / and " swapped.

<$formula formula="sum([[accounts]listed[type]get[totalvalue]])/">

should be

<$formula formula="sum([[accounts]listed[type]get[totalvalue]])"/>

I also have an expense tracker that I am working on in case there are any pieces that would be helpful for you https://ooktech.com/TiddlyWiki/ExpenseReports/

manuar...@gmail.com

unread,
Apr 1, 2018, 3:24:15 PM4/1/18
to TiddlyWiki
Thanks for the reply, I already corrected myself but for some reason the message got deleted.

Right now the macro for the sum of all the bank value is working alright, that is

<$formula formula="sum([<currentTiddler>listed[to]get[value]]) - sum([<currentTiddler>listed[from]get[value]]) + sum([<currentTiddler>get[initialvalue]])"/>

So I can easily get the total value of, say, bank. Still, the problem of how to get the total value of cash + bank + any other account is unsolved.  

I was exploring the usage of variables here, or maybe I should go for some data tiddlers as the expenses tw you linked me (I'll study that, thanks!)
Reply all
Reply to author
Forward
0 new messages