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