[GNC] Help with Python interface
Sam Bull
h1tsfx at sambull.org
Mon Apr 14 17:53:15 EDT 2025
On Mon, 2025-04-14 at 11:44 -0400, John Ralls wrote:
> > On 13 Apr 2025, at 07:11, Sam Bull <h1tsfx at sambull.org> wrote:
> >
> > I'm trying to figure out how to use the Python bindings, but the documentation is
> > almost
> > non existent. One of the suggestions is to use help() where everything is documented
> > as
> > "wrapper method for function", so I don't see how that is useful at all…
>
> It tells you what C function to look up
> in https://code.gnucash.org/docs/STABLE/modules.html.
I don't think it provides anything more than dir() or tab completion in the interpreter
though. Those docs seem very limited too, so still not providing much help there.
It turns out that the Llama LLM is actually pretty good (unlike ChatGPT, which just
repeatedly told me to use a non-existent method). So, I've figure most of it out from that
now.
> > A way to search for transactions (or splits maybe?) in the account.
>
> See https://code.gnucash.org/docs/STABLE/group__Query.html
I've loaded all the splits into memory and searched directly in Python for the moment.
But, I'll try the Query API again later, when I have the motivation to figure it out.
> > It would probably also make sense to be able to reconcile transactions.
>
> Search for reconcile in https://code.gnucash.org/docs/STABLE/group__Account.html
Again, very limited information here, not sure what I'm meant to be using. I can't tell
from the description if set_start_reconciled_balance() is something I want to use or not.
Right now I've figured out how to set each split to the reconciled state and then check
the account balance at the end to give the user a warning if it doesn't match up (asking
them to do a reconciliation manually).
I also tried to use GetReconciledBalanceAsOfDate(), but it returns some unusual object
which doesn't seem to represent a useful number (atleast in Python). Maybe it's better to
use the regular balance anyway though, as that would highlight if extra transactions have
been missed.
Thanks,
Sam
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 195 bytes
Desc: This is a digitally signed message part
URL: <http://lists.gnucash.org/pipermail/gnucash-user/attachments/20250414/30d314af/attachment.sig>
More information about the gnucash-user
mailing list