gnucash master: Bug 754530 Add CSV Export Simple Layout

Geert Janssens gjanssens at code.gnucash.org
Thu Oct 8 16:30:37 EDT 2015


Updated	 via  https://github.com/Gnucash/gnucash/commit/e5c0ec88 (commit)
	from  https://github.com/Gnucash/gnucash/commit/c3e054a9 (commit)



commit e5c0ec88aac75fc42351396fd7804fad9a517da0
Author: Robert Fewell <14uBobIT at gmail.com>
Date:   Thu Sep 24 13:06:03 2015 +0100

    Bug 754530 Add CSV Export Simple Layout
    
    This patch adds a simple layout to the CSV Transaction export.

diff --git a/src/import-export/csv-exp/assistant-csv-export.c b/src/import-export/csv-exp/assistant-csv-export.c
index 368a18d..21ce9ef 100644
--- a/src/import-export/csv-exp/assistant-csv-export.c
+++ b/src/import-export/csv-exp/assistant-csv-export.c
@@ -44,8 +44,8 @@
 #include "csv-tree-export.h"
 #include "csv-transactions-export.h"
 
-#define GNC_PREFS_GROUP    "dialogs.export.csv"
-#define GNC_PREF_PANED_POS "paned-position"
+#define GNC_PREFS_GROUP               "dialogs.export.csv"
+#define GNC_PREF_PANED_POS            "paned-position"
 #define ASSISTANT_CSV_EXPORT_CM_CLASS "assistant-csv-export"
 
 /* This static indicates the debugging module that this .o belongs to.  */
