r16265 - gnucash/branches/csv-import/src/import-export/csv - Fixed the compile errors from the previous commit.

Benjamin Sperisen lasindi at cvs.gnucash.org
Sun Jul 8 05:48:11 EDT 2007


Author: lasindi
Date: 2007-07-08 05:48:11 -0400 (Sun, 08 Jul 2007)
New Revision: 16265
Trac: http://svn.gnucash.org/trac/changeset/16265

Modified:
   gnucash/branches/csv-import/src/import-export/csv/gnc-csv-model.c
Log:
Fixed the compile errors from the previous commit.


Modified: gnucash/branches/csv-import/src/import-export/csv/gnc-csv-model.c
===================================================================
--- gnucash/branches/csv-import/src/import-export/csv/gnc-csv-model.c	2007-07-08 09:45:04 UTC (rev 16264)
+++ gnucash/branches/csv-import/src/import-export/csv/gnc-csv-model.c	2007-07-08 09:48:11 UTC (rev 16265)
@@ -342,26 +342,28 @@
 
 /** A struct encaspulating a property of a transaction. */
 /* TODO Comment */
-static typedef struct
+typedef struct
 {
   gboolean essential;
   int type;
   void* value;
+  int date_format;
 } TransProperty;
 
-static TransProperty* trans_property_new(int type)
+static TransProperty* trans_property_new(int type, int date_format)
 {
   TransProperty* prop = g_malloc(sizeof(TransProperty));
   prop->type = type;
+  prop->date_format = date_format;
   switch(type)
   {
   case GNC_CSV_DATE:
   case GNC_CSV_AMOUNT:
-    essential = TRUE
+    prop->essential = TRUE;
     break;
 
   default:
-    essential = FALSE;
+    prop->essential = FALSE;
   }
   return prop;
 }
@@ -372,7 +374,7 @@
   {
   case GNC_CSV_DATE:
   case GNC_CSV_AMOUNT:
-    g_free(value);
+    g_free(prop->value);
     break;
   }
   g_free(prop);
@@ -391,29 +393,33 @@
   {
   case GNC_CSV_DATE:
     prop->value = g_malloc(sizeof(time_t));
-    *(prop->value) = parse_date(str);
-    return prop->value != -1;
+    *((time_t*)(prop->value)) = parse_date(str, prop->date_format);
+    return *((time_t*)(prop->value)) != -1;
 
   case GNC_CSV_DESCRIPTION:
-    *prop->value = g_strdup(str);
+    prop->value = g_strdup(str);
     return TRUE;
 
   case GNC_CSV_AMOUNT:
     prop->value = g_malloc(sizeof(gnc_numeric));
-    *(prop->value) = double_to_gnc_numeric(atof(str), 1,
+    *((gnc_numeric*)(prop->value)) = double_to_gnc_numeric(atof(str), 1,
                                            GNC_RND_ROUND);
     /* TODO error handling */
     return TRUE;
   }
+  return FALSE; /* We should never actually get here. */
 }
 
 /** Creates a transaction from a list of "TransProperty"s.
  */
-static Transaction trans_from_trans_properties(GList* properties, GNCBook* book)
+static Transaction* trans_from_trans_properties(GList* properties, Account* account)
 {
   Transaction* trans;
   Split* split;
   GList* properties_begin = properties;
+  GNCBook* book = gnc_account_get_book(account);
+  gnc_commodity* currency = xaccAccountGetCommodity(account);
+  gnc_numeric amount;
   
   unsigned int essential_properties_left = 2;
   while(properties != NULL)
@@ -438,16 +444,15 @@
     switch(prop->type)
     {
     case GNC_CSV_DATE:
-      xaccTransSetDatePostedSecs(trans, date);
+      xaccTransSetDatePostedSecs(trans, *((time_t*)(prop->value)));
       break;
 
     case GNC_CSV_DESCRIPTION:
-      xaccTransSetDescription(trans, description);
+      xaccTransSetDescription(trans, (char*)(prop->value));
       break;
-      
+
     case GNC_CSV_AMOUNT:
-      gnc_numeric amount = double_to_gnc_numeric(atof(line->pdata[j]), 1,
-                                                 GNC_RND_ROUND);
+      amount = *((gnc_numeric*)(prop->value));
       split = xaccMallocSplit(book);
       xaccSplitSetAccount(split, account);
       xaccSplitSetParent(split, trans);



More information about the gnucash-changes mailing list