r17644 - gnucash/trunk/src - Add account defaulting for posting vendor bill

Christian Stimming cstim at cvs.gnucash.org
Sat Oct 25 04:59:40 EDT 2008


Author: cstim
Date: 2008-10-25 04:59:40 -0400 (Sat, 25 Oct 2008)
New Revision: 17644
Trac: http://svn.gnucash.org/trac/changeset/17644

Modified:
   gnucash/trunk/src/business/business-gnome/dialog-date-close.c
   gnucash/trunk/src/business/business-gnome/dialog-date-close.h
   gnucash/trunk/src/business/business-gnome/dialog-employee.c
   gnucash/trunk/src/business/business-gnome/dialog-invoice.c
   gnucash/trunk/src/gnome-utils/dialog-options.c
   gnucash/trunk/src/gnome-utils/gnc-account-sel.c
   gnucash/trunk/src/gnome-utils/gnc-account-sel.h
   gnucash/trunk/src/gnome/druid-loan.c
Log:
Add account defaulting for posting vendor bill

In the post screen for vendor bills, in trunk, the account combo box
initially has no entry and the user needs to pick one.  This isn't a
bug, but is an extra step for the user, so the trunk patch does
defaulting.  I tested the "memory" function to make sure the defaulting
doesn't smash the account the user picked for this vendor the last time
through, and it works (doesn't conflict).

Patch by aradzak <aradzak at oracleatbelfry.com>.

Modified: gnucash/trunk/src/business/business-gnome/dialog-date-close.c
===================================================================
--- gnucash/trunk/src/business/business-gnome/dialog-date-close.c	2008-10-25 08:23:20 UTC (rev 17643)
+++ gnucash/trunk/src/business/business-gnome/dialog-date-close.c	2008-10-25 08:59:40 UTC (rev 17644)
@@ -101,7 +101,7 @@
 }
 
 static void
-fill_in_acct_info (DialogDateClose *ddc)
+fill_in_acct_info (DialogDateClose *ddc, gboolean set_default_acct)
 {
   GNCAccountSel *gas = GNC_ACCOUNT_SEL (ddc->acct_combo);
 
@@ -109,7 +109,7 @@
   gnc_account_sel_set_acct_filters( gas, ddc->acct_types );
   gnc_account_sel_set_new_account_ability( gas, TRUE );
   gnc_account_sel_set_new_account_modal( gas, TRUE );
-  gnc_account_sel_set_account( gas, ddc->acct );
+  gnc_account_sel_set_account( gas, ddc->acct, set_default_acct );
 }
 
 static void
@@ -227,6 +227,7 @@
 				const char *acct_label_message,
 				const char *question_check_message,
 				gboolean ok_is_default,
+                                gboolean set_default_acct,
 				GList * acct_types, GNCBook *book,
 				GncBillTerm *terms,
 				/* Returned Data... */
@@ -311,7 +312,7 @@
     gnc_date_edit_set_time_ts (GNC_DATE_EDIT (ddc->date), *ddue);
 
   /* Setup the account widget */
