gnucash maint: Multiple changes pushed
Christopher Lam
clam at code.gnucash.org
Tue Oct 12 21:10:37 EDT 2021
Updated via https://github.com/Gnucash/gnucash/commit/76378011 (commit)
via https://github.com/Gnucash/gnucash/commit/ff0c02db (commit)
via https://github.com/Gnucash/gnucash/commit/203432c4 (commit)
via https://github.com/Gnucash/gnucash/commit/2ace810e (commit)
via https://github.com/Gnucash/gnucash/commit/8940d9d8 (commit)
via https://github.com/Gnucash/gnucash/commit/1b0bfa5d (commit)
from https://github.com/Gnucash/gnucash/commit/1354698b (commit)
commit 763780114a5920ac7b6dab64ced227a9fd0136e1
Merge: 1354698b2 ff0c02dba
Author: Christopher Lam <christopher.lck at gmail.com>
Date: Wed Oct 13 09:08:51 2021 +0800
Merge branch 'price_and_reconcile' into maint #1165
commit ff0c02dba5cc9e91389c09a1cb88b207098f8bd6
Author: Christopher Lam <christopher.lck at gmail.com>
Date: Tue Oct 12 18:22:49 2021 +0800
[reconcile-view][bug] dr/cr query tests amount instead of value
Because split->amount and split->value are generally of equal sign,
EXCEPT in stock transactions whereby split->value can be zero and
split->amount is non-zero. e.g. a stock split transaction.
Querying the split amount instead will allow stock accounts with
stock splits to be reconciled.
diff --git a/gnucash/gnome/reconcile-view.c b/gnucash/gnome/reconcile-view.c
index 489ff7a2b..289ca2f8d 100644
--- a/gnucash/gnome/reconcile-view.c
+++ b/gnucash/gnome/reconcile-view.c
@@ -313,6 +313,7 @@ gnc_reconcile_view_new (Account *account, GNCReconcileViewType type,
GList *accounts = NULL;
GList *splits;
Query *query;
+ QofNumericMatch sign;
g_return_val_if_fail (account, NULL);
g_return_val_if_fail ((type == RECLIST_DEBIT) ||
@@ -345,15 +346,11 @@ gnc_reconcile_view_new (Account *account, GNCReconcileViewType type,
g_list_free (accounts);
- /* limit the matches to CREDITs and DEBITs only, depending on the type */
- if (type == RECLIST_CREDIT)
- xaccQueryAddValueMatch(query, gnc_numeric_zero (),
- QOF_NUMERIC_MATCH_CREDIT,
- QOF_COMPARE_GTE, QOF_QUERY_AND);
- else
- xaccQueryAddValueMatch(query, gnc_numeric_zero (),
- QOF_NUMERIC_MATCH_DEBIT,
- QOF_COMPARE_GTE, QOF_QUERY_AND);
+ sign = (type == RECLIST_CREDIT) ?
+ QOF_NUMERIC_MATCH_CREDIT : QOF_NUMERIC_MATCH_DEBIT;
+
+ xaccQueryAddNumericMatch (query, gnc_numeric_zero (), sign, QOF_COMPARE_GTE,
+ QOF_QUERY_AND, SPLIT_AMOUNT, NULL);
/* limit the matches only to Cleared and Non-reconciled splits */
xaccQueryAddClearedMatch (query, CLEARED_NO | CLEARED_CLEARED, QOF_QUERY_AND);
commit 203432c436d504ac86e2b392b39df7aa3aa11eae
Author: Christopher Lam <christopher.lck at gmail.com>
Date: Tue Oct 12 04:14:10 2021 +0800
[split-register-model.c] Hide price==1 for zero-amount splits
mainly of interest in zero-amount zero-value splits in the stock
register eg dividend splits.
diff --git a/gnucash/register/ledger-core/split-register-model.c b/gnucash/register/ledger-core/split-register-model.c
index c2146d4a7..c5f955a0a 100644
--- a/gnucash/register/ledger-core/split-register-model.c
+++ b/gnucash/register/ledger-core/split-register-model.c
@@ -1389,11 +1389,12 @@ gnc_split_register_get_price_entry (VirtualLocation virt_loc,
split = gnc_split_register_get_split (reg, virt_loc.vcell_loc);
- price = xaccSplitGetSharePrice (split);
- curr = xaccTransGetCurrency (xaccSplitGetParent (split));
- if (gnc_numeric_zero_p (price))
+ if (gnc_numeric_zero_p (xaccSplitGetAmount(split)) ||
+ gnc_numeric_zero_p (xaccSplitGetValue(split)))
return NULL;
+ price = xaccSplitGetSharePrice (split);
+ curr = xaccTransGetCurrency (xaccSplitGetParent (split));
return xaccPrintAmount (price, gnc_default_price_print_info (curr));
}
commit 2ace810e055249f5046c9226058d019abf9b4d5d
Author: Christopher Lam <christopher.lck at gmail.com>
Date: Tue Oct 12 04:14:55 2021 +0800
[split-register-model.c] more efficient acct->full_names constructor
don't repeatedly allocate
diff --git a/gnucash/register/ledger-core/split-register-model.c b/gnucash/register/ledger-core/split-register-model.c
index 04b211348..c2146d4a7 100644
--- a/gnucash/register/ledger-core/split-register-model.c
+++ b/gnucash/register/ledger-core/split-register-model.c
@@ -32,6 +32,7 @@
#include "gnc-prefs.h"
#include "gnc-ui.h"
#include "gnc-uri-utils.h"
+#include "gnc-glib-utils.h"
#include "gnc-filepath-utils.h"
#include "gnc-warnings.h"
#include "doclinkcell.h"
@@ -2191,37 +2192,27 @@ gnc_split_register_confirm (VirtualLocation virt_loc, gpointer user_data)
if (protected_trans_cell)
{
- GList* node;
+ GList* acc_g_list = NULL;
gchar* acc_list = NULL;
gchar* message_format;
- for (node = xaccTransGetSplitList (trans); node; node = node->next)
+ for (GList *node = xaccTransGetSplitList (trans); node; node = node->next)
{
Split* split = node->data;
-
if (xaccSplitGetReconcile (split) == YREC)
{
- Account* acc = xaccSplitGetAccount (split);
- gchar* name = gnc_account_get_full_name (acc);
-
- if (acc_list == NULL)
- acc_list = g_strconcat ("\n", name, NULL);
- else
- {
- gchar* acc_list_copy = g_strdup (acc_list);
- g_free (acc_list);
- acc_list = g_strconcat (acc_list_copy, "\n", name, NULL);
- g_free (acc_list_copy);
- }
- g_free (name);
+ gchar* name = gnc_account_get_full_name (xaccSplitGetAccount (split));
+ acc_g_list = g_list_prepend (acc_g_list, name);
}
}
+ acc_list = gnc_g_list_stringjoin (acc_g_list, "\n");
title = _ ("Change transaction containing a reconciled split?");
message_format =
_ ("The transaction you are about to change contains reconciled splits in the following accounts:\n%s"
"\n\nAre you sure you want to continue with this change?");
message = g_strdup_printf (message_format, acc_list);
+ g_list_free_full (acc_g_list, g_free);
g_free (acc_list);
}
commit 8940d9d8c603443d8539cc47b65a36e43296b182
Author: Christopher Lam <christopher.lck at gmail.com>
Date: Tue Oct 12 04:14:33 2021 +0800
[split-register-model.c] prepend parent account, faster
it's only required to accumulate account amounts. acct order is
irrelevant.
diff --git a/gnucash/register/ledger-core/split-register-model.c b/gnucash/register/ledger-core/split-register-model.c
index 6124da164..04b211348 100644
--- a/gnucash/register/ledger-core/split-register-model.c
+++ b/gnucash/register/ledger-core/split-register-model.c
@@ -89,7 +89,7 @@ gnc_split_register_get_rbaln (VirtualLocation virt_loc, gpointer user_data,
if (subaccounts)
{
children = gnc_account_get_descendants (account);
- children = g_list_append (children, account);
+ children = g_list_prepend (children, account);
}
/* Get the row number we're on, then start with the first row. */
@@ -1601,7 +1601,7 @@ get_trans_total_value_subaccounts (SplitRegister* reg, Transaction* trans)
return total;
children = gnc_account_get_descendants (parent);
- children = g_list_append (children, parent);
+ children = g_list_prepend (children, parent);
for (child = children; child; child = child->next)
{
commit 1b0bfa5da72c978c476c5592c75a27e894803c45
Author: Christopher Lam <christopher.lck at gmail.com>
Date: Sat Oct 9 20:11:07 2021 +0800
[reports] QofQuery must be qof_query_destroyed
diff --git a/gnucash/report/reports/standard/ifrs-cost-basis.scm b/gnucash/report/reports/standard/ifrs-cost-basis.scm
index af35c3f54..78f8d2846 100644
--- a/gnucash/report/reports/standard/ifrs-cost-basis.scm
+++ b/gnucash/report/reports/standard/ifrs-cost-basis.scm
@@ -194,11 +194,6 @@ commissions in cumulative average cost and gain/loss after commission")
(define cap-purch-costs? (opt-val gnc:pagename-general optname-cap-purch-costs))
(define document (gnc:make-html-document))
- (define (elt->cell split)
- (gnc:html-markup-anchor
- (gnc:split-anchor-text split)
- (amount->monetary (xaccSplitGetAmount split))))
-
(define large 10000000)
(define (get-fx db from to time)
(/ (gnc-pricedb-convert-balance-nearest-price-t64 db large from to time)
@@ -232,7 +227,9 @@ commissions in cumulative average cost and gain/loss after commission")
(let ((query (qof-query-create-for-splits)))
(qof-query-set-book query (gnc-get-current-book))
(xaccQueryAddSingleAccountMatch query stock-acct QOF-QUERY-AND)
- (xaccQueryGetSplitsUniqueTrans query))))
+ (let ((result (xaccQueryGetSplitsUniqueTrans query)))
+ (qof-query-destroy query)
+ result))))
(define (to-commodity amt)
(if format-cells
diff --git a/gnucash/report/reports/standard/lot-viewer.scm b/gnucash/report/reports/standard/lot-viewer.scm
index 4ffe9c040..0a09f0558 100644
--- a/gnucash/report/reports/standard/lot-viewer.scm
+++ b/gnucash/report/reports/standard/lot-viewer.scm
@@ -108,7 +108,9 @@
query (logand CLEARED-ALL (lognot CLEARED-VOIDED)) QOF-QUERY-AND)
(xaccQueryAddSingleAccountMatch query account QOF-QUERY-AND)
(xaccQueryAddDateMatchTT query #t from-date #t to-date QOF-QUERY-AND)
- (filter desc-filter? (qof-query-run query))))
+ (let ((result (filter desc-filter? (qof-query-run query))))
+ (qof-query-destroy query)
+ result)))
(transactions
(sort-and-delete-duplicates
(map xaccSplitGetParent splits)
diff --git a/gnucash/report/reports/standard/test/test-register.scm b/gnucash/report/reports/standard/test/test-register.scm
index 12d6d1d77..9805e5f6c 100644
--- a/gnucash/report/reports/standard/test/test-register.scm
+++ b/gnucash/report/reports/standard/test/test-register.scm
@@ -63,7 +63,8 @@
(qof-query-set-book query (gnc-get-current-book))
(xaccQueryAddAccountMatch query (list bank)
QOF-GUID-MATCH-ANY QOF-QUERY-AND)
- (set-option options "__reg" "query" (gnc-query2scm query)))
+ (set-option options "__reg" "query" (gnc-query2scm query))
+ (qof-query-destroy query))
(let ((sxml (options->sxml options "basic")))
;; this is a simplistic test - counts the number of populated
Summary of changes:
gnucash/gnome/reconcile-view.c | 15 ++++------
.../register/ledger-core/split-register-model.c | 34 +++++++++-------------
.../report/reports/standard/ifrs-cost-basis.scm | 9 ++----
gnucash/report/reports/standard/lot-viewer.scm | 4 ++-
.../report/reports/standard/test/test-register.scm | 3 +-
5 files changed, 27 insertions(+), 38 deletions(-)
More information about the gnucash-changes
mailing list