r15663 - gnucash/trunk/src/import-export/hbci - Add check for entered transaction to always have a recipient name; add some more logging code for aqbanking results.
Christian Stimming
cstim at cvs.gnucash.org
Sun Feb 25 16:54:57 EST 2007
Author: cstim
Date: 2007-02-25 16:54:56 -0500 (Sun, 25 Feb 2007)
New Revision: 15663
Trac: http://svn.gnucash.org/trac/changeset/15663
Modified:
gnucash/trunk/src/import-export/hbci/dialog-hbcitrans.c
gnucash/trunk/src/import-export/hbci/gnc-hbci-utils.c
gnucash/trunk/src/import-export/hbci/gnc-hbci-utils.h
Log:
Add check for entered transaction to always have a recipient name; add some more logging code for aqbanking results.
Modified: gnucash/trunk/src/import-export/hbci/dialog-hbcitrans.c
===================================================================
--- gnucash/trunk/src/import-export/hbci/dialog-hbcitrans.c 2007-02-25 20:36:10 UTC (rev 15662)
+++ gnucash/trunk/src/import-export/hbci/dialog-hbcitrans.c 2007-02-25 21:54:56 UTC (rev 15663)
@@ -581,6 +581,29 @@
} /* check Transaction_purpose */
}
+ {
+ char *othername = gnc_hbci_getremotename (td->hbci_trans);
+ if (!othername || (strlen (othername) == 0)) {
+ gtk_widget_show_all (td->dialog);
+ values_ok = !gnc_verify_dialog
+ (GTK_WIDGET (td->dialog),
+ TRUE,
+ "%s",
+ _("You did not enter a recipient name. A recipient name is "
+ "required for an online transfer.\n"
+ "\n"
+ "Do you want to enter the job again?"));
+ if (othername)
+ g_free (othername);
+ if (values_ok) {
+ AB_Transaction_free (td->hbci_trans);
+ td->hbci_trans = NULL;
+ return GTK_RESPONSE_CANCEL;
+ }
+ continue;
+ } /* check Recipient Name (in aqbanking: Remote Name) */
+ }
+
/* FIXME: If this is a direct debit, set the textkey/ "Textschluessel"/
transactionCode according to some GUI selection here!! */
/*if (td->trans_type == SINGLE_DEBITNOTE)
Modified: gnucash/trunk/src/import-export/hbci/gnc-hbci-utils.c
===================================================================
--- gnucash/trunk/src/import-export/hbci/gnc-hbci-utils.c 2007-02-25 20:36:10 UTC (rev 15662)
+++ gnucash/trunk/src/import-export/hbci/gnc-hbci-utils.c 2007-02-25 21:54:56 UTC (rev 15663)
@@ -247,8 +247,12 @@
return MAX(tmp_result, cause);
}
#endif
-int
-gnc_hbci_debug_outboxjob (AB_JOB *job, gboolean verbose)
+
+/** Return the HBCI return code of the given 'job', or zero if none was
+ * found. If 'verbose' is TRUE, make a lot of debugging messages about
+ * this outboxjob. */
+static int
+gnc_hbci_debug_outboxjob (GNCInteractor *inter, AB_JOB *job, gboolean verbose)
{
int cause = 0;
AB_JOB_STATUS jobstatus;
@@ -264,6 +268,15 @@
jobstatus = AB_Job_GetStatus (job);
if (jobstatus == AB_Job_StatusError) {
+ if (AB_Job_GetResultText (job)) {
+ /* Add the "result text" to the log window */
+ char *logstring = g_strdup_printf("Job %s had an error: %s\n",
+ AB_Job_Type2Char(AB_Job_GetType(job)),
+ AB_Job_GetResultText(job));
+ GNCInteractor_add_log_text (inter, logstring);
+ g_free (logstring);
+ }
+
if (!verbose)
g_warning("gnc_hbci_debug_outboxjob: Job %s had an error: %s\n",
AB_Job_Type2Char(AB_Job_GetType(job)),
@@ -491,9 +504,9 @@
} while (gnc_hbci_Error_retry (parent, err, inter));
if (job)
- resultcode = gnc_hbci_debug_outboxjob (job, be_verbose);
+ resultcode = gnc_hbci_debug_outboxjob (inter, job, be_verbose);
if (!hbci_Error_isOk(err)) {
- if (job) gnc_hbci_debug_outboxjob (job, TRUE);
+ if (job) gnc_hbci_debug_outboxjob (inter, job, TRUE);
if (inter) GNCInteractor_show_nodelete (inter);
return FALSE;
}
@@ -503,7 +516,7 @@
return TRUE;
}
else {
- g_message("gnc_AB_BANKING_execute: Some error at executeQueue.");
+ g_message("gnc_AB_BANKING_execute: Some error at executeQueue (see gwen/aqbanking messages above); this does not necessarily mean that the results are unusable.");
GNCInteractor_show_nodelete (inter);
return TRUE; /* <- This used to be a FALSE but this was probably
* as wrong as it could get. @%$! */
@@ -778,8 +791,35 @@
{
/* Description */
char *h_descr = gnc_hbci_getpurpose (h_trans);
+ char *othername = gnc_hbci_getremotename (h_trans);
+ char *g_descr;
+
+ /* Get othername */
+ /*DEBUG("HBCI Description '%s'", h_descr);*/
+
+ if (othername && strlen (othername) > 0)
+ g_descr =
+ ((strlen (h_descr) > 0) ?
+ g_strdup_printf ("%s; %s",
+ h_descr,
+ othername) :
+ g_strdup (othername));
+ else
+ g_descr =
+ ((strlen (h_descr) > 0) ?
+ g_strdup (h_descr) :
+ g_strdup (_("Unspecified")));
+
+ g_free (h_descr);
+ if (othername) g_free (othername);
+ return g_descr;
+}
+
+char *gnc_hbci_getremotename (const AB_TRANSACTION *h_trans)
+{
+ /* Description */
char *othername = NULL;
- char *g_descr;
+ char *result;
const GWEN_STRINGLIST *h_remotename = AB_Transaction_GetRemoteName (h_trans);
struct cb_struct cb_object;
@@ -796,22 +836,13 @@
/*DEBUG("HBCI Description '%s'", h_descr);*/
if (othername && (strlen (othername) > 0))
- g_descr =
- ((strlen (h_descr) > 0) ?
- g_strdup_printf ("%s; %s",
- h_descr,
- othername) :
- g_strdup (othername));
+ result = g_strdup (othername);
else
- g_descr =
- ((strlen (h_descr) > 0) ?
- g_strdup (h_descr) :
- g_strdup (_("Unspecified")));
+ result = NULL;
g_iconv_close(cb_object.gnc_iconv_handler);
- free (h_descr);
- free (othername);
- return g_descr;
+ g_free (othername);
+ return result;
}
char *gnc_hbci_getpurpose (const AB_TRANSACTION *h_trans)
@@ -835,7 +866,7 @@
g_descr = g_strdup (h_descr ? h_descr : "");
g_iconv_close(cb_object.gnc_iconv_handler);
- free (h_descr);
+ g_free (h_descr);
return g_descr;
}
Modified: gnucash/trunk/src/import-export/hbci/gnc-hbci-utils.h
===================================================================
--- gnucash/trunk/src/import-export/hbci/gnc-hbci-utils.h 2007-02-25 20:36:10 UTC (rev 15662)
+++ gnucash/trunk/src/import-export/hbci/gnc-hbci-utils.h 2007-02-25 21:54:56 UTC (rev 15663)
@@ -85,12 +85,6 @@
AB_ACCOUNT *
gnc_hbci_get_hbci_acc (const AB_BANKING *api, Account *gnc_acc);
-/* Return the HBCI return code of the given 'job', or zero if none was
- * found. If 'verbose' is TRUE, make a lot of debugging messages about
- * this outboxjob. */
-int
-gnc_hbci_debug_outboxjob (AB_JOB *job, gboolean verbose);
-
/** Clean up the queue after executing, i.e. delete the job as good as
possible. */
void
@@ -173,6 +167,11 @@
* purpose, an empty (but allocated) string is returned. */
char *gnc_hbci_getpurpose (const AB_TRANSACTION *h_trans);
+/* Retrieve the merged "remote name" fields from the transaction. The
+ * returned string must be g_free'd by the caller. If there was no
+ * "remote name" field, NULL (!) is returned. */
+char *gnc_hbci_getremotename (const AB_TRANSACTION *h_trans);
+
/** Return the first customer that can act on the specified account,
or NULL if none was found (and an error message is printed on
stdout). */
More information about the gnucash-changes
mailing list