[Gnucash-changes] Add sanity checks and ask user when there are no
purpose lines.
Christian Stimming
cstim at cvs.gnucash.org
Mon May 23 16:16:24 EDT 2005
Log Message:
-----------
Add sanity checks and ask user when there are no purpose lines.
2005-05-23 Christian Stimming <stimming at tuhh.de>
* src/import-export/hbci/dialog-hbcitrans.c: Add sanity checks and
ask user when there are no purpose lines.
Modified Files:
--------------
gnucash:
ChangeLog
gnucash/src/import-export/hbci:
dialog-hbcitrans.c
gnc-hbci-utils.c
gnc-hbci-utils.h
Revision Data
-------------
Index: ChangeLog
===================================================================
RCS file: /home/cvs/cvsroot/gnucash/ChangeLog,v
retrieving revision 1.1906
retrieving revision 1.1907
diff -LChangeLog -LChangeLog -u -r1.1906 -r1.1907
--- ChangeLog
+++ ChangeLog
@@ -1,3 +1,8 @@
+2005-05-23 Christian Stimming <stimming at tuhh.de>
+
+ * src/import-export/hbci/dialog-hbcitrans.c: Add sanity checks and
+ ask user when there are no purpose lines.
+
2005-05-06 Christian Stimming <stimming at tuhh.de>
* src/import-export/hbci/druid-hbci-initial.c (on_aqhbci_button):
Index: gnc-hbci-utils.h
===================================================================
RCS file: /home/cvs/cvsroot/gnucash/src/import-export/hbci/gnc-hbci-utils.h,v
retrieving revision 1.20
retrieving revision 1.21
diff -Lsrc/import-export/hbci/gnc-hbci-utils.h -Lsrc/import-export/hbci/gnc-hbci-utils.h -u -r1.20 -r1.21
--- src/import-export/hbci/gnc-hbci-utils.h
+++ src/import-export/hbci/gnc-hbci-utils.h
@@ -109,6 +109,10 @@
* string must be g_free'd by the caller. */
char *gnc_hbci_memo_tognc (const AB_TRANSACTION *h_trans);
+/* Retrieve the merged purpose fields from the transaction. The
+ * returned string must be g_free'd by the caller. If there was no
+ * purpose, an empty (but allocated) string is returned. */
+char *gnc_hbci_getpurpose (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). */
Index: dialog-hbcitrans.c
===================================================================
RCS file: /home/cvs/cvsroot/gnucash/src/import-export/hbci/dialog-hbcitrans.c,v
retrieving revision 1.42
retrieving revision 1.43
diff -Lsrc/import-export/hbci/dialog-hbcitrans.c -Lsrc/import-export/hbci/dialog-hbcitrans.c -u -r1.42 -r1.43
--- src/import-export/hbci/dialog-hbcitrans.c
+++ src/import-export/hbci/dialog-hbcitrans.c
@@ -504,6 +504,27 @@
continue;
} /* check Transaction_value */
+ {
+ char *purpose = gnc_hbci_getpurpose (td->hbci_trans);
+ printf ("%d: %s\n", strlen(purpose), purpose);
+ if (strlen(purpose) == 0) {
+ gtk_widget_show_all (td->dialog);
+ values_ok = !gnc_verify_dialog
+ (GTK_WIDGET (td->dialog),
+ TRUE,
+ "%s",
+ _("You did not enter any transaction purpose. A purpose is \n"
+ "required for an online transfer.\n"
+ "\n"
+ "Do you want to enter the job again?"));
+ if (values_ok) {
+ AB_Transaction_free (td->hbci_trans);
+ return -1;
+ }
+ continue;
+ } /* check Transaction_purpose */
+ }
+
/* FIXME: If this is a direct debit, set the textkey/ "Textschluessel"/
transactionCode according to some GUI selection here!! */
/*if (td->trans_type == SINGLE_DEBITNOTE)
Index: gnc-hbci-utils.c
===================================================================
RCS file: /home/cvs/cvsroot/gnucash/src/import-export/hbci/gnc-hbci-utils.c,v
retrieving revision 1.52
retrieving revision 1.53
diff -Lsrc/import-export/hbci/gnc-hbci-utils.c -Lsrc/import-export/hbci/gnc-hbci-utils.c -u -r1.52 -r1.53
--- src/import-export/hbci/gnc-hbci-utils.c
+++ src/import-export/hbci/gnc-hbci-utils.c
@@ -533,10 +533,9 @@
char *gnc_hbci_descr_tognc (const AB_TRANSACTION *h_trans)
{
/* Description */
- char *h_descr = NULL;
+ char *h_descr = gnc_hbci_getpurpose (h_trans);
char *othername = NULL;
char *g_descr;
- const GWEN_STRINGLIST *h_purpose = AB_Transaction_GetPurpose (h_trans);
const GWEN_STRINGLIST *h_remotename = AB_Transaction_GetRemoteName (h_trans);
struct cb_struct cb_object;
@@ -544,16 +543,7 @@
iconv_open(gnc_hbci_book_encoding(), gnc_hbci_AQBANKING_encoding());
g_assert(cb_object.gnc_iconv_handler != (iconv_t)(-1));
- /* Don't use list_string_concat_delim here since we need to
- g_strstrip every single element of the string list, which is
- only done in our callback gnc_list_string_cb. The separator is
- also set there. */
- cb_object.result = &h_descr;
- if (h_purpose)
- GWEN_StringList_ForEach (h_purpose,
- &gnc_list_string_cb,
- &cb_object);
-
+ /* Get othername */
cb_object.result = &othername;
if (h_remotename)
GWEN_StringList_ForEach (h_remotename,
@@ -563,14 +553,14 @@
if (othername && (strlen (othername) > 0))
g_descr =
- ((h_descr && (strlen (h_descr) > 0)) ?
+ ((strlen (h_descr) > 0) ?
g_strdup_printf ("%s; %s",
h_descr,
othername) :
g_strdup (othername));
else
g_descr =
- ((h_descr && (strlen (h_descr) > 0)) ?
+ ((strlen (h_descr) > 0) ?
g_strdup (h_descr) :
g_strdup (_("Unspecified")));
@@ -580,6 +570,31 @@
return g_descr;
}
+char *gnc_hbci_getpurpose (const AB_TRANSACTION *h_trans)
+{
+ /* Description */
+ char *h_descr = NULL;
+ char *g_descr;
+ const GWEN_STRINGLIST *h_purpose = AB_Transaction_GetPurpose (h_trans);
+ struct cb_struct cb_object;
+
+ cb_object.gnc_iconv_handler =
+ iconv_open(gnc_hbci_book_encoding(), gnc_hbci_AQBANKING_encoding());
+ g_assert(cb_object.gnc_iconv_handler != (iconv_t)(-1));
+
+ cb_object.result = &h_descr;
+ if (h_purpose)
+ GWEN_StringList_ForEach (h_purpose,
+ &gnc_list_string_cb,
+ &cb_object);
+
+ g_descr = g_strdup (h_descr ? h_descr : "");
+
+ iconv_close(cb_object.gnc_iconv_handler);
+ free (h_descr);
+ return g_descr;
+}
+
char *gnc_hbci_memo_tognc (const AB_TRANSACTION *h_trans)
{
/* Memo in the Split. HBCI's transactionText contains strings like
More information about the gnucash-changes
mailing list