Add investment transaction using InvestFields

Jim's Avatar


24 Aug, 2020 06:34 AM

Having a bit of trouble. I have this:

 invFlds = InvestFields()
    invFlds.txnType = InvestTxnType.BUY_XFER = date
    invFlds.taxDate = date
    invFlds.secCurr = sec = secAcct
    invFlds.hasXfrAcct = True
    invFlds.xfrAcct = root.getAccountByName('Investment:Initial Holdings')
    invFlds.hasShares = True
    invFlds.shares = shares
    invFlds.hasAmount = True
    invFlds.amount = amount
    invFlds.hasFee = True

#invFlds.fee = 999

txn = ParentTxn.makeParentTxn(book,date,date,entered,check,investmentAccount,desc,memo,-1,ParentTxn.STATUS_RECONCILING)

If I uncomment the invFlds.fee line I get this error:

File "D:\DataDrive\Documents\Jim\Documents\Moneydance\", line 130, in test invFlds.storeFields(txn) at com.infinitekind.moneydance.model.AbstractTxn.setAccount( at com.infinitekind.moneydance.model.InvestFields.storeFields( at jdk.internal.reflect.GeneratedMethodAccessor63.invoke(Unknown Source) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.base/java.lang.reflect.Method.invoke(Unknown Source) java.lang.NullPointerException: java.lang.NullPointerException

I'm not sure how I can add a fee?

  1. Support Staff 1 Posted by Sean Reilly on 24 Aug, 2020 10:55 AM

    Sean Reilly's Avatar

    Hi Jim,

    If there is a non-zero fee then you'll need to set the category (or account) to which the fee should be assigned. If you set invFlds.feeAcct = yourFeeCategory then it should work.


    Sean Reilly
    Developer, The Infinite Kind

  2. 2 Posted by Jim on 24 Aug, 2020 02:47 PM

    Jim's Avatar

    Thanks Sean!

  3. System closed this discussion on 23 Nov, 2020 02:50 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