[balsheet-pnl] bugfix last pnl period must not be decreased by 1 day

logic error to calculate last period date pair for col-header.

pnl report-dates are stored as a list of time64. consider a regular
profit&loss for "quarterly income & expense amounts for last
calendar year". dates are 1-jan to 31-dec. the report-dates are
'(1-jan 1-apr 1-jul 1-oct 31-dec). the inc/exp accounts balances are
queried for the above dates, and the delta change (sans closing
entries) constitutes the desired answer.

the col-header needs to report "1-jan to 31-mar", which it does by
retrieving 2 consecutive dates in the list (1-jan 1-apr), then
decrease second date by 1 day to obtain "1-jan to 31-mar" . however
this fails for the last period which would return '1-oct to 30-dec'.

this commit changes display for last period to return last report-date
so that the header is fixed to '1-oct to 31-dec'.

this is cosmetic for header dates only, calculations of periodic
income/expense amounts were never affected and included entries on the
last report-date (e.g. 31-dec as above).
This commit is contained in:
Christopher Lam 2019-09-08 23:37:10 +08:00
parent 7a36c229c5
commit 23d0fa1324

View File

@ -1081,14 +1081,17 @@ also show overall period profit & loss."))
(closing-regexp (get-option pagename-entries optname-closing-regexp)) (closing-regexp (get-option pagename-entries optname-closing-regexp))
(include-overall-period? (get-option gnc:pagename-general (include-overall-period? (get-option gnc:pagename-general
optname-include-overall-period)) optname-include-overall-period))
(col-idx->datepair (lambda (idx) (col-idx->datepair
(if (eq? idx 'overall-period) (lambda (idx)
(cons (car report-dates) (last report-dates)) (cond
((eq? idx 'overall-period)
(cons (car report-dates) (last report-dates)))
((= idx (- (length report-dates) 2))
(cons (list-ref report-dates idx) (last report-dates)))
(else
(cons (list-ref report-dates idx) (cons (list-ref report-dates idx)
(gnc:time64-end-day-time (decdate (list-ref report-dates (1+ idx)) DayDelta))))))
(decdate
(list-ref report-dates (1+ idx))
DayDelta))))))
(col-idx->monetarypair (lambda (balancelist idx) (col-idx->monetarypair (lambda (balancelist idx)
(if (eq? idx 'overall-period) (if (eq? idx 'overall-period)
(cons (car balancelist) (last balancelist)) (cons (car balancelist) (last balancelist))