GnuCash c935c2f+
Loading...
Searching...
No Matches
Functions
csv-tree-export.h File Reference

CSV Export Account Tree. More...

#include "assistant-csv-export.h"

Go to the source code of this file.

Functions

void csv_tree_export (CsvExportInfo *info)
 The csv_tree_export() will let the user export the account tree to a delimited file.
 

Detailed Description

CSV Export Account Tree.

Author
Copyright (c) 2012 Robert Fewell

Definition in file csv-tree-export.h.

Function Documentation

◆ csv_tree_export()

void csv_tree_export ( CsvExportInfo info)

The csv_tree_export() will let the user export the account tree to a delimited file.

Definition at line 50 of file csv-tree-export.cpp.

51{
52 ENTER("");
53 DEBUG("File name is : %s", info->file_name);
54
55 /* Open File for writing */
56 auto ss{gnc_open_filestream(info->file_name)};
57
58 /* Header string */
59 StringVec headervec = {
60 _("Type"), _("Full Account Name"), _("Account Name"),
61 _("Account Code"), _("Description"), _("Account Color"),
62 _("Notes"), _("Symbol"), _("Namespace"),
63 _("Hidden"), _("Tax Info"), _("Placeholder")
64 };
65
66 /* Write header line */
67 info->failed = ss.fail() ||
68 !gnc_csv_add_line (ss, headervec, info->use_quotes, info->separator_str);
69
70 /* Get list of Accounts */
71 auto root{gnc_book_get_root_account (gnc_get_current_book())};
72 auto accts{gnc_account_get_descendants_sorted (root)};
73 auto str_or_empty = [](const char* a){ return a ? a : ""; };
74 auto bool_to_char = [](bool b){ return b ? "T" : "F"; };
75
76 /* Go through list of accounts */
77 for (GList *ptr = accts; !info->failed && ptr; ptr = g_list_next (ptr))
78 {
79 auto acc{static_cast<Account*>(ptr->data)};
80 DEBUG("Account being processed is : %s", xaccAccountGetName (acc));
81
82 StringVec line = {
84 account_get_fullname_str (acc),
86 str_or_empty (xaccAccountGetCode (acc)),
87 str_or_empty (xaccAccountGetDescription (acc)),
88 str_or_empty (xaccAccountGetColor (acc)),
89 str_or_empty (xaccAccountGetNotes (acc)),
92 bool_to_char (xaccAccountGetHidden (acc)),
93 bool_to_char (xaccAccountGetTaxRelated (acc)),
94 bool_to_char (xaccAccountGetPlaceholder (acc)),
95 };
96 info->failed = !gnc_csv_add_line (ss, line, info->use_quotes, info->separator_str);
97 }
98
99 g_list_free (accts);
100 LEAVE("");
101}
const char * xaccAccountGetName(const Account *acc)
Get the account's name.
Definition Account.cpp:3289
const char * xaccAccountGetDescription(const Account *acc)
Get the account's description.
Definition Account.cpp:3343
const char * xaccAccountGetColor(const Account *acc)
Get the account's color.
Definition Account.cpp:3350
GList * gnc_account_get_descendants_sorted(const Account *account)
This function returns a GList containing all the descendants of the specified account,...
Definition Account.cpp:3052
GNCAccountType xaccAccountGetType(const Account *acc)
Returns the account's account type.
Definition Account.cpp:3267
const char * xaccAccountGetNotes(const Account *acc)
Get the account's notes.
Definition Account.cpp:3374
const char * xaccAccountGetCode(const Account *acc)
Get the account's accounting code.
Definition Account.cpp:3336
gnc_commodity * xaccAccountGetCommodity(const Account *acc)
Get the account's commodity
Definition Account.cpp:3408
const char * gnc_commodity_get_namespace(const gnc_commodity *cm)
Retrieve the namespace for the specified commodity.
const char * gnc_commodity_get_mnemonic(const gnc_commodity *cm)
Retrieve the mnemonic for the specified commodity.
gboolean xaccAccountGetHidden(const Account *acc)
Get the "hidden" flag for an account.
Definition Account.cpp:4190
gboolean xaccAccountGetPlaceholder(const Account *acc)
Get the "placeholder" flag for an account.
Definition Account.cpp:4119
const char * xaccAccountTypeEnumAsString(GNCAccountType type)
Conversion routines for the account types to/from strings that are used in persistent storage,...
Definition Account.cpp:4247
gboolean xaccAccountGetTaxRelated(const Account *acc)
DOCUMENT ME!
Definition Account.cpp:4035
#define DEBUG(format, args...)
Print a debugging message.
Definition qoflog.h:264
#define LEAVE(format, args...)
Print a function exit debugging message.
Definition qoflog.h:282
#define ENTER(format, args...)
Print a function entry debugging message.
Definition qoflog.h:272
STRUCTS.