Hi,

Unfortunately this is a naive approach to this; Account names can (and
do) change.  You really need to use the internal Account GUID in the SX
storage.  But of course you want the user to be able to use the Account
Name.  So really what you need here is an input UI that lets the user
input the account name, but then internally it gets translated into the
account GUID..  For this I would almost recommend a "Function Editor"
popup dialog to help.

It's so much more complicated than what you have.  :(

Moreover, you need the *date* in there, because you really want to be
able to call xaccAccountGetBalanceAsOfDate() in the SX, because the SX
is run at a particular date that may be in the past.

Good Luck!

-derek

YaoCL <[email protected]> writes:

> Hi
>
> I am creating a SX which calculate amount by a related account’s balance. I 
> created a function like this
> ====
> (define (gnc:balance accName)
>       (let ((acc      (gnc-account-lookup-by-full-name 
> (gnc-get-current-root-account) accName)))
>               (gnc-numeric-to-double (xaccAccountGetBalance acc))))
> ====
>
> This function require a string parameter.  The gnc expression already support 
> Quote symbols to refer to string literial since this commit.
> <https://github.com/Gnucash/gnucash/commit/135289725c9cf439bf2e3bac017a5b1ba9589711>
>
> But I can not input double quote symbols into the formula editor. I am not a 
> developer of gnucash, Maybe my idea is naive. It looks like add get current 
> balance feature is as simple as let me input the Quote symbols into formula.
>
>
> References:
> Some mail thread related to this topic 
> <https://lists.gnucash.org/pipermail/gnucash-user/2008-December/027730.html>
> <http://lists.gnucash.org/pipermail/gnucash-user/2014-January/051964.html>
>
>
>
> _______________________________________________
> gnucash-devel mailing list
> [email protected]
> https://lists.gnucash.org/mailman/listinfo/gnucash-devel

-- 
       Derek Atkins, SB '93 MIT EE, SM '95 MIT Media Laboratory
       Member, MIT Student Information Processing Board  (SIPB)
       URL: http://web.mit.edu/warlord/    PP-ASEL-IA     N1NWH
       [email protected]                        PGP key available

_______________________________________________
gnucash-devel mailing list
[email protected]
https://lists.gnucash.org/mailman/listinfo/gnucash-devel

Reply via email to