tag:infinitekind.tenderapp.com,2009-01-14:/discussions/moneydance-development/2941-adding-buy-and-sell-transactions-with-investfieldsInfinite Kind: Discussion 2020-11-29T23:30:23Ztag:infinitekind.tenderapp.com,2009-01-14:Comment/485897282020-08-30T23:17:26Z2020-08-30T23:17:27ZAdding BUY and SELL transactions with InvestFields<div><p>Having some trouble here...<br>
I'm a but unclear what to feed into the investFields for buy and sells it seems. I have:<br>
''' invFlds = InvestFields()<br>
invFlds.txnType = InvestTxnType.BUY invFlds.date = dateInt invFlds.taxDate = dateInt</p>
<pre>
<code>invFlds.secCurr = security
invFlds.security = acct
invFlds.hasShares = True
invFlds.shares = qty
invFlds.hasAmount = True
invFlds.amount = amount
invFlds.hasFee = False
enteredInt = DateUtil.getStrippedDate()
check = ''
txn = ParentTxn.makeParentTxn(book,dateInt,dateInt,enteredInt,check,acct,desc,memo,-1,ParentTxn.STATUS_RECONCILING)
invFlds.storeFields(txn)
txn.syncItem()</code>
</pre>
<p>'''</p>
<p>if the 'acc' variable is set to the sub account for the security the resulting transaction looks like this (in the python console):<br>
''' [ParentTxn(b1a37ccf-19d5-4fce-839d-2fc8f879993d) 20200830 desc=AAPL; val=-234355; stat=x; #splits=1; chk=; acct=XXXXX:APPLE INC; splits=SplitTxn: val=11; amt=-234355; desc=; stat= ; cat=XXXXX:APPLE INC; tags=[(samt:11)(acctid:b57aabde-702e-4613-ae62-ca88e6352a08)(invest.splittype:sec)(obj_type:)(id:5438b295-3502-4f87-872f-fd0e9dede292)(pamt:-234355)(desc:)]; ], ; ] ''' Looks promising, but in the Register in the Moneydance UI is blank. The transaction doesn't show up at all!<br>
In the UI Security Details tab I see the transaction duplicated (it shows up twice).</p>
<p>I've also tried just feeing in the investment account for 'acct'. That creates and entry in the UI Register, but only the date and description are filled in. In pythin that transaction looks like:<br>
''' [ParentTxn(7ce81df3-064f-4217-b612-da427d3485db) 20200830 desc=AAPL; val=0; stat=x; #splits=0; chk=; acct=XXXXX; splits=; ] ''' Any thoughts as to what I'm missing here?</p></div>Jimtag:infinitekind.tenderapp.com,2009-01-14:Comment/485897282020-08-30T23:24:01Z2020-08-30T23:24:05ZAdding BUY and SELL transactions with InvestFields<div><p>Also just noticed that in the Portfolio View I see the amounts (shares, cost basis etc) are all crazy numbers...<br>
Also in the security details if I delete one of the duplicated transactions in the UI, the other one also disappears.</p></div>Jim