[grisbi-cvs] grisbi/src csv_parse.c, 1.20, 1.21 csv_parse.h, 1.9, 1.10 import.c, 1.304, 1.305 import.h, 1.45, 1.46 import_csv.c, 1.56, 1.57
Gunee
guneemwelloeux at users.sourceforge.net
Mon Nov 23 16:15:50 CET 2009
Update of /cvsroot/grisbi/grisbi/src
In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv20224
Modified Files:
csv_parse.c csv_parse.h import.c import.h import_csv.c
Log Message:
Added budgetary imputations to CSV file import
Index: import.h
===================================================================
RCS file: /cvsroot/grisbi/grisbi/src/import.h,v
retrieving revision 1.45
retrieving revision 1.46
diff -u -d -r1.45 -r1.46
--- import.h 3 Nov 2009 17:32:07 -0000 1.45
+++ import.h 23 Nov 2009 15:15:48 -0000 1.46
@@ -76,6 +76,7 @@
gulong cheque;
gchar *categ;
+ gchar *budget;
gsb_real montant;
Index: import.c
===================================================================
RCS file: /cvsroot/grisbi/grisbi/src/import.c,v
retrieving revision 1.304
retrieving revision 1.305
diff -u -d -r1.304 -r1.305
--- import.c 14 Nov 2009 21:33:31 -0000 1.304
+++ import.c 23 Nov 2009 15:15:47 -0000 1.305
@@ -42,6 +42,7 @@
#include "./gsb_currency.h"
#include "./gsb_data_account.h"
#include "./gsb_data_category.h"
+#include "./gsb_data_budget.h"
#include "./gsb_data_currency.h"
#include "./gsb_data_form.h"
#include "./gsb_data_fyear.h"
@@ -147,6 +148,8 @@
static void pointe_opes_importees ( struct struct_compte_importation *imported_account,
gint account_number );
static void traitement_operations_importees ( void );
+static void gsb_import_lookup_budget ( struct struct_ope_importation *imported_transaction,
+ gint transaction_number);
/*END_STATIC*/
/*START_EXTERN*/
@@ -2371,6 +2374,14 @@
&&
strlen (imported_transaction -> categ))
{
+ // Fill budget if existing
+ if ( imported_transaction -> budget
+ &&
+ strlen (imported_transaction -> budget))
+ {
+ gsb_import_lookup_budget(imported_transaction, transaction_number);
+ }
+
if ( imported_transaction -> categ[0] == '[' )
{
/* it's a transfer,
@@ -2407,6 +2418,7 @@
gsb_data_category_get_sub_category_number_by_name ( category_number,
tab_str[1],
TRUE ));
+ g_strfreev(tab_str);
}
}
else if ( etat.get_categorie_for_payee &&
@@ -2443,6 +2455,15 @@
{
gsb_data_transaction_set_category_number ( transaction_number, 0 );
gsb_data_transaction_set_sub_category_number ( transaction_number, 0 );
+
+ // Fill budget if existing
+ if ( imported_transaction -> budget
+ &&
+ strlen (imported_transaction -> budget))
+ {
+ gsb_import_lookup_budget(imported_transaction, transaction_number);
+ }
+
}
}
@@ -4441,6 +4462,40 @@
return FALSE;
}
+
+/**
+ * Lookup the budget and create it if necessary
+ *
+ * \param budget_str nom du budget à rechercher
+ *
+ * \return void
+ * */
+void gsb_import_lookup_budget ( struct struct_ope_importation *imported_transaction, gint transaction_number)
+{
+ gint budget_number;
+ gchar ** tab_str;
+
+ tab_str = g_strsplit ( imported_transaction -> budget,
+ ":",
+ 2 );
+
+ /* get the budget and create it if doesn't exist */
+ if (tab_str[0])
+ tab_str[0] = g_strstrip (tab_str[0]);
+ budget_number = gsb_data_budget_get_number_by_name ( tab_str[0],
+ TRUE,
+ imported_transaction -> montant.mantissa < 0 );
+ gsb_data_transaction_set_budgetary_number ( transaction_number,
+ budget_number );
+ if (tab_str[1])
+ tab_str[1] = g_strstrip (tab_str[1]);
+ gsb_data_transaction_set_sub_budgetary_number ( transaction_number,
+ gsb_data_budget_get_sub_budget_number_by_name ( budget_number,
+ tab_str[1],
+ TRUE ));
+ g_strfreev(tab_str);
+}
+
/* Local Variables: */
/* c-basic-offset: 4 */
/* End: */
Index: csv_parse.h
===================================================================
RCS file: /cvsroot/grisbi/grisbi/src/csv_parse.h,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -d -r1.9 -r1.10
--- csv_parse.h 13 Oct 2008 12:41:59 -0000 1.9
+++ csv_parse.h 23 Nov 2009 15:15:47 -0000 1.10
@@ -8,6 +8,7 @@
/* START_DECLARATION */
gboolean csv_import_parse_balance ( struct struct_ope_importation * ope, gchar * string );
gboolean csv_import_parse_category ( struct struct_ope_importation * ope, gchar * string );
+gboolean csv_import_parse_budget ( struct struct_ope_importation * ope, gchar * string );
gboolean csv_import_parse_credit ( struct struct_ope_importation * ope, gchar * string );
gboolean csv_import_parse_currency ( struct struct_ope_importation * ope, gchar * string );
gboolean csv_import_parse_date ( struct struct_ope_importation * ope, gchar * string );
@@ -17,6 +18,7 @@
gboolean csv_import_parse_payee ( struct struct_ope_importation * ope, gchar * string );
gboolean csv_import_parse_split ( struct struct_ope_importation * ope, gchar * string );
gboolean csv_import_parse_sub_category ( struct struct_ope_importation * ope, gchar * string );
+gboolean csv_import_parse_sub_budget ( struct struct_ope_importation * ope, gchar * string );
gboolean csv_import_parse_value_date ( struct struct_ope_importation * ope, gchar * string );
gboolean csv_import_parse_voucher ( struct struct_ope_importation * ope, gchar * string );
gboolean csv_import_validate_amount ( gchar * string );
Index: csv_parse.c
===================================================================
RCS file: /cvsroot/grisbi/grisbi/src/csv_parse.c,v
retrieving revision 1.20
retrieving revision 1.21
diff -u -d -r1.20 -r1.21
--- csv_parse.c 10 Oct 2008 06:50:39 -0000 1.20
+++ csv_parse.c 23 Nov 2009 15:15:47 -0000 1.21
@@ -370,6 +370,21 @@
*
*
*/
+gboolean csv_import_parse_budget ( struct struct_ope_importation * ope, gchar * string )
+{
+ g_return_val_if_fail ( string, FALSE );
+ if ( ope -> budget )
+ g_free ( ope -> budget );
+ ope -> budget = my_strdup ( string );
+ return TRUE;
+}
+
+
+
+/**
+ *
+ *
+ */
gboolean csv_import_parse_sub_category ( struct struct_ope_importation * ope, gchar * string )
{
g_return_val_if_fail ( string, FALSE );
@@ -382,6 +397,21 @@
/**
+ *
+ *
+ */
+gboolean csv_import_parse_sub_budget ( struct struct_ope_importation * ope, gchar * string )
+{
+ g_return_val_if_fail ( string, FALSE );
+ if ( ! ope -> budget || ! strlen ( string ) )
+ return FALSE;
+ ope -> budget = g_strconcat ( ope -> budget, " : ", string, NULL );
+ return TRUE;
+}
+
+
+
+/**
* TODO: Use a real parsing
*
*/
Index: import_csv.c
===================================================================
RCS file: /cvsroot/grisbi/grisbi/src/import_csv.c,v
retrieving revision 1.56
retrieving revision 1.57
diff -u -d -r1.56 -r1.57
--- import_csv.c 3 Oct 2009 22:14:56 -0000 1.56
+++ import_csv.c 23 Nov 2009 15:15:48 -0000 1.57
@@ -72,7 +72,7 @@
static gint * csv_fields_config = NULL;
/** Contain configuration of CSV fields. */
-struct csv_field csv_fields[16] = {
+struct csv_field csv_fields[18] = {
{ N_("Unknown field"), 0.0, NULL, NULL , "" },
{ N_("Currency"), 0.0, csv_import_validate_string, csv_import_parse_currency, "" },
{ N_("Date"), 0.0, csv_import_validate_date, csv_import_parse_date, "" },
@@ -83,6 +83,8 @@
{ N_("Voucher number"), 0.0, csv_import_validate_number, csv_import_parse_voucher, "" },
{ N_("Category"), 0.0, csv_import_validate_string, csv_import_parse_category, "" },
{ N_("Sub-Category"), 0.0, csv_import_validate_string, csv_import_parse_sub_category, "" },
+ { N_("Imputation"), 0.0, csv_import_validate_string, csv_import_parse_budget, "" },
+ { N_("Sub-Imputation"), 0.0, csv_import_validate_string, csv_import_parse_sub_budget, "" },
{ N_("Balance"), 0.0, csv_import_validate_amount, csv_import_parse_balance, "" },
{ N_("Credit (amount)"),0.0, csv_import_validate_amount, csv_import_parse_credit, "" },
{ N_("Debit (absolute)"),0.0, csv_import_validate_amount, csv_import_parse_debit,
More information about the cvs
mailing list