[Gnucash-changes] More HBCI work.

Christian Stimming cstim at cvs.gnucash.org
Thu Sep 30 10:49:37 EDT 2004


Log Message:
-----------
More HBCI work.

2004-09-30  Christian Stimming  <stimming at tuhh.de>

	* src/import-export/hbci/gnc-hbci-getbalance.c: Fix HBCI balance
	retrieval when some of the returned balance is NULL.

Modified Files:
--------------
    gnucash:
        ChangeLog
    gnucash/src/import-export/hbci:
        gnc-hbci-getbalance.c
        hbci-interaction.c

Revision Data
-------------
Index: ChangeLog
===================================================================
RCS file: /home/cvs/cvsroot/gnucash/ChangeLog,v
retrieving revision 1.1842
retrieving revision 1.1843
diff -LChangeLog -LChangeLog -u -r1.1842 -r1.1843
--- ChangeLog
+++ ChangeLog
@@ -1,3 +1,8 @@
+2004-09-30  Christian Stimming  <stimming at tuhh.de>
+
+	* src/import-export/hbci/gnc-hbci-getbalance.c: Fix HBCI balance
+	retrieval when some of the returned balance is NULL.
+
 2004-09-28  Derek Atkins  <derek at ihtfp.com>
 
 	* src/engine/qofquerycore.c: Fix for x86_64.
Index: hbci-interaction.c
===================================================================
RCS file: /home/cvs/cvsroot/gnucash/src/import-export/hbci/hbci-interaction.c,v
retrieving revision 1.46
retrieving revision 1.47
diff -Lsrc/import-export/hbci/hbci-interaction.c -Lsrc/import-export/hbci/hbci-interaction.c -u -r1.46 -r1.47
--- src/import-export/hbci/hbci-interaction.c
+++ src/import-export/hbci/hbci-interaction.c
@@ -359,7 +359,9 @@
     else {
       g_assert (maxLen > strlen(resultbuffer));
       strcpy(resultbuffer, passwd);
-      if (text && data->cache_pin) {
+      /* Watch out: If we only compare the user string, then don't
+	 cache this if a TAN is asked for. */
+      if (text && data->cache_pin && !(strstr(text, "TAN"))) {
 	/*printf("Cached the PIN for user %s.\n", HBCI_User_userId (user));*/
 	data->cache_text= g_strdup(text);
 	if (data->pw)
Index: gnc-hbci-getbalance.c
===================================================================
RCS file: /home/cvs/cvsroot/gnucash/src/import-export/hbci/gnc-hbci-getbalance.c,v
retrieving revision 1.29
retrieving revision 1.30
diff -Lsrc/import-export/hbci/gnc-hbci-getbalance.c -Lsrc/import-export/hbci/gnc-hbci-getbalance.c -u -r1.29 -r1.30
--- src/import-export/hbci/gnc-hbci-getbalance.c
+++ src/import-export/hbci/gnc-hbci-getbalance.c
@@ -198,10 +198,9 @@
   const AB_ACCOUNT_STATUS *response;
   const AB_BALANCE *noted_grp, *booked_grp;
   const AB_VALUE *booked_val, *noted_val;
-
   time_t booked_tt;
-
   gboolean dialogres;
+  double booked_value, noted_value;
 
   response = AB_JobGetBalance_GetAccountStatus((AB_JOB*)job);
   if (!response) {
@@ -212,18 +211,35 @@
   noted_grp = AB_AccountStatus_GetNotedBalance(response);
   booked_grp = AB_AccountStatus_GetBookedBalance(response);
 
-  if (!booked_grp || !noted_grp) {
-    printf("gnc_hbci_getbalance_finish: Oops, booked_grp or noted_grp == NULL.\n");
-    return TRUE;
+  if (booked_grp) {
+    booked_val = AB_Balance_GetValue(booked_grp);
+    booked_tt = GWEN_Time_toTime_t (AB_Balance_GetTime(booked_grp));
+    if (booked_val)
+      booked_value = AB_Value_GetValue (booked_val);
+    else {
+      printf("gnc_hbci_getbalance_finish: Warning: booked_val == NULL. Assuming 0.\n");
+      booked_value = 0.0;
+    }
+  } else {
+    printf("gnc_hbci_getbalance_finish: Warning: booked_grp == NULL. Assuming 0.\n");
+    booked_value = 0.0;
   }
-  booked_val = AB_Balance_GetValue(booked_grp);
-  
-  noted_val = AB_Balance_GetValue(noted_grp);
-  
-  booked_tt = GWEN_Time_toTime_t (AB_Balance_GetTime(booked_grp));
-    
-  if ((AB_Value_GetValue (noted_val) == 0) &&
-      (AB_Value_GetValue (booked_val) == 0))
+
+  if (noted_grp) {
+    noted_val = AB_Balance_GetValue(noted_grp);
+    /* noted_tt = GWEN_Time_toTime_t (AB_Balance_GetTime(noted_grp)); */
+    if (noted_val)
+      noted_value = AB_Value_GetValue (noted_val);
+    else {
+      printf("gnc_hbci_getbalance_finish: Warning: noted_val == NULL. Assuming 0.\n");
+      noted_value = 0.0;
+    }
+  } else {
+    printf("gnc_hbci_getbalance_finish: Warning: noted_grp == NULL. Assuming 0.\n");
+    noted_value = 0.0;
+  }
+
+  if ((noted_value == 0.0) && (booked_value == 0.0))
     {
       gnome_ok_dialog_parented 
 	/* Translators: Strings from this file are really only
@@ -248,7 +264,7 @@
 	   "Account booked balance is %s\n"),
 	 booked_str);
       char *message2 = 
-	((AB_Value_GetValue (noted_val) == 0) ?
+	((noted_value == 0.0) ?
 	 g_strdup_printf("%s", "") :
 	 bal_print_balance
 	 (_("For your information: This account also \n"
@@ -271,7 +287,7 @@
   if (dialogres) 
     {
       gnc_numeric value =
-	double_to_gnc_numeric (AB_Value_GetValue (booked_val),
+	double_to_gnc_numeric (booked_value,
 			       xaccAccountGetCommoditySCU(gnc_acc),
 			       GNC_RND_ROUND);
       recnWindowWithBalance (parent, 


More information about the gnucash-changes mailing list