Add investment transaction using InvestFields
Having a bit of trouble. I have this:
invFlds = InvestFields()
invFlds.txnType = InvestTxnType.BUY_XFER
invFlds.date = date
invFlds.taxDate = date
invFlds.secCurr = sec
invFlds.security = 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)
invFlds.storeFields(txn)
txn.syncItem()</code>
If I uncomment the invFlds.fee line I get this error:
File "D:\DataDrive\Documents\Jim\Documents\Moneydance\newTransactionSample.md.py", line 130, in test invFlds.storeFields(txn) at com.infinitekind.moneydance.model.AbstractTxn.setAccount(AbstractTxn.java:272) at com.infinitekind.moneydance.model.InvestFields.storeFields(InvestFields.java:413) 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?
Comments are currently closed for this discussion. You can start a new one.
Keyboard shortcuts
Generic
? | 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
Support Staff 1 Posted by Sean Reilly on 24 Aug, 2020 10:55 AM
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.
Thanks!
Sean
--
Sean Reilly
Developer, The Infinite Kind
https://infinitekind.com
2 Posted by Jim on 24 Aug, 2020 02:47 PM
Thanks Sean!
System closed this discussion on 23 Nov, 2020 02:50 PM.