gnucash master: Multiple changes pushed

Christopher Lam clam at code.gnucash.org
Sat May 16 11:27:00 EDT 2020


Updated	 via  https://github.com/Gnucash/gnucash/commit/5b597dfe (commit)
	 via  https://github.com/Gnucash/gnucash/commit/0f56bed0 (commit)
	 via  https://github.com/Gnucash/gnucash/commit/9116fece (commit)
	 via  https://github.com/Gnucash/gnucash/commit/c69153fc (commit)
	from  https://github.com/Gnucash/gnucash/commit/a81f1554 (commit)



commit 5b597dfea4e9cb485f2fcbf18ff49938a8ee7deb
Author: Christopher Lam <christopher.lck at gmail.com>
Date:   Sat May 16 18:53:05 2020 +0800

    [html-chart] add z-index:999 to anchor
    
    otherwise it is not always visible

diff --git a/gnucash/report/html-chart.scm b/gnucash/report/html-chart.scm
index 2a15a9aa4..5abd87225 100644
--- a/gnucash/report/html-chart.scm
+++ b/gnucash/report/html-chart.scm
@@ -387,7 +387,7 @@ document.getElementById(chartid).onclick = function(evt) {
       var datasetIndex = activepoints[0]['_datasetIndex'];
       var datasetURLs = myChart.data.datasets[datasetIndex].urls;
       // console.log('index=',index,'datasetIndex=',datasetIndex);
-      anchor.style = 'position:absolute; top:' + (evt.clientY - 30) + 'px; left:' + (evt.clientX - 20) + 'px; display: block; padding: 5px; border-radius: 5px; background: #4E9CAF; text-align:center; color:white; ';
+      anchor.style = 'position:absolute; top:' + (evt.clientY - 30) + 'px; left:' + (evt.clientX - 20) + 'px; display: block; padding: 5px; border-radius: 5px; background: #4E9CAF; text-align:center; color:white; z-index: 999;';
       switch (typeof(datasetURLs)) {
         case 'string':
           anchor.href = datasetURLs;

commit 0f56bed0d97cce13b55e4b776cbd6bae188c63ab
Author: Christopher Lam <christopher.lck at gmail.com>
Date:   Sun Apr 5 21:29:25 2020 +0800

    [receipt.eguile] simplify
    
    1. taxtables? was a hack to disable tax display; this is now obsolete
    since bug 573645 was fixed with 8221aada. the equivalent
    taxinvoice.eguile.scm hack was removed with 0eb2c2b3 but never removed
    in receipt.eguile.scm
    
    2. break out date<? comparator
    
    3. use lispy for-each instead of pythonic for
    
    3. compact code

diff --git a/gnucash/report/reports/support/receipt.eguile.scm b/gnucash/report/reports/support/receipt.eguile.scm
index 6097384c1..c11c1ac13 100644
--- a/gnucash/report/reports/support/receipt.eguile.scm
+++ b/gnucash/report/reports/support/receipt.eguile.scm
@@ -25,7 +25,12 @@
 ;; Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
 ;; 02111-1307 USA
 
-  (define (display-report opt-invoice owner endowner ownertype)
+  (define (display-report opt-invoice)
+
+    (define (date<? s1 s2)
+      (< (xaccTransGetDate (xaccSplitGetParent s1))
+         (xaccTransGetDate (xaccSplitGetParent s2))))
+
     ;; Main function that creates the receipt invoice report
     (let* (; invoice and company details
            (invoiceid  (gncInvoiceGetID         opt-invoice))
@@ -40,7 +45,7 @@
            (txn        (gncInvoiceGetPostedTxn  opt-invoice))
            (currency   (gncInvoiceGetCurrency   opt-invoice))
            (entries    (gncInvoiceGetEntries    opt-invoice))
-           (splits     '())
+           (splits     (sort (gnc-lot-get-split-list lot) date<?))
            (coyname    (gnc:company-info book gnc:*company-name*))
            (coycontact (gnc:company-info book gnc:*company-contact*))
            (coyaddr    (gnc:company-info book gnc:*company-addy*))
@@ -49,55 +54,32 @@
            (coyfax     (gnc:company-info book gnc:*company-fax*))
            (coyurl     (gnc:company-info book gnc:*company-url*))
            (coyemail   (gnc:company-info book gnc:*company-email*))
+           (owner      (gncInvoiceGetOwner opt-invoice))
            (owneraddr  (gnc:owner-get-name-and-address-dep owner))
            (billcontact (gncAddressGetName (gnc:owner-get-address owner)))
            ; flags and counters
            (discount?  #f) ; any discounts on this invoice?
            (tax?       #f) ; any taxable entries on this invoice?
-           (taxtables? #t) ; are tax tables available in this version?
            (payments?  #f) ; have any payments been made on this invoice?
            (units?     #f) ; does any row specify units?
            (qty?       #f) ; does any row have qty <> 1?
-           (maxcols    5)  ; cols of product line
-           (no-of-items 0)) ; number of items
-
-      ; load splits, if any
-      (if (not (null? lot))
-        (set! splits
-          (sort-list (gnc-lot-get-split-list lot) ; sort by date
-                     (lambda (s1 s2)
-                       (let ((t1 (xaccSplitGetParent s1))
-                             (t2 (xaccSplitGetParent s2)))
-                         (< (xaccTransGetDate t1)
-                            (xaccTransGetDate t2)))))))
-
-      ; pre-scan invoice entries to look for discounts and taxes
-      (for entry in entries do
-          (let ((action    (gncEntryGetAction entry))
-                (qty       (gncEntryGetQuantity entry))
-                (discount  (gncEntryGetInvDiscount entry))
-                (taxtable  (gncEntryGetInvTaxTable entry)))
-            (set! no-of-items (+ no-of-items 1))
-            (if (not (string=? action ""))
-              (set! units? #t))
-            (if (not (= (gnc-numeric-to-double qty) 1.0))
-              (set! qty? #t))
-            (if (not (gnc-numeric-zero-p discount)) (set! discount? #t))
-            ;(if taxable - no, this flag is redundant
-            (if (not (eq? taxtable '()))
-              (begin ; presence of a tax table means it's taxed
-                (set! tax? #t)
-                (let ((ttentries (gncTaxTableGetEntries taxtable)))
-                  (if (string-prefix? "#<swig-pointer PriceList" (object->string ttentries))
-                    ; error in SWIG binding -- disable display of tax details
-                    ; (see https://bugs.gnucash.org/show_bug.cgi?id=573645)
-                    (set! taxtables? #f))))))) ; hack required until Swig is fixed
-
-      ; pre-scan invoice splits to see if any payments have been made
-      (for split in splits do
-          (let* ((t (xaccSplitGetParent split)))
-            (if (not (equal? t txn))
-              (set! payments? #t))))
+           (maxcols    5))  ; cols of product line
+
+      ;; pre-scan invoice entries to look for discounts and taxes
+      (for-each
+       (lambda (entry)
+         (unless (string-null? (gncEntryGetAction entry)) (set! units? #t))
+         (unless (= 1   (gncEntryGetQuantity entry))      (set! qty? #t))
+         (unless (zero? (gncEntryGetInvDiscount entry))   (set! discount? #t))
+         (unless (null? (gncEntryGetInvTaxTable entry))   (set! tax? #t)))
+       entries)
+
+      ;; pre-scan invoice splits to see if any payments have been made
+      (let lp ((splits splits))
+        (cond
+         ((null? splits) #f)
+         ((equal? (xaccSplitGetParent (car splits)) txn) (lp (cdr splits)))
+         (else (set! payments? #t))))
 
 ?>
 
@@ -174,7 +156,8 @@
                  (dsc-total (- inv-total tax-total sub-total))
                  (total-col (gnc:make-commodity-collector)))
             (total-col 'add currency inv-total)
-            (for entry in entries do
+            (for-each
+             (lambda (entry)
                 (let ((qty       (gncEntryGetQuantity entry))
                       (each      (gncEntryGetInvPrice entry))
                       (action    (gncEntryGetAction entry))
@@ -194,7 +177,7 @@
           <td align="right"><?scm:d (format #f "~4,2,,,'0f" (gnc-numeric-to-double each)) ?></td>
           <td align="right" nowrap><?scm:d (format #f "~4,2,,,'0f" (gnc-numeric-to-double rval)) ?>
           <!-- <td align="right" nowrap><?scm:d (fmtnumeric rval) ?> -->
-              <?scm (if (and tax? taxtables?) (begin ?>
+              <?scm (if tax? (begin ?>
                  T
               <?scm ) (begin ?>
                   
@@ -202,20 +185,21 @@
           </td>
         </tr>
 
-        <?scm (if (not(equal? 0 (string-length (gncEntryGetNotes entry)))) (begin ?>
+        <?scm (if (string-null? (gncEntryGetNotes entry)) (begin ?>
           <tr>
             <td align="left"> </td>
             <td align="left" colspan="<?scm:d (- maxcols 1) ?>"><?scm:d (gncEntryGetNotes entry) ?></td>
           </tr>
         <?scm )) ?>
 
-        <?scm )) ?>
+        <?scm ))
+             entries) ?>
 
         <!-- display subtotals row -->
         <tr valign="top">
           <td align="center" class="total total_first" colspan="<?scm:d maxcols ?>">
               <?scm:d "Total No. Items:" ?> 
-              <?scm:d no-of-items ?>
+              <?scm:d (length entries) ?>
           </td>
         </tr>
 
@@ -240,10 +224,11 @@
         <?scm )) ?>
 
         <?scm
-          (if payments?
-            (for split in splits do
+          (when payments?
+            (for-each
+             (lambda (split)
                 (let ((t (xaccSplitGetParent split)))
-                  (if (not (equal? t txn)) ; don't process the entry itself as a split
+                  (unless (equal? t txn) ; don't process the entry itself as a split
                     (let ((c (xaccTransGetCurrency t))
                           (a (xaccSplitGetValue    split)))
                       (total-col 'add c a)
@@ -253,7 +238,8 @@
           <td align="left" colspan="<?scm:d (- maxcols 3) ?>"><?scm:d opt-payment-recd-heading ?></td>
           <td align="right" colspan="2"><?scm:d (fmtmoney c a) ?></td>
         </tr>
-        <?scm ))))) ?>
+        <?scm ))))
+             splits)) ?>
 
         <!-- total row -->
         <tr valign="top">
@@ -287,18 +273,20 @@
 <?scm )) ; end of display-report function
 
   ; 'mainline' code: check for a valid invoice, then display the report
-  (if (null? opt-invoice)
-    (begin
-      (display (string-append "<h2>" (_ "Receipt") "</h2>"))
-      (display (string-append "<p>" (_ "No invoice has been selected -- please use the Options menu to select one.") "</p>")))
-    (let* ((owner     (gncInvoiceGetOwner  opt-invoice))
-           (endowner  (gncOwnerGetEndOwner owner))
-           (ownertype (gncOwnerGetType     endowner)))
-      (if (not (eqv? ownertype GNC-OWNER-CUSTOMER))
-        (begin
-          (display (string-append "<h2>" (_ "Receipt") "</h2>"))
-          (display (string-append "<p>" (_ "This report is designed for customer (sales) invoices only. Please use the Options menu to select an <em>Invoice</em>, not a Bill or Expense Voucher.") "</p>")))
-        (display-report opt-invoice owner endowner ownertype))))
+  (cond
+   ((null? opt-invoice)
+    (display (string-append "<h2>" (_ "Receipt") "</h2>"))
+    (display (string-append "<p>" (_ "No invoice has been selected -- please use the Options menu to select one.") "</p>")))
+
+   ((not (eqv? GNC-OWNER-CUSTOMER
+               (gncOwnerGetType
+                (gncOwnerGetEndOwner
+                 (gncInvoiceGetOwner opt-invoice)))))
+    (display (string-append "<h2>" (_ "Receipt") "</h2>"))
+    (display (string-append "<p>" (_ "This report is designed for customer (sales) invoices only. Please use the Options menu to select an <em>Invoice</em>, not a Bill or Expense Voucher.") "</p>")))
+
+   (else
+    (display-report opt-invoice)))
 
 ?>
 </div>

commit 9116fece7d7d34a2d85c1904e67130fd25af0a25
Author: Christopher Lam <christopher.lck at gmail.com>
Date:   Sun Apr 5 22:47:34 2020 +0800

    [taxinvoice] remove dead code, simplify
    
    * customer-only filter for invoice option never been in use.

diff --git a/gnucash/report/reports/standard/taxinvoice.scm b/gnucash/report/reports/standard/taxinvoice.scm
index 1e7e39858..dcb795e22 100644
--- a/gnucash/report/reports/standard/taxinvoice.scm
+++ b/gnucash/report/reports/standard/taxinvoice.scm
@@ -45,28 +45,29 @@
   ;; depending on how complicated the tax table is.
   ;; (When called from within the eguile template, anything
   ;; (display)ed becomes part of the HTML string.)
-  (if (or (not taxable) (eq? taxtable '()))
-    (display " ")
+  (cond
+   ((or (not taxable) (eq? taxtable '()))
+    (display " "))
+   (else
     (let* ((amttot  (gnc:make-commodity-collector))
            (pctot   (gnc:make-value-collector))
            (entries (gncTaxTableGetEntries taxtable))
            (amt?    #f)  ; becomes #t if any entries are amounts
            (pc?     #f)) ; becomes #t if any entries are percentages
-      (for entry in entries do
-          (let ((tttype (gncTaxTableEntryGetType   entry))
-                (ttamt  (gncTaxTableEntryGetAmount entry)))
-            (if (equal? tttype GNC-AMT-TYPE-VALUE)
-              (begin
-                (set! amt? #t)
-                (amttot 'add curr ttamt))
-              (begin
-                (set! pc? #t)
-                (pctot 'add ttamt)))))
-      (if pc? (begin (display (fmtnumeric (pctot 'total #f))) (display "%")))
-      (if (and amt? pc?) (display " + "))        ; both - this seems unlikely in practice
-      (if amt?
-        (display-comm-coll-total amttot #f))
-      (if (and (not amt?) (not pc?)) (display (_ "n/a"))))))        ; neither
+      (for-each
+       (lambda (entry)
+         (cond
+          ((eqv? (gncTaxTableEntryGetType entry) GNC-AMT-TYPE-VALUE)
+           (set! amt? #t)
+           (amttot 'add curr (gncTaxTableEntryGetAmount entry)))
+          (else
+           (set! pc? #t)
+           (pctot 'add (gncTaxTableEntryGetAmount entry)))))
+       entries)
+      (if pc? (format #t "~a%" (pctot 'total #f)))
+      (if (and amt? pc?) (display " + "))
+      (if amt? (display-comm-coll-total amttot #f))
+      (if (equal? amt? pc? #f) (display (_ "n/a")))))))
 
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;;; Define all the options
@@ -119,20 +120,6 @@
 (define optname-payment-recd   		(N_ "Payment received text"))
 (define optname-extra-notes    		(N_ "Extra notes"))
 
-; Choose only customer invoices
-; (This doesn't work very nicely -- all invoices and bills
-;  are offered for selection, but if a non-customer invoice
-;  is selected, the user is dumped back to viewing the
-;  previous invoice (or none) with no error message)
-(define (customers-only invoice)
-  (let* ((owner     (gncInvoiceGetOwner  invoice))
-         (endowner  (gncOwnerGetEndOwner owner))
-         (ownertype (gncOwnerGetType     endowner)))
-    ;(gnc:debug "ownertype is ")(gnc:debug ownertype)
-    (if (eqv? ownertype GNC-OWNER-CUSTOMER)
-      (list #t invoice)
-      (list #f invoice))))
-
 (define (options-generator)
   ;; Options
   (define report-options (gnc:new-options))
@@ -142,8 +129,7 @@
   (add-option
     (gnc:make-invoice-option ; defined in gnucash/scm/business-options.scm
       gnc:pagename-general gnc:optname-invoice-number 
-      "a" "" (lambda () '()) 
-      #f))        ;customers-only)) ;-- see above
+      "a" "" (lambda () '()) #f))
 
   ;; Elements page options
 (add-option (gnc:make-simple-boolean-option	elementspage	optname-col-date		"a" (N_ "Display the date?") #t))
@@ -225,7 +211,6 @@
                 notespage optname-extra-notes "a"
                 (_ "Notes added at end of invoice -- may contain HTML markup.") 
                 (_ "Thank you for your patronage!")))
-                ;(N_ "(Development version -- don't rely on the numbers on this report without double-checking them.<br/>Change the 'Extra Notes' option to get rid of this message)")))
 
   (add-option (gnc:make-text-option	notespage optname-extra-css "b"
                 (N_ "Embedded CSS.")	"h1.coyname { text-align: left; }"))

commit c69153fce1e540d957583ecb0defcbeca772557c
Author: Christopher Lam <christopher.lck at gmail.com>
Date:   Sun Apr 5 21:57:18 2020 +0800

    [taxinvoice.eguile] simplify
    
    1. break out date<? comparator
    
    2. the (if (not (null? opt-invoice)) ...) section is always run
    because display-report is only called when opt-invoice isn't null
    
    3. use lispy for-each instead of pythonic for loops

diff --git a/gnucash/report/reports/support/taxinvoice.eguile.scm b/gnucash/report/reports/support/taxinvoice.eguile.scm
index 1a14bc508..16c3b290e 100644
--- a/gnucash/report/reports/support/taxinvoice.eguile.scm
+++ b/gnucash/report/reports/support/taxinvoice.eguile.scm
@@ -29,8 +29,12 @@
 ;; along with this program; if not, write to the Free Software
 ;; Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
 ;; 02111-1307 USA
+  (define (display-report opt-invoice)
+
+    (define (date<? s1 s2)
+      (< (xaccTransGetDate (xaccSplitGetParent s1))
+         (xaccTransGetDate (xaccSplitGetParent s2))))
 
-  (define (display-report opt-invoice owner endowner ownertype)
     ;; Main function that creates the tax invoice report
     (let* (; invoice and company details
            (invoiceid    (gncInvoiceGetID         opt-invoice))
@@ -47,7 +51,7 @@
            (txn          (gncInvoiceGetPostedTxn  opt-invoice))
            (currency     (gncInvoiceGetCurrency   opt-invoice))
            (entries      (gncInvoiceGetEntries    opt-invoice))
-           (splits      '());'
+           (splits       (sort (gnc-lot-get-split-list lot) date<?))
            (dateformat   (gnc:options-fancy-date book))
            (coyname      (gnc:company-info book gnc:*company-name*))
            (coycontact   (gnc:company-info book gnc:*company-contact*))
@@ -57,70 +61,41 @@
            (coyfax       (gnc:company-info book gnc:*company-fax*))
            (coyurl       (gnc:company-info book gnc:*company-url*))
            (coyemail     (gnc:company-info book gnc:*company-email*))
+           (owner        (gncInvoiceGetOwner  opt-invoice))
            (owneraddr  (gnc:owner-get-address-dep owner))
            (ownername  (gnc:owner-get-name-dep owner))
            (jobnumber  (gncJobGetID (gncOwnerGetJob (gncInvoiceGetOwner  opt-invoice))))
            (jobname    (gncJobGetName (gncOwnerGetJob (gncInvoiceGetOwner  opt-invoice))))
            (billcontact  (gncAddressGetName (gnc:owner-get-address owner)))
-           (cust-doc?  #f)
+           (cust-doc? (eqv? (gncInvoiceGetType opt-invoice) GNC-INVOICE-CUST-INVOICE))
            (reverse-payments? (not (gncInvoiceAmountPositive opt-invoice)))
            ; flags and counters
            (discount?  #f) ; any discounts on this invoice?
            (tax?       #f) ; any taxable entries on this invoice?
-           (taxtables? #t) ; are tax tables available in this version?
            (payments?  #f) ; have any payments been made on this invoice?
            (units?     #f) ; does any row specify units?
            (qty?       #f) ; does any row have qty <> 1?
            (tbl_cols   0)) ; number of columns for 'colspan' attributes
-
-      ; load splits, if any
-      (if (not (null? lot))
-        (set! splits
-          (sort-list (gnc-lot-get-split-list lot) ; sort by date
-                     (lambda (s1 s2)
-                       (let ((t1 (xaccSplitGetParent s1))
-                             (t2 (xaccSplitGetParent s2)))
-                         (< (xaccTransGetDate t1)
-                            (xaccTransGetDate t2)))))))
-
-
-      ;; Is this an invoice or something else
-      (if (not (null? opt-invoice))
-          (begin
-            (set! owner (gncInvoiceGetOwner  opt-invoice))
-            (let ((type (gncInvoiceGetType  opt-invoice)))
-              (cond
-               ((eqv? type GNC-INVOICE-CUST-INVOICE)
-                (set! cust-doc? #t))
-               
-               ))))
       
-      ; pre-scan invoice entries to look for discounts and taxes
-      (for entry in entries do
-          (let ((action    (gncEntryGetAction entry))
-                (qty       (gncEntryGetDocQuantity entry credit-note?))
-                (discount  (gncEntryGetInvDiscount entry))
-                (taxable?  (if cust-doc? (gncEntryGetInvTaxable entry) (gncEntryGetBillTaxable entry)))
-                (taxtable  (if cust-doc? (gncEntryGetInvTaxTable entry) (gncEntryGetBillTaxTable entry))))
-            (if (not (string=? action ""))
-              (set! units? #t))
-            (if (not (= (gnc-numeric-to-double qty) 1.0))
-              (set! qty? #t))
-            (if cust-doc? ; Only invoices have discounts
-                (if (not (gnc-numeric-zero-p discount)) (set! discount? #t)))
-            ;(if taxable - no, this flag is redundant
-            (if taxable? ; Also check if the taxable flag is set
-              (if  (not (eq? taxtable '()))
-              (begin ; presence of a tax table AND taxable flag means it's taxed
-                (set! tax? #t))))))
-
-      ; pre-scan invoice splits to see if any payments have been made
-      (for split in splits do
-          (let* ((t (xaccSplitGetParent split)))
-            (if (not (equal? t txn))
-              (set! payments? #t))))
-
+      ;; pre-scan invoice entries to look for discounts and taxes
+      (for-each
+       (lambda (entry)
+         (unless (string-null? (gncEntryGetAction entry)) (set! units? #t))
+         (unless (= 1 (gncEntryGetDocQuantity entry credit-note?)) (set! qty? #t))
+         (cond
+          (cust-doc?
+           (unless (zero? (gncEntryGetInvDiscount entry)) (set! discount? #t))
+           (unless (null? (gncEntryGetInvTaxTable entry)) (set! tax? #t)))
+          (else
+           (unless (null? (gncEntryGetBillTaxTable entry)) (set! tax? #t)))))
+       entries)
 
+      ;; pre-scan invoice splits to see if any payments have been made
+      (let lp ((splits splits))
+        (cond
+         ((null? splits) #f)
+         ((equal? (xaccSplitGetParent (car splits)) txn) (lp (cdr splits)))
+         (else (set! payments? #t))))
 ?>
 
 <!-- ====================================================================== -->
@@ -306,7 +281,7 @@
         <th align="right"><?scm:d opt-disc-rate-heading ?></th>
         <th align="right"><?scm:d opt-disc-amount-heading ?></th>
       <?scm (set! tbl_cols (+ tbl_cols 2)) )) ?>
-      <?scm (if (and tax? taxtables?) (begin ?>
+      <?scm (if tax? (begin ?>
         <th align="right"><?scm:d opt-net-price-heading ?></th>
         <?scm (set! tbl_cols (+ tbl_cols 1)) ?>
         <?scm (if opt-col-taxrate (begin ?>
@@ -326,7 +301,8 @@
              (dsc-total (- inv-total tax-total sub-total))
              (total-col (gnc:make-commodity-collector)))
         (total-col 'add currency inv-total)
-        (for entry in entries do
+        (for-each
+         (lambda (entry)
             (let ((qty       (gncEntryGetDocQuantity entry credit-note?))
                   (each      (gncEntryGetPrice entry cust-doc? opt-netprice))
                   (action    (gncEntryGetAction entry))
@@ -364,7 +340,7 @@
         <?scm )) ?>
         <td align="right"><?scm:d (fmtmoney currency rdiscval) ?></td>
       <?scm )) ?>
-      <?scm (if (and tax? taxtables?) (begin ?>
+      <?scm (if tax? (begin ?>
         <td align="right"><?scm:d (fmtmoney currency rval) ?></td>
         <?scm (if opt-col-taxrate (begin ?>
         <td align="right"><?scm (taxrate taxable taxtable currency) ?></td>
@@ -374,20 +350,21 @@
       <!-- TO DO: need an option about whether to display the tax-inclusive total? -->
       <td align="right"><?scm:d (fmtmoney currency (gnc-numeric-add rval rtaxval GNC-DENOM-AUTO GNC-RND-ROUND)) ?></td>
     </tr>
-    <?scm )) ?>
+    <?scm ))
+         entries) ?>
 
     <!-- subtotals row -->
     <?scm (if (or tax? discount? payments?) (begin ?>
       <tr valign="top">
         <td align="left" class="subtotal" colspan="<?scm:d
-        (- tbl_cols (if (and tax? taxtables? opt-col-taxrate) 1 0)
-                    (if (and tax? taxtables?) 1 -1)
+        (- tbl_cols (if (and tax? opt-col-taxrate) 1 0)
+                    (if tax? 1 -1)
                     (if (and discount?) 1 0)
         ) ?>"><strong><?scm:d opt-subtotal-heading ?></strong></td>
         <?scm (if discount? (begin ?>
         <td align="right" class="subtotal"><strong><?scm:d (fmtmoney currency dsc-total) ?></strong></td>
         <?scm )) ?>
-        <?scm (if (and tax? taxtables?) (begin ?>
+        <?scm (if tax? (begin ?>
           <td align="right" class="subtotal"><strong><?scm:d (fmtmoney currency sub-total) ?></strong></td>
           <?scm (if opt-col-taxrate (begin ?>
           <td> </td>
@@ -400,25 +377,26 @@
 
     <!-- payments row -->
     <?scm
-      (if payments?
-        (for split in splits do
-            (let ((t (xaccSplitGetParent split)))
-              (if (not (equal? t txn)) ; don't process the entry itself as a split ;'
-                (let ((c (xaccTransGetCurrency t))
-                (a (if reverse-payments?
-                    (gnc-numeric-neg(xaccSplitGetValue split))
-                    (xaccSplitGetValue split)))
-                )
-                  (total-col 'add c a) ;'
+      (when payments?
+        (for-each
+         (lambda (split)
+           (let ((t (xaccSplitGetParent split)))
+             (unless (equal? t txn) ; don't process the entry itself as a split ;'
+               (let ((c (xaccTransGetCurrency t))
+                     (a (if reverse-payments?
+                            (- (xaccSplitGetValue split))
+                            (xaccSplitGetValue split))))
+                 (total-col 'add c a)
     ?>
     <tr valign="top">
-      <?scm (if opt-col-date (begin ?>
+      <?scm (when opt-col-date ?>
       <td align="center"><?scm:d (qof-print-date (xaccTransGetDate t)) ?></td>
-      <?scm )) ?>
+      <?scm ) ?>
       <td align="left" colspan="<?scm:d (+ tbl_cols (if opt-col-date 0 1)) ?>"><?scm:d opt-payment-recd-heading ?></td>
       <td align="right"><?scm:d (fmtmoney c a) ?></td>
     </tr>
-    <?scm ))))) ?>
+    <?scm ))))
+         splits)) ?>
 
     <!-- total row -->
     <tr valign="top">
@@ -437,18 +415,16 @@
 
 <?scm )) ; end of display-report function
 
-  ; 'mainline' code: check for a valid invoice, then display the report
+  ;; 'mainline' code: check for a valid invoice, then display the report
+
 
+  (cond
+   ((null? opt-invoice)
+    (display (string-append "<h2>" (_ "Tax Invoice") "</h2>"))
+    (display (string-append "<p>" (_ "No invoice has been selected -- please use the Options menu to select one.") "</p>")))
 
-    (if (null? opt-invoice)
-    (begin
-      (display (string-append "<h2>" (_ "Tax Invoice") "</h2>"))
-      (display (string-append "<p>" (_ "No invoice has been selected -- please use the Options menu to select one.") "</p>"))
-    )
-    (let* ((owner     (gncInvoiceGetOwner  opt-invoice))
-           (endowner  (gncOwnerGetEndOwner owner))
-           (ownertype (gncOwnerGetType     endowner)))
-      (display-report opt-invoice owner endowner ownertype)))
+   (else
+    (display-report opt-invoice)))
 
 ?>
 </div>



Summary of changes:
 gnucash/report/html-chart.scm                      |   2 +-
 gnucash/report/reports/standard/taxinvoice.scm     |  53 +++-----
 gnucash/report/reports/support/receipt.eguile.scm  | 116 ++++++++---------
 .../report/reports/support/taxinvoice.eguile.scm   | 138 +++++++++------------
 4 files changed, 129 insertions(+), 180 deletions(-)



More information about the gnucash-changes mailing list