mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
Remove the number-collector.
It is redundant and incorrect since gnc-numeric was replaced with Scheme rationals in the report code.
This commit is contained in:
@@ -46,7 +46,7 @@
|
|||||||
(if (or (not taxable) (eq? taxtable '()))
|
(if (or (not taxable) (eq? taxtable '()))
|
||||||
(display " ")
|
(display " ")
|
||||||
(let* ((amttot (gnc:make-commodity-collector))
|
(let* ((amttot (gnc:make-commodity-collector))
|
||||||
(pctot (gnc:make-number-collector))
|
(pctot (gnc:make-value-collector))
|
||||||
(entries (gncTaxTableGetEntries taxtable))
|
(entries (gncTaxTableGetEntries taxtable))
|
||||||
(amt? #f) ; becomes #t if any entries are amounts
|
(amt? #f) ; becomes #t if any entries are amounts
|
||||||
(pc? #f)) ; becomes #t if any entries are percentages
|
(pc? #f)) ; becomes #t if any entries are percentages
|
||||||
|
|||||||
@@ -53,7 +53,7 @@
|
|||||||
(if (or (not taxable) (eq? taxtable '()))
|
(if (or (not taxable) (eq? taxtable '()))
|
||||||
(display " ")
|
(display " ")
|
||||||
(let* ((amttot (gnc:make-commodity-collector))
|
(let* ((amttot (gnc:make-commodity-collector))
|
||||||
(pctot (gnc:make-number-collector))
|
(pctot (gnc:make-value-collector))
|
||||||
(entries (gncTaxTableGetEntries taxtable))
|
(entries (gncTaxTableGetEntries taxtable))
|
||||||
(amt? #f) ; becomes #t if any entries are amounts
|
(amt? #f) ; becomes #t if any entries are amounts
|
||||||
(pc? #f)) ; becomes #t if any entries are percentages
|
(pc? #f)) ; becomes #t if any entries are percentages
|
||||||
|
|||||||
@@ -404,8 +404,8 @@
|
|||||||
;; numeric-collectors, where [abc] are numeric-collectors. See the
|
;; numeric-collectors, where [abc] are numeric-collectors. See the
|
||||||
;; real variable names below.
|
;; real variable names below.
|
||||||
(define (make-newrate unknown-coll un->known-coll known-pair)
|
(define (make-newrate unknown-coll un->known-coll known-pair)
|
||||||
(let ((a (gnc:make-number-collector))
|
(let ((a (gnc:make-value-collector))
|
||||||
(b (gnc:make-number-collector)))
|
(b (gnc:make-value-collector)))
|
||||||
(a 'add (unknown-coll 'total #f))
|
(a 'add (unknown-coll 'total #f))
|
||||||
(b 'add
|
(b 'add
|
||||||
;; round to (at least) 8 significant digits
|
;; round to (at least) 8 significant digits
|
||||||
@@ -448,7 +448,7 @@
|
|||||||
;; If this is an Euro currency, create the
|
;; If this is an Euro currency, create the
|
||||||
;; pair of appropriately exchanged amounts.
|
;; pair of appropriately exchanged amounts.
|
||||||
(if euro-monetary
|
(if euro-monetary
|
||||||
(let ((a (gnc:make-number-collector)))
|
(let ((a (gnc:make-value-collector)))
|
||||||
(a 'add
|
(a 'add
|
||||||
(gnc:gnc-monetary-amount euro-monetary))
|
(gnc:gnc-monetary-amount euro-monetary))
|
||||||
(list report-commodity
|
(list report-commodity
|
||||||
@@ -578,8 +578,8 @@
|
|||||||
;; entry doesn't exist in comm-list
|
;; entry doesn't exist in comm-list
|
||||||
;; create sub-alist from scratch
|
;; create sub-alist from scratch
|
||||||
(let ((pair (list transaction-comm
|
(let ((pair (list transaction-comm
|
||||||
(cons (gnc:make-number-collector)
|
(cons (gnc:make-value-collector)
|
||||||
(gnc:make-number-collector)))))
|
(gnc:make-value-collector)))))
|
||||||
((caadr pair) 'add value-amount)
|
((caadr pair) 'add value-amount)
|
||||||
((cdadr pair) 'add share-amount)
|
((cdadr pair) 'add share-amount)
|
||||||
(set! comm-list (list account-comm (list pair)))
|
(set! comm-list (list account-comm (list pair)))
|
||||||
@@ -603,8 +603,8 @@
|
|||||||
(begin
|
(begin
|
||||||
(set!
|
(set!
|
||||||
pair (list (car foreignlist)
|
pair (list (car foreignlist)
|
||||||
(cons (gnc:make-number-collector)
|
(cons (gnc:make-value-collector)
|
||||||
(gnc:make-number-collector))))
|
(gnc:make-value-collector))))
|
||||||
(set!
|
(set!
|
||||||
comm-list (list (car comm-list)
|
comm-list (list (car comm-list)
|
||||||
(cons pair (cadr comm-list))))
|
(cons pair (cadr comm-list))))
|
||||||
@@ -665,8 +665,8 @@
|
|||||||
(if (not comm-list)
|
(if (not comm-list)
|
||||||
;; no, create sub-alist from scratch
|
;; no, create sub-alist from scratch
|
||||||
(let ((pair (list transaction-comm
|
(let ((pair (list transaction-comm
|
||||||
(cons (gnc:make-number-collector)
|
(cons (gnc:make-value-collector)
|
||||||
(gnc:make-number-collector)))))
|
(gnc:make-value-collector)))))
|
||||||
((caadr pair) 'add value-amount)
|
((caadr pair) 'add value-amount)
|
||||||
((cdadr pair) 'add share-amount)
|
((cdadr pair) 'add share-amount)
|
||||||
(set! comm-list (list account-comm (list pair)))
|
(set! comm-list (list account-comm (list pair)))
|
||||||
@@ -690,8 +690,8 @@
|
|||||||
(begin
|
(begin
|
||||||
(set!
|
(set!
|
||||||
pair (list (car foreignlist)
|
pair (list (car foreignlist)
|
||||||
(cons (gnc:make-number-collector)
|
(cons (gnc:make-value-collector)
|
||||||
(gnc:make-number-collector))))
|
(gnc:make-value-collector))))
|
||||||
(set!
|
(set!
|
||||||
comm-list (list (car comm-list)
|
comm-list (list (car comm-list)
|
||||||
(cons pair (cadr comm-list))))
|
(cons pair (cadr comm-list))))
|
||||||
|
|||||||
@@ -263,28 +263,6 @@
|
|||||||
(define (gnc:value-collector-total collector)
|
(define (gnc:value-collector-total collector)
|
||||||
(collector 'total #f))
|
(collector 'total #f))
|
||||||
|
|
||||||
|
|
||||||
;; Same as above but with gnc:numeric
|
|
||||||
(define (gnc:make-number-collector)
|
|
||||||
(let ;;; values
|
|
||||||
((value 0))
|
|
||||||
(lambda (action amount) ;;; Dispatch function
|
|
||||||
(case action
|
|
||||||
((add) (if (number? amount)
|
|
||||||
(set! value (gnc-numeric-add amount value
|
|
||||||
GNC-DENOM-AUTO GNC-DENOM-LCD))
|
|
||||||
(gnc:warn
|
|
||||||
"gnc:Number-collector called with wrong argument: "
|
|
||||||
amount)))
|
|
||||||
((total) value)
|
|
||||||
(else (gnc:warn "bad gnc:number-collector action: " action))))))
|
|
||||||
|
|
||||||
;; Replace all 'action function calls by the normal functions below.
|
|
||||||
(define (gnc:number-collector-add collector amount)
|
|
||||||
(collector 'add amount))
|
|
||||||
(define (gnc:number-collector-total collector)
|
|
||||||
(collector 'total #f))
|
|
||||||
|
|
||||||
;; A commodity collector. This is intended to handle multiple
|
;; A commodity collector. This is intended to handle multiple
|
||||||
;; currencies' amounts. The amounts are accumulated via 'add, the
|
;; currencies' amounts. The amounts are accumulated via 'add, the
|
||||||
;; result can be fetched via 'format. This used to work with strings
|
;; result can be fetched via 'format. This used to work with strings
|
||||||
@@ -337,12 +315,12 @@
|
|||||||
(gnc-commodity-get-fraction commodity) GNC-RND-ROUND)))
|
(gnc-commodity-get-fraction commodity) GNC-RND-ROUND)))
|
||||||
(if (not pair)
|
(if (not pair)
|
||||||
(begin
|
(begin
|
||||||
;; create a new pair, using the gnc:number-collector
|
;; create a new pair, using the gnc:value-collector
|
||||||
(set! pair (list commodity (gnc:make-number-collector)))
|
(set! pair (list commodity (gnc:make-value-collector)))
|
||||||
;; and add it to the alist
|
;; and add it to the alist
|
||||||
(set! commoditylist (cons pair commoditylist))))
|
(set! commoditylist (cons pair commoditylist))))
|
||||||
;; add the value
|
;; add the value
|
||||||
(gnc:number-collector-add (cadr pair) rvalue)))
|
(gnc:value-collector-add (cadr pair) rvalue)))
|
||||||
|
|
||||||
;; helper function to walk an association list, adding each
|
;; helper function to walk an association list, adding each
|
||||||
;; (commodity -> collector) pair to our list at the appropriate
|
;; (commodity -> collector) pair to our list at the appropriate
|
||||||
@@ -351,15 +329,14 @@
|
|||||||
(cond ((null? clist) '())
|
(cond ((null? clist) '())
|
||||||
(else (add-commodity-value
|
(else (add-commodity-value
|
||||||
(caar clist)
|
(caar clist)
|
||||||
(gnc:number-collector-total (cadar clist)))
|
(gnc:value-collector-total (cadar clist)))
|
||||||
(add-commodity-clist (cdr clist)))))
|
(add-commodity-clist (cdr clist)))))
|
||||||
|
|
||||||
(define (minus-commodity-clist clist)
|
(define (minus-commodity-clist clist)
|
||||||
(cond ((null? clist) '())
|
(cond ((null? clist) '())
|
||||||
(else (add-commodity-value
|
(else (add-commodity-value
|
||||||
(caar clist)
|
(caar clist)
|
||||||
(gnc-numeric-neg
|
(- (gnc:value-collector-total (cadar clist))))
|
||||||
(gnc:number-collector-total (cadar clist))))
|
|
||||||
(minus-commodity-clist (cdr clist)))))
|
(minus-commodity-clist (cdr clist)))))
|
||||||
|
|
||||||
;; helper function walk the association list doing a callback on
|
;; helper function walk the association list doing a callback on
|
||||||
@@ -367,7 +344,7 @@
|
|||||||
(define (process-commodity-list fn clist)
|
(define (process-commodity-list fn clist)
|
||||||
(map
|
(map
|
||||||
(lambda (pair) (fn (car pair)
|
(lambda (pair) (fn (car pair)
|
||||||
(gnc:number-collector-total (cadr pair))))
|
(gnc:value-collector-total (cadr pair))))
|
||||||
clist))
|
clist))
|
||||||
|
|
||||||
;; helper function which is given a commodity and returns, if
|
;; helper function which is given a commodity and returns, if
|
||||||
@@ -380,8 +357,8 @@
|
|||||||
(gnc-numeric-zero)
|
(gnc-numeric-zero)
|
||||||
(if sign?
|
(if sign?
|
||||||
(gnc-numeric-neg
|
(gnc-numeric-neg
|
||||||
(gnc:number-collector-total (cadr pair)))
|
(gnc:value-collector-total (cadr pair)))
|
||||||
(gnc:number-collector-total (cadr pair))))
|
(gnc:value-collector-total (cadr pair))))
|
||||||
'()))))
|
'()))))
|
||||||
|
|
||||||
;; helper function which is given a commodity and returns, if
|
;; helper function which is given a commodity and returns, if
|
||||||
@@ -394,8 +371,8 @@
|
|||||||
(gnc-numeric-zero)
|
(gnc-numeric-zero)
|
||||||
(if sign?
|
(if sign?
|
||||||
(gnc-numeric-neg
|
(gnc-numeric-neg
|
||||||
(gnc:number-collector-total (cadr pair)))
|
(gnc:value-collector-total (cadr pair)))
|
||||||
(gnc:number-collector-total (cadr pair)))))))
|
(gnc:value-collector-total (cadr pair)))))))
|
||||||
|
|
||||||
;; Dispatch function
|
;; Dispatch function
|
||||||
(lambda (action commodity amount)
|
(lambda (action commodity amount)
|
||||||
|
|||||||
Reference in New Issue
Block a user