Skip to content

Commit

Permalink
Merge branch 'stable-upgrade-trep-engine' into stable #1618
Browse files Browse the repository at this point in the history
  • Loading branch information
christopherlam committed Apr 29, 2023
2 parents 1a7fcb6 + ab002d1 commit 08e9f48
Show file tree
Hide file tree
Showing 3 changed files with 173 additions and 93 deletions.
4 changes: 4 additions & 0 deletions gnucash/report/reports/standard/income-gst-statement.scm
Expand Up @@ -6,6 +6,10 @@
;; Will reuse the Transaction Report with customised options
;; and calculated cells.
;;
;; Note: it uses a customised calculated-cells parameter when
;; calling the trep-engine renderer, with a legacy (vector...) form
;; instead of the modern association list preferred by trep-engine.
;;
;; This program is free software; you can redistribute it and/or
;; modify it under the terms of the GNU General Public License as
;; published by the Free Software Foundation; either version 2 of
Expand Down
38 changes: 23 additions & 15 deletions gnucash/report/reports/standard/reconcile-report.scm
Expand Up @@ -68,26 +68,34 @@ to the Reconciliation Date.")

(define (reconcile-report-calculated-cells options)
(letrec
((split-amount (lambda (s)
((split-amount (lambda (s tr?)
(if (gnc:split-voided? s)
(xaccSplitVoidFormerAmount s)
(xaccSplitGetAmount s))))
(split-currency (compose xaccAccountGetCommodity xaccSplitGetAccount))
(amount (lambda (s)
(gnc:make-gnc-monetary (split-currency s) (split-amount s))))
(debit-amount (lambda (s)
(and (positive? (split-amount s))
(amount s))))
(credit-amount (lambda (s)
(and (not (positive? (split-amount s)))
(gnc:monetary-neg (amount s))))))
(amount (lambda (s tr?)
(gnc:make-gnc-monetary (split-currency s) (split-amount s tr?))))
(debit-amount (lambda (s tr?)
(and (positive? (split-amount s tr?))
(amount s tr?))))
(credit-amount (lambda (s tr?)
(and (not (positive? (split-amount s tr?)))
(gnc:monetary-neg (amount s tr?))))))
;; similar to default-calculated-cells but disable dual-subtotals.
(list (vector (G_ "Funds In")
debit-amount #f #t #f
(const "") #t)
(vector (G_ "Funds Out")
credit-amount #f #t #f
(const "") #f))))
(list (list (cons 'heading (G_ "Funds In"))
(cons 'calc-fn debit-amount)
(cons 'reverse-column? #f)
(cons 'subtotal? #t)
(cons 'start-dual-column? #f)
(cons 'friendly-heading-fn (const ""))
(cons 'merge-dual-column? #t))
(list (cons 'heading (G_ "Funds Out"))
(cons 'calc-fn credit-amount)
(cons 'reverse-column? #f)
(cons 'subtotal? #t)
(cons 'start-dual-column? #f)
(cons 'friendly-heading-fn (const ""))
(cons 'merge-dual-column? #f)))))

(define (reconcile-report-renderer rpt)
(gnc:trep-renderer
Expand Down

0 comments on commit 08e9f48

Please sign in to comment.