@@ -65,6 +65,7 @@ void csv_export_assistant_finish_page_prepare (GtkAssistant *assistant, gpointer
 void csv_export_assistant_summary_page_prepare (GtkAssistant *assistant, gpointer user_data);
 
 void csv_export_quote_cb (GtkToggleButton *button, gpointer user_data);
+void csv_export_simple_cb (GtkToggleButton *button, gpointer user_data);
 void csv_export_sep_cb (GtkWidget *radio, gpointer user_data);
 void csv_export_custom_entry_cb (GtkWidget *widget, gpointer user_data);
 
@@ -94,10 +95,12 @@ static const gchar *start_tree_string = N_(
 static const gchar *start_trans_string = N_(
             "This assistant will help you export the Transactions to a file\n"
             " with the separator specified below.\n\n"
-            "There will be multiple rows for each transaction and may"
-            " require further manipulation to get them in a format you can use.\n\n"
-            "Each Transaction will appear once in the export and will be listed in"
-            " the order the accounts were processed\n\n"
+            "There will be multiple rows for each transaction and may require further"
+            " manipulation to get them in a format you can use. Each Transaction will"
+            " appear once in the export and will be listed in the order the accounts"
+            " were processed\n\n"
+            "By selecting the simple layout, the output will be equivalent to a single"
+            " row register view and as such some of the transfer detail could be lost.\n\n"
             "Select the settings you require for the file and then click 'Forward' to proceed"
             " or 'Cancel' to Abort Export.\n");
 
@@ -160,7 +163,8 @@ csv_export_file_chooser_confirm_cb (GtkWidget *button, CsvExportInfo *info)
  *
  * call back for type of separartor required
  *******************************************************/
-void csv_export_sep_cb (GtkWidget *radio, gpointer user_data)
+void
+csv_export_sep_cb (GtkWidget *radio, gpointer user_data)
 {
     CsvExportInfo *info = user_data;
     const gchar *name;
@@ -203,7 +207,8 @@ void csv_export_sep_cb (GtkWidget *radio, gpointer user_data)
  *
  * call back for use of quotes
  *******************************************************/
-void csv_export_quote_cb (GtkToggleButton *button, gpointer user_data)
+void
+csv_export_quote_cb (GtkToggleButton *button, gpointer user_data)
 {
     CsvExportInfo *info = user_data;
 
@@ -213,13 +218,29 @@ void csv_export_quote_cb (GtkToggleButton *button, gpointer user_data)
         info->use_quotes = FALSE;
 }
 
+/*******************************************************
+ * csv_export_simple_cb
+ *
+ * call back for use of simple_layout
+ *******************************************************/
+void
+csv_export_simple_cb (GtkToggleButton *button, gpointer user_data)
+{
+    CsvExportInfo *info = user_data;
+
+    if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON(button)))
+        info->simple_layout = TRUE;
+    else
+        info->simple_layout = FALSE;
+}
 
 /*******************************************************
  * csv_export_custom_entry_cb
  *
  * call back for custom separator
  *******************************************************/
-void csv_export_custom_entry_cb (GtkWidget *widget, gpointer user_data)
+void
+csv_export_custom_entry_cb (GtkWidget *widget, gpointer user_data)
 {
     CsvExportInfo *info = user_data;
     const gchar *custom_str;
@@ -244,10 +265,11 @@ void csv_export_custom_entry_cb (GtkWidget *widget, gpointer user_data)
  *
  * load the default settings for the assistant
  *******************************************************/
-static
-void load_settings (CsvExportInfo *info)
+static void
+load_settings (CsvExportInfo *info)
 {
     info->use_quotes = FALSE;
+    info->simple_layout = FALSE;
     info->separator_str = ",";
     info->file_name = NULL;
     info->starting_dir = NULL;
@@ -746,6 +768,8 @@ csv_export_close_handler (gpointer user_data)
 
     g_free (info->file_name);
     g_free (info->starting_dir);
+    if (info->mid_sep)
+        g_free (info->mid_sep);
 
     gnc_save_window_size (GNC_PREFS_GROUP, GTK_WINDOW(info->window));
     gtk_widget_destroy (info->window);
@@ -782,7 +806,12 @@ csv_export_assistant_create (CsvExportInfo *info)
     info->account_page = GTK_WIDGET(gtk_builder_get_object(builder, "account_page"));
 
     if (info->export_type == XML_EXPORT_TREE)
+    {
+        GtkWidget *chkbox = GTK_WIDGET(gtk_builder_get_object(builder, "simple_layout"));
+
+        gtk_widget_destroy (chkbox);
         gtk_widget_destroy (info->account_page);
+    }
     else
     {
         GtkTreeView *tree_view;
diff --git a/src/import-export/csv-exp/assistant-csv-export.glade b/src/import-export/csv-exp/assistant-csv-export.glade
index 8d1d2bd..10eb18d 100644
--- a/src/import-export/csv-exp/assistant-csv-export.glade
+++ b/src/import-export/csv-exp/assistant-csv-export.glade
@@ -34,9 +34,6 @@ Select the type of Export required and the separator that will be used.
           </packing>
         </child>
         <child>
-          <placeholder/>
-        </child>
-        <child>
           <object class="GtkHSeparator" id="hseparator1">
             <property name="visible">True</property>
             <property name="can_focus">False</property>
@@ -49,9 +46,6 @@ Select the type of Export required and the separator that will be used.
           </packing>
         </child>
         <child>
-          <placeholder/>
-        </child>
-        <child>
           <object class="GtkFrame" id="frame1">
             <property name="visible">True</property>
             <property name="can_focus">False</property>
@@ -72,11 +66,10 @@ Select the type of Export required and the separator that will be used.
                     <property name="row_spacing">3</property>
                     <child>
                       <object class="GtkCheckButton" id="quote_tbutton">
-                        <property name="label" translatable="yes">Quotes</property>
+                        <property name="label" translatable="yes">Use Quotes</property>
                         <property name="visible">True</property>
                         <property name="can_focus">True</property>
                         <property name="receives_default">False</property>
-                        <property name="use_action_appearance">False</property>
                         <property name="draw_indicator">True</property>
                         <signal name="toggled" handler="csv_export_quote_cb" swapped="no"/>
                       </object>
@@ -84,6 +77,20 @@ Select the type of Export required and the separator that will be used.
                         <property name="y_options">GTK_FILL</property>
                       </packing>
                     </child>
+                    <child>
+                      <object class="GtkCheckButton" id="simple_layout">
+                        <property name="label" translatable="yes">Simple Layout</property>
+                        <property name="visible">True</property>
+                        <property name="can_focus">True</property>
+                        <property name="receives_default">False</property>
+                        <property name="draw_indicator">True</property>
+                        <signal name="toggled" handler="csv_export_simple_cb" swapped="no"/>
+                      </object>
+                      <packing>
+                        <property name="left_attach">1</property>
+                        <property name="right_attach">2</property>
+                      </packing>
+                    </child>
                   </object>
                 </child>
               </object>
@@ -92,7 +99,7 @@ Select the type of Export required and the separator that will be used.
               <object class="GtkLabel" id="label1">
                 <property name="visible">True</property>
                 <property name="can_focus">False</property>
-                <property name="label" translatable="yes">Use Quotes</property>
+                <property name="label" translatable="yes">Options</property>
                 <property name="use_markup">True</property>
               </object>
             </child>
@@ -130,7 +137,6 @@ Select the type of Export required and the separator that will be used.
                         <property name="visible">True</property>
                         <property name="can_focus">True</property>
                         <property name="receives_default">False</property>
-                        <property name="use_action_appearance">False</property>
                         <property name="active">True</property>
                         <property name="draw_indicator">True</property>
                         <signal name="toggled" handler="csv_export_sep_cb" swapped="no"/>
@@ -145,7 +151,6 @@ Select the type of Export required and the separator that will be used.
                         <property name="visible">True</property>
                         <property name="can_focus">True</property>
                         <property name="receives_default">False</property>
-                        <property name="use_action_appearance">False</property>
                         <property name="active">True</property>
                         <property name="draw_indicator">True</property>
                         <property name="group">comma_radio</property>
@@ -164,7 +169,6 @@ Select the type of Export required and the separator that will be used.
                         <property name="visible">True</property>
                         <property name="can_focus">True</property>
                         <property name="receives_default">False</property>
-                        <property name="use_action_appearance">False</property>
                         <property name="active">True</property>
                         <property name="draw_indicator">True</property>
                         <property name="group">comma_radio</property>
@@ -183,7 +187,6 @@ Select the type of Export required and the separator that will be used.
                         <property name="visible">True</property>
                         <property name="can_focus">True</property>
                         <property name="receives_default">False</property>
-                        <property name="use_action_appearance">False</property>
                         <property name="active">True</property>
                         <property name="draw_indicator">True</property>
                         <property name="group">comma_radio</property>
@@ -200,7 +203,7 @@ Select the type of Export required and the separator that will be used.
                       <object class="GtkEntry" id="custom_entry">
                         <property name="visible">True</property>
                         <property name="can_focus">True</property>
-                        <property name="invisible_char">&#x25CF;</property>
+                        <property name="invisible_char">●</property>
                         <property name="invisible_char_set">True</property>
                         <property name="primary_icon_activatable">False</property>
                         <property name="secondary_icon_activatable">False</property>
@@ -382,7 +385,6 @@ Select the type of Export required and the separator that will be used.
                                 <property name="can_focus">True</property>
                                 <property name="receives_default">True</property>
                                 <property name="border_width">3</property>
-                                <property name="use_action_appearance">False</property>
                                 <child>
                                   <object class="GtkAlignment" id="alignment5">
                                     <property name="visible">True</property>
@@ -478,7 +480,6 @@ Select the type of Export required and the separator that will be used.
                     <property name="visible">True</property>
                     <property name="can_focus">True</property>
                     <property name="receives_default">False</property>
-                    <property name="use_action_appearance">False</property>
                     <property name="use_underline">True</property>
                     <property name="active">True</property>
                     <property name="draw_indicator">True</property>
@@ -495,7 +496,6 @@ Select the type of Export required and the separator that will be used.
                     <property name="visible">True</property>
                     <property name="can_focus">True</property>
                     <property name="receives_default">False</property>
-                    <property name="use_action_appearance">False</property>
                     <property name="use_underline">True</property>
                     <property name="draw_indicator">True</property>
                     <property name="group">show_all</property>
@@ -523,7 +523,7 @@ Select the type of Export required and the separator that will be used.
                       </object>
                       <packing>
                         <property name="x_options">GTK_FILL</property>
-                        <property name="y_options"></property>
+                        <property name="y_options"/>
                         <property name="x_padding">12</property>
                       </packing>
                     </child>
@@ -533,7 +533,6 @@ Select the type of Export required and the separator that will be used.
                         <property name="visible">True</property>
                         <property name="can_focus">True</property>
                         <property name="receives_default">False</property>
-                        <property name="use_action_appearance">False</property>
                         <property name="use_underline">True</property>
                         <property name="active">True</property>
                         <property name="draw_indicator">True</property>
@@ -543,7 +542,7 @@ Select the type of Export required and the separator that will be used.
                         <property name="left_attach">1</property>
                         <property name="right_attach">2</property>
                         <property name="x_options">GTK_FILL</property>
-                        <property name="y_options"></property>
+                        <property name="y_options"/>
                       </packing>
                     </child>
                     <child>
@@ -552,7 +551,6 @@ Select the type of Export required and the separator that will be used.
                         <property name="visible">True</property>
                         <property name="can_focus">True</property>
                         <property name="receives_default">False</property>
-                        <property name="use_action_appearance">False</property>
                         <property name="use_underline">True</property>
                         <property name="draw_indicator">True</property>
                         <property name="group">end_date_latest</property>
@@ -564,7 +562,7 @@ Select the type of Export required and the separator that will be used.
                         <property name="top_attach">6</property>
                         <property name="bottom_attach">7</property>
                         <property name="x_options">GTK_FILL</property>
-                        <property name="y_options"></property>
+                        <property name="y_options"/>
                       </packing>
                     </child>
                     <child>
@@ -573,7 +571,6 @@ Select the type of Export required and the separator that will be used.
                         <property name="visible">True</property>
                         <property name="can_focus">True</property>
                         <property name="receives_default">False</property>
-                        <property name="use_action_appearance">False</property>
                         <property name="use_underline">True</property>
                         <property name="draw_indicator">True</property>
                         <property name="group">end_date_latest</property>
@@ -585,7 +582,7 @@ Select the type of Export required and the separator that will be used.
                         <property name="top_attach">5</property>
                         <property name="bottom_attach">6</property>
                         <property name="x_options">GTK_FILL</property>
-                        <property name="y_options"></property>
+                        <property name="y_options"/>
                       </packing>
                     </child>
                     <child>
@@ -594,7 +591,6 @@ Select the type of Export required and the separator that will be used.
                         <property name="visible">True</property>
                         <property name="can_focus">True</property>
                         <property name="receives_default">False</property>
-                        <property name="use_action_appearance">False</property>
                         <property name="use_underline">True</property>
                         <property name="active">True</property>
                         <property name="draw_indicator">True</property>
@@ -606,7 +602,7 @@ Select the type of Export required and the separator that will be used.
                         <property name="top_attach">4</property>
                         <property name="bottom_attach">5</property>
                         <property name="x_options">GTK_FILL</property>
-                        <property name="y_options"></property>
+                        <property name="y_options"/>
                       </packing>
                     </child>
                     <child>
@@ -619,7 +615,7 @@ Select the type of Export required and the separator that will be used.
                         <property name="top_attach">3</property>
                         <property name="bottom_attach">4</property>
                         <property name="x_options">GTK_FILL</property>
-                        <property name="y_options"></property>
+                        <property name="y_options"/>
                       </packing>
                     </child>
                     <child>
@@ -633,7 +629,7 @@ Select the type of Export required and the separator that will be used.
                         <property name="top_attach">4</property>
                         <property name="bottom_attach">5</property>
                         <property name="x_options">GTK_FILL</property>
-                        <property name="y_options"></property>
+                        <property name="y_options"/>
                         <property name="x_padding">12</property>
                       </packing>
                     </child>
@@ -643,7 +639,6 @@ Select the type of Export required and the separator that will be used.
                         <property name="visible">True</property>
                         <property name="can_focus">True</property>
                         <property name="receives_default">False</property>
-                        <property name="use_action_appearance">False</property>
                         <property name="use_underline">True</property>
                         <property name="draw_indicator">True</property>
                         <property name="group">start_date_earliest</property>
@@ -655,7 +650,7 @@ Select the type of Export required and the separator that will be used.
                         <property name="top_attach">2</property>
                         <property name="bottom_attach">3</property>
                         <property name="x_options">GTK_FILL</property>
-                        <property name="y_options"></property>
+                        <property name="y_options"/>
                       </packing>
                     </child>
                     <child>
@@ -664,7 +659,6 @@ Select the type of Export required and the separator that will be used.
                         <property name="visible">True</property>
                         <property name="can_focus">True</property>
                         <property name="receives_default">False</property>
-                        <property name="use_action_appearance">False</property>
                         <property name="use_underline">True</property>
                         <property name="draw_indicator">True</property>
                         <property name="group">start_date_earliest</property>
@@ -676,71 +670,35 @@ Select the type of Export required and the separator that will be used.
                         <property name="top_attach">1</property>
                         <property name="bottom_attach">2</property>
                         <property name="x_options">GTK_FILL</property>
-                        <property name="y_options"></property>
+                        <property name="y_options"/>
                       </packing>
                     </child>
                     <child>
                       <object class="GtkHBox" id="start_date_hbox">
                         <property name="visible">True</property>
                         <property name="can_focus">False</property>
-                        <child>
-                          <placeholder/>
-                        </child>
                       </object>
                       <packing>
                         <property name="left_attach">2</property>
                         <property name="right_attach">3</property>
                         <property name="top_attach">2</property>
                         <property name="bottom_attach">3</property>
-                        <property name="x_options"></property>
+                        <property name="x_options"/>
                       </packing>
                     </child>
                     <child>
                       <object class="GtkHBox" id="end_date_hbox">
                         <property name="visible">True</property>
                         <property name="can_focus">False</property>
-                        <child>
-                          <placeholder/>
-                        </child>
                       </object>
                       <packing>
                         <property name="left_attach">2</property>
                         <property name="right_attach">3</property>
                         <property name="top_attach">6</property>
                         <property name="bottom_attach">7</property>
-                        <property name="x_options"></property>
+                        <property name="x_options"/>
                       </packing>
                     </child>
-                    <child>
-                      <placeholder/>
-                    </child>
-                    <child>
-                      <placeholder/>
-                    </child>
-                    <child>
-                      <placeholder/>
-                    </child>
-                    <child>
-                      <placeholder/>
-                    </child>
-                    <child>
-                      <placeholder/>
-                    </child>
-                    <child>
-                      <placeholder/>
-                    </child>
-                    <child>
-                      <placeholder/>
-                    </child>
-                    <child>
-                      <placeholder/>
-                    </child>
-                    <child>
-                      <placeholder/>
-                    </child>
-                    <child>
-                      <placeholder/>
-                    </child>
                   </object>
                   <packing>
                     <property name="expand">False</property>
@@ -761,9 +719,6 @@ Select the type of Export required and the separator that will be used.
             <property name="position">1</property>
           </packing>
         </child>
-        <child>
-          <placeholder/>
-        </child>
       </object>
       <packing>
         <property name="title" translatable="yes">Account Selection</property>
@@ -789,9 +744,6 @@ Enter file name and location for the Export...
             <property name="position">0</property>
           </packing>
         </child>
-        <child>
-          <placeholder/>
-        </child>
       </object>
       <packing>
         <property name="title" translatable="yes">Choose File Name for Export</property>
diff --git a/src/import-export/csv-exp/assistant-csv-export.h b/src/import-export/csv-exp/assistant-csv-export.h
index 71095e1..7ea4416 100644
--- a/src/import-export/csv-exp/assistant-csv-export.h
+++ b/src/import-export/csv-exp/assistant-csv-export.h
@@ -87,8 +87,12 @@ typedef struct
 
     char           *separator_str;
     gboolean        use_quotes;
+    gboolean        simple_layout;
     gboolean        use_custom;
     gboolean        failed;
+
+    gchar          *end_sep;
+    gchar          *mid_sep;
 } CsvExportInfo;
 
 
diff --git a/src/import-export/csv-exp/csv-transactions-export.c b/src/import-export/csv-exp/csv-transactions-export.c
index e4368e0..215a890 100644
--- a/src/import-export/csv-exp/csv-transactions-export.c
+++ b/src/import-export/csv-exp/csv-transactions-export.c
@@ -51,6 +51,10 @@ static QofLogModule log_module = GNC_MOD_ASSISTANT;
 #endif
 
 
+enum GncCsvLineType {TRANS_SIMPLE,
+                     TRANS_COMPLEX,
+                     SPLIT_LINE};
+
 /*******************************************************************/
 
 /*******************************************************
@@ -112,6 +116,450 @@ gchar *csv_txn_test_field_string (CsvExportInfo *info, const gchar *string_in)
     return string_out;
 }
 
+/******************** Helper functions *********************/
+
+// Transaction line starts with Date
+static gchar*
+begin_trans_string (Transaction *trans, CsvExportInfo *info)
+{
+    gchar *date = qof_print_date (xaccTransGetDate (trans));
+    gchar *result = g_strconcat (info->end_sep, date, info->mid_sep, NULL);
+    g_free (date);
+    return result;
+}
+
+
+// Split line start
+static gchar*
+begin_split_string (Transaction *trans, Split *split, gboolean t_void, CsvExportInfo *info)
+{
+    const gchar *str_rec_date;
+    const gchar *start;
+    gchar       *conv;
+    gchar       *result;
+    Timespec     ts = {0,0};
+
+    if (xaccSplitGetReconcile (split) == YREC)
+    {
+        xaccSplitGetDateReconciledTS (split, &ts);
+        str_rec_date = gnc_print_date (ts);
+    }
+    else
+        str_rec_date = "";
+
+    if (t_void)
+    {
+        start = xaccTransGetVoidReason (trans) ? xaccTransGetVoidReason (trans) : "" ;
+        conv = csv_txn_test_field_string (info, start);
+        result = g_strconcat (info->end_sep, info->mid_sep, info->mid_sep, str_rec_date,
+                              info->mid_sep, info->mid_sep, info->mid_sep, info->mid_sep, conv, info->mid_sep, NULL);
+        g_free (conv);
+    }
+    else
+         result = g_strconcat (info->end_sep, info->mid_sep, info->mid_sep, str_rec_date,
+                               info->mid_sep, info->mid_sep, info->mid_sep, info->mid_sep, info->mid_sep, NULL);
+
+    return result;
+}
+
+
+// Transaction Type
+static gchar*
+add_type (gchar *so_far, Transaction *trans, CsvExportInfo *info)
+{
+    gchar       *result;
+    char         type;
+    static char  ss[2];
+
+    type = xaccTransGetTxnType (trans);
+
+    if (type == TXN_TYPE_NONE)
+        type = ' ';
+    ss[0] = type;
+    ss[1] = '\0';
+    result = g_strconcat (so_far, ss, info->mid_sep, NULL);
+    g_free (so_far);
+    return result;
+}
+
+// Second Date
+static gchar*
+add_second_date (gchar *so_far, Transaction *trans, CsvExportInfo *info)
+{
+    gchar       *result;
+    const gchar *second_date;
+    char         type;
+    Timespec     ts = {0,0};
+
+    type = xaccTransGetTxnType (trans);
+
+    if (type == TXN_TYPE_INVOICE)
+    {
+        xaccTransGetDateDueTS (trans, &ts);
+        second_date = gnc_print_date (ts);
+        result = g_strconcat (so_far, second_date, info->mid_sep, NULL);
+    }
+    else
+        result = g_strconcat (so_far, info->mid_sep, NULL);
+
+    g_free (so_far);
+    return result;
+}
+
+// Account Name short or Long
+static gchar*
+add_account_name (gchar *so_far, Account *acc, Split *split, gboolean full, CsvExportInfo *info)
+{
+    gchar       *name;
+    gchar       *conv;
+    gchar       *result;
+    Account     *account = NULL;
+
+    if (split == NULL)
+        account = acc;
+    else
+        account = xaccSplitGetAccount (split);
+
+    if (full)
+        name = gnc_account_get_full_name (account);
+    else
+        name = g_strdup (xaccAccountGetName (account));
+
+    conv = csv_txn_test_field_string (info, name);
+    result = g_strconcat (so_far, conv, info->mid_sep, NULL);
+    g_free (conv);
+    g_free (so_far);
+    return result;
+}
+
+// Number
+static gchar*
+add_number (gchar *so_far, Transaction *trans, CsvExportInfo *info)
+{
+    const gchar *num;
+    gchar       *conv;
+    gchar       *result;
+
+    num = xaccTransGetNum (trans) ? xaccTransGetNum (trans) : "" ;
+    conv = csv_txn_test_field_string (info, num);
+    result = g_strconcat (so_far, conv, info->mid_sep, NULL);
+    g_free (conv);
+    g_free (so_far);
+    return result;
+}
+
+// Description
+static gchar*
+add_description (gchar *so_far, Transaction *trans, CsvExportInfo *info)
+{
+    const gchar *desc;
+    gchar       *conv;
+    gchar       *result;
+
+    desc = xaccTransGetDescription (trans) ? xaccTransGetDescription (trans) : "" ;
+    conv = csv_txn_test_field_string (info, desc);
+    result = g_strconcat (so_far, conv, info->mid_sep, NULL);
+    g_free (conv);
+    g_free (so_far);
+    return result;
+}
+
+// Notes
+static gchar*
+add_notes (gchar *so_far, Transaction *trans, CsvExportInfo *info)
+{
+    const gchar *notes;
+    gchar       *conv;
+    gchar       *result;
+
+    notes = xaccTransGetNotes (trans) ? xaccTransGetNotes (trans) : "" ;
+    conv = csv_txn_test_field_string (info, notes);
+    result = g_strconcat (so_far, conv, info->mid_sep, NULL);
+    g_free (conv);
+    g_free (so_far);
+    return result;
+}
+
+// Memo
+static gchar*
+add_memo (gchar *so_far, Split *split, CsvExportInfo *info)
+{
+    const gchar *memo;
+    gchar       *conv;
+    gchar       *result;
+
+    memo = xaccSplitGetMemo (split) ? xaccSplitGetMemo (split) : "" ;
+    conv = csv_txn_test_field_string (info, memo);
+    result = g_strconcat (so_far, conv, info->mid_sep, NULL);
+    g_free (conv);
+    g_free (so_far);
+    return result;
+}
+
+// Full Category Path or Not
+static gchar*
+add_category (gchar *so_far, Split *split, gboolean full, CsvExportInfo *info)
+{
+    gchar       *cat;
+    gchar       *conv;
+    gchar       *result;
+
+    if (full)
+        cat = xaccSplitGetCorrAccountFullName (split);
+    else
+        cat = g_strdup(xaccSplitGetCorrAccountName (split));
+
+    conv = csv_txn_test_field_string (info, cat);
+    result = g_strconcat (so_far, conv, info->mid_sep, NULL);
+    g_free (cat);
+    g_free (conv);
+    g_free (so_far);
+    return result;
+}
+
+// Line Type
+static gchar*
+add_line_type (gchar *so_far, gint line_type, CsvExportInfo *info)
+{
+    gchar *result;
+
+    if (line_type == SPLIT_LINE)
+        result = g_strconcat (so_far, "S", info->mid_sep, NULL);
+    else
+        result = g_strconcat (so_far, "T", info->mid_sep, NULL);
+
+    g_free (so_far);
+    return result;
+}
+
+// Action
+static gchar*
+add_action (gchar *so_far, Split *split, gint line_type, CsvExportInfo *info)
+{
+    const gchar *action;
+    gchar       *conv;
+    gchar       *result;
+
+    if ((line_type == TRANS_COMPLEX)||(line_type == TRANS_SIMPLE))
+        result = g_strconcat (so_far, "", info->mid_sep, NULL);
+    else
+    {
+        action = xaccSplitGetAction (split);
+        conv = csv_txn_test_field_string (info, action);
+        result = g_strconcat (so_far, conv, info->mid_sep, NULL);
+        g_free (conv);
+    }
+    g_free (so_far);
+    return result;
+}
+
+// Reconcile
+static gchar*
+add_reconcile (gchar *so_far, Split *split, CsvExportInfo *info)
+{
+    const gchar *recon;
+    gchar       *conv;
+    gchar       *result;
+
+    recon = gnc_get_reconcile_str (xaccSplitGetReconcile (split));
+    conv = csv_txn_test_field_string (info, recon);
+    result = g_strconcat (so_far, conv, info->mid_sep, NULL);
+    g_free (conv);
+    g_free (so_far);
+    return result;
+}
+
+// Commodity Mnemonic
+static gchar*
+add_comm_mnemonic (gchar *so_far, Transaction *trans, Split *split, CsvExportInfo *info)
+{
+    const gchar *comm_m;
+    gchar       *conv;
+    gchar       *result;
+
+    if (split == NULL)
+        comm_m = gnc_commodity_get_mnemonic (xaccTransGetCurrency (trans));
+    else
+        comm_m = gnc_commodity_get_mnemonic (xaccAccountGetCommodity (xaccSplitGetAccount(split)));
+
+    conv = csv_txn_test_field_string (info, comm_m);
+    result = g_strconcat (so_far, conv, info->mid_sep, NULL);
+    g_free (conv);
+    g_free (so_far);
+    return result;
+}
+
+// Commodity Namespace
+static gchar*
+add_comm_namespace (gchar *so_far, Transaction *trans, Split *split, CsvExportInfo *info)
+{
+    const gchar *comm_n;
+    gchar       *conv;
+    gchar       *result;
+
+    if (split == NULL)
+        comm_n = gnc_commodity_get_namespace (xaccTransGetCurrency (trans));
+    else
+        comm_n = gnc_commodity_get_namespace (xaccAccountGetCommodity (xaccSplitGetAccount(split)));
+
+    conv = csv_txn_test_field_string (info, comm_n);
+    result = g_strconcat (so_far, conv, info->mid_sep, NULL);
+    g_free (conv);
+    g_free (so_far);
+    return result;
+}
+
+// Amount with Symbol or not
+static gchar*
+add_amount (gchar *so_far, Split *split, gboolean t_void, gboolean symbol, gint line_type, CsvExportInfo *info)
+{
+    const gchar *amt;
+    gchar       *conv;
+    gchar       *result;
+
+    if (line_type == TRANS_COMPLEX)
+        result = g_strconcat (so_far, "", info->mid_sep, NULL);
+    else
+    {
+        if (symbol)
+        {
+            if (t_void)
+                amt = xaccPrintAmount (gnc_numeric_zero(), gnc_split_amount_print_info (split, TRUE));
+            else
+                amt = xaccPrintAmount (xaccSplitGetAmount (split), gnc_split_amount_print_info (split, TRUE));
+        }
+        else
+        {
+            if (t_void)
+                amt = xaccPrintAmount (xaccSplitVoidFormerAmount (split), gnc_split_amount_print_info (split, FALSE));
+            else
+                amt = xaccPrintAmount (xaccSplitGetAmount (split), gnc_split_amount_print_info (split, FALSE));
+        }
+        conv = csv_txn_test_field_string (info, amt);
+        result = g_strconcat (so_far, conv, info->mid_sep, NULL);
+        g_free (conv);
+    }
+    g_free (so_far);
+    return result;
+}
+
+// Share Price / Conversion factor
+static gchar*
+add_rate (gchar *so_far, Split *split, gboolean t_void, CsvExportInfo *info)
+{
+    const gchar *amt;
+    gchar       *conv;
+    gchar       *result;
+
+    if (t_void)
+        amt = xaccPrintAmount (gnc_numeric_zero(), gnc_split_amount_print_info (split, FALSE));
+    else
+        amt = xaccPrintAmount (xaccSplitGetSharePrice (split), gnc_split_amount_print_info (split, FALSE));
+
+    conv = csv_txn_test_field_string (info, amt);
+    result = g_strconcat (so_far, conv, info->end_sep, EOLSTR, NULL);
+    g_free (conv);
+    g_free (so_far);
+    return result;
+}
+
+// Share Price / Conversion factor
+static gchar*
+add_price (gchar *so_far, Split *split, gboolean t_void, CsvExportInfo *info)
+{
+    const gchar *string_amount;
+    gchar       *conv;
+    gchar       *result;
+
+    if (t_void)
+    {
+        gnc_numeric cf = gnc_numeric_div (xaccSplitVoidFormerValue (split), xaccSplitVoidFormerAmount (split), GNC_DENOM_AUTO,
+                                                   GNC_HOW_DENOM_SIGFIGS(6) | GNC_HOW_RND_ROUND_HALF_UP);
+        string_amount = xaccPrintAmount (cf, gnc_split_amount_print_info (split, FALSE));
+    }
+    else
+        string_amount = xaccPrintAmount (xaccSplitGetSharePrice (split), gnc_split_amount_print_info (split, FALSE));
+
+    conv = csv_txn_test_field_string (info, string_amount);
+    result = g_strconcat (so_far, conv, info->end_sep, EOLSTR, NULL);
+    g_free (conv);
+    return result;
+}
+
+// Transaction End of Line
+static gchar*
+add_trans_eol (gchar *so_far, CsvExportInfo *info)
+{
+    gchar *result = g_strconcat (so_far, "", info->mid_sep, "", info->end_sep, EOLSTR, NULL);
+
+    g_free (so_far);
+    return result;
+}
+
+/******************************************************************************/
+
+static gchar*
+make_simple_trans_line (Account *acc, Transaction *trans, Split *split, CsvExportInfo *info)
+{
+    gboolean t_void = xaccTransGetVoidStatus (trans);
+
+    gchar *result = begin_trans_string (trans, info);
+    result = add_account_name (result, acc, NULL, TRUE, info);
+    result = add_number (result, trans, info);
+    result = add_description (result, trans, info);
+    result = add_category (result, split, TRUE, info);
+    result = add_reconcile (result, split, info);
+    result = add_amount (result, split, t_void, TRUE, TRANS_SIMPLE, info);
+    result = add_amount (result, split, t_void, FALSE, TRANS_SIMPLE, info);
+    result = add_rate (result, split, t_void, info);
+    return result;
+}
+
+static gchar*
+make_complex_trans_line (Account *acc, Transaction *trans, Split *split, CsvExportInfo *info)
+{
+    gboolean t_void = xaccTransGetVoidStatus (trans);
+
+    gchar *result = begin_trans_string (trans, info);
+    result = add_type (result, trans, info);
+    result = add_second_date (result, trans, info);
+    result = add_account_name (result, acc, NULL, FALSE, info);
+    result = add_number (result, trans, info);
+    result = add_description (result, trans, info);
+    result = add_notes (result, trans, info);
+    result = add_memo (result, split, info);
+    result = add_category (result, split, TRUE, info);
+    result = add_category (result, split, FALSE, info);
+    result = add_line_type (result, TRANS_COMPLEX, info);
+    result = add_action (result,split, TRANS_COMPLEX, info);
+    result = add_reconcile (result, split, info);
+    result = add_amount (result, split, t_void, TRUE, TRANS_COMPLEX, info);
+    result = add_comm_mnemonic (result, trans, NULL, info);
+    result = add_comm_namespace (result, trans, NULL, info);
+    result = add_trans_eol (result, info);
+    return result;
+}
+
+static gchar*
+make_complex_split_line (Transaction *trans, Split *split, CsvExportInfo *info)
+{
+    gboolean t_void = xaccTransGetVoidStatus (trans);
+
+    gchar *result = begin_split_string (trans, split, t_void, info);
+    result = add_memo (result, split, info);
+    result = add_account_name (result, NULL, split, TRUE, info);
+    result = add_account_name (result, NULL, split, FALSE, info);
+    result = add_line_type (result, SPLIT_LINE, info);
+    result = add_action (result,split, SPLIT_LINE, info);
+    result = add_reconcile (result, split, info);
+    result = add_amount (result, split, t_void, TRUE, SPLIT_LINE, info);
+    result = add_comm_mnemonic (result, trans, split, info);
+    result = add_comm_namespace (result, trans, split, info);
+    result = add_amount (result, split, t_void, FALSE, SPLIT_LINE, info);
+    result = add_price (result, split, t_void, info);
+    return result;
+}
+
 
 /*******************************************************
  * account_splits
@@ -127,25 +575,10 @@ void account_splits (CsvExportInfo *info, Account *acc, FILE *fh )
     GList   *splits;
     QofBook *book;
 
-    gchar   *end_sep;
-    gchar   *mid_sep;
-
     q = qof_query_create_for (GNC_ID_SPLIT);
     book = gnc_get_current_book();
     qof_query_set_book (q, book);
 
-    /* Set up separators */
-    if (info->use_quotes)
-    {
-        end_sep = "\"";
-        mid_sep = g_strconcat ("\"", info->separator_str, "\"", NULL);
-    }
-    else
-    {
-        end_sep = "";
-        mid_sep = g_strconcat (info->separator_str, NULL);
-    }
-
     /* Sort by transaction date */
     p1 = g_slist_prepend (NULL, TRANS_DATE_POSTED);
     p1 = g_slist_prepend (p1, SPLIT_TRANS);
@@ -165,253 +598,63 @@ void account_splits (CsvExportInfo *info, Account *acc, FILE *fh )
         Split       *t_split;
         int          nSplits;
         int          cnt;
-        gchar       *part1;
-        gchar       *part2;
-        gchar       *date;
-        const gchar *currentSel;
-        const gchar *split_amount;
-        gchar       *str_temp = NULL;
-        gchar       *full_path = NULL;
-        Timespec     ts = {0,0};
-        char         type;
-        static char  ss[2];
+        gchar       *line;
 
         split = splits->data;
         trans = xaccSplitGetParent (split);
         nSplits = xaccTransCountSplits (trans);
         s_list = xaccTransGetSplitList (trans);
-        type = xaccTransGetTxnType (trans);
 
         // Look for trans already exported in trans_list
         if (g_list_find (info->trans_list, trans) != NULL)
             continue;
 
-        /* Date */
-        date = qof_print_date (xaccTransGetDate (trans));
-        part1 = g_strconcat (end_sep, date, mid_sep, NULL);
-        g_free (date);
-        /* Transaction Type */
-        if (type == TXN_TYPE_NONE)
-            type = ' ';
-        ss[0] = type;
-        ss[1] = '\0';
-        part2 = g_strconcat (part1, ss, mid_sep, NULL);
-        g_free (part1);
-        /* Second Date */
-        if (type == TXN_TYPE_INVOICE)
+        // Simple Layout
+        if (info->simple_layout)
         {
-            xaccTransGetDateDueTS (trans, &ts);
-            currentSel = gnc_print_date (ts);
-            part1 = g_strconcat (part2, currentSel, mid_sep, NULL);
-            g_free (part2);
-        }
-        else
-        {
-            part1 = g_strconcat (part2, mid_sep, NULL);
-            g_free (part2);
+            line = make_simple_trans_line (acc, trans, split, info);
+
+            /* Write to file */
+            if (!write_line_to_file (fh, line))
+            {
+                info->failed = TRUE;
+                break;
+            }
+            g_free (line);
+            continue;
         }
-        /* Name */
-        currentSel = xaccAccountGetName (acc);
-        str_temp = csv_txn_test_field_string (info, currentSel);
-        part2 = g_strconcat (part1, str_temp, mid_sep, NULL);
-        g_free (str_temp);
-        g_free (part1);
-        /* Number */
-        currentSel = xaccTransGetNum (trans) ? xaccTransGetNum (trans) : "" ;
-        str_temp = csv_txn_test_field_string (info, currentSel);
-        part1 = g_strconcat (part2, str_temp, mid_sep, NULL);
-        g_free (str_temp);
-        g_free (part2);
-        /* Description */
-        currentSel = xaccTransGetDescription (trans) ? xaccTransGetDescription (trans) : "" ;
-        str_temp = csv_txn_test_field_string (info, currentSel);
-        part2 = g_strconcat (part1, str_temp, mid_sep, NULL);
-        g_free (str_temp);
-        g_free (part1);
-        /* Notes */
-        currentSel = xaccTransGetNotes (trans) ? xaccTransGetNotes (trans) : "" ;
-        str_temp = csv_txn_test_field_string (info, currentSel);
-        part1 = g_strconcat (part2, str_temp, mid_sep, NULL);
-        g_free (str_temp);
-        g_free (part2);
-        /* Memo */
-        currentSel = xaccSplitGetMemo (split) ? xaccSplitGetMemo (split) : "" ;
-        str_temp = csv_txn_test_field_string (info, currentSel);
-        part2 = g_strconcat (part1, str_temp, mid_sep, NULL);
-        g_free (str_temp);
-        g_free (part1);
-        /* Full Category Path */
-        full_path = xaccSplitGetCorrAccountFullName (split);
-        str_temp = csv_txn_test_field_string (info, full_path);
-        part1 = g_strconcat (part2, str_temp, mid_sep, NULL);
-        g_free (full_path);
-        g_free (str_temp);
-        g_free (part2);
-        part2 = g_strconcat (part1, NULL);
-        g_free (part1);
-        /* Category */
-        currentSel = xaccSplitGetCorrAccountName (split);
-        str_temp = csv_txn_test_field_string (info, currentSel);
-        part1 = g_strconcat (part2, str_temp, mid_sep, "T", mid_sep, "", mid_sep, NULL);
-        g_free (str_temp);
-        g_free (part2);
-
-        part2 = g_strconcat (part1, NULL);
-        g_free (part1);
-
-        /* Reconcile and Amount with Symbol */
-        currentSel = gnc_get_reconcile_str (xaccSplitGetReconcile (split));
-        part1 = g_strconcat (part2, currentSel, mid_sep, "", mid_sep, NULL);
-        g_free (part2);
-
-        /* Commodity Mnemonic */
-        currentSel = gnc_commodity_get_mnemonic (xaccTransGetCurrency (trans));
-        str_temp = csv_txn_test_field_string (info, currentSel);
-        part2 = g_strconcat (part1, str_temp, mid_sep, NULL);
-        g_free (str_temp);
-        g_free (part1);
-
-        /* Commodity Namespace */
-        currentSel = gnc_commodity_get_namespace (xaccTransGetCurrency (trans));
-        str_temp = csv_txn_test_field_string (info, currentSel);
-        part1 = g_strconcat (part2, str_temp, mid_sep, NULL);
-        g_free (str_temp);
-        g_free (part2);
-
-        /* Amount Number Only and Rate/Price */
-        part2 = g_strconcat (part1, "", mid_sep, "", end_sep, EOLSTR, NULL);
-        g_free (part1);
+
+        // Complex Transaction Line.
+        line = make_complex_trans_line (acc, trans, split, info);
 
         /* Write to file */
-        if (!write_line_to_file (fh, part2))
+        if (!write_line_to_file (fh, line))
         {
             info->failed = TRUE;
             break;
         }
-        g_free (part2);
+        g_free (line);
 
-        /* Loop through the list of splits for the Transcation */
+        /* Loop through the list of splits for the Transaction */
         node = s_list;
         cnt = 0;
         while ((cnt < nSplits) && (info->failed == FALSE))
         {
-            gchar *fullname = NULL;
-            const gchar *str_rec_date;
-            gboolean t_void = xaccTransGetVoidStatus (trans);
             t_split = node->data;
 
+            // Complex Split Line.
+            line = make_complex_split_line (trans, t_split, info);
 
-            if (xaccSplitGetReconcile (t_split) == YREC)
-            {
-                xaccSplitGetDateReconciledTS (t_split, &ts);
-                str_rec_date = gnc_print_date (ts);
-            }
-            else
-                str_rec_date = "";
-
-            /* Start of line */
-            if (t_void)
-            {
-                currentSel = xaccTransGetVoidReason (trans) ? xaccTransGetVoidReason (trans) : "" ;
-                str_temp = csv_txn_test_field_string (info, currentSel);
-                part1 = g_strconcat (end_sep, mid_sep, mid_sep, str_rec_date, mid_sep, mid_sep, mid_sep, mid_sep, str_temp, mid_sep, NULL);
-                g_free (str_temp);
-            }
-            else
-                part1 = g_strconcat (end_sep, mid_sep, mid_sep, str_rec_date, mid_sep, mid_sep, mid_sep, mid_sep, mid_sep, NULL);
-
-            /* Memo */
-            currentSel = xaccSplitGetMemo (t_split) ? xaccSplitGetMemo (t_split) : "" ;
-            str_temp = csv_txn_test_field_string (info, currentSel);
-            part2 = g_strconcat (part1, str_temp, mid_sep, NULL);
-            g_free (str_temp);
-            g_free (part1);
-
-            /* Full Account */
-            fullname = gnc_account_get_full_name (xaccSplitGetAccount (t_split));
-            str_temp = csv_txn_test_field_string (info, fullname);
-            part1 = g_strconcat (part2, str_temp, mid_sep, NULL);
-            g_free (str_temp);
-            g_free (fullname);
-            g_free (part2);
-
-            part2 = g_strconcat (part1, NULL);
-            g_free (part1);
-
-            /* Account */
-            currentSel = xaccAccountGetName (xaccSplitGetAccount (t_split));
-            str_temp = csv_txn_test_field_string (info, currentSel);
-            part1 = g_strconcat (part2, str_temp, mid_sep, "S", mid_sep, NULL);
-            g_free (str_temp);
-            g_free (part2);
-
-            /* Action */
-            currentSel = xaccSplitGetAction (t_split);
-            str_temp = csv_txn_test_field_string (info, currentSel);
-            part2 = g_strconcat (part1, str_temp, mid_sep, NULL);
-            g_free (str_temp);
-            g_free (part1);
-
-            /* Reconcile */
-            currentSel = gnc_get_reconcile_str (xaccSplitGetReconcile (t_split));
-            part1 = g_strconcat (part2, currentSel, mid_sep, NULL);
-            g_free (part2);
-
-            /* Amount with Symbol */
-            split_amount = xaccPrintAmount (xaccSplitGetAmount (t_split), gnc_split_amount_print_info (t_split, TRUE));
-            str_temp = csv_txn_test_field_string (info, split_amount);
-            part2 = g_strconcat (part1, str_temp, mid_sep, NULL);
-            g_free (str_temp);
-            g_free (part1);
-
-            /* Commodity Mnemonic */
-            currentSel = gnc_commodity_get_mnemonic (xaccAccountGetCommodity (xaccSplitGetAccount(t_split)));
-            str_temp = csv_txn_test_field_string (info, currentSel);
-            part1 = g_strconcat (part2, str_temp, mid_sep, NULL);
-            g_free (str_temp);
-            g_free (part2);
-
-            /* Commodity Namespace */
-            currentSel = gnc_commodity_get_namespace (xaccAccountGetCommodity (xaccSplitGetAccount(t_split)));
-            str_temp = csv_txn_test_field_string (info, currentSel);
-            part2 = g_strconcat (part1, str_temp, mid_sep, NULL);
-            g_free (str_temp);
-            g_free (part1);
-
-            /* Amount Numbers only */
-            if (t_void)
-                split_amount = xaccPrintAmount (xaccSplitVoidFormerAmount (t_split), gnc_split_amount_print_info (t_split, FALSE));
-            else
-                split_amount = xaccPrintAmount (xaccSplitGetAmount (t_split), gnc_split_amount_print_info (t_split, FALSE));
-            str_temp = csv_txn_test_field_string (info, split_amount);
-            part1 = g_strconcat (part2, str_temp, mid_sep, NULL);
-            g_free (str_temp);
-            g_free (part2);
-
-            /* Share Price / Conversion factor */
-            if (t_void)
-            {
-                gnc_numeric cf = gnc_numeric_div (xaccSplitVoidFormerValue (t_split), xaccSplitVoidFormerAmount (t_split), GNC_DENOM_AUTO,
-                                                   GNC_HOW_DENOM_SIGFIGS(6) | GNC_HOW_RND_ROUND_HALF_UP);
-                split_amount = xaccPrintAmount (cf, gnc_split_amount_print_info (t_split, FALSE));
-            }
-            else
-                split_amount = xaccPrintAmount (xaccSplitGetSharePrice (t_split), gnc_split_amount_print_info (t_split, FALSE));
-            str_temp = csv_txn_test_field_string (info, split_amount);
-            part2 = g_strconcat (part1, str_temp, end_sep, EOLSTR, NULL);
-            g_free (str_temp);
-            g_free (part1);
-
-            if (!write_line_to_file (fh, part2))
+            if (!write_line_to_file (fh, line))
                 info->failed = TRUE;
 
-            g_free (part2);
+            g_free (line);
+
             cnt++;
             node = node->next;
         }
         info->trans_list = g_list_prepend (info->trans_list, trans); // add trans to trans_list
     }
-    g_free (mid_sep);
     qof_query_destroy (q);
     g_list_free (splits);
 }
@@ -427,55 +670,63 @@ void csv_transactions_export (CsvExportInfo *info)
     FILE    *fh;
     Account *acc;
     GList   *ptr;
-    gboolean num_action = qof_book_use_split_action_for_num_field(gnc_get_current_book());
+    gboolean num_action = qof_book_use_split_action_for_num_field (gnc_get_current_book());
 
     ENTER("");
     DEBUG("File name is : %s", info->file_name);
 
     info->failed = FALSE;
 
+    /* Set up separators */
+    if (info->use_quotes)
+    {
+        info->end_sep = "\"";
+        info->mid_sep = g_strconcat ("\"", info->separator_str, "\"", NULL);
+    }
+    else
+    {
+        info->end_sep = "";
+        info->mid_sep = g_strconcat (info->separator_str, NULL);
+    }
+
     /* Open File for writing */
     fh = g_fopen (info->file_name, "w" );
     if (fh != NULL)
     {
         gchar *header;
-        gchar *end_sep;
-        gchar *mid_sep;
         int i;
 
-        /* Set up separators */
-        if (info->use_quotes)
+        /* Header string */
+        if (info->simple_layout)
         {
-            end_sep = "\"";
-            mid_sep = g_strconcat ("\"", info->separator_str, "\"", NULL);
+            header = g_strconcat (info->end_sep, _("Date"), info->mid_sep, _("Account Name"),
+                                  info->mid_sep, (num_action ? _("Transaction Number") : _("Number")),
+                                  info->mid_sep, _("Description"), info->mid_sep, _("Full Category Path"),
+                                  info->mid_sep, _("Reconcile"), info->mid_sep, _("Amount With Sym"),
+                                  info->mid_sep, _("Amount Num."), info->mid_sep, _("Rate/Price"),
+                                  info->end_sep, EOLSTR, NULL);
         }
         else
         {
-            end_sep = "";
-            mid_sep = g_strconcat (info->separator_str, NULL);
+            header = g_strconcat (info->end_sep, _("Date"), info->mid_sep, _("Transaction Type"), info->mid_sep, _("Second Date"),
+                                  info->mid_sep, _("Account Name"), info->mid_sep, (num_action ? _("Transaction Number") : _("Number")),
+                                  info->mid_sep, _("Description"), info->mid_sep, _("Notes"), info->mid_sep, _("Memo"),
+                                  info->mid_sep, _("Full Category Path"), info->mid_sep, _("Category"), info->mid_sep, _("Row Type"),
+                                  info->mid_sep, (num_action ? _("Number/Action") : _("Action")),
+                                  info->mid_sep, _("Reconcile"), info->mid_sep, _("Amount With Sym"),
+                                  info->mid_sep, _("Commodity Mnemonic"), info->mid_sep, _("Commodity Namespace"),
+                                  info->mid_sep, _("Amount Num."), info->mid_sep, _("Rate/Price"),
+                                  info->end_sep, EOLSTR, NULL);
         }
-
-        /* Header string */
-        header = g_strconcat (end_sep, _("Date"), mid_sep, _("Transaction Type"), mid_sep, _("Second Date"),
-                              mid_sep, _("Account Name"), mid_sep, (num_action ? _("Transaction Number") : _("Number")),
-                              mid_sep, _("Description"), mid_sep, _("Notes"), mid_sep, _("Memo"),
-                              mid_sep, _("Full Category Path"), mid_sep, _("Category"), mid_sep, _("Row Type"),
-                              mid_sep, (num_action ? _("Number/Action") : _("Action")),
-                              mid_sep, _("Reconcile"), mid_sep, _("Amount With Sym"),
-                              mid_sep, _("Commodity Mnemonic"), mid_sep, _("Commodity Namespace"),
-                              mid_sep, _("Amount Num."), mid_sep, _("Rate/Price"),
-                              end_sep, EOLSTR, NULL);
         DEBUG("Header String: %s", header);
 
         /* Write header line */
         if (!write_line_to_file (fh, header))
         {
             info->failed = TRUE;
-            g_free (mid_sep);
             g_free (header);
             return;
         }
-        g_free (mid_sep);
         g_free (header);
 
         /* Go through list of accounts */



Summary of changes:
 src/import-export/csv-exp/assistant-csv-export.c   |  51 +-
 .../csv-exp/assistant-csv-export.glade             | 104 +--
 src/import-export/csv-exp/assistant-csv-export.h   |   4 +
 .../csv-exp/csv-transactions-export.c              | 753 ++++++++++++++-------
 4 files changed, 574 insertions(+), 338 deletions(-)



More information about the gnucash-changes mailing list