Bug #635632: Update existing eguile reports to use new for syntax.

Patch by Matthijs Kooijman <matthijs@stdin.nl>:

    This makes use of the new for syntax introduced in the previous
    commit, making these reports and templates a bit easier to read and
    modify.

git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@19889 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
Christian Stimming 2010-11-27 21:54:29 +00:00
parent 626f8dfe7a
commit c7cba6884e
4 changed files with 13 additions and 28 deletions

View File

@ -76,8 +76,7 @@
(car (gnc-transaction-get-date-posted t2)))))))) (car (gnc-transaction-get-date-posted t2))))))))
; pre-scan invoice entries to look for discounts and taxes ; pre-scan invoice entries to look for discounts and taxes
(for-each (for entry in entries do
(lambda (entry)
(let ((action (gncEntryGetAction entry)) (let ((action (gncEntryGetAction entry))
(qty (gncEntryGetQuantity entry)) (qty (gncEntryGetQuantity entry))
(discount (gncEntryGetInvDiscount entry)) (discount (gncEntryGetInvDiscount entry))
@ -96,15 +95,12 @@
; error in SWIG binding -- disable display of tax details ; error in SWIG binding -- disable display of tax details
; (see http://bugzilla.gnome.org/show_bug.cgi?id=573645) ; (see http://bugzilla.gnome.org/show_bug.cgi?id=573645)
(set! taxtables? #f))))))) ; hack required until Swig is fixed (set! taxtables? #f))))))) ; hack required until Swig is fixed
entries)
; pre-scan invoice splits to see if any payments have been made ; pre-scan invoice splits to see if any payments have been made
(for-each (for split in splits do
(lambda (split)
(let* ((t (xaccSplitGetParent split))) (let* ((t (xaccSplitGetParent split)))
(if (not (equal? t txn)) (if (not (equal? t txn))
(set! payments? #t)))) (set! payments? #t))))
splits)
?> ?>
@ -285,8 +281,7 @@
(sub-total (gnc:make-commodity-collector)) (sub-total (gnc:make-commodity-collector))
(dsc-total (gnc:make-commodity-collector)) (dsc-total (gnc:make-commodity-collector))
(inv-total (gnc:make-commodity-collector))) (inv-total (gnc:make-commodity-collector)))
(for-each ; entry in entries (for entry in entries do
(lambda (entry)
(let ((qty (gncEntryGetQuantity entry)) (let ((qty (gncEntryGetQuantity entry))
(each (gncEntryGetInvPrice entry)) (each (gncEntryGetInvPrice entry))
(action (gncEntryGetAction entry)) (action (gncEntryGetAction entry))
@ -333,7 +328,7 @@
<!-- TO DO: need an option about whether to display the tax-inclusive total? --> <!-- 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> <td align="right"><?scm:d (fmtmoney currency (gnc-numeric-add rval rtaxval GNC-DENOM-AUTO GNC-RND-ROUND)) ?></td>
</tr> </tr>
<?scm )) entries) ?> <?scm )) ?>
<!-- display subtotals row --> <!-- display subtotals row -->
<?scm (if (or tax? discount? payments?) (begin ?> <?scm (if (or tax? discount? payments?) (begin ?>
@ -354,8 +349,7 @@
<!-- payments --> <!-- payments -->
<?scm <?scm
(if payments? (if payments?
(for-each (for split in splits do
(lambda (split)
(let ((t (xaccSplitGetParent split))) (let ((t (xaccSplitGetParent split)))
(if (not (equal? t txn)) ; don't process the entry itself as a split (if (not (equal? t txn)) ; don't process the entry itself as a split
(let ((c (xaccTransGetCurrency t)) (let ((c (xaccTransGetCurrency t))
@ -367,7 +361,7 @@
<td align="left" colspan="<?scm:d (- spancols1 1) ?>"><?scm:d opt-payment-recd-heading ?></td> <td align="left" colspan="<?scm:d (- spancols1 1) ?>"><?scm:d opt-payment-recd-heading ?></td>
<td align="right"><?scm:d (fmtmoney c a) ?></td> <td align="right"><?scm:d (fmtmoney c a) ?></td>
</tr> </tr>
<?scm )))) splits)) ?> <?scm ))))) ?>
<!-- total row --> <!-- total row -->
<tr valign="top"> <tr valign="top">

View File

@ -55,8 +55,7 @@
(entries (gncTaxTableGetEntries taxtable)) (entries (gncTaxTableGetEntries taxtable))
(amt? #f) ; becomes #t if any entries are amounts (amt? #f) ; becomes #t if any entries are amounts
(pc? #f)) ; becomes #t if any entries are percentages (pc? #f)) ; becomes #t if any entries are percentages
(for-each (for entry in entries do
(lambda (entry)
(let ((tttype (gncTaxTableEntryGetType entry)) (let ((tttype (gncTaxTableEntryGetType entry))
(ttamt (gncTaxTableEntryGetAmount entry))) (ttamt (gncTaxTableEntryGetAmount entry)))
(if (equal? tttype GNC-AMT-TYPE-VALUE) (if (equal? tttype GNC-AMT-TYPE-VALUE)
@ -66,7 +65,6 @@
(begin (begin
(set! pc? #t) (set! pc? #t)
(pctot 'add ttamt))))) (pctot 'add ttamt)))))
entries)
(if pc? (begin (display (fmtnumeric (pctot 'total #f))) (display "%"))) (if pc? (begin (display (fmtnumeric (pctot 'total #f))) (display "%")))
(if (and amt? pc?) (display " +&nbsp;")) ; both - this seems unlikely in practice (if (and amt? pc?) (display " +&nbsp;")) ; both - this seems unlikely in practice
(if amt? (if amt?

View File

@ -76,8 +76,7 @@
onedepth1) onedepth1)
;; Recursively display the accounts table from the given tree ;; Recursively display the accounts table from the given tree
;; (as returned by process-acc-list) ;; (as returned by process-acc-list)
(for-each (for accrec in tree do
(lambda (accrec)
(let ((rshift2 0) ; adjust the amount column by this much (let ((rshift2 0) ; adjust the amount column by this much
(showamt? #t)) ; whether to show the amount (e.g. not if zero) (showamt? #t)) ; whether to show the amount (e.g. not if zero)
(if (and (accrec-sublist accrec) (if (and (accrec-sublist accrec)
@ -122,8 +121,7 @@
(format-comm-coll-total (accrec-subtotal-cc accrec)) (format-comm-coll-total (accrec-subtotal-cc accrec))
(<= (accrec-depth accrec) 1) ; total? (<= (accrec-depth accrec) 1) ; total?
(> (accrec-depth accrec) 0))))))) ; leftoverrule? (> (accrec-depth accrec) 0))))))) ; leftoverrule?
tree )
))
?> ?>
<!-- The HTML starts here... --> <!-- The HTML starts here... -->
@ -288,8 +286,7 @@
<p><?scm:d (_ "<strong>Exchange Rates</strong> used for this report") ?> <p><?scm:d (_ "<strong>Exchange Rates</strong> used for this report") ?>
<table border="0"> <table border="0">
<?scm <?scm
(for-each (for xpair in xlist do
(lambda (xpair)
(let* ((comm (car xpair)) (let* ((comm (car xpair))
(one-num (gnc:make-gnc-numeric 10000 1)) (one-num (gnc:make-gnc-numeric 10000 1))
(one-foreign-mny (gnc:make-gnc-monetary comm one-num)) (one-foreign-mny (gnc:make-gnc-monetary comm one-num))
@ -308,7 +305,6 @@
</tr> </tr>
<?scm <?scm
)) ))
xlist)
?> ?>
</table> </table>
<?scm <?scm

View File

@ -80,12 +80,11 @@
(define (debug . args) (define (debug . args)
(if debugging? (if debugging?
(for-each (for arg in args do
(lambda (arg)
(if (string? arg) (if (string? arg)
(display (string-append arg " ")) (display (string-append arg " "))
(display (string-append (dump arg) " ")))) (display (string-append (dump arg) " "))))
args))) ))
(define (hrule cols) ; in fact just puts in an empty row for spacing (define (hrule cols) ; in fact just puts in an empty row for spacing
(display "<tr valign=\"center\"><td colspan=\"") (display "<tr valign=\"center\"><td colspan=\"")
@ -164,12 +163,10 @@
(display " sublist: ") (if (accrec-sublist accrec) (display " sublist: ") (if (accrec-sublist accrec)
(begin (begin
(display "\n<ul>") (display "\n<ul>")
(for-each (for sub-accrec in (accrec-sublist accrec) do
(lambda (sub-accrec)
(display "\n<li>") (display "\n<li>")
(accrec-printer sub-accrec port) (accrec-printer sub-accrec port)
(display "</li>")) (display "</li>"))
(accrec-sublist accrec))
(display "</ul>")) (display "</ul>"))
(display "#f"))) (display "#f")))
(define accrectype (make-record-type "accrecc" (define accrectype (make-record-type "accrecc"