mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
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:
parent
4b9194a1dd
commit
7d546af657
@ -1,6 +1,7 @@
|
|||||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
;; gnc-numeric.scm : rational number representation for gnucash
|
;; gnc-numeric.scm : rational number representation for gnucash
|
||||||
;; Copyright 2000 Bill Gribble <grib@gnumatic.com>
|
;; 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
|
;; This program is free software; you can redistribute it and/or
|
||||||
;; modify it under the terms of the GNU General Public License as
|
;; modify it under the terms of the GNU General Public License as
|
||||||
@ -65,5 +66,22 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
(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))
|
||||||
|
|
||||||
|
@ -221,6 +221,11 @@
|
|||||||
; (gnc:numeric-to-string datum))
|
; (gnc:numeric-to-string datum))
|
||||||
(sprintf #f "%.2f" (gnc:numeric-to-double 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)
|
(define (gnc:default-html-number-renderer datum params)
|
||||||
(sprintf #f "%.2f" datum))
|
(sprintf #f "%.2f" datum))
|
||||||
|
|
||||||
|
@ -151,6 +151,10 @@
|
|||||||
rv "<number>"
|
rv "<number>"
|
||||||
gnc:default-html-number-renderer #f)
|
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
|
;; store it in the style sheet hash
|
||||||
(hash-set! *gnc:_style-sheets_* style-sheet-name rv)
|
(hash-set! *gnc:_style-sheets_* style-sheet-name rv)
|
||||||
rv)
|
rv)
|
||||||
|
@ -26,13 +26,20 @@
|
|||||||
(define (gnc:commodity-amount->string amount info)
|
(define (gnc:commodity-amount->string amount info)
|
||||||
(gnc:amount->string-helper amount info))
|
(gnc:amount->string-helper amount info))
|
||||||
|
|
||||||
;; pair is a list of one gnc:commodity and one gnc:numeric value. This
|
;; pair is a list of one gnc:commodity and one gnc:numeric
|
||||||
;; function should disappear once this is an "official" data type, so
|
;; value. Deprecated -- use <gnc-monetary> instead.
|
||||||
;; that the data type will be accepted by the html-renderer.
|
|
||||||
(define (gnc:commodity-value->string pair)
|
(define (gnc:commodity-value->string pair)
|
||||||
(gnc:commodity-amount->string
|
(gnc:commodity-amount->string
|
||||||
(cadr pair) (gnc:commodity-print-info (car pair) #t)))
|
(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
|
;; True if the account is of type currency, stock, or mutual-fund
|
||||||
(define (gnc:account-has-shares? account)
|
(define (gnc:account-has-shares? account)
|
||||||
;; FYI: The val->sym function used to be called
|
;; FYI: The val->sym function used to be called
|
||||||
|
Loading…
Reference in New Issue
Block a user