gnucash stable: Multiple changes pushed

John Ralls jralls at code.gnucash.org
Mon Sep 23 14:47:23 EDT 2024


Updated	 via  https://github.com/Gnucash/gnucash/commit/7b34971c (commit)
	 via  https://github.com/Gnucash/gnucash/commit/c584337c (commit)
	from  https://github.com/Gnucash/gnucash/commit/63714e5e (commit)



commit 7b34971c8777e0f1326831d57f935304c2391e95
Author: John Ralls <jralls at ceridwen.us>
Date:   Sun Sep 22 16:15:52 2024 -0700

    Gnc-options-date: Make the accounting period struct tm empty...
    
    If the accounting period start-choice is anything but absolute instead
    of matching the accounting period month and day to the present month and
    day. The latter is a non-obvious hack that depends on
    gnc_accounting_period_fiscal_start() returning the present day if it's
    not set.

diff --git a/libgnucash/engine/gnc-option-date.cpp b/libgnucash/engine/gnc-option-date.cpp
index 51d7c4a65a..ee3c72b0d7 100644
--- a/libgnucash/engine/gnc-option-date.cpp
+++ b/libgnucash/engine/gnc-option-date.cpp
@@ -23,6 +23,7 @@
 #include "gnc-option-date.hpp"
 #include <array>
 #include "gnc-datetime.hpp"
+#include <gnc-prefs.h>
 #include <iostream>
 #include <cassert>
 #include <algorithm>
@@ -496,14 +497,10 @@ gnc_relative_date_to_time64(RelativeDatePeriod period)
     if (period == RelativeDatePeriod::TODAY)
         return static_cast<time64>(now_t);
     auto now{static_cast<tm>(now_t)};
-    auto acct_per{static_cast<tm>(GncDateTime(gnc_accounting_period_fiscal_start()))};
-
-    if (acct_per.tm_mon == now.tm_mon && acct_per.tm_mday == now.tm_mday)
-    {
-        //No set accounting period, use the calendar year
-        acct_per.tm_mon = 0;
-        acct_per.tm_mday = 0;
-    }
+    struct tm acct_per{};
+    if (gnc_prefs_get_bool (GNC_PREFS_GROUP_ACCT_SUMMARY,
+                            GNC_PREF_START_CHOICE_ABS))
+        acct_per = static_cast<tm>(GncDateTime(gnc_accounting_period_fiscal_start()));
 
     switch(reldate_offset(period))
     {

commit c584337c3a0136ac078b9f7fd25d90724271026f
Author: John Ralls <jralls at ceridwen.us>
Date:   Sun Sep 22 16:12:54 2024 -0700

    Bug 799395 - relative date offset quarters occasionally wrong
    
    If the accounting period start month and the present month are the
    same the present month would be offset by 3. Don't do that.

diff --git a/libgnucash/engine/gnc-option-date.cpp b/libgnucash/engine/gnc-option-date.cpp
index 68d4454653..51d7c4a65a 100644
--- a/libgnucash/engine/gnc-option-date.cpp
+++ b/libgnucash/engine/gnc-option-date.cpp
@@ -528,7 +528,7 @@ gnc_relative_date_to_time64(RelativeDatePeriod period)
             break;
         case RelativeDateOffset::QUARTER:
         {
-            auto delta = (now.tm_mon > acct_per.tm_mon ?
+            auto delta = (now.tm_mon >= acct_per.tm_mon ?
                           ( now.tm_mon - acct_per.tm_mon) % 3 :
                           3 - ((acct_per.tm_mon - now.tm_mon) % 3));
             now.tm_mon = now.tm_mon - delta;



Summary of changes:
 libgnucash/engine/gnc-option-date.cpp | 15 ++++++---------
 1 file changed, 6 insertions(+), 9 deletions(-)



More information about the gnucash-changes mailing list