Reports - getting numeric value from commodity collector

Darryl Cousins darryl at darrylcousins.net.nz
Sat Nov 26 00:03:24 EST 2005


Hi,

Aah! This works for me:

   ;; calculate taxes
   (set! mytaxes (gnc:numeric-mul num
                 (gnc:double-to-gnc-numeric (* tax-rate 0.01) 100 GNC-RND-NEVER)
                      100 GNC-DENOM-REDUCE))
       ))

Full code below.

Thanks Derek for your help. Another schema-newbie makes his first steps.

Best regards,
Darryl Cousins

    (if show-taxes?
        (begin

     ;; collect total profit - procedure taken from html-utilities.scm
     (set! myprofit (gnc:accounts-get-comm-total-profit (filter use-acct? accounts) my-get-balance))
     (set! myprofit (gnc:sum-collector-commodity myprofit report-currency exchange-fn))

     ;; collect the numeric bit
     (set! num (gnc:gnc-monetary-amount myprofit))

     ;; check for zero or negative profit
     (cond ((gnc:numeric-zero-p num)
             (set! mytaxes (gnc:numeric-create 0 100)))
           ((gnc:numeric-negative-p num)
             (set! mytaxes (gnc:numeric-create 0 100)))
           (else
             ;; calculate taxes
             (set! mytaxes (gnc:numeric-mul num
                              (gnc:double-to-gnc-numeric (* tax-rate 0.01) 100 GNC-RND-NEVER)
                              100 GNC-DENOM-REDUCE))
             ))

     ;; reconstruct monetary for printing
     (set! mytaxes (gnc:make-gnc-monetary report-currency mytaxes))

     ;; tab it to the table
     (gnc:html-acct-table-row-helper!
       table tree-depth
       1 (_ "Taxes Payable")
       mytaxes
       #f "primary-subheading" #t #f)
      ))

          ;; add the table
          (gnc:html-document-add-object! doc table)






More information about the gnucash-user mailing list