Reports - getting numeric value from commodity collector

Darryl Cousins darryl at darrylcousins.net.nz
Thu Nov 24 21:53:38 EST 2005


Hi Everyone,

I'm rather new to GnuCash and guile/schema however I've made some
progress in creating my own 'Statement of Financial Performance using
reports/pnl.scm as a starting point. All well and good.

My problem is in adding a final row to the report after Profit which
calculates the income tax owing on the profit (company tax at 33% here
in NZ).

I've managed thus:

    (if show-taxes?
        (begin
     (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))
     (set! myprofit (gnc:gnc-monetary-amount myprofit))
     (gnc:html-acct-table-row-helper!
       table tree-depth
       1 (_ "Taxes Payable")
       myprofit
       #f "primary-subheading" #t #f)
      ))

Which so far just gives the total profit figure. My dilemma is to
extract the number alone from the commodity collector (as returned from
gncsum-collector-commodity OR extract the number from the gnc-numeric
construct. Once I have the number itself then I can (* myprofit 0.33).
Probably then I'll be in trouble turning that back into a commodity
object.

Any help would be appreciated.

Best regards,
Darryl Cousins



More information about the gnucash-user mailing list