. See the file
@@ -281,52 +261,43 @@
(gnc:option-value
(gnc:lookup-option (gnc:report-options report-obj) section name)))
- (define (curr-period budget)
- (let ((now (current-time))
- (max-period (1- (gnc-budget-get-num-periods budget))))
- (let loop ((period 0))
- (cond
- ((< now (gnc-budget-get-period-end-date budget period)) period)
- ((<= max-period period) period)
- (else (loop (1+ period)))))))
-
- (define (option->period period budget manual-period)
- (let ((max-period (1- (gnc-budget-get-num-periods budget))))
- (min max-period
- (max 0
- (case period
- ((first) 0)
- ((previous) (1- (curr-period budget)))
- ((current) (curr-period budget))
- ((next) (1+ (curr-period budget)))
- ((last) max-period)
- ((manual) (1- manual-period)))))))
-
- (let* ((budget (get-option gnc:pagename-general optname-budget))
- (budget-valid? (and budget (not (null? budget))))
- (running-sum (get-option gnc:pagename-display optname-running-sum))
- (chart-type (get-option gnc:pagename-display optname-chart-type))
- (height (get-option gnc:pagename-display optname-plot-height))
- (width (get-option gnc:pagename-display optname-plot-width))
- (accounts (get-option gnc:pagename-accounts optname-accounts))
- (depth-limit (get-option gnc:pagename-accounts optname-depth-limit))
- (report-title (get-option gnc:pagename-general gnc:optname-reportname))
- (start-period (get-option gnc:pagename-general optname-budget-period-start))
- (start-period-exact (and budget-valid?
- (option->period
- start-period budget
- (get-option
- gnc:pagename-general
- optname-budget-period-start-exact))))
- (end-period (get-option gnc:pagename-general optname-budget-period-end))
- (end-period-exact (and budget-valid?
- (option->period
- end-period budget
- (get-option
- gnc:pagename-general
- optname-budget-period-end-exact))))
- (document (gnc:make-html-document)))
+ ;; This is a helper function to find out the level of the account
+ ;; with in the account tree
+ (define (get-account-level account level)
+ (let (
+ (parent (gnc-account-get-parent account))
+ )
+ (cond
+ (
+ (null? parent) ;; exit
+ level
+ )
+ (else
+ (get-account-level parent (+ level 1))
+ )
+ )
+ )
+ )
+ (let* (
+ (budget (get-option gnc:pagename-general optname-budget))
+ (budget-valid? (and budget (not (null? budget))))
+ (running-sum (get-option gnc:pagename-display optname-running-sum))
+ (chart-type (get-option gnc:pagename-display optname-chart-type))
+ (height (get-option gnc:pagename-display optname-plot-height))
+ (width (get-option gnc:pagename-display optname-plot-width))
+ (accounts (get-option gnc:pagename-accounts optname-accounts))
+ (depth-limit (get-option gnc:pagename-accounts optname-depth-limit))
+ (report-title (get-option gnc:pagename-general
+ gnc:optname-reportname))
+ (document (gnc:make-html-document))
+ (from-date-t64 (gnc:time64-start-day-time
+ (gnc:date-option-absolute-time
+ (get-option gnc:pagename-general optname-from-date))))
+ (to-date-t64 (gnc:time64-end-day-time
+ (gnc:date-option-absolute-time
+ (get-option gnc:pagename-general optname-to-date))))
+ )
(cond
((null? accounts)
;; No accounts selected
@@ -342,25 +313,33 @@
;; Else create chart for each account
(else
- (for-each
- (lambda (acct)
- (if (or (and (eq? depth-limit 'all)
- (null? (gnc-account-get-descendants acct)))
- (and (not (eq? depth-limit 'all))
- (<= (gnc-account-get-current-depth acct) depth-limit)
- (null? (gnc-account-get-descendants acct)))
- (and (not (eq? depth-limit 'all))
- (= (gnc-account-get-current-depth acct) depth-limit)))
+ (for-each
+ (lambda (acct)
+ (if (or
+ (and (equal? depth-limit 'all)
+ (null? (gnc-account-get-descendants acct))
+ )
+ (and (not (equal? depth-limit 'all))
+ (<= (get-account-level acct 0) depth-limit)
+ (null? (gnc-account-get-descendants acct))
+ )
+ (and (not (equal? depth-limit 'all))
+ (= (get-account-level acct 0) depth-limit)
+ )
+ )
(gnc:html-document-add-object!
- document
- (gnc:chart-create-budget-actual
- budget acct running-sum chart-type
- width height
- (min start-period-exact end-period-exact)
- (max start-period-exact end-period-exact)))))
- accounts)))
+ document
+ (gnc:chart-create-budget-actual budget acct running-sum chart-type width height from-date-t64 to-date-t64)
+ )
+ )
+ )
+ accounts
+ )
+ )
+ ) ;; end cond
- document))
+ document
+))
;; Here we define the actual report
(gnc:define-report
diff --git a/gnucash/report/reports/standard/new-aging.scm b/gnucash/report/reports/standard/new-aging.scm
index 9129c076a6..b878b023ec 100644
--- a/gnucash/report/reports/standard/new-aging.scm
+++ b/gnucash/report/reports/standard/new-aging.scm
@@ -44,6 +44,22 @@
(define optname-show-zeros (N_ "Show zero balance items"))
(define optname-date-driver (N_ "Due or Post Date"))
+;; Display tab options
+(define optname-addr-source (N_ "Address Source"))
+
+(define addr-options-list
+ (list (list (N_ "Address Name") "b"
+ (N_ "Display Address Name. This, and other fields, may be useful if \
+copying this report to a spreadsheet for use in a mail merge."))
+ (list (N_ "Address 1") "c" (N_ "Display Address 1."))
+ (list (N_ "Address 2") "d" (N_ "Display Address 2."))
+ (list (N_ "Address 3") "e" (N_ "Display Address 3."))
+ (list (N_ "Address 4") "f" (N_ "Display Address 4."))
+ (list (N_ "Address Phone") "g" (N_ "Display Phone."))
+ (list (N_ "Address Fax") "h" (N_ "Display Fax."))
+ (list (N_ "Address Email") "i" (N_ "Display Email."))
+ (list (N_ "Active") "j" (N_ "Display Active status."))))
+
(define no-APAR-account (_ "No valid A/Payable or A/Receivable \
account found. Please ensure valid AP/AR account exists."))
@@ -100,8 +116,41 @@ exist but have no suitable transactions."))
(N_ "Post date is leading.")))))
(gnc:options-set-default-section options "General")
+
+ (for-each
+ (lambda (opt)
+ (add-option
+ (gnc:make-simple-boolean-option
+ gnc:pagename-display (car opt) (cadr opt) (caddr opt) #f)))
+ addr-options-list)
+
options))
+(define (options->address options receivable? owner)
+ (define (op-value name)
+ (gnc:option-value (gnc:lookup-option options gnc:pagename-display name)))
+ (let* ((address-list-names (map car addr-options-list))
+ (address-list-options (map op-value address-list-names))
+ (addr-source (if receivable? (op-value optname-addr-source) 'billing))
+ (result-list
+ (cond
+ (owner
+ (let ((addr (if (eq? addr-source 'shipping)
+ (gncCustomerGetShipAddr (gncOwnerGetCustomer owner))
+ (gncOwnerGetAddr owner))))
+ (list (gncAddressGetName addr)
+ (gncAddressGetAddr1 addr)
+ (gncAddressGetAddr2 addr)
+ (gncAddressGetAddr3 addr)
+ (gncAddressGetAddr4 addr)
+ (gncAddressGetPhone addr)
+ (gncAddressGetFax addr)
+ (gncAddressGetEmail addr)
+ (if (gncOwnerGetActive owner) (_ "Y") (_ "N")))))
+ (else address-list-names))))
+ (fold-right (lambda (opt elt prev) (if opt (cons elt prev) prev))
+ '() address-list-options result-list)))
+
(define (txn-is-invoice? txn)
(eqv? (xaccTransGetTxnType txn) TXN-TYPE-INVOICE))
@@ -137,9 +186,9 @@ exist but have no suitable transactions."))
owner))
(define (aging-renderer report-obj receivable)
+ (define options (gnc:report-options report-obj))
(define (op-value section name)
- (gnc:option-value
- (gnc:lookup-option (gnc:report-options report-obj) section name)))
+ (gnc:option-value (gnc:lookup-option options section name)))
(define make-heading-list
(list ""
@@ -200,7 +249,9 @@ exist but have no suitable transactions."))
splits)))
(cond
((null? accounts)
- (gnc:html-table-set-col-headers! table make-heading-list)
+ (gnc:html-table-set-col-headers!
+ table (append make-heading-list
+ (options->address options receivable #f)))
(gnc:html-document-add-object!
document (if (null? (gnc:html-table-data table))
(gnc:make-html-text empty-APAR-accounts)
@@ -276,7 +327,8 @@ exist but have no suitable transactions."))
(gnc:make-html-text
(gnc:html-markup-anchor
(gnc:owner-report-text owner account)
- (gnc:make-gnc-monetary comm aging-total))))))))
+ (gnc:make-gnc-monetary comm aging-total)))))
+ (options->address options receivable owner))))
(lp (cdr acc-owners)
other-owner-splits
(map + acc-totals
@@ -288,7 +340,21 @@ exist but have no suitable transactions."))
(aging-options-generator (gnc:new-options)))
(define (receivable-options-generator)
- (aging-options-generator (gnc:new-options)))
+ (let ((options (aging-options-generator (gnc:new-options))))
+ (define (add-option new-option)
+ (gnc:register-option options new-option))
+
+ (add-option
+ (gnc:make-multichoice-option
+ gnc:pagename-display optname-addr-source "a" (N_ "Address source.") 'billing
+ (list
+ (vector 'billing
+ (N_ "Billing")
+ (N_ "Address fields from billing address."))
+ (vector 'shipping
+ (N_ "Shipping")
+ (N_ "Address fields from shipping address.")))))
+ options))
(define (payables-renderer report-obj)
(aging-renderer report-obj #f))
diff --git a/gnucash/report/reports/standard/view-column.scm b/gnucash/report/reports/standard/view-column.scm
index 55c2d59225..a95826b326 100644
--- a/gnucash/report/reports/standard/view-column.scm
+++ b/gnucash/report/reports/standard/view-column.scm
@@ -138,9 +138,9 @@
(gnc:html-table-cell-append-objects!
contents-cell
(gnc:make-html-text
- (string-append
- "" (_ "Report error") "
"
- (_ "An error occurred while running the report.")))))
+ (gnc:html-markup-h3 (_ "Report error"))
+ (_ "An error occurred while running the report.")
+ (gnc:html-markup "pre" gnc:last-captured-error))))
;; increment the alloc number for each occupied row
(let loop ((row current-row-num))
diff --git a/gnucash/report/test/test-report-extras.scm b/gnucash/report/test/test-report-extras.scm
index 1613929220..fb9528a37f 100644
--- a/gnucash/report/test/test-report-extras.scm
+++ b/gnucash/report/test/test-report-extras.scm
@@ -53,11 +53,11 @@
(if test-title
(gnc:html-document-set-title! document test-title))
(let ((render (gnc:html-document-render document)))
- (with-output-to-file (format #f "/tmp/~a-~a.html"
+ (call-with-output-file (format #f "/tmp/~a-~a.html"
(string-map sanitize-char prefix)
(string-map sanitize-char test-title))
- (lambda ()
- (display render)))
+ (lambda (p)
+ (display render p)))
render)))
(define (strip-string s1 s2)
diff --git a/gnucash/report/test/test-report-html.scm b/gnucash/report/test/test-report-html.scm
index c3e5beb242..a45f853326 100644
--- a/gnucash/report/test/test-report-html.scm
+++ b/gnucash/report/test/test-report-html.scm
@@ -892,9 +892,9 @@ HTML Document Title
\n\
(gnc:html-document-set-style-sheet! doc (gnc:html-style-sheet-find "Default"))
(gnc:html-document-add-object! doc table)
(let ((render (gnc:html-document-render doc)))
- (with-output-to-file (format #f "/tmp/html-acct-table-~a.html" prefix)
- (lambda ()
- (display render)))
+ (call-with-output-file (format #f "/tmp/html-acct-table-~a.html" prefix)
+ (lambda (p)
+ (display render p)))
(xml->sxml render
#:trim-whitespace? #t
#:entities '((nbsp . "\xa0")
diff --git a/gnucash/report/trep-engine.scm b/gnucash/report/trep-engine.scm
index fbcce9f052..7509a40ad8 100644
--- a/gnucash/report/trep-engine.scm
+++ b/gnucash/report/trep-engine.scm
@@ -2204,9 +2204,9 @@ be excluded from periodic reporting.")
(if (list? csvlist)
(catch #t
(lambda ()
- (with-output-to-file filename
- (lambda ()
- (display (lists->csv (append infolist csvlist))))))
+ (call-with-output-file filename
+ (lambda (p)
+ (display (lists->csv (append infolist csvlist)) p))))
(lambda (key . args)
;; Translators: ~a error type, ~a filename, ~s error details
(let ((fmt (N_ "error ~a during csv output to ~a: ~s")))
diff --git a/gnucash/ui/gnc-plugin-page-register-ui.xml b/gnucash/ui/gnc-plugin-page-register-ui.xml
index 23d64d5580..517afcbca1 100644
--- a/gnucash/ui/gnc-plugin-page-register-ui.xml
+++ b/gnucash/ui/gnc-plugin-page-register-ui.xml
@@ -25,6 +25,8 @@
+
+