22 #include <unordered_map> 30 #include <glib/gi18n.h> 32 #include "qofbook.hpp" 36 static const FeaturesTable features_table
38 { GNC_FEATURE_CREDIT_NOTES,
"Customer and vendor credit notes (requires at least GnuCash 2.5.0)" },
39 { GNC_FEATURE_NUM_FIELD_SOURCE,
"User specifies source of 'num' field'; either transaction number or split action (requires at least GnuCash 2.5.0)" },
40 { GNC_FEATURE_KVP_EXTRA_DATA,
"Extra data for addresses, jobs or invoice entries (requires at least GnuCash 2.6.4)" },
41 { GNC_FEATURE_GUID_BAYESIAN,
"Use account GUID as key for Bayesian data (requires at least GnuCash 2.6.12)" },
42 { GNC_FEATURE_GUID_FLAT_BAYESIAN,
"Use account GUID as key for bayesian data and store KVP flat (requires at least Gnucash 2.6.19)" },
43 { GNC_FEATURE_SQLITE3_ISO_DATES,
"Use ISO formatted date-time strings in SQLite3 databases (requires at least GnuCash 2.6.20)"},
44 { GNC_FEATURE_REG_SORT_FILTER,
"Store the register sort and filter settings in .gcm metadata file (requires at least GnuCash 3.3)"},
45 { GNC_FEATURE_BUDGET_UNREVERSED,
"Store budget amounts unreversed (i.e. natural) signs (requires at least Gnucash 3.8)"},
46 { GNC_FEATURE_BUDGET_SHOW_EXTRA_ACCOUNT_COLS,
"Show extra account columns in the Budget View (requires at least Gnucash 3.8)"},
47 { GNC_FEATURE_EQUITY_TYPE_OPENING_BALANCE, GNC_FEATURE_EQUITY_TYPE_OPENING_BALANCE
" (requires at least Gnucash 4.3)" },
61 static const FeaturesTable obsolete_features{
62 {GNC_FEATURE_BOOK_CURRENCY,
"User-specified book currency stored in KVP. Never implemented but some user managed to get it set anyway. (requires at least GnuCash 2.7.0)"},
72 header = N_(
"This Dataset contains features not supported " 73 "by this version of GnuCash. You must use a " 74 "newer version of GnuCash in order to support " 75 "the following features:");
84 auto unknowns {qof_book_get_unknown_features (book, features_table)};
88 auto obsolete = std::remove_if(unknowns.begin(), unknowns.end(),
90 return obsolete_features.find(unknown.first) != obsolete_features.end();
92 while (obsolete != unknowns.end())
94 qof_book_unset_feature(book, obsolete->first.data());
95 obsolete = unknowns.erase(obsolete);
101 auto accum = [](
const auto& a,
const auto& b){
return a +
"\n* " + b.second.data(); };
102 auto msg {std::accumulate (unknowns.begin(), unknowns.end(),
103 std::string (_(header)), accum)};
104 return g_strdup (msg.c_str());
109 g_return_if_fail (book);
110 g_return_if_fail (feature);
113 auto iter = features_table.find (feature);
114 if (iter == features_table.end ())
116 PWARN(
"Tried to set unknown feature as used.");
120 qof_book_set_feature (book, feature, iter->second.data());
126 g_return_if_fail (book);
127 g_return_if_fail (feature);
130 auto iter = features_table.find (feature);
131 if (iter == features_table.end ())
133 PWARN(
"Tried to set unknown feature as unused.");
137 qof_book_unset_feature (book, feature);
140 gboolean gnc_features_check_used (QofBook *book,
const gchar * feature)
142 return qof_book_test_feature (book, feature);
#define G_LOG_DOMAIN
Functions providing the SX List as a plugin page.
void gnc_features_set_used(QofBook *book, const gchar *feature)
Indicate that the current book uses the given feature.
#define PWARN(format, args...)
Log a warning.
void gnc_features_set_unused(QofBook *book, const gchar *feature)
Indicate that the current book does not use the given feature.
gchar * gnc_features_test_unknown(QofBook *book)
Test if the current book relies on features only introduced in a more recent version of GnuCash...
Encapsulate all the information about a dataset.
Utility functions for file access.