gnucash stable: Multiple changes pushed
Christopher Lam
clam at code.gnucash.org
Fri Apr 7 08:42:02 EDT 2023
Updated via https://github.com/Gnucash/gnucash/commit/5dc0b827 (commit)
via https://github.com/Gnucash/gnucash/commit/229efb52 (commit)
from https://github.com/Gnucash/gnucash/commit/e5349a8b (commit)
commit 5dc0b8271a790406f1bcf62e74e8ab42f9c7dee0
Author: Christopher Lam <christopher.lck at gmail.com>
Date: Fri Apr 7 20:41:11 2023 +0800
[csv-transactions-export] fix category in export with simple layout
If Trading accounts is enabled, and the transaction is a transfer
between two accounts of differing commodities, the CSV simple-layout
export would incorrectly show "--Split Transaction--" as the
category.
This commit changes the algorithm to ignore the trading splits when
determining the other split account, thereby returning a more useful
other account name.
diff --git a/gnucash/import-export/csv-exp/csv-transactions-export.cpp b/gnucash/import-export/csv-exp/csv-transactions-export.cpp
index 55ba6ceec9..bec67baf95 100644
--- a/gnucash/import-export/csv-exp/csv-transactions-export.cpp
+++ b/gnucash/import-export/csv-exp/csv-transactions-export.cpp
@@ -130,15 +130,8 @@ get_memo (Split *split)
static std::string
get_category (Split *split, bool full)
{
- if (full)
- {
- auto cat{xaccSplitGetCorrAccountFullName (split)};
- auto rv{std::string (cat)};
- g_free (cat);
- return rv;
- }
- else
- return xaccSplitGetCorrAccountName (split);
+ auto other{xaccSplitGetOtherSplit(split)};
+ return other ? get_account_name (other, full) : _("-- Split Transaction --");
}
// Action
commit 229efb52ede7438dd21707c12cbb98cc6815a0a6
Author: Christopher Lam <christopher.lck at gmail.com>
Date: Fri Apr 7 20:27:29 2023 +0800
[csv-export-helpers] move account_get_fullname_str to support file
diff --git a/gnucash/import-export/csv-exp/csv-export-helpers.cpp b/gnucash/import-export/csv-exp/csv-export-helpers.cpp
index f39953636b..a945881ac8 100644
--- a/gnucash/import-export/csv-exp/csv-export-helpers.cpp
+++ b/gnucash/import-export/csv-exp/csv-export-helpers.cpp
@@ -82,3 +82,12 @@ gnc_csv_add_line (std::ostream& ss, const StringVec& str_vec,
return !ss.fail();
}
+
+std::string
+account_get_fullname_str (Account *account)
+{
+ auto name{gnc_account_get_full_name (account)};
+ auto rv{std::string(name)};
+ g_free (name);
+ return rv;
+}
diff --git a/gnucash/import-export/csv-exp/csv-export-helpers.hpp b/gnucash/import-export/csv-exp/csv-export-helpers.hpp
index be8fc24dc8..cf0c4e395b 100644
--- a/gnucash/import-export/csv-exp/csv-export-helpers.hpp
+++ b/gnucash/import-export/csv-exp/csv-export-helpers.hpp
@@ -35,5 +35,7 @@ using StringVec = std::vector<std::string>;
bool gnc_csv_add_line (std::ostream& ss, const StringVec& charsvec,
bool use_quotes, const char* sep);
+std::string account_get_fullname_str (Account*);
+
#endif
diff --git a/gnucash/import-export/csv-exp/csv-transactions-export.cpp b/gnucash/import-export/csv-exp/csv-transactions-export.cpp
index c1f5c08c8a..55ba6ceec9 100644
--- a/gnucash/import-export/csv-exp/csv-transactions-export.cpp
+++ b/gnucash/import-export/csv-exp/csv-transactions-export.cpp
@@ -83,15 +83,7 @@ static std::string
get_account_name (Split *split, bool full)
{
auto account{xaccSplitGetAccount (split)};
- if (full)
- {
- auto name{gnc_account_get_full_name (account)};
- auto rv{std::string(name)};
- g_free (name);
- return rv;
- }
- else
- return xaccAccountGetName (account);
+ return full ? account_get_fullname_str (account) : xaccAccountGetName (account);
}
// Number
diff --git a/gnucash/import-export/csv-exp/csv-tree-export.cpp b/gnucash/import-export/csv-exp/csv-tree-export.cpp
index e52c3ba591..9b8810ec9b 100644
--- a/gnucash/import-export/csv-exp/csv-tree-export.cpp
+++ b/gnucash/import-export/csv-exp/csv-tree-export.cpp
@@ -40,15 +40,6 @@
/* This static indicates the debugging module that this .o belongs to. */
static QofLogModule log_module = GNC_MOD_ASSISTANT;
-static std::string
-account_get_fullname_str (Account *account)
-{
- auto name{gnc_account_get_full_name (account)};
- auto rv{std::string(name)};
- g_free (name);
- return rv;
-}
-
/*******************************************************
* csv_tree_export
*
Summary of changes:
.../import-export/csv-exp/csv-export-helpers.cpp | 9 +++++++++
.../import-export/csv-exp/csv-export-helpers.hpp | 2 ++
.../csv-exp/csv-transactions-export.cpp | 21 +++------------------
gnucash/import-export/csv-exp/csv-tree-export.cpp | 9 ---------
4 files changed, 14 insertions(+), 27 deletions(-)
More information about the gnucash-changes
mailing list