gnucash maint: Multiple changes pushed

Christopher Lam clam at code.gnucash.org
Mon Dec 13 09:53:21 EST 2021


Updated	 via  https://github.com/Gnucash/gnucash/commit/d3a7d3f1 (commit)
	 via  https://github.com/Gnucash/gnucash/commit/c3eaff9b (commit)
	from  https://github.com/Gnucash/gnucash/commit/793c8735 (commit)



commit d3a7d3f104f3e04d088041fde6bc6a8a51c902dd
Author: Christopher Lam <christopher.lck at gmail.com>
Date:   Mon Dec 13 22:51:13 2021 +0800

    [ifrs-cost-basis] slight reordering of columns
    
    from https://bugs.gnucash.org/show_bug.cgi?id=797796#c228

diff --git a/gnucash/report/reports/standard/ifrs-cost-basis.scm b/gnucash/report/reports/standard/ifrs-cost-basis.scm
index 5752ad239..fbd36ca9a 100644
--- a/gnucash/report/reports/standard/ifrs-cost-basis.scm
+++ b/gnucash/report/reports/standard/ifrs-cost-basis.scm
@@ -378,9 +378,9 @@ the split action field to detect capitalized fees on stock activity")
                    "proceeds-val" "proceeds-cost" "conv-purchase-val"
                    "conv-purchase-cost" "conv-dividends"
                    "conv-proceeds-val" "conv-proceeds-cost"
-                   "average-cost-basis/unit-for-sale" "average-cost-basis-of-sale"
                    "cumulative-average-cost-basis"
-                   "gain-post-commission" "gain-pre-commission" "net-proceeds"
+                   "average-cost-basis/unit-for-sale" "average-cost-basis-of-sale"
+                   "net-proceeds" "gain-post-commission" "gain-pre-commission"
                    "cumul-gross-profit" "cumul-net-profit" "cumul-tot-return"))
 
       (let lp ((splits splits)
@@ -502,12 +502,12 @@ the split action field to detect capitalized fees on stock activity")
                       (to-cell (to-report-currency conv-dividends))
                       (to-cell (to-report-currency conv-proceeds-value))
                       (to-cell (to-report-currency conv-proceeds-cost))
+                      (to-cell (to-report-currency cumul-average-cost-basis))
                       (to-cell (to-report-currency average-cost-basis/unit-for-sale))
                       (to-cell (to-report-currency (M- average-cost-basis-of-sale)))
-                      (to-cell (to-report-currency cumul-average-cost-basis))
+                      (to-cell (to-report-currency net-proceeds))
                       (to-cell (to-report-currency gain-post-commission))
                       (to-cell (to-report-currency gain-pre-commission))
-                      (to-cell (to-report-currency net-proceeds))
                       (to-cell (to-report-currency new-gross-profit))
                       (to-cell (to-report-currency new-net-profit))
                       (to-cell (to-report-currency new-tot-return))))
