2002-11-25 Benoit Gr�goire <bock@step.polymtl.ca>

* src/import-export/Account-matcher.[c,h]: Minor changes to make
	the matcher more generic:  Improved text handling, default account
	support, enable account description, disable showing Online ID
	column if online_id isn't specified in the function call.
	* src/import-export/generic-import.glade: Adjust text for above 		changes.
	* src/import-export/gnc-gen-transaction.c:  Use the more feature		 complete Account-matcher.h from the generic import module instead
	 of dialog-account-pick.h.  Christian, tell me you didn't implement
	a fourth account picker from scratch.
	* src/import-export/ofx/gnc-ofx-import.c: Adapt text to
	Account-matcher changes.


git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@7553 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
Benoit Grégoire 2002-11-25 08:43:19 +00:00
parent b05f24cce9
commit 8fdd995500
6 changed files with 118 additions and 27 deletions

View File

@ -1,3 +1,15 @@
2002-11-25 Benoit Grégoire <bock@step.polymtl.ca>
* src/import-export/Account-matcher.[c,h]: Minor changes to make
the matcher more generic: Improved text handling, default account
support, enable account description, disable showing Online ID
column if online_id isn't specified in the function call.
* src/import-export/generic-import.glade: Adjust text for above changes.
* src/import-export/gnc-gen-transaction.c: Use the more feature complete Account-matcher.h from the generic import module instead
of dialog-account-pick.h. Christian, tell me you didn't implement
a fourth account picker from scratch.
* src/import-export/ofx/gnc-ofx-import.c: Adapt text to
Account-matcher changes.
2002-11-24 Joshua Sled <jsled@asynchronous.org>
* src/gnome/druid-loan.c (ld_rev_prep): Initial support for a

View File

