Skip to content

Commit

Permalink
CsvTransExp - repeat transaction details on every line in multi-line …
Browse files Browse the repository at this point in the history
…mode

The GnuCash Csv Importer can deal with both cases,
but there has been user feedback that the format
with only the first line displaying transaction
details is confusing and/or not readily usable
in external tools.
  • Loading branch information
gjanssens committed Feb 14, 2023
1 parent be0579d commit aa0a68f
Showing 1 changed file with 15 additions and 27 deletions.
42 changes: 15 additions & 27 deletions gnucash/import-export/csv-exp/csv-transactions-export.c
Original file line number Diff line number Diff line change
Expand Up @@ -379,8 +379,20 @@ make_simple_trans_line (Transaction *trans, Split *split, CsvExportInfo *info)
}

static gchar*
make_split_part (gchar* exp_line, Split *split, bool t_void, CsvExportInfo *info)
make_complex_trans_line (Transaction *trans, Split *split, CsvExportInfo *info)
{
// Transaction fields
gchar *exp_line = g_strdup("");
exp_line = add_date (exp_line, trans, info);
exp_line = add_guid (exp_line, trans, info);
exp_line = add_number (exp_line, trans, info);
exp_line = add_description (exp_line, trans, info);
exp_line = add_notes (exp_line, trans, info);
exp_line = add_commodity (exp_line, trans, info);
exp_line = add_void_reason (exp_line, trans, info);
bool t_void = xaccTransGetVoidStatus (trans);

//Split fields
exp_line = add_action (exp_line, split, info);
exp_line = add_memo (exp_line, split, info);
exp_line = add_account_name (exp_line, split, true, info);
Expand All @@ -392,32 +404,8 @@ make_split_part (gchar* exp_line, Split *split, bool t_void, CsvExportInfo *info
exp_line = add_reconcile (exp_line, split, info);
exp_line = add_reconcile_date (exp_line, split, info);
exp_line = add_price (exp_line, split, t_void, info);
return exp_line;
}

static gchar*
make_complex_trans_line (Transaction *trans, Split *split, CsvExportInfo *info)
{
gchar *exp_line = g_strdup("");
exp_line = add_date (exp_line, trans, info);
exp_line = add_guid (exp_line, trans, info);
exp_line = add_number (exp_line, trans, info);
exp_line = add_description (exp_line, trans, info);
exp_line = add_notes (exp_line, trans, info);
exp_line = add_commodity (exp_line, trans, info);
exp_line = add_void_reason (exp_line, trans, info);
return make_split_part (exp_line, split, xaccTransGetVoidStatus (trans), info);
}

static gchar*
make_complex_split_line (Transaction *trans, Split *split, CsvExportInfo *info)
{
/* Pure split lines don't have any transaction information,
* so start with empty fields for all transaction columns.
*/
gchar *result = g_strconcat (info->end_sep, info->mid_sep, info->mid_sep, info->mid_sep,
info->mid_sep, info->mid_sep, info->mid_sep, info->mid_sep, NULL);
return make_split_part (result, split, xaccTransGetVoidStatus (trans), info);
return exp_line;
}


Expand Down Expand Up @@ -504,7 +492,7 @@ void account_splits (CsvExportInfo *info, Account *acc, FILE *fh )
continue;

// Write complex Split Line.
line = make_complex_split_line (trans, t_split, info);
line = make_complex_trans_line (trans, t_split, info);
info->failed = !write_line_to_file (fh, line);
g_free (line);
if (info->failed)
Expand Down

0 comments on commit aa0a68f

Please sign in to comment.