mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
[balsheet-eg] don't use safe-cadr and safe-cdr
they are safety hacks which indicate inability to deal with lists. use lists properly.
This commit is contained in:
parent
8ffe7771f1
commit
f1ff789657
@ -46,11 +46,13 @@
|
||||
;; 'Safe' versions of cdr and cadr that don't crash
|
||||
;; if the list is empty (is there a better way?)
|
||||
(define-public safe-cdr
|
||||
;; deprecate
|
||||
(match-lambda
|
||||
((_ . x) x)
|
||||
(_ '())))
|
||||
|
||||
(define-public safe-cadr
|
||||
;; deprecate
|
||||
(match-lambda
|
||||
((_ x . y) x)
|
||||
(_ '())))
|
||||
|
@ -458,13 +458,12 @@
|
||||
(>= (gnc-account-get-current-depth (car account-list))
|
||||
curr-depth))
|
||||
(let* ((account (car account-list))
|
||||
(accrest (cdr account-list))
|
||||
(accnext (and (pair? accrest) (car accrest)))
|
||||
(comm (xaccAccountGetCommodity account))
|
||||
(bal (xaccAccountGetBalanceAsOfDate account opt-date))
|
||||
(depth (flattened-acc-depth account))
|
||||
(treedepth 1)
|
||||
;; Next account only qualifies as 'deeper' if we're not flattening
|
||||
(next-acc-deeper (and (not (null? (safe-cadr account-list)))
|
||||
(> (flattened-acc-depth (safe-cadr account-list)) depth)))
|
||||
(newacc (newaccrec-clean)))
|
||||
(accrec-set-account! newacc account)
|
||||
(accrec-set-code! newacc (xaccAccountGetCode account))
|
||||
@ -483,11 +482,11 @@
|
||||
(add-to-cc total-cc comm bal neg?)
|
||||
(add-to-cc (accrec-subtotal-cc newacc) comm bal neg?)
|
||||
|
||||
(if next-acc-deeper
|
||||
;; Next account only qualifies as 'deeper' if we're not flattening
|
||||
(if (and accnext (> (flattened-acc-depth accnext) depth))
|
||||
;; recurse to deal with deeper level accounts,
|
||||
;; then store the resulting list
|
||||
(let* ((result-v (process-acc-list-r
|
||||
(safe-cdr account-list) (1+ curr-depth) neg?))
|
||||
(let* ((result-v (process-acc-list-r accrest (1+ curr-depth) neg?))
|
||||
(subtree (vector-ref result-v 0))
|
||||
(subtotal-cc (vector-ref result-v 2))
|
||||
(subtreedepth (vector-ref result-v 3))
|
||||
|
Loading…
Reference in New Issue
Block a user