From 0fc726dc0fa0dc3248e0d53ef7c2400404a567ff Mon Sep 17 00:00:00 2001 From: Derek Atkins Date: Wed, 26 Dec 2007 03:28:09 +0000 Subject: [PATCH] Show the balance row for all transactions before the "from" date. Patch by Jeff Green BP git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@16729 57a11ea4-9604-0410-9ed3-97b8803252fd --- .../business-reports/owner-report.scm | 44 +++++++++++++------ 1 file changed, 30 insertions(+), 14 deletions(-) diff --git a/src/business/business-reports/owner-report.scm b/src/business/business-reports/owner-report.scm index 3cf6c7c256..78ff52a556 100644 --- a/src/business/business-reports/owner-report.scm +++ b/src/business/business-reports/owner-report.scm @@ -184,6 +184,27 @@ table)) +;; +;; Adds the 'Balance' row to the table if it has not been printed and +;; total is not zero +;; +;; Returns printed? +;; +(define (add-balance-row table txn odd-row? printed? start-date total) + (if (not printed?) + (begin + (set! printed? #t) + (if (not (gnc-numeric-zero-p total)) + (let ((row (list (gnc-print-date start-date) "" "" "Balance" "" + (gnc:make-html-table-cell/markup "number-cell" + (gnc:make-gnc-monetary (xaccTransGetCurrency txn) total)))) + (row-style (if odd-row? "normal-row" "alternate-row"))) + (gnc:html-table-append-row/markup! table row-style row) + (set! odd-row? (not odd-row?)) + (set! row-style (if odd-row? "normal-row" "alternate-row"))) + ))) + printed?) + ;; ;; Make sure the caller checks the type first and only calls us with ;; invoice and payment transactions. we don't verify it here. @@ -240,19 +261,9 @@ (if (gnc:timepair-later start-date date) (begin - - ; Maybe print out the 'balance' row - (if (not printed?) - (begin - (set! printed? #t) - (if (not (gnc-numeric-zero-p total)) - (let ((row (make-row start-date #f "" (_ "Balance") "" total)) - (row-style (if odd-row? "normal-row" "alternate-row"))) - (gnc:html-table-append-row/markup! table row-style - (reverse row)) - (set! odd-row? (not odd-row?)) - (set! row-style (if odd-row? "normal-row" "alternate-row"))) - ))) + + ; Adds 'balance' row if needed + (set! printed? (add-balance-row table txn odd-row? printed? start-date total)) ; Now print out the invoice row (if (not (null? invoice)) @@ -305,7 +316,12 @@ (set! total (gnc-numeric-add-fixed total (cadr result))) (set! odd-row? (caddr result)) )))) - txns)) + txns) + ;Balance row may not have been added if all transactions were before + ;start-date (and no other rows would be added either) so add it now + (if (not (null? txns)) + (add-balance-row table (car txns) odd-row? printed? start-date total) + )) (gnc:html-table-append-row/markup! table