Funny sidebar balances when creating txns in jython

davidcullen's Avatar


03 Aug, 2021 08:14 AM

Dear all,
I’m not sure what is happening, and whether I’m doing things incorrectly, but a funny thing is happening with MD Version 2021.1 (3069).
I’m creating txns under jython, as follows:
First, I create a ParentTxn:

newTxn =  ParentTxn(book)
newTxn.setDescription("Debit interest apportioned FY " + fmt(fy))
newTxn.setAccount(_account('Rental:Z:Interest apportionable:' + em))
Then, I add Splits:
txnSplit = SplitTxn(newTxn)
txnSplit.setAccount(interest_split_account(tag, cf['date']))
txnSplit.setDescription("Apportioned amount")
Finally, I post the ParentTxn:
The new txns seem all to be created correctly,BUT I have the accounts listed in the MD sidebar.
After creating and posting the txns, the sidebar shows nonsense balances, as attached screenshot shows. The “correct” balances are also shown in the attachment.
When I quit the MD app completely, and then re-open it, the sidebar reverts to showing the “correct” balances (and the newly created txns continue to show correctly).
Why does the sidebar show the incorrect balances? Am I not doing something correctly when I create the txns?
Thanks for your guidance.
David Cullen.
  1. Support Staff 1 Posted by Sean Reilly on 05 Aug, 2021 11:02 AM

    Sean Reilly's Avatar

    Hi David,

    I think the idea is that you're not supposed to invoke refreshAccountBalances() from the python script. If you remove that, do the balances not update automatically?


    Sean Reilly
    Director/Developer, The Infinite Kind

  2. 2 Posted by davidcullen on 06 Aug, 2021 03:21 AM

    davidcullen's Avatar

    Many thanks!
    It seems to work fine now that I have disabled book.refreshAccountBalances().
    For some reason, I had thought (incorrectly) that book.refreshAccountBalances() was necessary.
    Thanks for the insight.

  3. Maddy closed this discussion on 06 Aug, 2021 12:18 PM.

Comments are currently closed for this discussion. You can start a new one.

Keyboard shortcuts


? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac