[invoice] refactor gncOrder handling

Previously the function addorder was being passed as an argument to
add gncOrder references to a list, for later displaying in
report. This commit will simplify it - instead of passing a function
to make-entry-table, the report will query invoice orders directly
when needed.
This commit is contained in:
Christopher Lam 2018-06-02 22:35:09 +08:00
parent cf3ccb9f1e
commit 1afacb97ba

View File

@ -287,7 +287,7 @@
gnc:*report-options*)
(define (make-entry-table invoice options add-order cust-doc? credit-note?)
(define (make-entry-table invoice options cust-doc? credit-note?)
(define (opt-val section name)
(gnc:option-value
(gnc:lookup-option options section name)))
@ -419,9 +419,6 @@
current-row-style
cust-doc? credit-note?)))
(let ((order (gncEntryGetOrder current)))
(if (not (null? order)) (add-order order)))
(do-rows-with-subtotals rest
table
used-columns
@ -539,7 +536,6 @@
title))
(let* ((document (gnc:make-html-document))
(orders '())
(invoice (opt-val gnc:pagename-general gnc:optname-invoice-number))
(references? (opt-val "Display" "References"))
(job? (opt-val "Display" "Job Details"))
@ -547,10 +543,6 @@
(jobname (gncJobGetName (gncOwnerGetJob (gncInvoiceGetOwner invoice))))
(custom-title (opt-val gnc:pagename-general "Custom Title")))
(define (add-order o)
(if (and references? (not (member o orders)))
(addto! orders o)))
(if (null? invoice)
(gnc:html-document-add-object! document
@ -565,7 +557,6 @@
(cust-doc? (memq type (list GNC-INVOICE-CUST-INVOICE GNC-INVOICE-CUST-CREDIT-NOTE)))
(credit-note? (memq type (list GNC-INVOICE-CUST-CREDIT-NOTE GNC-INVOICE-VEND-CREDIT-NOTE
GNC-INVOICE-EMPL-CREDIT-NOTE)))
(default-title (case type
((GNC-INVOICE-VEND-INVOICE)
(_ "Bill"))
@ -578,7 +569,7 @@
(title (title-string default-title custom-title))
(table (make-entry-table invoice
(gnc:report-options report-obj)
add-order cust-doc? credit-note?)))
cust-doc? credit-note?)))
(gnc:html-document-set-title! document (format #f (_"~a #~a") title
(gncInvoiceGetID invoice)))
@ -607,6 +598,7 @@
(gnc:html-document-add-object! document
(make-client-table owner orders))
(make-break! document)
(make-break! document)