diff --git a/gnucash/report/reports/standard/test/test-ifrs-cost-basis.scm b/gnucash/report/reports/standard/test/test-ifrs-cost-basis.scm
index f4c7d2c2d..a64441b0d 100644
--- a/gnucash/report/reports/standard/test/test-ifrs-cost-basis.scm
+++ b/gnucash/report/reports/standard/test/test-ifrs-cost-basis.scm
@@ -268,59 +268,59 @@
 
         (test-equal "BUY 50 SPY"
           '("12/11/19" "Buy SPY" "50 SPY" "150 SPY" "Buy" "CAD" "C$1.0000"
-            "C$16,000.00" "C$9.95" "C$16,000.00" "C$9.95" "C$200.10"
-            "C$36,019.90" "C$0.00" "C$0.00" "C$0.00")
+            "C$16,000.00" "C$9.95" "C$16,000.00" "C$9.95" "C$36,019.90"
+            "C$200.10" "C$0.00" "C$0.00" "C$0.00")
           (sxml->table-row-col sxml 1 2 #f))
 
         (test-equal "Sell 75 SPY"
           '("03/18/20" "Sell SPY" "-75 SPY" "75 SPY" "Sell" "CAD" "C$1.0000"
-            "C$12,000.00" "C$9.95" "C$12,000.00" "C$9.95" "C$240.13"
-            "C$18,009.95" "C$18,009.95" "-C$6,019.90" "-C$6,009.95"
-            "C$11,990.05" "-C$6,009.95" "-C$6,019.90" "-C$6,019.90")
+            "C$12,000.00" "C$9.95" "C$12,000.00" "C$9.95" "C$18,009.95"
+            "C$240.13" "C$18,009.95" "C$11,990.05" "-C$6,019.90"
+            "-C$6,009.95" "-C$6,009.95" "-C$6,019.90" "-C$6,019.90")
           (sxml->table-row-col sxml 1 3 #f))
 
         (test-equal "BUY 250 SPY"
           '("04/01/20" "Buy SPY" "250 SPY" "325 SPY" "Buy" "CAD" "C$1.0000"
-            "C$42,000.00" "C$9.95" "C$42,000.00" "C$9.95" "C$240.13"
-            "C$60,019.90" "-C$6,009.95" "-C$6,019.90" "-C$6,019.90")
+            "C$42,000.00" "C$9.95" "C$42,000.00" "C$9.95" "C$60,019.90"
+            "C$240.13" "-C$6,009.95" "-C$6,019.90" "-C$6,019.90")
           (sxml->table-row-col sxml 1 4 #f))
 
         (test-equal "Return Capital $2500"
           '("04/16/20" "Return of Capital" "0 SPY" "325 SPY" "Return of Capital"
-            "CAD" "C$1.0000" "-C$2,500.00" "-C$2,500.00" "C$184.68"
-            "C$57,519.90" "-C$6,009.95" "-C$6,019.90" "-C$6,019.90")
+            "CAD" "C$1.0000" "-C$2,500.00" "-C$2,500.00" "C$57,519.90"
+            "C$184.68" "-C$6,009.95" "-C$6,019.90" "-C$6,019.90")
           (sxml->table-row-col sxml 1 5 #f))
 
         (test-equal "BUY 125 SPY"
           '("05/02/20" "Buy spy" "125 SPY" "450 SPY" "Buy" "CAD" "C$1.0000"
-            "C$47,500.00" "C$0.00" "C$47,500.00" "C$0.00" "C$176.98"
-            "C$105,019.90" "-C$6,009.95" "-C$6,019.90" "-C$6,019.90")
+            "C$47,500.00" "C$0.00" "C$47,500.00" "C$0.00" "C$105,019.90"
+            "C$176.98" "-C$6,009.95" "-C$6,019.90" "-C$6,019.90")
           (sxml->table-row-col sxml 1 6 #f))
 
         (test-equal "2:1 split"
-          '("05/11/20" "stock split" "450 SPY" "900 SPY" "Stock split"
-            "CAD" "C$1.0000" "C$233.38" "C$105,019.90" "-C$6,009.95"
-            "-C$6,019.90" "-C$6,019.90")
+          ' ("05/11/20" "stock split" "450 SPY" "900 SPY" "Stock split"
+             "CAD" "C$1.0000" "C$105,019.90" "C$233.38" "-C$6,009.95"
+             "-C$6,019.90" "-C$6,019.90")
           (sxml->table-row-col sxml 1 7 #f))
 
         (test-equal "sell 135 SPY"
           '("05/21/20" "Sell SPY" "-135 SPY" "765 SPY" "Sell" "CAD" "C$1.0000"
-            "C$21,500.00" "C$9.95" "C$21,500.00" "C$9.95" "C$116.69"
-            "C$15,752.98" "C$89,266.92" "C$5,737.06" "C$5,747.02"
-            "C$21,490.05" "-C$262.94" "-C$282.84" "-C$282.84")
+            "C$21,500.00" "C$9.95" "C$21,500.00" "C$9.95" "C$89,266.92"
+            "C$116.69" "C$15,752.98" "C$21,490.05" "C$5,737.06"
+            "C$5,747.02" "-C$262.94" "-C$282.84" "-C$282.84")
           (sxml->table-row-col sxml 1 8 #f))
 
         (test-equal "BUY 150 SPY"
           '("06/03/20" "Buy spy" "150 SPY" "915 SPY" "Buy" "CAD" "C$1.0000"
-            "C$21,000.00" "C$0.00" "C$21,000.00" "C$0.00" "C$116.69"
-            "C$110,266.92" "-C$262.94" "-C$282.84" "-C$282.84")
+            "C$21,000.00" "C$0.00" "C$21,000.00" "C$0.00" "C$110,266.92"
+            "C$116.69" "-C$262.94" "-C$282.84" "-C$282.84")
           (sxml->table-row-col sxml 1 9 #f))
 
         (test-equal "sell 915 SPY close long"
-          '("06/10/20" "Sell SPY" "-915 SPY" "0 SPY" "Sell" "CAD"
-            "C$1.0000" "C$128,100.00" "C$9.95" "C$128,100.00" "C$9.95"
-            "C$120.51" "C$110,266.92" "C$0.00" "C$17,823.14" "C$17,833.08"
-            "C$128,090.05" "C$17,570.15" "C$17,540.30" "C$17,540.30")
+          ' ("06/10/20" "Sell SPY" "-915 SPY" "0 SPY" "Sell" "CAD"
+             "C$1.0000" "C$128,100.00" "C$9.95" "C$128,100.00" "C$9.95"
+             "C$0.00" "C$120.51" "C$110,266.92" "C$128,090.05" "C$17,823.14"
+             "C$17,833.08" "C$17,570.15" "C$17,540.30" "C$17,540.30")
           (sxml->table-row-col sxml 1 10 #f))
 
         (test-equal "short-sell 85 SPY"
@@ -332,21 +332,21 @@
         (test-equal "short-sell 65 SPY"
           '("06/15/20" "Sell SPY Short" "-65 SPY" "-150 SPY" "Short Sell"
             "CAD" "C$1.0000" "-C$11,050.00" "C$9.95" "-C$11,050.00" "C$9.95"
-            "C$139.88" "-C$22,930.10" "C$17,570.15" "C$17,540.30" "C$17,540.30")
+            "-C$22,930.10" "C$139.88" "C$17,570.15" "C$17,540.30" "C$17,540.30")
           (sxml->table-row-col sxml 1 12 #f))
 
         (test-equal "buy 50 SPY short"
           '("06/18/20" "Buy SPY Close Short" "50 SPY" "-100 SPY" "Cover Buy"
             "CAD" "C$1.0000" "-C$5,000.00" "C$9.95" "-C$5,000.00" "C$9.95"
-            "C$152.87" "-C$7,643.37" "-C$15,286.73" "C$2,633.42" "C$2,643.37"
-            "-C$5,009.95" "C$20,213.52" "C$20,173.72" "C$20,173.72")
+            "-C$15,286.73" "C$152.87" "-C$7,643.37" "-C$5,009.95" "C$2,633.42"
+            "C$2,643.37" "C$20,213.52" "C$20,173.72" "C$20,173.72")
           (sxml->table-row-col sxml 1 13 #f))
 
         (test-equal "BUY 100 SPY close short"
           '("06/20/20" "Buy SPY Close Short" "100 SPY" "0 SPY" "Cover Buy"
             "CAD" "C$1.0000" "-C$8,000.00" "C$4.98" "-C$8,000.00" "C$4.98"
-            "C$152.87" "-C$15,286.73" "C$0.00" "C$7,281.75" "C$7,286.73"
-            "-C$8,004.98" "C$27,500.25" "C$27,455.47" "C$27,455.47")
+            "C$0.00" "C$152.87" "-C$15,286.73" "-C$8,004.98" "C$7,281.75"
+            "C$7,286.73" "C$27,500.25" "C$27,455.47" "C$27,455.47")
           (sxml->table-row-col sxml 1 14 #f))
 
         (test-equal "BUY 100 SPY"

commit c3eaff9bb2c704a3367fe5eb4f790e6c9925b222
Author: Christopher Lam <christopher.lck at gmail.com>
Date:   Thu Dec 9 12:57:45 2021 +0800

    [account.cpp] gnc_account_and_descendants_empty: don't copy children

diff --git a/libgnucash/engine/Account.cpp b/libgnucash/engine/Account.cpp
index ee375d304..e1e8e0f3d 100644
--- a/libgnucash/engine/Account.cpp
+++ b/libgnucash/engine/Account.cpp
@@ -4011,15 +4011,14 @@ as well, use gnc_account_and_descendants_empty.");
 gboolean gnc_account_and_descendants_empty (Account *acc)
 {
     g_return_val_if_fail (GNC_IS_ACCOUNT (acc), FALSE);
-    if (xaccAccountGetSplitList (acc)) return FALSE;
-    auto empty = TRUE;
-    auto *children = gnc_account_get_children (acc);
-    for (auto *n = children; n && empty; n = n->next)
+    auto priv = GET_PRIVATE (acc);
+    if (priv->splits != nullptr) return FALSE;
+    for (auto *n = priv->children; n; n = n->next)
     {
-        empty = gnc_account_and_descendants_empty ((Account*)n->data);
+	if (!gnc_account_and_descendants_empty (static_cast<Account*>(n->data)))
+	    return FALSE;
     }
-    g_list_free (children);
-    return empty;
+    return TRUE;
 }
 
 LotList *



Summary of changes:
 .../report/reports/standard/ifrs-cost-basis.scm    |  8 ++--
 .../reports/standard/test/test-ifrs-cost-basis.scm | 56 +++++++++++-----------
 libgnucash/engine/Account.cpp                      | 13 +++--
 3 files changed, 38 insertions(+), 39 deletions(-)



More information about the gnucash-changes mailing list