Generic import patch
Benoit Grégoire
bock@step.polymtl.ca
Tue, 30 Jul 2002 22:21:16 -0400
When I grow up I shall have CVS access ;)
Index: AccWindow.h
===================================================================
RCS file: /home/cvs/cvsroot/gnucash/src/AccWindow.h,v
retrieving revision 1.13
diff -u -r1.13 AccWindow.h
--- AccWindow.h 11 Feb 2002 01:59:46 -0000 1.13
+++ AccWindow.h 31 Jul 2002 02:09:45 -0000
@@ -45,6 +45,15 @@
/* Note that the caller owns the valid_types list */
Account * gnc_ui_new_accounts_from_name_window_with_types (const char *name,
GList *valid_types);
+/* Notes:
+ -the caller owns the valid_types list
+ -the parent parameter has priority over the eventual account path in the
name
+ -all parameters can be NULL
+*/
+Account * gnc_ui_new_accounts_from_name_with_defaults (const char *name,
+ GList *valid_types,
+ gnc_commodity * default_commodity,
+ Account * parent);
void gnc_ui_set_default_new_account_currency (const char *currency);
Index: dialog-account/dialog-account.c
===================================================================
RCS file: /home/cvs/cvsroot/gnucash/src/dialog-account/dialog-account.c,v
retrieving revision 1.8
diff -u -r1.8 dialog-account.c
--- dialog-account/dialog-account.c 28 May 2002 00:17:13 -0000 1.8
+++ dialog-account/dialog-account.c 31 Jul 2002 02:09:50 -0000
@@ -121,7 +121,8 @@
static AccountWindow *
gnc_ui_new_account_window_internal (Account *base_account,
GList *subaccount_names,
- GList *valid_types);
+ GList *valid_types,
+ gnc_commodity * default_commodity);
static void make_account_changes(GHashTable *change_type);
static void gnc_ui_refresh_account_window (AccountWindow *aw);
@@ -1687,7 +1688,8 @@
static AccountWindow *
gnc_ui_new_account_window_internal (Account *base_account,
GList *subaccount_names,
- GList *valid_types)
+ GList *valid_types,
+ gnc_commodity * default_commodity)
{
gnc_commodity *commodity;
AccountWindow *aw;
@@ -1724,8 +1726,14 @@
gnc_resume_gui_refresh ();
- commodity = gnc_default_currency ();
-
+ if(default_commodity!=NULL)
+ {
+ commodity = default_commodity;
+ }
+ else
+ {
+ commodity = gnc_default_currency ();
+ }
gnc_general_select_set_selected (GNC_GENERAL_SELECT (aw->commodity_edit),
commodity);
@@ -1760,13 +1768,13 @@
gnc_ui_new_account_window (AccountGroup *this_is_not_used)
{
/* FIXME get_current_account went away. */
- return gnc_ui_new_account_window_internal (NULL, NULL, NULL);
+ return gnc_ui_new_account_window_internal (NULL, NULL, NULL, NULL);
}
AccountWindow *
gnc_ui_new_account_window_with_default(AccountGroup *this_is_not_used,
Account * parent) {
- return gnc_ui_new_account_window_internal (parent, NULL, NULL);
+ return gnc_ui_new_account_window_internal (parent, NULL, NULL, NULL);
}
@@ -1844,13 +1852,21 @@
Account *
gnc_ui_new_accounts_from_name_window (const char *name)
{
- return gnc_ui_new_accounts_from_name_window_with_types (name, NULL);
+ return gnc_ui_new_accounts_from_name_with_defaults (name, NULL, NULL,
NULL);
}
Account *
gnc_ui_new_accounts_from_name_window_with_types (const char *name,
GList *valid_types)
{
+ return gnc_ui_new_accounts_from_name_with_defaults(name, valid_types,
NULL, NULL);
+}
+
+Account * gnc_ui_new_accounts_from_name_with_defaults (const char *name,
+ GList *valid_types,
+ gnc_commodity * default_commodity,
+ Account * parent)
+{
AccountWindow *aw;
Account *base_account;
Account *created_account;
@@ -1865,8 +1881,12 @@
else
subaccount_names = gnc_split_account_name (name, &base_account);
+ if (parent != NULL)
+ {
+ base_account=parent;
+ }
aw = gnc_ui_new_account_window_internal (base_account, subaccount_names,
- valid_types);
+ valid_types, default_commodity);
for (node = subaccount_names; node; node = node->next)
g_free (node->data);
Index: import-export/generic-import-design.txt
===================================================================
RCS file:
/home/cvs/cvsroot/gnucash/src/import-export/generic-import-design.txt,v
retrieving revision 1.1
diff -u -r1.1 generic-import-design.txt
--- import-export/generic-import-design.txt 21 Jun 2002 00:46:21 -0000 1.1
+++ import-export/generic-import-design.txt 31 Jul 2002 02:09:52 -0000
@@ -10,8 +10,11 @@
-Identifying and if necessary creating the source account: The account is
identified using the account number for ofx and HBCI, and the account
description for qif, if available. The account number or identifier is
stored in a kvp_string with key account_online_id. The online system can use
and format this frame however it sees fit, but it must be a kvp_string. A
function:
const char * gnc_import_get_acc_online_id(Account * account)
is provided for searching. If no account is found with a matching online_id,
the function:
-Account * gnc_import_select_account(char * account_online_id_value)
-must be called. The user can then select an existing account from a list
(the current account_online_id are displayed alongside the accounts), or
create a new one. The account_online_id is then stored in the selected or
created account's kvp_frame.
+Account * gnc_import_select_account(char * account_online_id_value,
+ char * account_human_description,
+ gnc_commodity * new_account_default_commodity,
+ GNCAccountType new_account_default_type);
+must be called (the last 3 parameters are optionnal). The user can then
select an existing account from a list, or create a new one. The
account_online_id is then stored in the selected or created account's
kvp_frame.
-Creating transaction and adding the source split (associated with the source
account, possibly created above), and filling it with as much information as
it has as it's disposal (much info is available for ofx, little for qif). If
a unique transaction id is available from the online system, is is stored in
the splits kvp_frame, using key transaction_online_id. No transaction
matching is done at this stage.
Index: import-export/generic-import.glade
===================================================================
RCS file: /home/cvs/cvsroot/gnucash/src/import-export/generic-import.glade,v
retrieving revision 1.1
diff -u -r1.1 generic-import.glade
--- import-export/generic-import.glade 21 Jun 2002 00:46:21 -0000 1.1
+++ import-export/generic-import.glade 31 Jul 2002 02:09:53 -0000
@@ -83,7 +83,7 @@
<widget>
<class>GtkLabel</class>
<name>label847715</name>
- <DEFANGED_label>The following online account is unknown:</DEFANGED_label>
+ <DEFANGED_label>The following online account is currently unknown to
GnuCash:</DEFANGED_label>
<justify>GTK_JUSTIFY_CENTER</justify>
<wrap>False</wrap>
<xalign>0.5</xalign>
@@ -117,7 +117,7 @@
<widget>
<class>GtkFrame</class>
<name>frame1</name>
- <DEFANGED_label>Please select or create matching Gnucash account:</DEFANGED_label>
+ <DEFANGED_label>Please select or create the matching Gnucash account:</DEFANGED_label>
<label_xalign>0</label_xalign>
<shadow_type>GTK_SHADOW_ETCHED_IN</shadow_type>
<child>
Index: import-export/gnc-generic-import.c
===================================================================
RCS file: /home/cvs/cvsroot/gnucash/src/import-export/gnc-generic-import.c,v
retrieving revision 1.1
diff -u -r1.1 gnc-generic-import.c
--- import-export/gnc-generic-import.c 21 Jun 2002 00:46:22 -0000 1.1
+++ import-export/gnc-generic-import.c 31 Jul 2002 02:09:53 -0000
@@ -57,6 +57,10 @@
GtkWidget * treeview;
AccountGroup * acct_group;
Account * selected_acct;
+ gchar * account_human_description;
+ gnc_commodity * new_account_default_commodity;
+ GNCAccountType new_account_default_type;
+
};
/* static gint
@@ -138,18 +142,26 @@
static void
gnc_ui_generic_account_picker_new_cb(GtkButton * w, gpointer user_data) {
struct _accountpickerdialog * picker = user_data;
+ GList * valid_types = NULL;
+
// printf(" gnc_ui_generic_account_picker_new_cb():Start\n");
- printf("WRITEME: gnc_ui_generic_account_picker_new_cb() Write a more
flexible function in dialog-account.c and AccWindow.h to fill in
defaults\n");
- picker->selected_acct =
gnc_ui_new_accounts_from_name_window_with_types("New OFX account", NULL);
- printf("WRITEME: gnc_ui_generic_account_picker_new_cb() Here we should
check if account type is compatible, currency matches, etc.\n");
+
+ if(picker->new_account_default_type!=NO_TYPE)
+ {
+ valid_types = g_list_prepend( valid_types,
&(picker->new_account_default_type));
+ }
+ picker->selected_acct = gnc_ui_new_accounts_from_name_with_defaults (
picker->account_human_description,
+ valid_types,
+ picker->new_account_default_commodity,
+ picker->selected_acct);
build_acct_tree(picker);
}
static void
gnc_ui_generic_account_picker_select_cb(GtkCTree * tree,
- GtkCTreeNode * node,
- gint column,
- gpointer user_data) {
+ GtkCTreeNode * node,
+ gint column,
+ gpointer user_data) {
struct _accountpickerdialog * picker = user_data;
//printf("gnc_ui_generic_account_picker_select_cb()\n");
gtk_ctree_node_get_row_data(tree, node);
@@ -188,18 +200,28 @@
}
}
-Account * gnc_import_select_account(char * account_online_id_value)
+Account * gnc_import_select_account(char * account_online_id_value,
+ char * account_human_description,
+ gnc_commodity * new_account_default_commodity,
+ GNCAccountType new_account_default_type)
{
struct _accountpickerdialog * picker = g_new0(struct _accountpickerdialog,
1);
+ const int ACCOUNT_DESCRIPTION_MAX_SIZE = 255;
gint ui_retval;
Account * retval = NULL;
GladeXML *xml;
GtkWidget * online_id_label;
+ gchar account_description_text[ACCOUNT_DESCRIPTION_MAX_SIZE];
+
picker->acct_group = gnc_get_current_group();
if(picker->acct_group == NULL)
{
printf("WARNING:gnc_import_select_account(): The account group is
NULL\n");
}
+ 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;
+
//printf("gnc_import_select_account(): Looking for account with online_id:
%s%s", account_online_id_value ,"\n");
retval = xaccGroupForEachAccount(picker->acct_group,
test_acct_online_id_match,
@@ -225,8 +247,17 @@
online_id_label = glade_xml_get_widget (xml, "online_id_label");
//printf("gnc_import_select_account(): Fin get widget\n");
- gtk_label_set_text((GtkLabel*)online_id_label,
account_online_id_value);
+ if(account_human_description!=NULL)
+ {
+ strncat(account_description_text, account_human_description,
ACCOUNT_DESCRIPTION_MAX_SIZE-strlen(account_description_text));
+ strncat(account_description_text, "\n",
ACCOUNT_DESCRIPTION_MAX_SIZE-strlen(account_description_text));
+ }
+ strncat(account_description_text, "(Account ID: ",
ACCOUNT_DESCRIPTION_MAX_SIZE-strlen(account_description_text));
+ 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));
+
+ gtk_label_set_text((GtkLabel*)online_id_label,
account_description_text);
build_acct_tree(picker);
ui_retval = gnome_dialog_run_and_close(GNOME_DIALOG(picker->dialog));
@@ -238,7 +269,8 @@
else {
retval=NULL;
}
- }
+ }
+ printf("WRITEME: gnc_import_select_account() Here we should check if
account type is compatible, currency matches, etc.\n");
g_free(picker);
// printf("gnc_import_select_account(): Return value: %p%s%s%s",retval,",
account name:",xaccAccountGetName(retval),"\n");
return retval;
Index: import-export/gnc-generic-import.h
===================================================================
RCS file: /home/cvs/cvsroot/gnucash/src/import-export/gnc-generic-import.h,v
retrieving revision 1.1
diff -u -r1.1 gnc-generic-import.h
--- import-export/gnc-generic-import.h 21 Jun 2002 00:46:23 -0000 1.1
+++ import-export/gnc-generic-import.h 31 Jul 2002 02:09:54 -0000
@@ -28,15 +28,19 @@
#include "Account.h"
-/* The gnc_import_select_account() method should be called with a string
- containing a unique identifier for the account. If an account with a
- matching online_id kvp_frame is found, the function immediately returns
- with a pointer to that account. Otherwise, the user is prompted to
- select a GnuCash account or create a new one.
- In both cases, the unique identifier is written to the account's
- kvp_frame, so the user won't be prompted again.
+/* The gnc_import_select_account():
+Must be called with a string containing a unique identifier for the account.
If an account with a matching online_id kvp_frame is found, the function
immediately returns with a pointer to that account. Otherwise, the user is
prompted to select a GnuCash account or create a new one (in both cases, the
unique identifier is written to the account's kvp_frame, so the user won't be
prompted again. If the user refuses to select or create an account
+ Params:
+ account_online_id_value: MANDATORY: The string containing your account_id
+ gchar * account_human_description: OPTIONNAL: A human-readable description
of the account. If not NULL, it will be shown before the id in the account
matching dialog. It will also be used as the default account name if a new
account is created.
+ gnc_commodity * new_account_default_currenc: OPTIONNAL: If not NULL, it
will be the account's commodity if a new account is created. If not NULL,
the function will also warn the user if the found or created account's
commodity doesn't match.
+ GNCAccountType new_account_default_type: OPTIONNAL: If not NO_TYPE, it
will be the account's type if a new account is created. If not NO_TYPE, the
function will also warn the user if the found or created account's commodity
doesn't match.
+ Return: A pointer to the found or created Account, or NULL if no account
was found or created.
*/
-Account * gnc_import_select_account(char * account_online_id_value);
+Account * gnc_import_select_account(char * account_online_id_value,
+ char * account_human_description,
+ gnc_commodity * new_account_default_commodity,
+ GNCAccountType new_account_default_type);
/* Your import module should create a new transaction in the current book,
add as many splits as it knows about, and associate each split with an
Index: import-export/ofx/gnc-ofx-import.c
===================================================================
RCS file: /home/cvs/cvsroot/gnucash/src/import-export/ofx/gnc-ofx-import.c,v
retrieving revision 1.3
diff -u -r1.3 gnc-ofx-import.c
--- import-export/ofx/gnc-ofx-import.c 24 Jun 2002 17:49:38 -0000 1.3
+++ import-export/ofx/gnc-ofx-import.c 31 Jul 2002 02:09:55 -0000
@@ -108,7 +108,7 @@
gnc_numeric gnc_amount;
if(data.account_id_valid==true){
- account = gnc_import_select_account(data.account_id);
+ account = gnc_import_select_account(data.account_id, NULL, NULL,
NO_TYPE);
if(account!=NULL)
{
book = xaccAccountGetBook(account);
@@ -193,7 +193,6 @@
notes=g_strdup_printf("%s%s%s",tmp,"|Trans type:", dest_string);
g_free(tmp);
}
- printf("Label ok\n");
if(data.memo_valid==true){
tmp=notes;
notes=g_strdup_printf("%s%s%s",tmp, "|Memo:", data.memo);
@@ -221,10 +220,12 @@
notes=g_strdup_printf("%s%s%s",tmp,"|Payee ID:", data.payee_id);
g_free(tmp);
}
- /*Add PAYEE and ADRESS here once supported by libofx*/
+
+ printf("WRITEME: Gnucash ofx_proc_transaction():Add PAYEE and ADRESS here
once supported by libofx!\n");
+
/* Ideally, gnucash should process the corrected transactions */
if(data.fi_id_corrected_valid==true){
- printf("WRITEME: Gnucash ofx_proc_transaction(): This transaction
corrected a previous transaction, but we created a new one instead!\n");
+ printf("WRITEME: Gnucash ofx_proc_transaction(): WARNING: This transaction
corrected a previous transaction, but we created a new one instead!\n");
tmp=notes;
notes=g_strdup_printf("%s%s%s%s",tmp,"|This corrects transaction
#",data.fi_id_corrected,"but Gnucash didn't process the correction!");
g_free(tmp);
@@ -267,7 +268,8 @@
if(data.account_id_valid==true){
//printf("ofx_proc_account() Now calling gnc_import_select_account()\n");
- selected_account = gnc_import_select_account(data.account_id);
+ printf("WRITEME: ofx_proc_account() Fill in the account type, default
name, currency, etc. \n");
+ selected_account = gnc_import_select_account(data.account_id, NULL, NULL,
NO_TYPE);
}
else
{
--
This message has been 'sanitized'. This means that potentially
dangerous content has been rewritten or removed. The following
log describes which actions were taken.
Sanitizer (start="1028082080"):
SanitizeFile (filename="unnamed.txt", mimetype="text/plain"):
Match (rule="2"):
Enforced policy: accept
Note: Forms invoke complex, interactive elements of the operating
system which may be buggy. In addition, carefully crafted
forms can be used to trick the user into performing attacks
on his own network (thus avoiding firewalls). References:
- http://www.securityfocus.com/bid/606
- http://www.remote.org/jochen/sec/hfpa/
Rewrote HTML tag: >>_label_<<
as: >>_DEFANGED_label_<<
Rewrote HTML tag: >>_/label_<<
as: >>_/DEFANGED_label_<<
Rewrote HTML tag: >>_label_<<
as: >>_DEFANGED_label_<<
Rewrote HTML tag: >>_/label_<<
as: >>_/DEFANGED_label_<<
Rewrote HTML tag: >>_label_<<
as: >>_DEFANGED_label_<<
Rewrote HTML tag: >>_/label_<<
as: >>_/DEFANGED_label_<<
Rewrote HTML tag: >>_label_<<
as: >>_DEFANGED_label_<<
Rewrote HTML tag: >>_/label_<<
as: >>_/DEFANGED_label_<<
Total modifications so far: 8
Anomy 0.0.0 : Sanitizer.pm
$Id: Sanitizer.pm,v 1.54 2002/02/15 16:59:07 bre Exp $