[budgets.c] handle both natural & reversed signs budgets

introduce new API
* gnc_using_unreversed_budgets - queries book's unreversed feature
* gnc_reverse_budget_balance - check if book unreversal status matches
  2nd argument. if so, return account's reversal status. else, return
  FALSE.

* gnome-budget-view can now show both natural and reversed budgets
* gnome-plugin-page-budget will now read&write both natural and
  reversed budgets.
This commit is contained in:
Christopher Lam
2019-10-19 16:19:11 +08:00
parent ded336f987
commit 2cd69e8d85
5 changed files with 59 additions and 13 deletions

View File

@@ -179,6 +179,23 @@ gnc_reverse_balance (const Account *account)
return reverse_type[type];
}
gboolean gnc_using_unreversed_budgets (QofBook* book)
{
return gnc_features_check_used (book, GNC_FEATURE_BUDGET_UNREVERSED);
}
/* similar to gnc_reverse_balance but also accepts a gboolean
unreversed which specifies the reversal strategy - FALSE = pre-4.x
always-assume-credit-accounts, TRUE = all amounts unreversed */
gboolean
gnc_reverse_budget_balance (const Account *account, gboolean unreversed)
{
if (unreversed == gnc_using_unreversed_budgets(gnc_account_get_book(account)))
return gnc_reverse_balance (account);
return FALSE;
}
gchar *
gnc_get_default_directory (const gchar *section)