gnucash maint: Bug 797326 - Enhancement: budget's Estimate tool should ignore Closing Entries
Christopher Lam
clam at code.gnucash.org
Fri Oct 25 08:19:29 EDT 2019
Updated via https://github.com/Gnucash/gnucash/commit/b2fcfbd3 (commit)
from https://github.com/Gnucash/gnucash/commit/1dc22e53 (commit)
commit b2fcfbd3c6c82c0da77ee781f91ebc84e35080c3
Author: Christopher Lam <christopher.lck at gmail.com>
Date: Fri Oct 25 18:27:47 2019 +0800
Bug 797326 - Enhancement: budget's Estimate tool should ignore Closing Entries
Addendum to 8b8c957ed -- if budgeted amounts exclude closing entries,
actual amounts should also exclude closing entries.
Amend documentation, modify budget test to add a closing entry which
will be ignored.
diff --git a/libgnucash/engine/Recurrence.c b/libgnucash/engine/Recurrence.c
index 093836ac4..cf1ef2904 100644
--- a/libgnucash/engine/Recurrence.c
+++ b/libgnucash/engine/Recurrence.c
@@ -419,7 +419,7 @@ recurrenceGetAccountPeriodValue(const Recurrence *r, Account *acc, guint n)
g_return_val_if_fail(r && acc, gnc_numeric_zero());
t1 = recurrenceGetPeriodTime(r, n, FALSE);
t2 = recurrenceGetPeriodTime(r, n, TRUE);
- return xaccAccountGetBalanceChangeForPeriod (acc, t1, t2, TRUE);
+ return xaccAccountGetNoclosingBalanceChangeForPeriod (acc, t1, t2, TRUE);
}
void
diff --git a/libgnucash/engine/Recurrence.h b/libgnucash/engine/Recurrence.h
index aa375d69d..6f8df001e 100644
--- a/libgnucash/engine/Recurrence.h
+++ b/libgnucash/engine/Recurrence.h
@@ -140,7 +140,8 @@ time64 recurrenceGetPeriodTime(const Recurrence *r, guint n, gboolean end);
/**
* @return the amount that an Account's value changed between the beginning
- * and end of the nth instance of the Recurrence.
+ * and end of the nth instance of the Recurrence. Please note this function
+ * is only used in budget reports and will exclude closing entries.
**/
gnc_numeric recurrenceGetAccountPeriodValue(const Recurrence *r,
Account *acct, guint n);
diff --git a/libgnucash/engine/gnc-budget.h b/libgnucash/engine/gnc-budget.h
index 548275833..af23c43c9 100644
--- a/libgnucash/engine/gnc-budget.h
+++ b/libgnucash/engine/gnc-budget.h
@@ -145,8 +145,12 @@ void gnc_budget_unset_account_period_value(
gboolean gnc_budget_is_account_period_value_set(
const GncBudget *budget, const Account *account, guint period_num);
+/* get the budget account period's budgeted value */
gnc_numeric gnc_budget_get_account_period_value(
const GncBudget *budget, const Account *account, guint period_num);
+
+/* get the budget account period's actual value, including children,
+ excluding closing entries */
gnc_numeric gnc_budget_get_account_period_actual_value(
const GncBudget *budget, Account *account, guint period_num);
diff --git a/libgnucash/engine/test/test-extras.scm b/libgnucash/engine/test/test-extras.scm
index 126f7e0ec..a0a1027d4 100644
--- a/libgnucash/engine/test/test-extras.scm
+++ b/libgnucash/engine/test/test-extras.scm
@@ -839,6 +839,7 @@
(budget (gnc-budget-new book))
(bank (cdr (assoc "Bank" account-alist)))
(income (cdr (assoc "Income" account-alist)))
+ (equity (cdr (assoc "Equity" account-alist)))
(expense (cdr (assoc "Expenses" account-alist))))
(gnc-budget-set-name budget "test budget")
(gnc-budget-begin-edit budget)
@@ -861,7 +862,9 @@
(env-create-transaction env (midperiod 2) bank income 67)
(env-create-transaction env (midperiod 3) bank income 77)
(env-create-transaction env (midperiod 0) expense bank 20)
- (env-create-transaction env (midperiod 1) expense bank 20))
+ (env-create-transaction env (midperiod 1) expense bank 20)
+ (let ((clos (env-create-transaction env (midperiod 1) income equity 55)))
+ (xaccTransSetIsClosingTxn clos #t)))
budget))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
Summary of changes:
libgnucash/engine/Recurrence.c | 2 +-
libgnucash/engine/Recurrence.h | 3 ++-
libgnucash/engine/gnc-budget.h | 4 ++++
libgnucash/engine/test/test-extras.scm | 5 ++++-
4 files changed, 11 insertions(+), 3 deletions(-)
More information about the gnucash-changes
mailing list