@ -47,6 +47,20 @@
static short module = MOD_IMPORT;
/********************************************************************\
* Constants *
\********************************************************************/
#define NUM_COLUMNS_CLIST 4
static const int CLIST_NAME= 0;
static const int CLIST_TYPE = 1;
static const int CLIST_DESCRIPTION = 2;
static const int CLIST_ONLINE_ID = 3;
/********************************************************************\
* Structs *
\********************************************************************/
struct _accountpickerdialog {
GtkWidget * dialog;
GtkWidget * treeview;
@ -67,18 +81,20 @@ struct _accountpickerdialog {
*
\********************************************************************/
static void acct_tree_add_accts(AccountGroup * accts, GtkCTree * tree, GtkCTreeNode * parent)
static void acct_tree_add_accts(struct _accountpickerdialog * picker, AccountGroup * accts, GtkCTree * tree, GtkCTreeNode * parent)
{
GtkCTreeNode * node;
Account *current_acct;
guint i;
gchar * acctinfo[3];
gchar * acctinfo[NUM_COLUMNS_CLIST];
for(i=0;i<xaccGroupGetNumAccounts(accts);i++)
{
current_acct = xaccGroupGetAccount(accts, i);
acctinfo[0]=(gchar *)xaccAccountGetName(current_acct);
acctinfo[1]=g_strdup(xaccAccountGetTypeStr(xaccAccountGetType(current_acct)));
acctinfo[2]=g_strdup(gnc_import_get_acc_online_id(current_acct));
acctinfo[CLIST_NAME]=(gchar *)xaccAccountGetName(current_acct);
acctinfo[CLIST_TYPE]=g_strdup(xaccAccountGetTypeStr(xaccAccountGetType(current_acct)));
acctinfo[CLIST_DESCRIPTION]=(gchar *)xaccAccountGetDescription(current_acct);
acctinfo[CLIST_ONLINE_ID]=g_strdup(gnc_import_get_acc_online_id(current_acct));
//printf("acct_tree_add_acct(): %s%s",xaccAccountGetName(current_acct),"\n");
node = gtk_ctree_insert_node (tree,
parent,
@ -91,7 +107,12 @@ static void acct_tree_add_accts(AccountGroup * accts, GtkCTree * tree, GtkCTreeN
gtk_ctree_node_set_row_data (tree,
node,
current_acct);
acct_tree_add_accts(xaccAccountGetChildren(current_acct), tree, node);
if(current_acct==picker->selected_acct)
{
gtk_ctree_select(tree,
node);
}
acct_tree_add_accts(picker, xaccAccountGetChildren(current_acct), tree, node);
}
}
@ -107,7 +128,7 @@ build_acct_tree(struct _accountpickerdialog * picker) {
gtk_clist_clear(GTK_CLIST(picker->treeview));
gtk_clist_set_column_justification (GTK_CLIST(picker->treeview),
1, GTK_JUSTIFY_CENTER);
acct_tree_add_accts(picker->acct_group, GTK_CTREE(picker->treeview), NULL);
acct_tree_add_accts(picker, picker->acct_group, GTK_CTREE(picker->treeview), NULL);
if(picker->selected_acct!=NULL) {
new_sel = gtk_ctree_find_by_row_data(GTK_CTREE(picker->treeview),
@ -193,7 +214,8 @@ Account * gnc_import_select_account(char * account_online_id_value,
char auto_create,
char * account_human_description,
gnc_commodity * new_account_default_commodity,
GNCAccountType new_account_default_type)
GNCAccountType new_account_default_type,
Account * default_selection)
{
#define ACCOUNT_DESCRIPTION_MAX_SIZE 255
struct _accountpickerdialog * picker;
@ -214,6 +236,7 @@ Account * gnc_import_select_account(char * account_online_id_value,
picker->account_human_description = account_human_description;
picker->new_account_default_commodity = new_account_default_commodity;
picker->new_account_default_type = new_account_default_type;
picker->selected_acct=default_selection;
DEBUG("Looking for account with online_id: %s", account_online_id_value);
if(account_online_id_value!=NULL)
@ -253,9 +276,18 @@ Account * gnc_import_select_account(char * account_online_id_value,
strncat(account_description_text, account_online_id_value, ACCOUNT_DESCRIPTION_MAX_SIZE-strlen(account_description_text));
strncat(account_description_text, ")", ACCOUNT_DESCRIPTION_MAX_SIZE-strlen(account_description_text));
}
else
{
gtk_clist_set_column_visibility (GTK_CLIST (picker->treeview),
CLIST_ONLINE_ID,
FALSE);
}
gtk_label_set_text((GtkLabel*)online_id_label, account_description_text);
build_acct_tree(picker);
gtk_clist_columns_autosize (GTK_CLIST (picker->treeview));
gtk_clist_column_titles_passive (GTK_CLIST (picker->treeview));
ui_retval = gnome_dialog_run_and_close(GNOME_DIALOG(picker->dialog));
if(ui_retval == 0) {

View File

@ -73,6 +73,9 @@
the function returns NULL, otherwise, the user will be asked to
create a new account.
Account * default_selection: If not NULL, that account will be
pre-selected by default.
Return: A pointer to the found or created Account, or NULL if no
account was found or created.
@ -81,6 +84,7 @@ Account * gnc_import_select_account(char * account_online_id_value,
char auto_create,
char * account_human_description,
gnc_commodity * new_account_default_commodity,
GNCAccountType new_account_default_type);
GNCAccountType new_account_default_type,
Account * default_selection);
#endif

View File

@ -83,7 +83,7 @@
<widget>
<class>GtkLabel</class>
<name>label847715</name>
<label>The following online account is currently unknown to GnuCash:</label>
<label>Please select or create an appropriate Gnucash account for:</label>
<justify>GTK_JUSTIFY_CENTER</justify>
<wrap>False</wrap>
<xalign>0.5</xalign>
@ -117,7 +117,7 @@
<widget>
<class>GtkFrame</class>
<name>frame1</name>
<label>Please select or create the matching Gnucash account:</label>
<label></label>
<label_xalign>0</label_xalign>
<shadow_type>GTK_SHADOW_ETCHED_IN</shadow_type>
<child>
@ -148,8 +148,8 @@
<handler>gnc_ui_generic_account_picker_unselect_cb</handler>
<last_modification_time>Fri, 07 Jun 2002 17:34:00 GMT</last_modification_time>
</signal>
<columns>3</columns>
<column_widths>215,48,80</column_widths>
<columns>4</columns>
<column_widths>215,48,82,80</column_widths>
<selection_mode>GTK_SELECTION_SINGLE</selection_mode>
<show_titles>True</show_titles>
<shadow_type>GTK_SHADOW_IN</shadow_type>
@ -184,6 +184,19 @@
<class>GtkLabel</class>
<child_name>CTree:title</child_name>
<name>label847713</name>
<label>Description</label>
<justify>GTK_JUSTIFY_CENTER</justify>
<wrap>False</wrap>
<xalign>0.5</xalign>
<yalign>0.5</yalign>
<xpad>0</xpad>
<ypad>0</ypad>
</widget>
<widget>
<class>GtkLabel</class>
<child_name>CTree:title</child_name>
<name>label847785</name>
<label>Account ID</label>
<justify>GTK_JUSTIFY_CENTER</justify>
<wrap>False</wrap>
@ -942,7 +955,6 @@
<widget>
<class>GtkCList</class>
<name>downloaded_clist</name>
<can_focus>False</can_focus>
<signal>
<name>select_row</name>
<handler>downloaded_transaction_select_cb</handler>

View File

@ -32,10 +32,10 @@
#include "global-options.h"
#include "gnc-ui-util.h"
#include "gnc-engine-util.h"
#include "dialog-account-pick.h"
#include "gnc-import-match-map.h"
#include "Transaction-matcher.h"
#include "Account-matcher.h"
struct _generic_transaction_info
{
@ -99,7 +99,13 @@ run_account_picker_dialog (GNCGenTransaction *info,
{
Account *old_acc, *new_acc;
old_acc = gnc_import_TransInfo_get_destacc (trans_info);
new_acc = gnc_account_picker_dialog(old_acc);
/* new_acc = gnc_account_picker_dialog(old_acc);*/
new_acc = gnc_import_select_account(NULL,
TRUE,
_("A destination split for the transaction you selected."),
xaccTransGetCurrency(gnc_import_TransInfo_get_trans(trans_info)),
NO_TYPE,
old_acc);
if (old_acc != new_acc) {
gnc_import_TransInfo_set_destacc (trans_info, new_acc);
refresh_clist_row (info, row, trans_info);

View File

@ -160,7 +160,7 @@ int ofx_proc_transaction_cb(struct OfxTransactionData data)
gchar *notes, *tmp;
if(data.account_id_valid==true){
account = gnc_import_select_account(data.account_id, 0, NULL, NULL, NO_TYPE);
account = gnc_import_select_account(data.account_id, 0, NULL, NULL, NO_TYPE, NULL);
if(account!=NULL)
{
/********** Create the transaction and setup transaction data ************/
@ -386,7 +386,8 @@ int ofx_proc_transaction_cb(struct OfxTransactionData data)
1,
investment_account_text,
investment_commodity,
STOCK);
STOCK,
NULL);
g_free (investment_account_text);
if(investment_account!=NULL&&
data.unitprice_valid==true&&
@ -440,7 +441,8 @@ int ofx_proc_transaction_cb(struct OfxTransactionData data)
1,
investment_account_text,
currency,
INCOME);
INCOME,
NULL);
income_acc_guid = xaccAccountGetGUID(income_account);
kvp_val = kvp_value_new_guid(income_acc_guid);
if( acc_frame==NULL)
@ -537,6 +539,8 @@ int ofx_proc_account_cb(struct OfxAccountData data)
gnc_commodity_table * commodity_table;
gnc_commodity * default_commodity;
GNCAccountType default_type=NO_TYPE;
gchar * account_description;
gchar * account_type_name;
if(data.account_id_valid==true){
//printf("ofx_proc_account() Now calling gnc_import_select_account()\n");
@ -556,23 +560,44 @@ int ofx_proc_account_cb(struct OfxAccountData data)
if(data.account_type_valid==true){
switch(data.account_type){
case OFX_CHECKING : default_type=BANK;
case OFX_CHECKING :
default_type=BANK;
account_type_name = g_strdup_printf(_("Unknown OFX checking account"));
break;
case OFX_SAVINGS : default_type=BANK;
case OFX_SAVINGS :
default_type=BANK;
account_type_name = g_strdup_printf(_("Unknown OFX savings account"));
break;
case OFX_MONEYMRKT : default_type=MONEYMRKT;
case OFX_MONEYMRKT :
default_type=MONEYMRKT;
account_type_name = g_strdup_printf(_("Unknown OFX money market account"));
break;
case OFX_CREDITLINE : default_type=CREDITLINE;
case OFX_CREDITLINE :
default_type=CREDITLINE;
account_type_name = g_strdup_printf(_("Unknown OFX credit line account"));
break;
case OFX_CMA : default_type=NO_TYPE;
case OFX_CMA :
default_type=NO_TYPE;
account_type_name = g_strdup_printf(_("Unknown OFX CMA account"));
break;
case OFX_CREDITCARD : default_type=CREDIT;
case OFX_CREDITCARD :
default_type=CREDIT;
account_type_name = g_strdup_printf(_("Unknown OFX credit card account"));
break;
default: PERR("WRITEME: ofx_proc_account() This is an unknown account type!");
}
}
selected_account = gnc_import_select_account(data.account_id, 1, data.account_name, default_commodity, default_type);
account_description = g_strdup_printf( /* This string is a default account
name. It MUST NOT contain the
character ':' anywhere in it or
in any translation. */
"%s \"%s\"",
account_type_name,
data.account_name);
selected_account = gnc_import_select_account(data.account_id, 1, account_description, default_commodity, default_type, NULL);
g_free(account_description);
g_free(account_type_name);
}
else
{