Bug 797548 - multicolumn income statement: some closing entries are not ignored when within reporting period

Remove closing-entries substring/regex filter.

We will rely on the closing flag created with the Tools>Close Book
tool. This means very *old* closing entries will need to be re-done
via Tools>Close Book using the same date as the old closing entries.
This commit is contained in:
Christopher Lam 2020-01-12 21:33:13 +08:00
parent fd24b01689
commit ead5c94787

View File

@ -96,15 +96,6 @@ below parent and children groups."))
(define optname-amount-links (N_ "Display amounts as hyperlinks")) (define optname-amount-links (N_ "Display amounts as hyperlinks"))
(define opthelp-amount-links (N_ "Shows each amounts in the table as a hyperlink to a register or report.")) (define opthelp-amount-links (N_ "Shows each amounts in the table as a hyperlink to a register or report."))
;; closing entries filter - for P&L report
(define pagename-entries "Closing Entries")
(define optname-closing-pattern (N_ "Closing Entries pattern"))
(define opthelp-closing-pattern (N_ "Any text in the Description column which identifies closing entries."))
(define optname-closing-casing (N_ "Closing Entries pattern is case-sensitive"))
(define opthelp-closing-casing (N_ "Causes the Closing Entries Pattern match to be case-sensitive."))
(define optname-closing-regexp (N_ "Closing Entries Pattern is regular expression"))
(define opthelp-closing-regexp (N_ "Causes the Closing Entries Pattern to be treated as a regular expression."))
;; section labels ;; section labels
(define optname-label-sections (N_ "Label sections")) (define optname-label-sections (N_ "Label sections"))
(define opthelp-label-sections (N_ "Whether or not to include a label for sections.")) (define opthelp-label-sections (N_ "Whether or not to include a label for sections."))
@ -347,23 +338,7 @@ also show overall period profit & loss."))
(add-option (add-option
(gnc:make-simple-boolean-option (gnc:make-simple-boolean-option
gnc:pagename-general optname-include-overall-period gnc:pagename-general optname-include-overall-period
"c6" opthelp-include-overall-period #f)) "c6" opthelp-include-overall-period #f)))
;; closing entry match criteria
(add-option
(gnc:make-string-option
pagename-entries optname-closing-pattern
"a" opthelp-closing-pattern (_ "Closing Entries")))
(add-option
(gnc:make-simple-boolean-option
pagename-entries optname-closing-casing
"b" opthelp-closing-casing #f))
(add-option
(gnc:make-simple-boolean-option
pagename-entries optname-closing-regexp
"c" opthelp-closing-regexp #f)))
(gnc:options-set-default-section options gnc:pagename-general) (gnc:options-set-default-section options gnc:pagename-general)
@ -795,10 +770,11 @@ also show overall period profit & loss."))
(gnc:make-commodity-collector)) (gnc:make-commodity-collector))
#:split->elt #:split->elt
(lambda (s) (lambda (s)
(unless (xaccTransGetIsClosingTxn (xaccSplitGetParent s))
(val-coll 'add (val-coll 'add
(xaccTransGetCurrency (xaccSplitGetParent s)) (xaccTransGetCurrency (xaccSplitGetParent s))
(xaccSplitGetValue s)) (xaccSplitGetValue s)))
(make-datum s (amt->monetary (xaccSplitGetBalance s)) (make-datum s (amt->monetary (xaccSplitGetNoclosingBalance s))
(gnc:collector+ val-coll))))))) (gnc:collector+ val-coll)))))))
accounts)) accounts))
@ -1139,10 +1115,7 @@ also show overall period profit & loss."))
(gnc:html-markup-anchor chart (_ "Barchart"))))))) (gnc:html-markup-anchor chart (_ "Barchart")))))))
((eq? report-type 'pnl) ((eq? report-type 'pnl)
(let* ((closing-str (get-option pagename-entries optname-closing-pattern)) (let* ((include-overall-period? (get-option gnc:pagename-general
(closing-cased (get-option pagename-entries optname-closing-casing))
(closing-regexp (get-option pagename-entries optname-closing-regexp))
(include-overall-period? (get-option gnc:pagename-general
optname-include-overall-period)) optname-include-overall-period))
(col-idx->datepair (col-idx->datepair
(lambda (idx) (lambda (idx)
@ -1161,44 +1134,13 @@ also show overall period profit & loss."))
(cons (list-ref balancelist idx) (cons (list-ref balancelist idx)
(list-ref balancelist (1+ idx)))))) (list-ref balancelist (1+ idx))))))
(closing-entries (let ((query (qof-query-create-for-splits)))
(qof-query-set-book query (gnc-get-current-book))
(xaccQueryAddAccountMatch
query income-expense
QOF-GUID-MATCH-ANY QOF-QUERY-AND)
(if (and closing-str (not (string-null? closing-str)))
(xaccQueryAddDescriptionMatch
query closing-str closing-cased closing-regexp
QOF-COMPARE-CONTAINS QOF-QUERY-AND))
(xaccQueryAddClosingTransMatch query #t QOF-QUERY-OR)
(let ((splits (qof-query-run query)))
(qof-query-destroy query)
splits)))
;; this function will query the above closing-entries for
;; splits within the date range, and produce the total
;; amount for these closing entries
(closing-adjustment
(lambda (account col-idx)
(define datepair (col-idx->datepair col-idx))
(define (include-split? split)
(and (equal? (xaccSplitGetAccount split) account)
(<= (car datepair)
(xaccTransGetDate (xaccSplitGetParent split))
(cdr datepair))))
(let ((account-closing-splits (filter include-split? closing-entries)))
(gnc:make-gnc-monetary
(xaccAccountGetCommodity account)
(apply + (map xaccSplitGetAmount account-closing-splits))))))
(get-cell-monetary-fn (get-cell-monetary-fn
(lambda (account col-idx) (lambda (account col-idx)
(let* ((balances (assoc-ref accounts-balances account)) (let* ((balances (assoc-ref accounts-balances account))
(monetarypair (col-idx->monetarypair balances col-idx))) (monetarypair (col-idx->monetarypair balances col-idx)))
(monetary-less (monetary-less
(cdr monetarypair) (cdr monetarypair)
(car monetarypair) (car monetarypair)))))
(closing-adjustment account col-idx)))))
(get-cell-anchor-fn (get-cell-anchor-fn
(lambda (account col-idx) (lambda (account col-idx)