mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
[options] compact book-currency-acounting functions
This commit is contained in:
parent
faf1b08cec
commit
a4eb5b1a59
@ -1464,10 +1464,10 @@ the option '~a'."))
|
|||||||
(xaccAccountGetCommodity account)))))
|
(xaccAccountGetCommodity account)))))
|
||||||
|
|
||||||
(let* ((value (if (eq? 'book-currency default-radiobutton-value)
|
(let* ((value (if (eq? 'book-currency default-radiobutton-value)
|
||||||
(cons default-radiobutton-value
|
(list default-radiobutton-value
|
||||||
(cons default-book-currency-value
|
default-book-currency-value
|
||||||
(cons default-cap-gains-policy-value '())))
|
default-cap-gains-policy-value)
|
||||||
(cons default-radiobutton-value '())))
|
(list default-radiobutton-value)))
|
||||||
(value->string (lambda ()
|
(value->string (lambda ()
|
||||||
(string-append "'" (gnc:value->string
|
(string-append "'" (gnc:value->string
|
||||||
(car value)))))
|
(car value)))))
|
||||||
@ -1488,42 +1488,32 @@ the option '~a'."))
|
|||||||
(set! value x)
|
(set! value x)
|
||||||
(gnc:error "Illegal Radiobutton option set"))) ;;setter
|
(gnc:error "Illegal Radiobutton option set"))) ;;setter
|
||||||
(lambda () (if (eq? 'book-currency default-radiobutton-value)
|
(lambda () (if (eq? 'book-currency default-radiobutton-value)
|
||||||
(cons default-radiobutton-value
|
(list default-radiobutton-value
|
||||||
(cons default-book-currency-value
|
default-book-currency-value
|
||||||
(cons default-cap-gains-policy-value
|
default-cap-gains-policy-value)
|
||||||
(cons '() '()))))
|
(list default-radiobutton-value))) ;; default-getter
|
||||||
(cons default-radiobutton-value '()))) ;; default-getter
|
|
||||||
(gnc:restore-form-generator value->string)
|
(gnc:restore-form-generator value->string)
|
||||||
(lambda (b p) ;; scm->kvp
|
(lambda (b p) ;; scm->kvp
|
||||||
(if (eq? 'book-currency (car value))
|
(case (car value)
|
||||||
(begin
|
((book-currency)
|
||||||
;; Currency = selected currency
|
;; Currency = selected currency
|
||||||
(qof-book-set-option
|
(qof-book-set-option b (currency->scm (cadr value))
|
||||||
b
|
book-currency-path)
|
||||||
(currency->scm (cadr value))
|
;; Default Gains Policy = selected policy
|
||||||
book-currency-path)
|
(qof-book-set-option b (symbol->string (caddr value))
|
||||||
;; Default Gains Policy = selected policy
|
gains-policy-path)
|
||||||
(qof-book-set-option
|
;; Default Gains Account = if selected, selected account
|
||||||
b
|
(if (car (cdddr value))
|
||||||
(symbol->string (caddr value))
|
(qof-book-set-option b (car (cdddr value))
|
||||||
gains-policy-path)
|
gains-loss-account-path)))
|
||||||
;; Default Gains Account = if selected, selected account
|
((trading)
|
||||||
(if (car (cdddr value))
|
;; Use Trading Accounts = "t"
|
||||||
(qof-book-set-option
|
(qof-book-set-option b "t" trading-accounts-path))))
|
||||||
b
|
|
||||||
(car (cdddr value))
|
|
||||||
gains-loss-account-path)))
|
|
||||||
(if (eq? 'trading (car value))
|
|
||||||
;; Use Trading Accounts = "t"
|
|
||||||
(qof-book-set-option b "t" trading-accounts-path))))
|
|
||||||
(lambda (b p) ;; kvp->scm
|
(lambda (b p) ;; kvp->scm
|
||||||
(let* ((trading-option-path-kvp?
|
(let* ((trading-option-path-kvp?
|
||||||
(qof-book-get-option
|
(qof-book-get-option b trading-accounts-path))
|
||||||
b trading-accounts-path))
|
(trading? (and trading-option-path-kvp?
|
||||||
(trading? (if (and trading-option-path-kvp?
|
(string=? "t" trading-option-path-kvp?)))
|
||||||
(string=? "t" trading-option-path-kvp?))
|
|
||||||
#t
|
|
||||||
#f))
|
|
||||||
(book-currency #f)
|
(book-currency #f)
|
||||||
(cap-gains-policy #f)
|
(cap-gains-policy #f)
|
||||||
(gains-loss-account-guid #f)
|
(gains-loss-account-guid #f)
|
||||||
@ -1573,25 +1563,26 @@ the option '~a'."))
|
|||||||
(string->symbol cap-gains-policy)
|
(string->symbol cap-gains-policy)
|
||||||
gains-loss-account-guid)
|
gains-loss-account-guid)
|
||||||
'())))
|
'())))
|
||||||
(set! value (cons 'neither '())))))
|
(set! value (list 'neither)))))
|
||||||
(lambda (x) ;; value validator
|
(lambda (x) ;; value validator
|
||||||
(if (list? x)
|
(cond
|
||||||
(if (legal-val (car x) ok-radiobutton-values)
|
((not (list? x))
|
||||||
(if (eq? 'book-currency (car x))
|
(list #f "value not a list"))
|
||||||
(if (currency? (currency->scm (cadr x)))
|
((not (legal-val (car x) ok-radiobutton-values))
|
||||||
(if (gnc-valid-policy-name (symbol->string (caddr x)))
|
(list #f "radiobutton-option: illegal choice"))
|
||||||
(if (car(cdddr x))
|
((not (eq? 'book-currency (car x)))
|
||||||
(if (valid-gains-loss-account?
|
(list #t x))
|
||||||
(currency->scm (cadr x))
|
((not (currency? (currency->scm (cadr x))))
|
||||||
(car(cdddr x)))
|
(list #f "currency-option: illegal value"))
|
||||||
(list #t x)
|
((not (gnc-valid-policy-name (symbol->string (caddr x))))
|
||||||
(list #f "gains-loss-account-option: illegal value"))
|
(list #f "cap-gains-policy-option: illegal value"))
|
||||||
(list #t x)) ;; must be valid if specified, otherwise OK
|
((not (car (cdddr x)))
|
||||||
(list #f "cap-gains-policy-option: illegal value"))
|
(list #t x))
|
||||||
(list #f "currency-option: illegal value"))
|
((not (valid-gains-loss-account? (currency->scm (cadr x))
|
||||||
(list #t x))
|
(car (cdddr x))))
|
||||||
(list #f "radiobutton-option: illegal choice"))
|
(list #f "gains-loss-account-option: illegal value"))
|
||||||
(list #f "value not a list")))
|
(else
|
||||||
|
(list #t x))))
|
||||||
(vector book-currency-documentation-string
|
(vector book-currency-documentation-string
|
||||||
default-book-currency-value
|
default-book-currency-value
|
||||||
default-cap-gains-policy-documentation-string
|
default-cap-gains-policy-documentation-string
|
||||||
|
Loading…
Reference in New Issue
Block a user