gnucash master: Multiple changes pushed
Christopher Lam
clam at code.gnucash.org
Thu Jan 12 20:53:09 EST 2023
Updated via https://github.com/Gnucash/gnucash/commit/6faaf511 (commit)
via https://github.com/Gnucash/gnucash/commit/fd007a0a (commit)
via https://github.com/Gnucash/gnucash/commit/6df866f8 (commit)
via https://github.com/Gnucash/gnucash/commit/fd37ee99 (commit)
from https://github.com/Gnucash/gnucash/commit/e9b1f466 (commit)
commit 6faaf51150edfc7f1bd3401b0542e602fc5042a0
Author: Christopher Lam <christopher.lck at gmail.com>
Date: Fri Jan 13 08:31:46 2023 +0800
gnc_ui_account_get_balance_limit_icon_name returns a new *char
gnc-tree-model-account.c must take ownership of string
diff --git a/gnucash/gnome-utils/gnc-tree-model-account.c b/gnucash/gnome-utils/gnc-tree-model-account.c
index 4da356212..0d993aa2f 100644
--- a/gnucash/gnome-utils/gnc-tree-model-account.c
+++ b/gnucash/gnome-utils/gnc-tree-model-account.c
@@ -834,7 +834,7 @@ gnc_tree_model_account_get_value (GtkTreeModel *tree_model,
case GNC_TREE_MODEL_ACCOUNT_COL_BALANCE_LIMIT:
g_value_init (value, G_TYPE_STRING);
string = gnc_ui_account_get_balance_limit_icon_name (account);
- g_value_set_string (value, string);
+ g_value_take_string (value, string);
break;
case GNC_TREE_MODEL_ACCOUNT_COL_CLEARED:
commit fd007a0af1a2e2d6ea197cd15d92b272165eed15
Merge: e9b1f4669 6df866f87
Author: Christopher Lam <christopher.lck at gmail.com>
Date: Fri Jan 13 07:45:31 2023 +0800
Merge branch 'maint'
diff --cc libgnucash/engine/test/utest-Account.cpp
index 60fb3888b,fb792148c..6e4a17661
--- a/libgnucash/engine/test/utest-Account.cpp
+++ b/libgnucash/engine/test/utest-Account.cpp
@@@ -1089,9 -1089,11 +1089,14 @@@ test_gnc_account_kvp_setters_getters (F
{
Account *account = xaccMallocAccount (gnc_account_get_book (fixture->acct));
xaccAccountSetType (account, ACCT_TYPE_EQUITY);
+ gnc_numeric h_balance = gnc_numeric_create (1700, 100);
+ gnc_numeric l_balance = gnc_numeric_create (1000, 100);
+ gnc_numeric balance_limit;
+ gnc_numeric post_balance = gnc_numeric_create (2345, 100);
+ gnc_numeric returned_post_balance;
+ time64 date = gnc_time (nullptr);
+ time64 returned_date;
+ int prev_months, prev_days;
// equity_type getter/setter
g_assert (xaccAccountGetIsOpeningBalance (account) == FALSE);
@@@ -1234,32 -1236,35 +1239,61 @@@
xaccAccountSetNotes (account, nullptr);
g_assert_cmpstr (xaccAccountGetNotes (account), ==, nullptr);
+ // Balance Limits getter/setter
+ g_assert (xaccAccountGetHigherBalanceLimit (account, &balance_limit) == false);
+ g_assert (xaccAccountGetLowerBalanceLimit (account, &balance_limit) == false);
+ g_assert (xaccAccountGetIncludeSubAccountBalances (account) == false);
+
+ xaccAccountSetHigherBalanceLimit (account, h_balance);
+ xaccAccountSetLowerBalanceLimit (account, l_balance);
+ xaccAccountSetIncludeSubAccountBalances (account, true);
+
+ g_assert (xaccAccountGetHigherBalanceLimit (account, &balance_limit) == true);
+ g_assert_cmpint (gnc_numeric_compare (h_balance, balance_limit), ==, 0);
+
+ g_assert (xaccAccountGetLowerBalanceLimit (account, &balance_limit) == true);
+ g_assert_cmpint (gnc_numeric_compare (l_balance, balance_limit), ==, 0);
+
+ g_assert (xaccAccountGetIncludeSubAccountBalances (account) == true);
+
+ xaccAccountSetIncludeSubAccountBalances (account, false);
+
+ xaccAccountClearHigherBalanceLimit (account);
+ xaccAccountClearLowerBalanceLimit (account);
+
+ g_assert (xaccAccountGetHigherBalanceLimit (account, &balance_limit) == false);
+ g_assert (xaccAccountGetLowerBalanceLimit (account, &balance_limit) == false);
+ g_assert (xaccAccountGetIncludeSubAccountBalances (account) == false);
+
+ // Reconcile getter/setter
+ date = date - (60*60*24*7); // -7 days
+ xaccAccountSetReconcileLastDate (account, date);
+ xaccAccountGetReconcileLastDate (account, &returned_date);
+ g_assert (date == returned_date);
+
+ date = date + (60*60*24*2); // +2 days
+ xaccAccountSetReconcilePostponeDate (account, date);
+ xaccAccountGetReconcilePostponeDate (account, &returned_date);
+ g_assert (date == returned_date);
+
+ g_assert (xaccAccountGetReconcilePostponeBalance (account, &returned_post_balance) == false);
+ xaccAccountSetReconcilePostponeBalance (account, post_balance);
+ g_assert (xaccAccountGetReconcilePostponeBalance (account, &returned_post_balance) == true);
+ g_assert_cmpint (gnc_numeric_compare (post_balance, returned_post_balance), ==, 0);
+
+ xaccAccountClearReconcilePostpone (account);
+ g_assert (xaccAccountGetReconcilePostponeBalance (account, &returned_post_balance) == false);
+
+ g_assert (xaccAccountGetReconcileLastInterval (account, &prev_months, &prev_days) == false);
+ xaccAccountSetReconcileLastInterval (account, 2, 6);
+ g_assert (xaccAccountGetReconcileLastInterval (account, &prev_months, &prev_days) == true);
+ g_assert (prev_months == 2);
+ g_assert (prev_days == 6);
+
+ g_assert (xaccAccountGetReconcileChildrenStatus (account) == false); //default
+ xaccAccountSetReconcileChildrenStatus (account, true);
+ g_assert (xaccAccountGetReconcileChildrenStatus (account) == true);
+
// STOCK_ACCOUNT tests from now on
xaccAccountSetType (account, ACCT_TYPE_STOCK);
commit 6df866f8769269ecab27889fa535a1341e8898c9
Author: Robert Fewell <14uBobIT at gmail.com>
Date: Thu Jan 12 14:34:30 2023 +0000
Add tests for the reconcile account functions
diff --git a/libgnucash/engine/test/utest-Account.cpp b/libgnucash/engine/test/utest-Account.cpp
index 093bc60a9..fb792148c 100644
--- a/libgnucash/engine/test/utest-Account.cpp
+++ b/libgnucash/engine/test/utest-Account.cpp
@@ -1089,6 +1089,11 @@ test_gnc_account_kvp_setters_getters (Fixture *fixture, gconstpointer pData)
{
Account *account = xaccMallocAccount (gnc_account_get_book (fixture->acct));
xaccAccountSetType (account, ACCT_TYPE_EQUITY);
+ gnc_numeric post_balance = gnc_numeric_create (2345, 100);
+ gnc_numeric returned_post_balance;
+ time64 date = gnc_time (nullptr);
+ time64 returned_date;
+ int prev_months, prev_days;
// equity_type getter/setter
g_assert (xaccAccountGetIsOpeningBalance (account) == FALSE);
@@ -1231,6 +1236,35 @@ test_gnc_account_kvp_setters_getters (Fixture *fixture, gconstpointer pData)
xaccAccountSetNotes (account, nullptr);
g_assert_cmpstr (xaccAccountGetNotes (account), ==, nullptr);
+ // Reconcile getter/setter
+ date = date - (60*60*24*7); // -7 days
+ xaccAccountSetReconcileLastDate (account, date);
+ xaccAccountGetReconcileLastDate (account, &returned_date);
+ g_assert (date == returned_date);
+
+ date = date + (60*60*24*2); // +2 days
+ xaccAccountSetReconcilePostponeDate (account, date);
+ xaccAccountGetReconcilePostponeDate (account, &returned_date);
+ g_assert (date == returned_date);
+
+ g_assert (xaccAccountGetReconcilePostponeBalance (account, &returned_post_balance) == false);
+ xaccAccountSetReconcilePostponeBalance (account, post_balance);
+ g_assert (xaccAccountGetReconcilePostponeBalance (account, &returned_post_balance) == true);
+ g_assert_cmpint (gnc_numeric_compare (post_balance, returned_post_balance), ==, 0);
+
+ xaccAccountClearReconcilePostpone (account);
+ g_assert (xaccAccountGetReconcilePostponeBalance (account, &returned_post_balance) == false);
+
+ g_assert (xaccAccountGetReconcileLastInterval (account, &prev_months, &prev_days) == false);
+ xaccAccountSetReconcileLastInterval (account, 2, 6);
+ g_assert (xaccAccountGetReconcileLastInterval (account, &prev_months, &prev_days) == true);
+ g_assert (prev_months == 2);
+ g_assert (prev_days == 6);
+
+ g_assert (xaccAccountGetReconcileChildrenStatus (account) == false); //default
+ xaccAccountSetReconcileChildrenStatus (account, true);
+ g_assert (xaccAccountGetReconcileChildrenStatus (account) == true);
+
// STOCK_ACCOUNT tests from now on
xaccAccountSetType (account, ACCT_TYPE_STOCK);
@@ -2555,26 +2589,7 @@ test_xaccAccountType_Compatibility (void)
g_assert_cmpint (check2->hits, ==, 1);
g_free (msg2);
}
-/* More KVP getters & setters
- * xaccAccountGetReconcileLastDate
- * xaccAccountSetReconcileLastDate
- * xaccAccountGetReconcilePostponeDate
- * xaccAccountSetReconcilePostponeDate
- * xaccAccountGetReconcilePostponeBalance
- * xaccAccountSetReconcilePostponeBalance
- * xaccAccountClearReconcilePostpone
- * xaccAccountGetAutoInterestXfer
- * xaccAccountSetAutoInterestXfer
- * xaccAccountGetLastNum
- * xaccAccountSetLastNum
- * xaccAccountSetReconcileChildrenStatus
- * xaccAccountGetReconcileChildrenStatus
- * xaccAccountGetReconcileLastInterval
- * xaccAccountSetReconcileLastInterval
- * dxaccAccountSetPriceSrc
- * dxaccAccountSetQuoteTZ
- * dxaccAccountGetQuoteTZ
- */
+
/* finder_help_function
static void
finder_help_function (const Account *acc, const char *description,// 3
commit fd37ee997d7cef61db82cdd226ca8cac31f4be75
Author: Robert Fewell <14uBobIT at gmail.com>
Date: Thu Jan 12 14:32:14 2023 +0000
Fix getting xaccAccountGetReconcilePostponeBalance
Change the G_VALUE from a INT64 to BOXED.
diff --git a/libgnucash/engine/Account.cpp b/libgnucash/engine/Account.cpp
index c9fe32b7a..81a5ea1f7 100644
--- a/libgnucash/engine/Account.cpp
+++ b/libgnucash/engine/Account.cpp
@@ -4878,7 +4878,7 @@ xaccAccountGetReconcilePostponeBalance (const Account *acc,
g_return_val_if_fail(GNC_IS_ACCOUNT(acc), FALSE);
qof_instance_get_path_kvp (QOF_INSTANCE(acc), &v,
{KEY_RECONCILE_INFO, KEY_POSTPONE, "balance"});
- if (G_VALUE_HOLDS_INT64 (&v))
+ if (G_VALUE_HOLDS_BOXED (&v))
{
bal = *(gnc_numeric*)g_value_get_boxed (&v);
if (bal.denom)
Summary of changes:
gnucash/gnome-utils/gnc-tree-model-account.c | 2 +-
libgnucash/engine/Account.cpp | 2 +-
libgnucash/engine/test/utest-Account.cpp | 55 ++++++++++++++++++----------
3 files changed, 37 insertions(+), 22 deletions(-)
More information about the gnucash-changes
mailing list