From 64720faaa16acbd47631f80782ca28aa7fe880cb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20K=C3=B6hler?= Date: Sat, 6 Sep 2008 17:21:00 +0000 Subject: [PATCH] Bug #548601: Do not import unawaited zero balances from aqbanking. Check whether an unawaited balance is zero and simply ignore it in this case. Unawaited here means that the user asked the application to fetch transactions, issue a transaction or anything else not resembling the fetching of account balances. Patch from Micha Lenk. BP git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@17495 57a11ea4-9604-0410-9ed3-97b8803252fd --- src/import-export/aqbanking/gnc-ab-utils.c | 29 +++++++++++++--------- 1 file changed, 17 insertions(+), 12 deletions(-) diff --git a/src/import-export/aqbanking/gnc-ab-utils.c b/src/import-export/aqbanking/gnc-ab-utils.c index 9fbd085884..5334f05de8 100644 --- a/src/import-export/aqbanking/gnc-ab-utils.c +++ b/src/import-export/aqbanking/gnc-ab-utils.c @@ -593,7 +593,24 @@ bal_accountinfo_cb(AB_IMEXPORTER_ACCOUNTINFO *element, gpointer user_data) else data->awaiting |= FOUND_BALANCES; + /* Lookup the most recent ACCOUNT_STATUS available */ + item = AB_ImExporterAccountInfo_GetFirstAccountStatus(element); + while (item) { + const GWEN_TIME *item_time = AB_AccountStatus_GetTime(item); + if (!best || GWEN_Time_Diff(best_time, item_time) < 0.0) { + best = item; + best_time = item_time; + } + item = AB_ImExporterAccountInfo_GetNextAccountStatus(element); + } + + booked_bal = AB_AccountStatus_GetBookedBalance(best); if (!(data->awaiting & AWAIT_BALANCES)) { + /* Ignore zero balances if we don't await a balance */ + if (!booked_bal || AB_Value_IsZero(AB_Balance_GetValue(booked_bal))) + return NULL; + + /* Ask the user whether to import unawaited non-zero balance */ if (gnc_verify_dialog(data->parent, TRUE, "%s", _("The bank has sent balance information " "in its response." @@ -611,19 +628,7 @@ bal_accountinfo_cb(AB_IMEXPORTER_ACCOUNTINFO *element, gpointer user_data) if (!gnc_acc) return NULL; data->gnc_acc = gnc_acc; - /* Lookup the most recent ACCOUNT_STATUS available */ - item = AB_ImExporterAccountInfo_GetFirstAccountStatus(element); - while (item) { - const GWEN_TIME *item_time = AB_AccountStatus_GetTime(item); - if (!best || GWEN_Time_Diff(best_time, item_time) < 0.0) { - best = item; - best_time = item_time; - } - item = AB_ImExporterAccountInfo_GetNextAccountStatus(element); - } - /* Lookup booked balance and time */ - booked_bal = AB_AccountStatus_GetBookedBalance(best); if (booked_bal) { const GWEN_TIME *ti = AB_Balance_GetTime(booked_bal); if (ti) {