mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
[budget] eradicate gnc-numeric methods
This commit is contained in:
parent
9d38d7fa8e
commit
86cbebd0ac
@ -289,7 +289,7 @@
|
||||
html-table acct-table budget params)
|
||||
(let* ((get-val (lambda (alist key)
|
||||
(let ((lst (assoc-ref alist key)))
|
||||
(if lst (car lst) lst))))
|
||||
(and lst (car lst)))))
|
||||
(show-actual? (get-val params 'show-actual))
|
||||
(show-budget? (get-val params 'show-budget))
|
||||
(show-diff? (get-val params 'show-difference))
|
||||
@ -306,12 +306,10 @@
|
||||
;; assumption.
|
||||
(colnum (quotient numcolumns 2)))
|
||||
|
||||
(define (negative-numeric-p x)
|
||||
(if (gnc-numeric-p x) (gnc-numeric-negative-p x) #f))
|
||||
(define (number-cell-tag x)
|
||||
(if (negative-numeric-p x) "number-cell-neg" "number-cell"))
|
||||
(if (negative? x) "number-cell-neg" "number-cell"))
|
||||
(define (total-number-cell-tag x)
|
||||
(if (negative-numeric-p x) "total-number-cell-neg" "total-number-cell"))
|
||||
(if (negative? x) "total-number-cell-neg" "total-number-cell"))
|
||||
|
||||
;; Calculate the value to use for the budget of an account for a
|
||||
;; specific set of periods. If there is 1 period, use that
|
||||
@ -330,10 +328,9 @@
|
||||
((= (length periodlist) 1)
|
||||
(gnc:get-account-period-rolledup-budget-value budget acct (car periodlist)))
|
||||
(else
|
||||
(gnc-numeric-add
|
||||
(+
|
||||
(gnc:get-account-period-rolledup-budget-value budget acct (car periodlist))
|
||||
(gnc:get-account-periodlist-budget-value budget acct (cdr periodlist))
|
||||
GNC-DENOM-AUTO GNC-RND-ROUND))))
|
||||
(gnc:get-account-periodlist-budget-value budget acct (cdr periodlist))))))
|
||||
|
||||
;; Calculate the value to use for the actual of an account for a
|
||||
;; specific set of periods. This is the sum of the actuals for
|
||||
@ -351,10 +348,9 @@
|
||||
((= (length periodlist) 1)
|
||||
(gnc-budget-get-account-period-actual-value budget acct (car periodlist)))
|
||||
(else
|
||||
(gnc-numeric-add
|
||||
(+
|
||||
(gnc-budget-get-account-period-actual-value budget acct (car periodlist))
|
||||
(gnc:get-account-periodlist-actual-value budget acct (cdr periodlist))
|
||||
GNC-DENOM-AUTO GNC-RND-ROUND))))
|
||||
(gnc:get-account-periodlist-actual-value budget acct (cdr periodlist))))))
|
||||
|
||||
;; Adds a line to tbe budget report.
|
||||
;;
|
||||
@ -371,9 +367,9 @@
|
||||
html-table rownum colnum budget acct rollup-budget?
|
||||
column-list exchange-fn)
|
||||
(let* ((current-col (+ colnum 1))
|
||||
(bgt-total (gnc-numeric-zero))
|
||||
(bgt-total 0)
|
||||
(bgt-total-unset? #t)
|
||||
(act-total (gnc-numeric-zero))
|
||||
(act-total 0)
|
||||
(comm (xaccAccountGetCommodity acct))
|
||||
(reverse-balance? (gnc-reverse-balance acct))
|
||||
(income-acct? (eq? (xaccAccountGetType acct) ACCT-TYPE-INCOME)))
|
||||
@ -397,7 +393,7 @@
|
||||
(style-tag-neg (string-append style-tag "-neg")))
|
||||
(if show-budget?
|
||||
(begin
|
||||
(set! bgt-val (if (gnc-numeric-zero-p bgt-numeric-val) "."
|
||||
(set! bgt-val (if (zero? bgt-numeric-val) "."
|
||||
(gnc:make-gnc-monetary comm bgt-numeric-val)))
|
||||
(gnc:html-table-set-cell/tag!
|
||||
html-table rownum current-col style-tag bgt-val)
|
||||
@ -407,7 +403,7 @@
|
||||
(set! act-val (gnc:make-gnc-monetary comm act-numeric-val))
|
||||
(gnc:html-table-set-cell/tag!
|
||||
html-table rownum current-col
|
||||
(if (gnc-numeric-negative-p act-numeric-val)
|
||||
(if (negative? act-numeric-val)
|
||||
style-tag-neg
|
||||
style-tag)
|
||||
act-val)
|
||||
@ -415,13 +411,13 @@
|
||||
(if show-diff?
|
||||
(begin
|
||||
(set! dif-val
|
||||
(if (and (gnc-numeric-zero-p bgt-numeric-val)
|
||||
(gnc-numeric-zero-p act-numeric-val))
|
||||
(if (and (zero? bgt-numeric-val)
|
||||
(zero? act-numeric-val))
|
||||
"."
|
||||
(gnc:make-gnc-monetary comm dif-numeric-val)))
|
||||
(gnc:html-table-set-cell/tag!
|
||||
html-table rownum current-col
|
||||
(if (gnc-numeric-negative-p dif-numeric-val)
|
||||
(if (negative? dif-numeric-val)
|
||||
style-tag-neg
|
||||
style-tag)
|
||||
dif-val)
|
||||
@ -446,27 +442,21 @@
|
||||
budget acct period-list))
|
||||
(act-numeric-val
|
||||
(if reverse-balance?
|
||||
(gnc-numeric-neg act-numeric-abs)
|
||||
(- act-numeric-abs)
|
||||
act-numeric-abs))
|
||||
|
||||
;; difference (budget to actual)
|
||||
(dif-numeric-val
|
||||
(gnc-numeric-sub
|
||||
bgt-numeric-val act-numeric-val
|
||||
GNC-DENOM-AUTO (+ GNC-DENOM-LCD GNC-RND-NEVER))))
|
||||
(- bgt-numeric-val act-numeric-val)))
|
||||
|
||||
(if (not (gnc-numeric-zero-p bgt-numeric-val))
|
||||
(if (not (zero? bgt-numeric-val))
|
||||
(begin
|
||||
(set! bgt-total (gnc-numeric-add bgt-total bgt-numeric-val
|
||||
GNC-DENOM-AUTO GNC-RND-ROUND))
|
||||
(set! bgt-total (+ bgt-total bgt-numeric-val))
|
||||
(set! bgt-total-unset? #f)))
|
||||
(set! act-total (gnc-numeric-add act-total act-numeric-val
|
||||
GNC-DENOM-AUTO GNC-RND-ROUND))
|
||||
(set! act-total (+ act-total act-numeric-val))
|
||||
(if income-acct?
|
||||
(set! dif-numeric-val
|
||||
(gnc-numeric-sub
|
||||
act-numeric-val bgt-numeric-val
|
||||
GNC-DENOM-AUTO (+ GNC-DENOM-LCD GNC-RND-NEVER))))
|
||||
(- act-numeric-val bgt-numeric-val)))
|
||||
(gnc:html-table-display-budget-columns!
|
||||
html-table rownum #f
|
||||
bgt-numeric-val act-numeric-val dif-numeric-val)))
|
||||
@ -478,12 +468,8 @@
|
||||
(gnc:html-table-display-budget-columns!
|
||||
html-table rownum #t bgt-total act-total
|
||||
(if income-acct?
|
||||
(gnc-numeric-sub
|
||||
act-total bgt-total
|
||||
GNC-DENOM-AUTO (+ GNC-DENOM-LCD GNC-RND-NEVER))
|
||||
(gnc-numeric-sub
|
||||
bgt-total act-total
|
||||
GNC-DENOM-AUTO (+ GNC-DENOM-LCD GNC-RND-NEVER)))))
|
||||
(- act-total bgt-total)
|
||||
(- bgt-total act-total))))
|
||||
((list? col-info)
|
||||
(gnc:html-table-add-budget-line-columns!
|
||||
html-table rownum budget acct col-info))
|
||||
|
Loading…
Reference in New Issue
Block a user