r20022 - gnucash/trunk/src/import-export/aqbanking - Bug #454109: Online banking: grey out online action menu items when there is no online account

Christian Stimming cstim at code.gnucash.org
Sat Jan 1 15:57:33 EST 2011


Author: cstim
Date: 2011-01-01 15:57:33 -0500 (Sat, 01 Jan 2011)
New Revision: 20022
Trac: http://svn.gnucash.org/trac/changeset/20022

Modified:
   gnucash/trunk/src/import-export/aqbanking/gnc-ab-getbalance.c
   gnucash/trunk/src/import-export/aqbanking/gnc-ab-gettrans.c
   gnucash/trunk/src/import-export/aqbanking/gnc-ab-transfer.c
Log:
Bug #454109: Online banking: grey out online action menu items when there is no online account

Patch by Manfred Usselmann:

Show error message, if assigned online account is not valid or cannot be found
or if the selected online action is not valid for this account. Improved
checking if online job has been successfully executed.

Modified: gnucash/trunk/src/import-export/aqbanking/gnc-ab-getbalance.c
===================================================================
--- gnucash/trunk/src/import-export/aqbanking/gnc-ab-getbalance.c	2011-01-01 20:57:22 UTC (rev 20021)
+++ gnucash/trunk/src/import-export/aqbanking/gnc-ab-getbalance.c	2011-01-01 20:57:33 UTC (rev 20022)
@@ -53,6 +53,7 @@
     GncGWENGui *gui = NULL;
     AB_IMEXPORTER_CONTEXT *context = NULL;
     GncABImExContextImport *ieci = NULL;
+    AB_JOB_STATUS job_status;
 
     g_return_if_fail(parent && gnc_acc);
 
@@ -79,6 +80,7 @@
     if (!ab_acc)
     {
         g_warning("gnc_ab_getbalance: No AqBanking account found");
+        gnc_error_dialog(parent, _("No valid online banking account assigned."));
         goto cleanup;
     }
 
@@ -92,6 +94,7 @@
     {
         g_warning("gnc_ab_getbalance: JobGetBalance not available for this "
                   "account");
+        gnc_error_dialog(parent, _("Online action \"Get Balance\" not available for this account."));
         goto cleanup;
     }
     job_list = AB_Job_List2_new();
@@ -109,13 +112,24 @@
     context = AB_ImExporterContext_new();
 
     /* Execute the job */
-    if (AB_Banking_ExecuteJobs(api, job_list, context
+    AB_Banking_ExecuteJobs(api, job_list, context
 #ifndef AQBANKING_VERSION_5_PLUS
-                               , 0
+                           , 0
 #endif
-                              ))
+                          );
+    /* Ignore the return value of AB_Banking_ExecuteJobs(), as the job's
+     * status always describes better whether the job was actually
+     * transferred to and accepted by the bank.  See also
+     * http://lists.gnucash.org/pipermail/gnucash-de/2008-September/006389.html
+     */
+    job_status = AB_Job_GetStatus(job);
+    if (job_status != AB_Job_StatusFinished
+            && job_status != AB_Job_StatusPending)
     {
         g_warning("gnc_ab_getbalance: Error on executing job");
+        gnc_error_dialog(parent, _("Error on executing job.\n\nStatus: %s - %s")
+                               , AB_Job_Status2Char(job_status)
+                               , AB_Job_GetResultText(job));
         goto cleanup;
     }
 

Modified: gnucash/trunk/src/import-export/aqbanking/gnc-ab-gettrans.c
===================================================================
--- gnucash/trunk/src/import-export/aqbanking/gnc-ab-gettrans.c	2011-01-01 20:57:22 UTC (rev 20021)
+++ gnucash/trunk/src/import-export/aqbanking/gnc-ab-gettrans.c	2011-01-01 20:57:33 UTC (rev 20022)
@@ -39,6 +39,7 @@
 #include "gnc-ab-kvp.h"
 #include "gnc-ab-utils.h"
 #include "gnc-gwen-gui.h"
+#include "gnc-ui.h"
 
 /* This static indicates the debugging module that this .o belongs to.  */
 static QofLogModule log_module = G_LOG_DOMAIN;
@@ -106,6 +107,7 @@
     GncGWENGui *gui = NULL;
     AB_IMEXPORTER_CONTEXT *context = NULL;
     GncABImExContextImport *ieci = NULL;
+    AB_JOB_STATUS job_status;
 
     g_return_if_fail(parent && gnc_acc);
 
@@ -132,6 +134,7 @@
     if (!ab_acc)
     {
         g_warning("gnc_ab_gettrans: No AqBanking account found");
+        gnc_error_dialog(parent, _("No valid online banking account assigned."));
         goto cleanup;
     }
 
@@ -154,6 +157,7 @@
     {
         g_warning("gnc_ab_gettrans: JobGetTransactions not available for this "
                   "account");
+        gnc_error_dialog(parent, _("Online action \"Get Transactions\" not available for this account."));
         goto cleanup;
     }
     AB_JobGetTransactions_SetFromTime(job, from_date);
@@ -173,13 +177,24 @@
     context = AB_ImExporterContext_new();
 
     /* Execute the job */
-    if (AB_Banking_ExecuteJobs(api, job_list, context
+    AB_Banking_ExecuteJobs(api, job_list, context
 #ifndef AQBANKING_VERSION_5_PLUS
-                               , 0
+                           , 0
 #endif
-                              ))
+                          );
+    /* Ignore the return value of AB_Banking_ExecuteJobs(), as the job's
+     * status always describes better whether the job was actually
+     * transferred to and accepted by the bank.  See also
+     * http://lists.gnucash.org/pipermail/gnucash-de/2008-September/006389.html
+     */
+    job_status = AB_Job_GetStatus(job);
+    if (job_status != AB_Job_StatusFinished
+            && job_status != AB_Job_StatusPending)
     {
         g_warning("gnc_ab_gettrans: Error on executing job");
+        gnc_error_dialog(parent, _("Error on executing job.\n\nStatus: %s - %s")
+                               , AB_Job_Status2Char(job_status)
+                               , AB_Job_GetResultText(job));
         goto cleanup;
     }
 

Modified: gnucash/trunk/src/import-export/aqbanking/gnc-ab-transfer.c
===================================================================
--- gnucash/trunk/src/import-export/aqbanking/gnc-ab-transfer.c	2011-01-01 20:57:22 UTC (rev 20021)
+++ gnucash/trunk/src/import-export/aqbanking/gnc-ab-transfer.c	2011-01-01 20:57:33 UTC (rev 20022)
@@ -115,6 +115,7 @@
     if (!ab_acc)
     {
         g_warning("gnc_ab_gettrans: No AqBanking account found");
+        gnc_error_dialog(parent, _("No valid online banking account assigned."));
         goto cleanup;
     }
 



More information about the gnucash-changes mailing list