> On Jan 6, 2020, at 8:55 AM, John Ralls <jra...@ceridwen.us> wrote:
>
>
>
>> On Jan 5, 2020, at 11:14 PM, Mike Alexander <m...@umich.edu> wrote:
>>
>> On 5 Jan 2020, at 23:27, John Ralls wrote:
>>
>> I want you to code review and test the PR when I finish. ;-)
>>
>> The online_id comes from from the import source, AQBanking in this
>> particular case--and we must be more careful because the code in question
>> applies to all of the importers except QIF--and the import source doesn't
>> generally contain any commodity information, so basing the match on that is
>> a non-starter.
>>
>> Returning the first match is what we do now. I get that that was the wrong
>> approach.
>>
>> As for GnuCash creating a new account when you've got a new TIAA security,
>> does that actually work? For that matter, are you able to connect to your
>> TIAA master account and import transactions for all of the securities you
>> have, all in one go? I thought that GnuCash didn't support that, never mind
>> creating a new security account if it fails to find a match. Mind, this
>> isn't the same as the matcher letting you create a new account when you
>> double-click on a yellow line, this is during the matcher setup when it
>> decides what asset/liability account the transactions belong to.
>>
>> Yes, the online ID comes from the import source, but the OFX importer is
>> dealing with two accounts for investment transactions: the cash account and
>> the security account. It uses the online ID from the OFX record for the cash
>> account. Then around line 635 in gnc-ofx-import.c it constructs an online ID
>> for the security account by concatenating that with the security's ID.
>>
>> It also has a commodity for the security account. This is converted to a
>> GnuCash commodity around line 624 and passed to gnc_import_select_account.
>> This function is documented to use this as part of the match (although it
>> actually didn't before I changed it) so I think using it as part of the
>> match would be ok.
>>
>> I am certainly able to import a bunch of security transactions for several
>> accounts from an OFX file in one go. I've been doing this every month for
>> several years without much trouble. I just imported 50 or so tonight. It
>> isn't perfect since the cash side of the buy and sell transactions is always
>> the parent TIAA account and I have to manually enter transactions to
>> properly account for this cash, but it sure helps a lot. Note that I am not
>> connecting to TIAA using AQBanking. That might work, but I download an OFX
>> file from their web site and import that.
>>
>> I don't know for sure that I can create an account during the import since
>> it's been a year or two since I created one and I can't recall if I did it
>> from within the import or not. I think I have done this in the past. I do
>> know that selecting an existing account from the import dialog works fine
>> and this, too, will store the online ID in the account. I tried to munge one
>> of the OFX files I have to cause it to create a new account, but didn't
>> manage to do it properly.
>>
>> Your solution is no doubt more complete and elegant than mine although mine
>> seems to work ok. I'll be glad to give it a try when you're ready.
>
> Unfortunately not more complete (yet) because I didn't know about and so
> hadn't accounted for the libofx import case you outlined here. I'll study
> that code and look for other uses of gnc_import_select_account to make sure
> that I understand everything that it needs to do. That will obviously take
> more than a day and I have other things I need to do this week so it will
> likely be the weekend before the PR is ready.
PR 631 (https://github.com/Gnucash/gnucash/pull/631). Please test.
Regards,
John Ralls
_______________________________________________
gnucash-devel mailing list
gnucash-devel@gnucash.org
https://lists.gnucash.org/mailman/listinfo/gnucash-devel