gnucash maint: Multiple changes pushed
John Ralls
jralls at code.gnucash.org
Fri Mar 22 16:31:29 EDT 2019
Updated via https://github.com/Gnucash/gnucash/commit/d209fec4 (commit)
via https://github.com/Gnucash/gnucash/commit/67c41aba (commit)
via https://github.com/Gnucash/gnucash/commit/d711cc35 (commit)
from https://github.com/Gnucash/gnucash/commit/ee9f1d5e (commit)
commit d209fec4c99d5d8de28bbc26e05792da48759bc3
Merge: 67c41aba5 d711cc35f
Author: John Ralls <jralls at ceridwen.us>
Date: Fri Mar 22 12:15:00 2019 -0700
Merge Chris Lam's 'maint-fix-639049' into maint.
commit 67c41aba560a34fa7cb88166e7ee1d17c957b228
Author: John Ralls <jralls at ceridwen.us>
Date: Fri Mar 22 12:14:38 2019 -0700
Add new balance-forecast.scm to potfiles.in.
diff --git a/po/POTFILES.in b/po/POTFILES.in
index 674b75b6f..742e71a18 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -466,6 +466,7 @@ gnucash/report/standard-reports/account-piecharts.scm
gnucash/report/standard-reports/account-summary.scm
gnucash/report/standard-reports/advanced-portfolio.scm
gnucash/report/standard-reports/average-balance.scm
+gnucash/report/standard-reports/balance-forecast.scm
gnucash/report/standard-reports/balance-sheet.scm
gnucash/report/standard-reports/budget-balance-sheet.scm
gnucash/report/standard-reports/budget-barchart.scm
commit d711cc35f80ff0d483fc174cca17fd3ea4b56b64
Author: christopherlam <christopher.lck at gmail.com>
Date: Thu Mar 21 18:52:23 2019 +0800
Bug 639049 - Asset Barchart Report includes also the first day of next month transactions
If the original date is an end-of-month date, we take it as an
indicator they always want monthdelta dates to be end-of-months.
This works for monthly/quarterly/halfyearly/annual.
Addendum to commit 65bfeaf5de8c52c77ba0f4e8f4d5d6ceeb45b33e which was
deemed to be an incomplete fix.
Also I'd forgotten to activate a test in test-date-utilities. Enable it.
diff --git a/libgnucash/app-utils/date-utilities.scm b/libgnucash/app-utils/date-utilities.scm
index e918c0177..c83b518dd 100644
--- a/libgnucash/app-utils/date-utilities.scm
+++ b/libgnucash/app-utils/date-utilities.scm
@@ -215,6 +215,13 @@
(define (gnc:time64-ge-date t1 t2)
(gnc:time64-le-date t2 t1))
+;; returns #t if adding 1 to mday causes a month change.
+(define (end-month? date)
+ (let ((nextdate (gnc-localtime date)))
+ (set-tm:mday nextdate (1+ (tm:mday nextdate)))
+ (not (= (tm:mon (gnc-localtime (gnc-mktime nextdate)))
+ (tm:mon (gnc-localtime date))))))
+
(define (incdate-months date nmonths)
(let* ((new-date (gnc-localtime date))
(newmonth (+ (tm:mon new-date) nmonths))
@@ -225,9 +232,14 @@
(let loop ((new-mday (tm:mday new-date)))
(set-tm:mday new-date new-mday)
(let ((res (gnc-mktime new-date)))
- (if (= new-month-proper (tm:mon (gnc-localtime res)))
- res
- (loop (1- new-mday)))))))
+ (cond
+ ;; next date causes a date slip. reduce mday.
+ ((not (= new-month-proper (tm:mon (gnc-localtime res))))
+ (loop (1- new-mday)))
+ ;; orig date is month-end. ensure all dates are month-ends.
+ ((and (end-month? date) (not (end-month? res)))
+ (loop (1+ new-mday)))
+ (else res))))))
;; Build a list of time intervals.
;;
diff --git a/libgnucash/app-utils/test/test-date-utilities.scm b/libgnucash/app-utils/test/test-date-utilities.scm
index 2f548e793..a495d9c75 100644
--- a/libgnucash/app-utils/test/test-date-utilities.scm
+++ b/libgnucash/app-utils/test/test-date-utilities.scm
@@ -8,6 +8,7 @@
(test-runner-factory gnc:test-runner)
(test-begin "test-date-utilities.scm")
(test-weeknum-calculator)
+ (test-make-date-list)
(test-date-get-quarter-string)
(test-end "test-date-utilities.scm"))
@@ -77,6 +78,17 @@
(create-time64 '(1970 1 15 0 0 1))
WeekDelta))
+ (test-equal "make-date-list start 30-nov monthly. all dates are month-ends."
+ (list (create-time64 '(1970 11 30 0 0 1))
+ (create-time64 '(1970 12 31 0 0 1))
+ (create-time64 '(1971 1 31 0 0 1))
+ (create-time64 '(1971 2 28 0 0 1))
+ (create-time64 '(1971 3 15 0 0 1)))
+ (gnc:make-date-list
+ (create-time64 '(1970 11 30 0 0 1))
+ (create-time64 '(1971 3 15 0 0 1))
+ MonthDelta))
+
(test-equal "make-date-list 31-dec-1970 to 15-4-1972 monthly including leapyear"
(list (create-time64 '(1970 12 31 0 0 1))
(create-time64 '(1971 1 31 0 0 1))
Summary of changes:
libgnucash/app-utils/date-utilities.scm | 18 +++++++++++++++---
libgnucash/app-utils/test/test-date-utilities.scm | 12 ++++++++++++
po/POTFILES.in | 1 +
3 files changed, 28 insertions(+), 3 deletions(-)
More information about the gnucash-changes
mailing list