-  fill_in_acct_info (ddc);
+  fill_in_acct_info (ddc, set_default_acct);
 
   /* Setup signals */
   glade_xml_signal_autoconnect_full( xml,
@@ -371,7 +372,7 @@
   acct_box = glade_xml_get_widget (xml, "acct_hbox");
   ddc->acct_combo = gnc_account_sel_new();
   if (*acct)
-    gnc_account_sel_set_account (GNC_ACCOUNT_SEL(ddc->acct_combo), *acct);
+    gnc_account_sel_set_account (GNC_ACCOUNT_SEL(ddc->acct_combo), *acct, FALSE);
   gtk_box_pack_start (GTK_BOX(acct_box), ddc->acct_combo, TRUE, TRUE, 0);
 
   date_box = glade_xml_get_widget (xml, "date_box");
@@ -393,7 +394,7 @@
   gnc_date_edit_set_time_ts (GNC_DATE_EDIT (ddc->date), *date);
 
   /* Setup the account widget */
-  fill_in_acct_info (ddc);
+  fill_in_acct_info (ddc, FALSE);
 
   /* Setup signals */
   glade_xml_signal_autoconnect_full( xml,

Modified: gnucash/trunk/src/business/business-gnome/dialog-date-close.h
===================================================================
--- gnucash/trunk/src/business/business-gnome/dialog-date-close.h	2008-10-25 08:23:20 UTC (rev 17643)
+++ gnucash/trunk/src/business/business-gnome/dialog-date-close.h	2008-10-25 08:59:40 UTC (rev 17644)
@@ -52,6 +52,7 @@
 				const char *acct_label_message,
 				const char *question_check_message,
 				gboolean ok_is_default,
+				gboolean set_default_acct,
 				GList * acct_types, GNCBook *book,
 				GncBillTerm *terms,
 				/* Returned Data... */

Modified: gnucash/trunk/src/business/business-gnome/dialog-employee.c
===================================================================
--- gnucash/trunk/src/business/business-gnome/dialog-employee.c	2008-10-25 08:23:20 UTC (rev 17643)
+++ gnucash/trunk/src/business/business-gnome/dialog-employee.c	2008-10-25 08:59:40 UTC (rev 17644)
@@ -549,7 +549,7 @@
     gtk_widget_set_sensitive (ew->ccard_acct_sel, FALSE);
   } else {
     gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (ew->ccard_acct_check), TRUE);
-    gnc_account_sel_set_account (GNC_ACCOUNT_SEL (ew->ccard_acct_sel), ccard_acct);
+    gnc_account_sel_set_account (GNC_ACCOUNT_SEL (ew->ccard_acct_sel), ccard_acct, FALSE);
   }
 
   /* XXX: Set the ACL */

Modified: gnucash/trunk/src/business/business-gnome/dialog-invoice.c
===================================================================
--- gnucash/trunk/src/business/business-gnome/dialog-invoice.c	2008-10-25 08:23:20 UTC (rev 17643)
+++ gnucash/trunk/src/business/business-gnome/dialog-invoice.c	2008-10-25 08:59:40 UTC (rev 17644)
@@ -664,7 +664,7 @@
   accumulate = gnc_gconf_get_bool(GCONF_SECTION_INVOICE, "accumulate_splits", NULL);
 
   if (!gnc_dialog_dates_acct_question_parented (iw_get_window(iw), message, ddue_label,
-				       post_label, acct_label, question_label, TRUE,
+				       post_label, acct_label, question_label, TRUE, TRUE,
 				       acct_types, iw->book, iw->terms,
 				       &ddue, &postdate, &memo, &acc, &accumulate))
     return;

Modified: gnucash/trunk/src/gnome/druid-loan.c
===================================================================
--- gnucash/trunk/src/gnome/druid-loan.c	2008-10-25 08:23:20 UTC (rev 17643)
+++ gnucash/trunk/src/gnome/druid-loan.c	2008-10-25 08:59:40 UTC (rev 17644)
@@ -1277,7 +1277,7 @@
         if ( ldd->ld.escrowAcct ) {
                 gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON(ldd->optEscrowCb),
                                               TRUE );
-                gnc_account_sel_set_account( ldd->optEscrowGAS, ldd->ld.escrowAcct );
+                gnc_account_sel_set_account( ldd->optEscrowGAS, ldd->ld.escrowAcct, FALSE );
         }
         for ( i=0; i<ldd->ld.repayOptCount; i++ ) {
                 rouid = ldd->repayOptsUI[i];
@@ -1414,11 +1414,11 @@
                 gtk_entry_set_text( ldd->repAmtEntry, ldd->ld.repAmount );
 
         gnc_account_sel_set_account( ldd->repAssetsFromGAS,
-                                     ldd->ld.repFromAcct );
+                                     ldd->ld.repFromAcct, FALSE );
         gnc_account_sel_set_account( ldd->repPrincToGAS,
-                                     ldd->ld.repPriAcct );
+                                     ldd->ld.repPriAcct, FALSE );
         gnc_account_sel_set_account( ldd->repIntToGAS,
-                                     ldd->ld.repIntAcct );
+                                     ldd->ld.repIntAcct, FALSE );
         gnc_frequency_setup_recurrence(ldd->repGncFreq,
                                        ldd->ld.repayment_schedule,
                                        ldd->ld.repStartDate);
