Still only creating an empty buy tx with the correct date in the correct account. The numbers in brackets correspond to the number on the attached which is a manually entered transaction that I'm trying to create via an extension. I am able to create non-investment transactions in other accounts,
CurrencyType security = book.getCurrencies().getCurrencyByName("Google");
ParentTxn ptTran = new ParentTxn(book);
Sean Reilly on 29 May, 2020 09:18 PM
One thing might be that the shares field should have a much higher number. I'm guessing that you mean that 100 shares were purchased. Because of how moneydance stores all amount values that should be multiplied by 10^x where x is the number of decimal places in the security CurrencyType object. If you have a floating point/double version of the amount you can call security.getLongValue(doubleValue) to get it. Or from a string, security.parse(stringValue, '.')
I figured it out! I was using the field InvestFields.secCurr which is a currency not the InvestFields.security field which is an account.
Now this begs the question, what is the best way to determine if the security is already in the account assuming that I have a security name like "Google" Is there a way to say 'add it if it's not already there'?
Sean Reilly on 03 Jun, 2020 03:02 PM
You will need to ensure two things for any securities referenced by investment transactions:
1) That a CurrencyType with Type==SECURITY for the security exists, and
2) There is a sub-account of your investment account that has security as a currency and an account type of AccountType.SECURITY