diff --git a/libgnucash/engine/Account.cpp b/libgnucash/engine/Account.cpp index afcb769799..241bdcf9d7 100644 --- a/libgnucash/engine/Account.cpp +++ b/libgnucash/engine/Account.cpp @@ -3242,6 +3242,15 @@ xaccAccountGetName (const Account *acc) return GET_PRIVATE(acc)->accountName; } +std::vector +gnc_account_get_all_parents (const Account *account) +{ + std::vector rv; + for (auto a = account; !gnc_account_is_root (a); a = gnc_account_get_parent (a)) + rv.push_back (a); + return rv; +} + gchar * gnc_account_get_full_name(const Account *account) { diff --git a/libgnucash/engine/Account.hpp b/libgnucash/engine/Account.hpp index 89649acfc4..598cd0a5df 100644 --- a/libgnucash/engine/Account.hpp +++ b/libgnucash/engine/Account.hpp @@ -61,6 +61,8 @@ void gnc_account_foreach_split_until_date (const Account *acc, time64 end_date, * @result Split* or nullptr if not found */ Split* gnc_account_find_split (const Account*, std::function, bool); +std::vector gnc_account_get_all_parents (const Account *account); + #endif /* GNC_COMMODITY_HPP */ /** @} */ /** @} */