mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
Remove obsolete file split in Account.c Transaction.c and Utilities.c
git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@7235 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
parent
bb4929da9f
commit
7498b09c29
@ -1,618 +0,0 @@
|
||||
/********************************************************************\
|
||||
* generic-import.c -- Functions and utilities to help writing *
|
||||
* import modules. See file generic-import-design.txt for *
|
||||
* description *
|
||||
* (GnuCash) *
|
||||
* Copyright (C) 2002 Benoit Grégoire <bock@step.polymtl.ca> *
|
||||
* *
|
||||
* This program is free software; you can redistribute it and/or *
|
||||
* modify it under the terms of the GNU General Public License as *
|
||||
* published by the Free Software Foundation; either version 2 of *
|
||||
* the License, or (at your option) any later version. *
|
||||
* *
|
||||
* This program is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU General Public License*
|
||||
* along with this program; if not, contact: *
|
||||
* *
|
||||
* Free Software Foundation Voice: +1-617-542-5942 *
|
||||
* 59 Temple Place - Suite 330 Fax: +1-617-542-2652 *
|
||||
* Boston, MA 02111-1307, USA gnu@gnu.org *
|
||||
\********************************************************************/
|
||||
|
||||
#define _GNU_SOURCE
|
||||
|
||||
#include "config.h"
|
||||
|
||||
|
||||
#include <glib.h>
|
||||
#include <gmodule.h>
|
||||
//#include <gtk/gtk.h>
|
||||
#include <glade/glade.h>
|
||||
|
||||
#include <stdlib.h>
|
||||
#include "gnc-generic-import.h"
|
||||
#include "Account.h"
|
||||
#include "Transaction.h"
|
||||
#include "dialog-commodity.h"
|
||||
#include "dialog-utils.h"
|
||||
#include "AccWindow.h"
|
||||
//#include "druid-utils.h"
|
||||
//#include "global-options.h"
|
||||
//#include "gnc-component-manager.h"
|
||||
#include "gnc-engine-util.h"
|
||||
//#include "gnc-file-dialog.h"
|
||||
//#include "gnc-gui-query.h"
|
||||
#include "gnc-ui-util.h"
|
||||
//#include "gnc-ui.h"
|
||||
//#include "messages.h"
|
||||
//#include "window-help.h"
|
||||
|
||||
//#include <g-wrap-wct.h>
|
||||
|
||||
static short module = MOD_IMPORT;
|
||||
|
||||
struct _accountpickerdialog {
|
||||
GtkWidget * dialog;
|
||||
GtkWidget * treeview;
|
||||
AccountGroup * acct_group;
|
||||
Account * selected_acct;
|
||||
gchar * account_human_description;
|
||||
gnc_commodity * new_account_default_commodity;
|
||||
GNCAccountType new_account_default_type;
|
||||
|
||||
};
|
||||
|
||||
struct _transmatcherdialog {
|
||||
GtkWidget * transaction_matcher;
|
||||
GtkWidget * downloaded_clist;
|
||||
GtkWidget * duplicates_clist;
|
||||
GList * transaction_list;
|
||||
|
||||
/* AccountGroup * acct_group;
|
||||
Account * selected_acct;
|
||||
gchar * account_human_description;
|
||||
gnc_commodity * new_account_default_commodity;
|
||||
GNCAccountType new_account_default_type;
|
||||
*/
|
||||
|
||||
};
|
||||
|
||||
struct _transactioninfo
|
||||
{
|
||||
Transaction * trans;
|
||||
char accepted_text[2];
|
||||
char date_text[20];
|
||||
char amount_text[20];
|
||||
char * clist_text[4];
|
||||
GList * match_list;
|
||||
|
||||
|
||||
};
|
||||
struct _matchinfo
|
||||
{
|
||||
Transaction * trans;
|
||||
GNC_match_probability probability;
|
||||
char probability_text[10];
|
||||
char date_text[20];
|
||||
char amount_text[20];
|
||||
char * clist_text[6];
|
||||
|
||||
|
||||
};
|
||||
/* static gint
|
||||
test_str_cmp(gconstpointer a, gconstpointer b) {
|
||||
return strcmp(a, b);
|
||||
}*/
|
||||
/********************************************************************\
|
||||
* Functions needed by gnc_import_select_account
|
||||
*
|
||||
\********************************************************************/
|
||||
|
||||
static void acct_tree_add_accts(AccountGroup * accts, GtkCTree * tree, GtkCTreeNode * parent)
|
||||
{
|
||||
GtkCTreeNode * node;
|
||||
Account *current_acct;
|
||||
guint i;
|
||||
gchar * acctinfo[3];
|
||||
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]=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,
|
||||
NULL,
|
||||
acctinfo,
|
||||
2,
|
||||
NULL,NULL,NULL,NULL,
|
||||
FALSE,//isleaf
|
||||
FALSE);
|
||||
gtk_ctree_node_set_row_data (tree,
|
||||
node,
|
||||
current_acct);
|
||||
acct_tree_add_accts(xaccAccountGetChildren(current_acct), tree, node);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
build_acct_tree(struct _accountpickerdialog * picker) {
|
||||
GtkCTreeNode * new_sel;
|
||||
TRACE("Begin");
|
||||
|
||||
if(picker->acct_group==NULL)
|
||||
{
|
||||
PERR("acct_group is NULL");
|
||||
}
|
||||
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);
|
||||
|
||||
if(picker->selected_acct!=NULL) {
|
||||
new_sel = gtk_ctree_find_by_row_data(GTK_CTREE(picker->treeview),
|
||||
NULL,
|
||||
picker->selected_acct);
|
||||
|
||||
gtk_ctree_select(GTK_CTREE(picker->treeview), new_sel);
|
||||
gtk_ctree_node_moveto(GTK_CTREE(picker->treeview), new_sel, 0,
|
||||
0.5, 0.0);
|
||||
}
|
||||
gtk_clist_columns_autosize (GTK_CLIST (picker->treeview));
|
||||
gtk_clist_column_titles_passive (GTK_CLIST (picker->treeview));
|
||||
}
|
||||
|
||||
/*static void
|
||||
new_child_string_cb(char * string, gpointer data) {
|
||||
printf("new_child_string_cb(char * string, gpointer data)\n");
|
||||
if(string) {
|
||||
strncpy(data, string, 250);
|
||||
}
|
||||
else {
|
||||
*(char *)data = 0;
|
||||
}
|
||||
}*/
|
||||
|
||||
/* When user clicks to create a new account */
|
||||
static void
|
||||
gnc_ui_generic_account_picker_new_cb(GtkButton * w, gpointer user_data) {
|
||||
struct _accountpickerdialog * picker = user_data;
|
||||
GList * valid_types = NULL;
|
||||
|
||||
TRACE("Begin");
|
||||
|
||||
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) {
|
||||
struct _accountpickerdialog * picker = user_data;
|
||||
TRACE("Begin");
|
||||
gtk_ctree_node_get_row_data(tree, node);
|
||||
picker->selected_acct = gtk_ctree_node_get_row_data(tree, node);
|
||||
}
|
||||
|
||||
/*Will be called when unselection an account, or when the user clicks cancel*/
|
||||
static void
|
||||
gnc_ui_generic_account_picker_unselect_cb(GtkCTree * tree,
|
||||
GtkCTreeNode * node,
|
||||
gint column,
|
||||
gpointer user_data) {
|
||||
struct _accountpickerdialog * picker = user_data;
|
||||
TRACE("Begin");
|
||||
picker->selected_acct = NULL;
|
||||
}
|
||||
|
||||
#if 0
|
||||
static int
|
||||
gnc_ui_generic_account_picker_map_cb(GtkWidget * w, gpointer user_data) {
|
||||
printf("gnc_ui_generic_account_picker_map_cb()\n");
|
||||
/* update the tree display */
|
||||
build_acct_tree(user_data);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/* 0 -- With the printf here, as below, this causes a
|
||||
* compilation problem with GCC 3.1:
|
||||
*
|
||||
* gnc-generic-import.c:414: output_operand: invalid expression as operand
|
||||
* Please submit a full bug report,
|
||||
* with preprocessed source if appropriate.
|
||||
* See <URL:http://bugzilla.redhat.com/bugzilla/> for instructions.
|
||||
* make[1]: *** [gnc-generic-import.lo] Error 1
|
||||
*/
|
||||
static int
|
||||
gnc_ui_generic_account_picker_map_cb(GtkWidget * w, gpointer user_data) {
|
||||
printf("gnc_ui_generic_account_picker_map_cb()\n");
|
||||
/* update the tree display */
|
||||
build_acct_tree(user_data);
|
||||
return FALSE;
|
||||
}
|
||||
#endif /* 0 */
|
||||
|
||||
static gpointer test_acct_online_id_match(Account *acct, gpointer param_online_id)
|
||||
{
|
||||
gchar * current_online_id = gnc_import_get_acc_online_id(acct);
|
||||
if( (current_online_id != NULL
|
||||
&& param_online_id != NULL )
|
||||
&& strcmp( current_online_id, param_online_id ) == 0 )
|
||||
{
|
||||
return (gpointer *) acct;
|
||||
}
|
||||
else
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
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;
|
||||
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 = g_new0(struct _accountpickerdialog, 1);
|
||||
picker->acct_group = gnc_get_current_group();
|
||||
if(picker->acct_group == NULL)
|
||||
{
|
||||
PWARN("The account group is NULL");
|
||||
}
|
||||
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;
|
||||
|
||||
DEBUG("Looking for account with online_id: %s", account_online_id_value);
|
||||
retval = xaccGroupForEachAccount(picker->acct_group,
|
||||
test_acct_online_id_match,
|
||||
account_online_id_value,
|
||||
TRUE);
|
||||
if(retval==NULL)
|
||||
{
|
||||
/* load the interface */
|
||||
xml = gnc_glade_xml_new ("generic-import.glade", "Generic Import Account Picker");
|
||||
/* connect the signals in the interface */
|
||||
if(xml==NULL)
|
||||
{
|
||||
PERR("Error opening the glade interface");
|
||||
}
|
||||
|
||||
glade_xml_signal_connect_data(xml, "gnc_ui_generic_account_picker_new_cb", GTK_SIGNAL_FUNC (gnc_ui_generic_account_picker_new_cb), picker);
|
||||
glade_xml_signal_connect_data(xml, "gnc_ui_generic_account_picker_select_cb", GTK_SIGNAL_FUNC(gnc_ui_generic_account_picker_select_cb), picker);
|
||||
glade_xml_signal_connect_data(xml, "gnc_ui_generic_account_picker_unselect_cb", GTK_SIGNAL_FUNC(gnc_ui_generic_account_picker_unselect_cb), picker);
|
||||
/* glade_xml_signal_connect_data(xml, "gnc_ui_generic_account_picker_map_cb", GTK_SIGNAL_FUNC(gnc_ui_generic_account_picker_map_cb), picker);*/
|
||||
|
||||
picker->dialog = glade_xml_get_widget (xml, "Generic Import Account Picker");
|
||||
picker->treeview = glade_xml_get_widget (xml, "account_tree");
|
||||
online_id_label = glade_xml_get_widget (xml, "online_id_label");
|
||||
|
||||
//printf("gnc_import_select_account(): Fin get widget\n");
|
||||
|
||||
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));
|
||||
|
||||
if(ui_retval == 0) {
|
||||
gnc_import_set_acc_online_id(picker->selected_acct, account_online_id_value);
|
||||
retval=picker->selected_acct;
|
||||
}
|
||||
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);
|
||||
DEBUG("Return value: %p%s%s%s",retval,", account name:",xaccAccountGetName(retval),"\n");
|
||||
return retval;
|
||||
}
|
||||
|
||||
/********************************************************************\
|
||||
* Setter and getter functions for the online_id kvp frame in
|
||||
* Account and Transaction
|
||||
\********************************************************************/
|
||||
|
||||
gchar * gnc_import_get_acc_online_id(Account * account)
|
||||
{
|
||||
gchar * string = NULL;
|
||||
kvp_frame * frame;
|
||||
kvp_value * value;
|
||||
frame = xaccAccountGetSlots(account);
|
||||
value = kvp_frame_get_slot(frame, "online_id");
|
||||
string = kvp_value_get_string(value);
|
||||
return string;
|
||||
}
|
||||
|
||||
void gnc_import_set_acc_online_id(Account * account, gchar * string_value)
|
||||
{
|
||||
kvp_frame * frame;
|
||||
kvp_value * value;
|
||||
frame = xaccAccountGetSlots(account);
|
||||
if(frame==NULL)
|
||||
{
|
||||
DEBUG("The kvp_frame was NULL, allocating new one\n");
|
||||
frame = kvp_frame_new();
|
||||
}
|
||||
value = kvp_frame_get_slot(frame, "online_id");
|
||||
//kvp_value_delete(value);
|
||||
value = kvp_value_new_string(string_value);
|
||||
kvp_frame_set_slot(frame,"online_id",value);
|
||||
xaccAccountSetSlots_nc(account,frame);
|
||||
return;
|
||||
}
|
||||
|
||||
gchar * gnc_import_get_trans_online_id(Transaction * transaction)
|
||||
{
|
||||
gchar * string = NULL;
|
||||
kvp_frame * frame;
|
||||
kvp_value * value;
|
||||
frame = xaccTransGetSlots(transaction);
|
||||
value = kvp_frame_get_slot(frame, "online_id");
|
||||
string = kvp_value_get_string(value);
|
||||
return string;
|
||||
}
|
||||
|
||||
void gnc_import_set_trans_online_id(Transaction * transaction, gchar * string_value)
|
||||
{
|
||||
kvp_frame * frame;
|
||||
kvp_value * value;
|
||||
TRACE("Begin");
|
||||
frame = xaccTransGetSlots(transaction);
|
||||
if(frame==NULL)
|
||||
{
|
||||
DEBUG("The kvp_frame was NULL, allocating new one");
|
||||
frame = kvp_frame_new();
|
||||
}
|
||||
value = kvp_frame_get_slot(frame, "online_id");
|
||||
if(value != NULL)
|
||||
{
|
||||
kvp_value_delete(value);
|
||||
}
|
||||
value = kvp_value_new_string(string_value);
|
||||
kvp_frame_set_slot(frame,"online_id",value);
|
||||
xaccTransSetSlots_nc(transaction,frame);
|
||||
return;
|
||||
}
|
||||
|
||||
/********************************************************************\
|
||||
* Functions used by gnc_import_add_trans(Transaction *trans)
|
||||
\********************************************************************/
|
||||
|
||||
/********************************************************************\
|
||||
* check_trans_online_id() Weird function, to be used by
|
||||
* xaccAccountForEachTransaction. Takes pointers to two transaction
|
||||
* and returns TRUE if their online_id kvp_frame do NOT match or
|
||||
* if both pointers point to the same transaction
|
||||
\********************************************************************/
|
||||
static gboolean check_trans_online_id(Transaction *trans1, void *trans2)
|
||||
{
|
||||
gchar * online_id1 = gnc_import_get_trans_online_id(trans1);
|
||||
gchar * online_id2 = gnc_import_get_trans_online_id((Transaction *)trans2);
|
||||
|
||||
if(trans1==(Transaction *)trans2||strcmp(online_id1, online_id2)!=0)
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
else
|
||||
{
|
||||
//printf("test_trans_online_id(): Duplicate found\n");
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
#if 0
|
||||
void gnc_import_add_trans(Transaction *trans)
|
||||
{
|
||||
gint i;
|
||||
Split * source_split;
|
||||
Account * dest_acct;
|
||||
gboolean trans_not_found=TRUE;
|
||||
|
||||
/*For each split in the transaction, check if the parent account contains a transaction with the same online id */
|
||||
for(i=0;(source_split=xaccTransGetSplit(trans,i))!=NULL&&(trans_not_found==TRUE);i++)
|
||||
{
|
||||
printf("gnc_import_add_trans():Checking split %d%s",i," for duplicates\n");
|
||||
dest_acct=xaccSplitGetAccount(source_split);
|
||||
trans_not_found = xaccAccountForEachTransaction(dest_acct,
|
||||
check_trans_online_id,
|
||||
trans);
|
||||
}
|
||||
if(trans_not_found==FALSE)
|
||||
{
|
||||
printf("gnc_import_add_trans(): Transaction with same online ID exists, destroying current transaction\n");
|
||||
xaccTransBeginEdit(trans);
|
||||
xaccTransDestroy(trans);
|
||||
xaccTransCommitEdit(trans);
|
||||
}
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
static void init_matcher_gui(struct _transmatcherdialog * matcher)
|
||||
{
|
||||
GladeXML *xml;
|
||||
|
||||
DEBUG("Begin...");
|
||||
matcher->transaction_list = NULL;
|
||||
/* load the interface */
|
||||
xml = gnc_glade_xml_new ("generic-import.glade", "transaction_matcher");
|
||||
/* connect the signals in the interface */
|
||||
if(xml==NULL)
|
||||
{
|
||||
PERR("Error opening the glade interface\n");
|
||||
}
|
||||
|
||||
/*
|
||||
glade_xml_signal_connect_data(xml, "gnc_ui_generic_account_picker_select_cb", GTK_SIGNAL_FUNC(gnc_ui_generic_account_picker_select_cb), picker);
|
||||
glade_xml_signal_connect_data(xml, "gnc_ui_generic_account_picker_unselect_cb", GTK_SIGNAL_FUNC(gnc_ui_generic_account_picker_unselect_cb), picker);
|
||||
glade_xml_signal_connect_data(xml, "gnc_ui_generic_account_picker_map_cb", GTK_SIGNAL_FUNC(gnc_ui_generic_account_picker_map_cb), picker);
|
||||
*/
|
||||
matcher->transaction_matcher = glade_xml_get_widget (xml, "transaction_matcher");
|
||||
matcher->downloaded_clist = glade_xml_get_widget (xml, "downloaded_clist");
|
||||
matcher->duplicates_clist = glade_xml_get_widget (xml, "duplicates_clist");
|
||||
|
||||
/* build_acct_tree(matcher);*/
|
||||
|
||||
/*ui_retval = gnome_dialog_run_and_close(GNOME_DIALOG(matcher->transaction_matcher));*/
|
||||
DEBUG("before gtk_widget_show(matcher->transaction_matcher); ");
|
||||
gtk_widget_show(matcher->transaction_matcher);
|
||||
|
||||
/*
|
||||
if(ui_retval == 0) {
|
||||
gnc_import_set_acc_online_id(picker->selected_acct, account_online_id_value);
|
||||
retval=picker->selected_acct;
|
||||
}
|
||||
else {
|
||||
retval=NULL;
|
||||
}
|
||||
*/
|
||||
|
||||
}/* end init_matcher_gui */
|
||||
|
||||
static void update_matcher_gui(struct _transmatcherdialog * matcher)
|
||||
{
|
||||
GList * list_element;
|
||||
DEBUG("%s", "Begin...");
|
||||
gtk_clist_clear((GtkCList*)matcher->downloaded_clist);
|
||||
list_element = g_list_first(matcher->transaction_list);
|
||||
while(list_element!=NULL)
|
||||
{
|
||||
gtk_clist_append((GtkCList *)matcher->downloaded_clist, ((struct _transactioninfo *)list_element->data)->clist_text);
|
||||
|
||||
list_element=g_list_next(list_element);
|
||||
}
|
||||
DEBUG("%s", "End");
|
||||
}/* end update_matcher_gui */
|
||||
|
||||
static gpointer * split_find_match(Split * split, struct _transactioninfo * transaction_info)
|
||||
{
|
||||
struct _matchinfo * match_info;
|
||||
time_t split_date;
|
||||
DEBUG("Begin");
|
||||
//DEBUG("%s",xaccSplitGetMemo(split));
|
||||
|
||||
match_info->clist_text[0]=match_info->probability_text;/*Probability*/
|
||||
split_date = xaccTransGetDate(xaccSplitGetParent(split));
|
||||
strftime(match_info->date_text,
|
||||
sizeof(match_info->date_text)-1,
|
||||
"%c",
|
||||
localtime(&split_date)
|
||||
);
|
||||
match_info->clist_text[1]=match_info->date_text; /*Date*/
|
||||
strncpy(match_info->amount_text,
|
||||
gnc_numeric_to_string(xaccSplitGetAmount(split)),
|
||||
sizeof(match_info->amount_text)-1
|
||||
);
|
||||
match_info->clist_text[2]=match_info->amount_text;/*Amount*/
|
||||
match_info->clist_text[3]=xaccSplitGetMemo(split);/*Description*/
|
||||
|
||||
match_info = g_new0(struct _matchinfo,1);
|
||||
|
||||
return (gpointer *)split;
|
||||
}/* end split_find_match */
|
||||
|
||||
/* New version with GUI */
|
||||
void gnc_import_add_trans(Transaction *trans)
|
||||
{
|
||||
static struct _transmatcherdialog * matcher;
|
||||
gint i;
|
||||
Split * source_split;
|
||||
Account * dest_acct;
|
||||
gboolean trans_not_found=TRUE;
|
||||
time_t trans_date;
|
||||
struct _transactioninfo * transaction_info;
|
||||
GList * list_element;
|
||||
|
||||
gnc_should_log(MOD_IMPORT, GNC_LOG_TRACE);
|
||||
|
||||
DEBUG("%s", "Begin...");
|
||||
|
||||
if(matcher == NULL)
|
||||
{
|
||||
DEBUG("Gui not yet opened");
|
||||
matcher = g_new0(struct _transmatcherdialog, 1);
|
||||
init_matcher_gui(matcher);
|
||||
DEBUG("Gui init done");
|
||||
}
|
||||
|
||||
transaction_info=g_new0(struct _transactioninfo,1);
|
||||
|
||||
source_split=xaccTransGetSplit(trans,0);/*Only use first split, the source split*/
|
||||
transaction_info->trans=trans;
|
||||
transaction_info->clist_text[0]=transaction_info->accepted_text;/*Accepted*/
|
||||
transaction_info->clist_text[1]=xaccAccountGetName(xaccSplitGetAccount(source_split)); /*Account*/
|
||||
trans_date = xaccTransGetDate(trans);
|
||||
strftime(transaction_info->date_text,
|
||||
sizeof(transaction_info->date_text)-1,
|
||||
"%c",
|
||||
localtime(&trans_date)
|
||||
);
|
||||
transaction_info->clist_text[2]=transaction_info->date_text; /*Date*/
|
||||
strncpy(transaction_info->amount_text,
|
||||
gnc_numeric_to_string(xaccSplitGetAmount(source_split)),
|
||||
sizeof(transaction_info->amount_text)-1
|
||||
);
|
||||
transaction_info->clist_text[3]=transaction_info->amount_text;/*Amount*/
|
||||
transaction_info->clist_text[4]=xaccSplitGetMemo(source_split);/*Description*/
|
||||
|
||||
|
||||
|
||||
g_list_foreach( xaccAccountGetSplitList(xaccSplitGetAccount(source_split)),
|
||||
split_find_match,
|
||||
(gpointer)transaction_info);
|
||||
|
||||
matcher->transaction_list = g_list_append(matcher->transaction_list,
|
||||
transaction_info);
|
||||
update_matcher_gui(matcher);
|
||||
|
||||
#if 0
|
||||
/*For each split in the transaction, check if the parent account contains a transaction with the same online id */
|
||||
for(i=0;(source_split=xaccTransGetSplit(trans,i))!=NULL&&(trans_not_found==TRUE);i++)
|
||||
{
|
||||
TRACE("%s%d%s","Checking split %d%s",i," for duplicates");
|
||||
dest_acct=xaccSplitGetAccount(source_split);
|
||||
trans_not_found = xaccAccountForEachTransaction(dest_acct,
|
||||
check_trans_online_id,
|
||||
trans);
|
||||
}
|
||||
if(trans_not_found==FALSE)
|
||||
{
|
||||
DEBUG("%s","Transaction with same online ID exists, destroying current transaction");
|
||||
xaccTransBeginEdit(trans);
|
||||
xaccTransDestroy(trans);
|
||||
xaccTransCommitEdit(trans);
|
||||
}
|
||||
#endif /* 0 */
|
||||
return;
|
||||
}
|
Loading…
Reference in New Issue
Block a user