Templates, formulas outside SX

Josh Sled jsled at asynchronous.org
Thu Jan 7 17:39:25 EST 2010


"Aylons Hazzud" <aylons at gmail.com> writes:
> Is it possible to create a template w/o a SX? I frequently make

No.  First-order template transactions has been a desire for a long
time.

The UI will memorize transactions and auto-fill the splits (exactly) as
per the last transaction with the same description. This, while helpful,
is not enough.


> How can I create a template using variables? When I try to do it in the SX
> template editor, it tells me "Scheduled Transactions with variables cannot
> be automatically created". So, how do I create them? Manually editing some
> text (XML?) files? Which are they?

All this message is saying is that you can't select the "auto-create"
checkbox for the SX.  "Auto-create" means "don't bother asking my
approval to create this SX, just do it."  SXes with variables *require*
dialog to solicit the values for the variables.  "Auto create" ("don't
tell me about it") and variables ("ask me for a value") are thus
mutually exclusive.


> Still inside templates and formulas, but now talking about SX: can I  create
> a template using the total balance of an account as a variable? I  always pay
> my credit card full balance, and I would want this value to be  scheduled, 10
> days in advance.

No.

The expression evaluator will allow scheme functions to be called, in a
format like "foo( arg1 : arg2 : arg3 )".

Some more details at http://wiki.gnucash.org/wiki/FAQ#Q:_How_do_I_use_variables_and_formula_in_scheduled_transactions.3F

Thus you could have a function like "getBalance(account [, date])".
Accounts have a path/name, but more correctly in gnucash, they're
identified by their GUID.

You could have that "account" argument be the path of the account, which
would break if/when the account name/hierarchy changes.  This would work
90% of the time, though.  (Having the SX code attach to account
rename/deletion hooks would allow an opportunity to inspect all template
formulæ and see if they'd be affected, and prompt the user to fix up as
need be, but yet more work.)

You could have that "account" argument be the leaf-node name of the
account, which would break if/when accounts have the same name.  This
would probably work much of the time, but it is too brittle.

You could have that "account" argument be the GUID of the account, but
there's no easy way to get the GUID for an account in the UI.   It's
also hideous to look at. :) 

Ideally, there would be a layer between the cell editing and actual
expression storage that would allow one to insert UI, like a proper
expression editor … maybe even one that understood that "the 0th
argument of 'getBalance' is an Account", and thus used an account
selector widget, but serialized the argument as an account GUID…

… just a SMOP. :)

Similarly for the date argument, too.  Note that if you go on vacation
for a month, and come back to create multiple SXes over time, the date
of the balance is suddenly very relevant.  And, too, it really should
take into account the other hypothetical SXes being created in the same
"since last run" run.  It starts to get pretty messy; gnucash does not
really have the infrastructure to make it simple.

-- 
...jsled
http://asynchronous.org/ - a=jsled; b=asynchronous.org; echo ${a}@${b}


More information about the gnucash-user mailing list