Christian Stimming's report patch.

git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@3614 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
Dave Peticolas 2001-02-07 09:27:30 +00:00
parent 4b9194a1dd
commit 7d546af657
4 changed files with 39 additions and 5 deletions

View File

@ -1,6 +1,7 @@
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; gnc-numeric.scm : rational number representation for gnucash
;; Copyright 2000 Bill Gribble <grib@gnumatic.com>
;; Copyright 2001 Christian Stimming <stimming@tu-harburg.de>
;;
;; This program is free software; you can redistribute it and/or
;; modify it under the terms of the GNU General Public License as
@ -64,6 +65,23 @@
(- arg))
(define <gnc-monetary>
(make-record-type "<gnc-monetary>"
'(commodity amount)))
;; Constructor; takes one <gnc:commodity*> and one <gnc-numeric>
(define (gnc:make-gnc-monetary c a)
(if (and (gw:wcp-is-of-type? <gnc:commodity*> c) (gnc:gnc-numeric? a))
((record-constructor <gnc-monetary>) c a)
#f))
(define gnc:gnc-monetary?
(record-predicate <gnc-monetary>))
(define gnc:gnc-monetary-commodity
(record-accessor <gnc-monetary> 'commodity))
(define gnc:gnc-monetary-amount
(record-accessor <gnc-monetary> 'amount))

View File

@ -221,6 +221,11 @@
; (gnc:numeric-to-string datum))
(sprintf #f "%.2f" (gnc:numeric-to-double datum)))
(define (gnc:default-html-gnc-monetary-renderer datum params)
(gnc:amount->string-helper
(gnc:gnc-monetary-amount datum)
(gnc:commodity-print-info (gnc:gnc-monetary-amount datum) #t)))
(define (gnc:default-html-number-renderer datum params)
(sprintf #f "%.2f" datum))

View File

@ -151,6 +151,10 @@
rv "<number>"
gnc:default-html-number-renderer #f)
(gnc:html-style-sheet-set-style!
rv "<gnc-monetary>"
gnc:default-html-gnc-monetary-renderer #f)
;; store it in the style sheet hash
(hash-set! *gnc:_style-sheets_* style-sheet-name rv)
rv)

View File

@ -26,13 +26,20 @@
(define (gnc:commodity-amount->string amount info)
(gnc:amount->string-helper amount info))
;; pair is a list of one gnc:commodity and one gnc:numeric value. This
;; function should disappear once this is an "official" data type, so
;; that the data type will be accepted by the html-renderer.
;; pair is a list of one gnc:commodity and one gnc:numeric
;; value. Deprecated -- use <gnc-monetary> instead.
(define (gnc:commodity-value->string pair)
(gnc:commodity-amount->string
(cadr pair) (gnc:commodity-print-info (car pair) #t)))
;; Just for convenience. But in reports you should rather stick to the
;; style-info mechanism and simple plug the <gnc-monetary> into the
;; html-renderer.
(define (gnc:monetary->string value)
(gnc:amount->string-helper
(gnc:gnc-monetary-amount value)
(gnc:commodity-print-info (gnc:gnc-monetary-amount value) #t)))
;; True if the account is of type currency, stock, or mutual-fund
(define (gnc:account-has-shares? account)
;; FYI: The val->sym function used to be called