Wrap new amount printing API for guile.

Make gnucash load startup files when running as shell.


git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@3112 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
Dave Peticolas
2000-11-02 04:07:21 +00:00
parent a13f2dc367
commit 6f41f77088
10 changed files with 61 additions and 48 deletions

View File

@@ -30,6 +30,7 @@ src/gnome/window-main.c
src/gnome/window-reconcile.c
src/gnome/window-register.c
src/gnome/window-report.c
src/guile/gnucash.c
src/register/recncell.c
src/register/splitreg.c
src/FileDialog.c

View File

@@ -23,4 +23,3 @@
(gnc:load "startup.scm")
(gnc:load "main.scm")
(gnc:startup)

View File

@@ -432,11 +432,11 @@
(if (< amount 0)
(string-append
"color=#ff0000>("
(gnc:amount->string (- amount) #f #t #f)
(gnc:amount->string (- amount) (gnc:default-print-info #f))
")")
(string-append
">&nbsp;"
(gnc:amount->string amount #f #t #f)
(gnc:amount->string amount (gnc:default-print-info #f))
"&nbsp;"))
"</font>")
#f))
@@ -462,8 +462,9 @@
(color (if neg "ff0000" #f))
(prefix (if neg "(" NBSP))
(suffix (if neg ")" NBSP))
(displayamt (gnc:amount->string absamt #f #t #f)))
(displayamt
(gnc:amount->string absamt (gnc:default-print-info #f))))
(html-font-and-color "Courier" color
(list prefix displayamt suffix)))
#f))

View File

@@ -20,24 +20,17 @@
(gnc:support "report-utilities.scm")
(gnc:depend "engine-utilities.scm")
(define (gnc:amount->string amount print_currency_symbol?
print_separators? shares_value?)
(gnc:amount->string-helper (exact->inexact amount)
print_currency_symbol?
print_separators?
shares_value?
;; fixme
(gnc:commodity-get-mnemonic
(gnc:locale-default-currency))))
(define (gnc:amount->string amount info)
(gnc:amount->string-helper (exact->inexact amount) info))
(define (gnc:amount->formatted-string amount shares_value?)
(gnc:amount->string amount #t #t shares_value?))
;(define (gnc:amount->formatted-string amount shares_value?)
; (gnc:amount->string amount #t #t shares_value?))
(define (gnc:amount->formatted-currency-string amount
this_currency shares_value?)
(gnc:amount->string-helper (exact->inexact amount)
#t #t shares_value?
this_currency))
;(define (gnc:amount->formatted-currency-string amount
; this_currency shares_value?)
; (gnc:amount->string-helper (exact->inexact amount)
; #t #t shares_value?
; this_currency))
(define (gnc:account-has-shares? account)
(let ((type (gnc:account-type->symbol (gnc:account-get-type account))))

View File

@@ -159,7 +159,8 @@
(non-zero-at-date-accounts
(gnc:group-get-accounts children) date) date #t))
(gnc:account-get-name account))
(gnc:amount->string acc-bal #f #t #f))))
(gnc:amount->string acc-bal
(gnc:account-value-print-info account #t)))))
;; build the table for the list of 'accounts' passed
(define (acc-sum-table accnts date do-children?)
@@ -204,7 +205,10 @@
"</TD></TR>"))
(begin
(set! rept-total (gnc:amount->string (account-total-at-date accounts enddate) #f #t #f))
(set! rept-total
(gnc:amount->string
(account-total-at-date accounts enddate)
(gnc:account-value-print-info (car accounts) #t)))
; Grab account names
(set! acctname

View File

@@ -233,14 +233,16 @@
(reduce-splits deltas splits))
(define (format-numbers-in-list list)
(if (null? list)
'()
(cond ((number? (car list))
(cons (gnc:amount->string (car list) #f #t #f)
(format-numbers-in-list (cdr list))))
(else
(cons (car list)
(format-numbers-in-list (cdr list)))))))
(define print-info (gnc:default-print-info #f))
(define (format-internal list)
(cond ((null? list) '())
((number? (car list))
(cons (gnc:amount->string (car list) print-info)
(format-internal (cdr list))))
(else
(cons (car list)
(format-internal (cdr list))))))
(format-internal list))
(define (format-reduced-list list)
(define (reduce-line line)

View File

@@ -50,7 +50,12 @@
(let ((shares (gnc:split-get-share-balance last-split))
(price (gnc:split-get-share-price last-split))
(balance (gnc:split-get-balance last-split))
(cost (gnc:split-get-cost-basis last-split)))
(cost 0) ; fixme (gnc:split-get-cost-basis last-split)))
(quantity-print-info
(gnc:split-quantity-print-info last-split #f))
(price-print-info (gnc:default-price-print-info))
(value-print-info
(gnc:split-value-print-info last-split #f)))
(total-value 'add balance)
(total-cost 'add cost)
@@ -59,20 +64,21 @@
(gnc:account-get-name account)
(gnc:commodity-get-printname
(gnc:account-get-security account))
(gnc:amount->string shares #f #t #t)
(gnc:amount->string price #f #t #f)
(gnc:amount->string balance #f #t #f)
(gnc:amount->string cost #f #t #f)
(gnc:amount->string (- balance cost) #f #t #f)))))
(gnc:amount->string shares quantity-print-info)
(gnc:amount->string price price-print-info)
(gnc:amount->string balance value-print-info)
(gnc:amount->string cost value-print-info)
(gnc:amount->string (- balance cost) value-print-info)))))
(define (net-row)
(let ((value (total-value 'total #f))
(cost (total-cost 'total #f)))
(cost (total-cost 'total #f))
(print-info (gnc:default-print-info #f)))
(list (html-strong (string-db 'lookup 'net))
"&nbsp" "&nbsp" "&nbsp"
(gnc:amount->string value #f #t #f)
(gnc:amount->string cost #f #t #f)
(gnc:amount->string (- value cost) #f #t #f))))
(gnc:amount->string value print-info)
(gnc:amount->string cost print-info)
(gnc:amount->string (- value cost) print-info))))
(define (report-rows-main)
(gnc:group-map-all-accounts

View File

@@ -303,13 +303,14 @@
;; Here we print the value of the number option formatted as
;; currency. When printing currency values, you should use
;; the functions (gnc:amount->string) and
;; (gnc:amount->formatted-string) which are defined in
;; report-utilities. These functions will format the number
;; the function (gnc:amount->string), which is defined in
;; report-utilities. This functions will format the number
;; appropriately in the current locale. Don't try to format
;; it yourself -- it will be wrong in other locales.
(make-para 'num-string-2
(bold (gnc:amount->formatted-string num-val #f)))
(bold
(gnc:amount->string num-val
(gnc:default-print-info #f))))
(list-option-list list-val)

View File

@@ -40,6 +40,8 @@
;; do loop string-search
(define (string-search string sub-str start)
(if (not string)
(set! string ""))
(do ((sub-len (string-length sub-str))
;; must recompute sub-len because order is unknown
(limit (- (string-length string) (string-length sub-str)))
@@ -166,7 +168,8 @@
(if (or full-names (equal? level 1))
(gnc:account-get-full-name account)
(gnc:account-get-name account)))
(value (gnc:amount->formatted-string lx-value #f))
(value (gnc:amount->string lx-value
(gnc:account-value-print-info #f)))
(account-name (do ((i 1 (+ i 1))
(accum account-name
(string-append indent-1 accum)))
@@ -183,7 +186,9 @@
"right")))))
;;(if (not (equal? lx-value 0.0)) ; this fails, round off, I guess
(if (or (not suppress-0) (= level 1)
(not (equal? value (gnc:amount->formatted-string 0.0 #f))))
(not (equal? value
(gnc:amount->formatted-string
0.0 (gnc:account-value-print-info #f)))))
(html-table-row-align
(append (list account-name) nbsp-x-value)
align-x)

View File

@@ -38,7 +38,8 @@
" ("
(string-db 'lookup 'open-bal-string)
" "
(gnc:amount->formatted-string signed-balance #f)
(gnc:amount->string signed-balance
(gnc:account-value-print-info acc #f))
")"
)))