@@ -1483,7 +1483,7 @@
                                                    ldd );
         }
 
-        gnc_account_sel_set_account( ldd->payAcctToGAS,   rod->to );
+        gnc_account_sel_set_account( ldd->payAcctToGAS,   rod->to, FALSE );
 
         uniq = (rod->schedule != NULL);
         gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON(ldd->payTxnFreqPartRb),
@@ -1684,9 +1684,9 @@
         if ( newState )
         {
                 gnc_account_sel_set_account( ldd->payAcctEscToGAS,
-                                             ldd->ld.escrowAcct );
+                                             ldd->ld.escrowAcct, FALSE );
                 gnc_account_sel_set_account( ldd->payAcctEscFromGAS,
-                                             ldd->ld.escrowAcct );
+                                             ldd->ld.escrowAcct, FALSE );
         }
 }
 
@@ -1711,7 +1711,7 @@
         {
                 gnc_account_sel_set_account( ldd->payAcctFromGAS,
                                              ldd->ld.repayOpts[ldd->currentIdx]
-                                             ->from );
+                                             ->from, FALSE );
         }
 }
 

Modified: gnucash/trunk/src/gnome-utils/dialog-options.c
===================================================================
--- gnucash/trunk/src/gnome-utils/dialog-options.c	2008-10-25 08:23:20 UTC (rev 17643)
+++ gnucash/trunk/src/gnome-utils/dialog-options.c	2008-10-25 08:59:40 UTC (rev 17644)
@@ -2384,7 +2384,8 @@
     acc = SWIG_MustGetPtr(value, SWIG_TypeQuery("_p_Account"), 4, 0);
   }
 	
-  gnc_account_sel_set_account (GNC_ACCOUNT_SEL(widget), acc);
+  //doesn't default because this function is called to set a specific account
+  gnc_account_sel_set_account (GNC_ACCOUNT_SEL(widget), acc, FALSE);
 
   return FALSE;
 }

Modified: gnucash/trunk/src/gnome-utils/gnc-account-sel.c
===================================================================
--- gnucash/trunk/src/gnome-utils/gnc-account-sel.c	2008-10-25 08:23:20 UTC (rev 17643)
+++ gnucash/trunk/src/gnome-utils/gnc-account-sel.c	2008-10-25 08:59:40 UTC (rev 17644)
@@ -285,11 +285,18 @@
   return TRUE;
 }
 void
-gnc_account_sel_set_account( GNCAccountSel *gas, Account *acct )
+gnc_account_sel_set_account( GNCAccountSel *gas, Account *acct, gboolean set_default_acct )
 {
 	gas_find_data data;
 
-	gtk_combo_box_set_active( GTK_COMBO_BOX(gas->combo), -1 );
+        if (set_default_acct)
+        {
+          gtk_combo_box_set_active(GTK_COMBO_BOX(gas->combo), 0);
+        }
+        else
+        {
+	  gtk_combo_box_set_active( GTK_COMBO_BOX(gas->combo), -1 );
+        }
         if ( acct == NULL )
                 return;
 

Modified: gnucash/trunk/src/gnome-utils/gnc-account-sel.h
===================================================================
--- gnucash/trunk/src/gnome-utils/gnc-account-sel.h	2008-10-25 08:23:20 UTC (rev 17643)
+++ gnucash/trunk/src/gnome-utils/gnc-account-sel.h	2008-10-25 08:59:40 UTC (rev 17644)
@@ -70,9 +70,9 @@
 /**
  * Sets the GAS to the given account.  If the account doesn't exist in the
  * list, then it doesn't change the state of the GAS.  If the account is
- * NULL, then the first list selection is made.
+ * NULL, then the first list selection is made if set_default_acct is TRUE.
  **/
-void       gnc_account_sel_set_account( GNCAccountSel *gas, Account *acct );
+void       gnc_account_sel_set_account( GNCAccountSel *gas, Account *acct, gboolean set_default_acct );
 /**
  * Returns the currently-selected Account.  If, for some reason the selection
  * is in a bad state, NULL will be returned.



More information about the gnucash-changes mailing list