Bug 637004 Optionally allow customer and vendor address info to display

Use an internal option to hold receivable/payable flag,
  remove trailing spaces.
This commit is contained in:
goodvibes2 2016-06-20 19:45:28 +10:00 committed by Geert Janssens
parent 3e37be8144
commit 5ed887715b
3 changed files with 74 additions and 60 deletions

View File

@ -331,11 +331,12 @@ more than one currency. This report is not designed to cope with this possibilit
(qof-query-set-sort-increasing query #t #t #t)))
(define (aging-options-generator options receivable)
(define (aging-options-generator options)
(let* ((add-option
(lambda (new-option)
(gnc:register-option options new-option))))
(gnc:options-add-report-date!
options gnc:pagename-general
optname-to-date "a")
@ -405,21 +406,10 @@ totals to report currency.")
(vector 'duedate (N_ "Due Date") (N_ "Due date is leading.")) ;; Should be using standard label for due date?
(vector 'postdate (N_ "Post Date") (N_ "Post date is leading."))))) ;; Should be using standard label for post date?
;; display tab options
;; display tab options
(gnc:debug "aging-options-generator: receivable=" receivable)
(if receivable
(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."))))))
;; option optname-addr-source is added in receivables.scm
;; as cannot access the value of an option in aging-options-generator
(add-option
(gnc:make-simple-boolean-option
@ -510,7 +500,9 @@ copying this report to a spreadsheet for use in a mail merge.")
(define oldintervalreversed (reverse (make-interval-list to-date)))
(reverse (cons dayforcurrent oldintervalreversed)))
(define (aging-renderer report-obj reportname account reverse? receivable)
(define (aging-renderer report-obj reportname account reverse?)
(define receivable #t) ;; receivable=#t payable=#f
(define (get-name a)
(let* ((owner (company-get-owner-obj (cdr a))))
@ -536,7 +528,6 @@ copying this report to a spreadsheet for use in a mail merge.")
(> (compare-buckets a b) 0))))))
(define (get-sort-pred sort-criterion sort-order)
(let ((choice (assq-ref sort-preds sort-criterion)))
(gnc:debug "sort-criterion" sort-criterion)
@ -555,10 +546,7 @@ copying this report to a spreadsheet for use in a mail merge.")
(gnc:lookup-option (gnc:report-options report-obj) section name))
(define (op-value section name)
(begin
;; (gnc:debug "op-value: name=" name)
(gnc:option-value (get-op section name)))
)
(gnc:option-value (get-op section name)))
;; XXX: This is a hack - will be fixed when we move to a
@ -660,13 +648,11 @@ copying this report to a spreadsheet for use in a mail merge.")
;; note customers have a shipping address but not vendors
(define (get-addr owner disp-addr-source)
(begin
;; (gnc:debug "get-addr: disp-addr-source=" disp-addr-source)
(if (and receivable (eq? disp-addr-source 'shipping))
(gncCustomerGetShipAddr (gncOwnerGetCustomer owner)) ;; shipping
(gncOwnerGetAddr owner))) ;; billing
)
(gncCustomerGetShipAddr (gncOwnerGetCustomer owner)) ;; shipping
(gncOwnerGetAddr owner))) ;; billing
(set! receivable (eq? (op-value "__hidden" "receivable-or-payable") 'R))
(gnc:report-starting reportname)
(let* ((companys (make-hash-table 23))
(report-title (op-value gnc:pagename-general gnc:optname-reportname))
@ -706,7 +692,7 @@ copying this report to a spreadsheet for use in a mail merge.")
(document (gnc:make-html-document)))
; (gnc:debug "Account: " account)
;; add optional column headings
;; add optional column headings
(if disp-addr-name
(set! heading-list (append heading-list (list (_ "Address Name")))))
(if disp-addr1

View File

@ -37,7 +37,6 @@
(define acc-page gnc:pagename-general)
(define this-acc (N_ "Payable Account"))
(define receivable #f) ;; receivable = #t, payable = #f
(define (options-generator)
(let* ((options (gnc:new-options))
@ -51,7 +50,16 @@
"w" (N_ "The payable account you wish to examine.")
#f #f (list ACCT-TYPE-PAYABLE)))
(aging-options-generator options receivable)))
;; As aging.scm functions are used by both receivables.scm and payables.scm
;; add option "receivable" on hidden page "__hidden" with default value 'P
;; so aging.scm functions can tell if they are reporting on
;; accounts receivable or payable, as customers have a shipping address
;; but vendors do not. The Address Source option therefore only applies
;; to customers.
(add-option
(gnc:make-internal-option "__hidden" "receivable-or-payable" 'P))
(aging-options-generator options)))
(define (payables-renderer report-obj)
(define (opt-val section name)
@ -60,7 +68,7 @@
(let ((payables-account (opt-val acc-page this-acc)))
(gnc:debug "payables-account" payables-account)
(aging-renderer report-obj this-acc payables-account #f receivable)))
(aging-renderer report-obj this-acc payables-account #f)))
(define payables-aging-guid "e57770f2dbca46619d6dac4ac5469b50")

View File

@ -37,7 +37,7 @@
(define acc-page gnc:pagename-general)
(define this-acc (N_ "Receivables Account"))
(define receivable #t) ;; receivable = #t, payable = #f
(define optname-addr-source (N_ "Address Source")) ;; Billing or Shipping addresses
(define (options-generator)
(let* ((options (gnc:new-options))
@ -51,7 +51,27 @@
"w" (N_ "The receivables account you wish to examine.")
#f #f (list ACCT-TYPE-RECEIVABLE)))
(aging-options-generator options receivable)))
;; As aging.scm functions are used by both receivables.scm and payables.scm
;; add option "receivable" on hidden page "__hidden" with default value 'R
;; so aging.scm functions can tell if they are reporting on
;; accounts receivable or payable, as customers have a shipping address
;; but vendors do not. The Address Source option therefore only applies
;; to customers.
(add-option
(gnc:make-internal-option "__hidden" "receivable-or-payable" 'R))
(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.")))))
(aging-options-generator options)))
(define (receivables-renderer report-obj)
(define (op-value section name)
@ -61,7 +81,7 @@
(let* ((receivables-account (op-value acc-page this-acc)))
(gnc:debug "receivables-account" receivables-account)
(aging-renderer report-obj this-acc receivables-account #t receivable)))
(aging-renderer report-obj this-acc receivables-account #t)))
(define receivables-aging-guid "9cf76bed17f14401b8e3e22d0079cb98")