tag:infinitekind.tenderapp.com,2009-01-14:/discussions/moneydance-development/2631-creating-transactionsInfinite Kind: Discussion 2020-03-09T08:50:25Ztag:infinitekind.tenderapp.com,2009-01-14:Comment/479024132019-12-06T11:05:12Z2019-12-06T11:05:12ZCreating Transactions<div><p>Changing the first amount on the split txn to -Amount seems to work. Is this the correct way of doing this?</p></div>Mike Bray (Quote Loader Author)tag:infinitekind.tenderapp.com,2009-01-14:Comment/479024132019-12-06T11:50:55Z2019-12-06T11:50:55ZCreating Transactions<div><p>Hi Mike,</p>
<p>The best way to record, or edit, investment transactions is to use the InvestFields class. Create a new InvestFields object and set the various properties on it, or use the setFieldStatus(Txn) method with an existing transaction from the investment account. Once you've got the right properties into the InvestFields class then use the storeFields(Txn) method for it to apply the changes to the transaction you gave it, which could just be a new blank ParentTxn.</p>
<p>Thanks,<br>
Sean</p>
<p>-- Sean Reilly<br>
Developer/Director<br>
infinitekind.com (<a href="http://infinitekind.com">http://infinitekind.com</a>)</p></div>Sean Reillytag:infinitekind.tenderapp.com,2009-01-14:Comment/479024132019-12-06T13:21:41Z2019-12-06T13:21:41ZCreating Transactions<div><p>Great thanks Sean</p></div>Mike Bray (Quote Loader Author)tag:infinitekind.tenderapp.com,2009-01-14:Comment/479024132019-12-07T11:34:29Z2019-12-07T11:34:29ZCreating Transactions<div><p>Hi Sean</p>
<p>Does storeFields(Txn) create the SplitTxns? I am getting a nullPointerException.</p>
<p>Regards<br>
mike</p></div>Mike Bray (Quote Loader Author)tag:infinitekind.tenderapp.com,2009-01-14:Comment/479024132019-12-07T17:04:23Z2019-12-07T17:04:23ZCreating Transactions<div><p>Hi Mike,<br>
Yes, storeFields(Txn) will automatically create the appropriate splits if they're not already in the transaction. Can you paste the NPE stack trace? You will need to make sure any required fields are there... I guess I don't have a helpful validator on it yet.</p>
<p>Thanks,<br>
Sean</p></div>Sean Reillytag:infinitekind.tenderapp.com,2009-01-14:Comment/479024132019-12-08T08:48:33Z2019-12-08T09:07:47ZCreating Transactions<div><p>Hi Sean, I found my error. I have one last point. When I have transactions that are against the Investment Account rather than a Security (e.g. interest, management fee) I use the InvestTxnType.BANK and set the following fields:</p>
<p>Amount (positive for income, negative for expense)<br>
hasAmount true<br>
Category (Interest or Management Fee)<br>
hasCategory true<br>
date<br>
taxdate<br>
txnType InvestTxnType.BANK</p>
<p>This creates the transactions but with a zero amount. Further testing and I changed 'category' and 'hasCategory' to 'xfrAcct' and 'has xfrAcct' it worked. I suppose using xfr as the transaction type would infer using the xfrAcct, however, the 'transfer' is to a category. Adding two new transaction types of 'Investment Income' and 'Investment Expense' would help.</p></div>Mike Bray (Quote Loader Author)tag:infinitekind.tenderapp.com,2009-01-14:Comment/479024132019-12-08T22:32:51Z2019-12-08T22:32:51ZCreating Transactions<div><p>Hi Mike,</p>
<p>Hmm... I think you may need to set hasXfrAcct=true and set the xfrAcct to the expense category? Please let me know if that doesn't work.</p>
<p>Thanks,<br>
Sean</p></div>Sean Reillytag:infinitekind.tenderapp.com,2009-01-14:Comment/479024132019-12-09T08:45:35Z2019-12-09T08:54:13ZCreating Transactions<div><p>Hi Sean</p>
<p>I updated my post with that exact method which worked, see the updated post for a suggestion.<br>
Mike</p></div>Mike Bray (Quote Loader Author)