@@ -529,11 +529,12 @@ for styling the invoice. Please see the exported report for the CSS class names.
529529
530530 table)))
531531
532- (define (make-invoice-details-table invoice options )
532+ (define (make-invoice-details-table options )
533533 ; ; dual-column. invoice date/due, billingID, terms, job name/number
534534 (define (opt-val section name )
535535 (gnc-optiondb-lookup-value options section name))
536536 (let* ((invoice-details-table (gnc:make-html-table))
537+ (invoice (opt-val gnc:pagename-general gnc:optname-invoice-number))
537538 (book (gncInvoiceGetBook invoice))
538539 (date-format (gnc:options-fancy-date book))
539540 (jobnumber (gncJobGetID (gncOwnerGetJob (gncInvoiceGetOwner invoice))))
@@ -595,19 +596,37 @@ for styling the invoice. Please see the exported report for the CSS class names.
595596 (gnc:make-html-div/markup
596597 " div-align-right"
597598 jobname)))))
598- invoice-details-table))
599599
600- (define (make-img img-url )
601- ; ; just an image
602- (gnc:make-html-text
603- (gnc:html-markup-img
604- (make-file-url img-url))))
600+ (gnc:make-html-div/markup " invoice-details-table" invoice-details-table)))
601+
602+ (define (make-picture options )
603+ (define (opt-val section name )
604+ (gnc-optiondb-lookup-value options section name))
605+ (let ((img-url (opt-val " Layout" " Picture Location" )))
606+ (gnc:make-html-div/markup
607+ " picture"
608+ (gnc:make-html-text
609+ (gnc:html-markup-img
610+ (make-file-url img-url))))))
611+
612+ (define (make-client-table options )
613+
614+ (define (get-orders invoice )
615+ (fold
616+ (lambda (a b )
617+ (let ((order (gncEntryGetOrder a)))
618+ (if (member order b) b (cons order b))))
619+ '() (gncInvoiceGetEntries invoice)))
605620
606- (define (make-client-table owner orders options )
607621 (define (opt-val section name )
608622 (gnc-optiondb-lookup-value options section name))
623+
609624 ; ; this is a single-column table.
610- (let ((table (gnc:make-html-table)))
625+ (let* ((invoice (opt-val gnc:pagename-general gnc:optname-invoice-number))
626+ (owner (gncInvoiceGetOwner invoice))
627+ (references? (opt-val " Display" " References" ))
628+ (orders (if references? (get-orders invoice) '() ))
629+ (table (gnc:make-html-table)))
611630
612631 (gnc:html-table-append-row! table
613632 (list
@@ -640,7 +659,7 @@ for styling the invoice. Please see the exported report for the CSS class names.
640659 reference))))))
641660 orders)
642661
643- table))
662+ (gnc:make-html-div/markup " client- table" table) ))
644663
645664(define (make-date-row label date date-format )
646665 (list
@@ -649,9 +668,14 @@ for styling the invoice. Please see the exported report for the CSS class names.
649668 " div-align-right"
650669 (gnc-print-time64 date date-format))))
651670
652- (define (make-company-table book )
671+ (define (make-company-table options )
672+
673+ (define (opt-val section name )
674+ (gnc-optiondb-lookup-value options section name))
675+
653676 ; ; single-column table. my name, address, and printdate
654677 (let* ((table (gnc:make-html-table))
678+ (book (gncInvoiceGetBook (opt-val gnc:pagename-general gnc:optname-invoice-number)))
655679 (name (gnc:company-info book gnc:*company-name*))
656680 (addy (gnc:company-info book gnc:*company-addy*))
657681 (phone (gnc:company-info book gnc:*company-phone*))
@@ -701,14 +725,17 @@ for styling the invoice. Please see the exported report for the CSS class names.
701725 table (list (gnc:make-html-div/markup
702726 " maybe-align-right company-tax-nr" taxnr))))
703727
704- table))
728+ (gnc:make-html-div/markup " company-table" table)))
729+
730+ (define (make-today options )
731+ (gnc:make-html-div/markup
732+ " invoice-print-date" (qof-print-date (current-time))))
705733
706734(define (reg-renderer report-obj )
707735 (let* ((document (gnc:make-html-document))
708736 (options (gnc:report-options report-obj))
709737 (opt-val (lambda (section name ) (gnc-optiondb-lookup-value options section name)))
710738 (invoice (opt-val gnc:pagename-general gnc:optname-invoice-number))
711- (references? (opt-val " Display" " References" ))
712739 (custom-title (opt-val gnc:pagename-general " Custom Title" )))
713740
714741 (if (null? invoice)
@@ -720,9 +747,7 @@ for styling the invoice. Please see the exported report for the CSS class names.
720747 (G_ " No valid invoice selected. Click on the Options button and select the invoice to use." )))
721748
722749 (let* ((book (gncInvoiceGetBook invoice))
723- (owner (gncInvoiceGetOwner invoice))
724750 (type (gncInvoiceGetType invoice))
725- (orders (if references? (delete-duplicates (map gncEntryGetOrder (gncInvoiceGetEntries invoice))) '() ))
726751 (cust-doc? (memv type (list GNC-INVOICE-CUST-INVOICE GNC-INVOICE-CUST-CREDIT-NOTE)))
727752 (credit-note? (memv type (list GNC-INVOICE-CUST-CREDIT-NOTE GNC-INVOICE-VEND-CREDIT-NOTE GNC-INVOICE-EMPL-CREDIT-NOTE)))
728753 (default-title (cond
@@ -744,23 +769,11 @@ for styling the invoice. Please see the exported report for the CSS class names.
744769 ; ; i.e. "~a Nr. ~a"
745770 (invoice-title (format #f (G_" ~a #~a" ) title (gncInvoiceGetID invoice)))
746771 (layout-lookup-table (list (cons 'none #f )
747- (cons 'picture (gnc:make-html-div/markup
748- " picture"
749- (make-img (opt-val " Layout" " Picture Location" ))))
750- (cons 'invoice (gnc:make-html-div/markup
751- " invoice-details-table"
752- (make-invoice-details-table
753- invoice options)))
754- (cons 'client (gnc:make-html-div/markup
755- " client-table"
756- (make-client-table
757- owner orders options)))
758- (cons 'company (gnc:make-html-div/markup
759- " company-table"
760- (make-company-table book)))
761- (cons 'today (gnc:make-html-div/markup
762- " invoice-print-date"
763- (qof-print-date (current-time))))))
772+ (cons 'picture (make-picture options))
773+ (cons 'invoice (make-invoice-details-table options))
774+ (cons 'client (make-client-table options))
775+ (cons 'company (make-company-table options))
776+ (cons 'today (make-today options))))
764777 (layout-lookup (lambda (loc ) (cdr (assq (opt-val " Layout" loc) layout-lookup-table)))))
765778
766779 (gnc:html-document-set-style-text! document (opt-val " Layout" " CSS" ))
0 commit comments