mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
Bug 770303 - Incorrect commodity match during import OFX and possible solution.
Comparing only on the strlen of the imported commodity produces false matches when the account commodity string begins with the same characters but is longer. E.g. if the imported commodity is F (Ford Motor) and Facebook (FB) is encountered first in the account list then the matcher will select Facebook, but that will fail when the commodity GUIDs are compared.
This commit is contained in:
parent
9069f2626a
commit
ea3862499b
@ -83,14 +83,18 @@ gnc_commodity * gnc_import_select_commodity(const char * cusip,
|
||||
commodity_list = g_list_first(commodity_list);
|
||||
while ( commodity_list != NULL && retval == NULL)
|
||||
{
|
||||
const char* tmp_cusip = NULL;
|
||||
tmp_commodity = commodity_list->data;
|
||||
if (gnc_commodity_get_cusip(tmp_commodity) != NULL &&
|
||||
cusip != NULL &&
|
||||
strncmp(gnc_commodity_get_cusip(tmp_commodity), cusip, strlen(cusip)) == 0)
|
||||
DEBUG("Looking at commodity %s",
|
||||
gnc_commodity_get_fullname(tmp_commodity));
|
||||
tmp_cusip = gnc_commodity_get_cusip(tmp_commodity);
|
||||
if (tmp_cusip != NULL && cusip != NULL)
|
||||
{
|
||||
retval = tmp_commodity;
|
||||
int len = strlen(cusip) > strlen(tmp_cusip) ? strlen(cusip) :
|
||||
strlen(tmp_cusip);
|
||||
if (strncmp(tmp_cusip, cusip, len) == 0)
|
||||
{
|
||||
retval = tmp_commodity;
|
||||
DEBUG("Commodity %s%s",
|
||||
gnc_commodity_get_fullname(retval), " matches.");
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user