mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
[commodity-utilities] compact code, use (ice-9 match)
This commit is contained in:
@@ -618,10 +618,9 @@ construct with gnc:make-gnc-monetary and gnc:monetary->string instead.")
|
||||
;; total balances from get-exchange-totals are divided by each
|
||||
;; other.
|
||||
(map
|
||||
(lambda (e)
|
||||
(list (car e)
|
||||
(abs (/ ((cdadr e) 'total #f)
|
||||
((caadr e) 'total #f)))))
|
||||
(match-lambda
|
||||
((comm (domestic . foreign))
|
||||
(list comm (abs (/ (foreign 'total #f) (domestic 'total #f))))))
|
||||
(gnc:get-exchange-totals report-commodity end-date)))
|
||||
|
||||
(define (gnc:make-exchange-cost-alist report-commodity end-date)
|
||||
@@ -629,12 +628,10 @@ construct with gnc:make-gnc-monetary and gnc:monetary->string instead.")
|
||||
;; total balances from get-exchange-totals are divided by each
|
||||
;; other.
|
||||
(map
|
||||
(lambda (e)
|
||||
(list (car e)
|
||||
(if (zero? ((caadr e) 'total #f))
|
||||
0
|
||||
(abs (/ ((cdadr e) 'total #f)
|
||||
((caadr e) 'total #f))))))
|
||||
(match-lambda
|
||||
((comm (domestic . foreign))
|
||||
(let ((denom (domestic 'total #f)))
|
||||
(list comm (if (zero? denom) 0 (abs (/ (foreign 'total #f) denom)))))))
|
||||
(gnc:get-exchange-cost-totals report-commodity end-date)))
|
||||
|
||||
|
||||
@@ -973,7 +970,7 @@ construct with gnc:make-gnc-monetary and gnc:monetary->string instead.")
|
||||
(define (gnc:uniform-commodity? amt report-commodity)
|
||||
;; function to see if the commodity-collector amt
|
||||
;; contains any foreign commodities
|
||||
(let ((list-of-commodities (amt 'format (lambda (comm amt) comm) #f)))
|
||||
(or (null? list-of-commodities)
|
||||
(and (null? (cdr list-of-commodities))
|
||||
(gnc-commodity-equiv report-commodity (car list-of-commodities))))))
|
||||
(match (amt 'format (lambda (comm amt) comm) #f)
|
||||
(() #t)
|
||||
((comm) (gnc-commodity-equiv report-commodity comm))
|
||||
(_ #f)))
|
||||
|
||||
Reference in New Issue
Block a user