Skip to content

Commit

Permalink
CsvTransExport - omit trading splits unless exporting from a trading …
Browse files Browse the repository at this point in the history
…account
  • Loading branch information
gjanssens committed Feb 14, 2023
1 parent c6a9390 commit 9df059e
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions gnucash/import-export/csv-exp/csv-transactions-export.c
Original file line number Diff line number Diff line change
Expand Up @@ -494,6 +494,7 @@ make_complex_split_line (Transaction *trans, Split *split, CsvExportInfo *info)
static
void account_splits (CsvExportInfo *info, Account *acc, FILE *fh )
{
bool is_trading_acct = acc && (xaccAccountGetType (acc) == ACCT_TYPE_TRADING);

// Setup the query for normal transaction export
if (info->export_type == XML_EXPORT_TRANS)
Expand Down Expand Up @@ -527,6 +528,11 @@ void account_splits (CsvExportInfo *info, Account *acc, FILE *fh )
if (!split_acc)
continue;

// Only export trading splits when exporting a trading account
if (!is_trading_acct &&
(xaccAccountGetType (split_acc) == ACCT_TYPE_TRADING))
continue;

if (info->simple_layout)
{
// Write line in simple layout, equivalent to a single line register view
Expand Down Expand Up @@ -555,6 +561,11 @@ void account_splits (CsvExportInfo *info, Account *acc, FILE *fh )
if (split == t_split)
continue;

// Only export trading splits if exporting a trading account
Account *tsplit_acc = xaccSplitGetAccount (t_split);
if (!is_trading_acct &&
(xaccAccountGetType (tsplit_acc) == ACCT_TYPE_TRADING))
continue;

// Write complex Split Line.
line = make_complex_split_line (trans, t_split, info);
Expand Down

0 comments on commit 9df059e

Please sign in to comment.