1/3 [report-utilities][API] copy funcs engine.scm to report-utilities.scm

The following copied from similarly named functions in libgnucash

gnc:account-full-name<?
gnc:accounts-get-children-depth
This commit is contained in:
Christopher Lam 2020-10-30 19:52:42 +08:00
parent 25e4efc2b7
commit a10c084022
4 changed files with 20 additions and 6 deletions

View File

@ -56,6 +56,18 @@
(let ((type (xaccAccountGetType account)))
(member type (list ACCT-TYPE-STOCK ACCT-TYPE-MUTUAL))))
;; account related functions
;; helper for sorting of account list
(define (gnc:account-full-name<? a b)
(gnc:string-locale<? (gnc-account-get-full-name a) (gnc-account-get-full-name b)))
(define (gnc:accounts-get-children-depth accounts)
(1- (apply max
(map (lambda (acct)
(+ (gnc-account-get-current-depth acct)
(gnc-account-get-tree-depth acct)))
accounts))))
;; True if the account is of type income or expense
(define (gnc:account-is-inc-exp? account)

View File

@ -672,6 +672,8 @@
(export gnc:account-has-shares?)
(export gnc:account-is-stock?)
(export gnc:account-is-inc-exp?)
(export gnc:account-full-name<?)
(export gnc:accounts-get-children-depth)
(export gnc:filter-accountlist-type)
(export gnc:decompose-accountlist)
(export gnc:account-get-type-string-plural)

View File

@ -717,7 +717,7 @@
(else
(let* ((tree-depth (if (eq? display-depth 'all)
(accounts-get-children-depth accounts)
(gnc:accounts-get-children-depth accounts)
display-depth))
(to-period-val (lambda (v)
(inexact->exact
@ -732,7 +732,7 @@
(list 'zero-balance-mode
(if show-zb-accts? 'show-leaf-acct 'omit-leaf-acct))
(list 'report-budget budget)))
(accounts (sort accounts account-full-name<?))
(accounts (sort accounts gnc:account-full-name<?))
(accumulate? (get-option gnc:pagename-general optname-accumulate))
(acct-table (gnc:make-html-acct-table/env/accts env accounts))
(footnotes (make-footnote-collector))

View File

@ -158,7 +158,7 @@
(accounts (if show-subaccts?
(gnc:accounts-and-all-descendants accounts)
accounts))
(accounts (sort accounts account-full-name<?)))
(accounts (sort accounts gnc:account-full-name<?)))
(define (add-accounts-flow accounts accounts-alist)
(let loop ((accounts accounts)
@ -193,7 +193,7 @@
(if (not (null? accounts))
(let* ((tree-depth (if (equal? display-depth 'all)
(accounts-get-children-depth accounts)
(gnc:accounts-get-children-depth accounts)
display-depth))
(account-disp-list
(map
@ -242,12 +242,12 @@
(cons 'to-report-currency to-report-currency)))))
(let ((money-in-accounts (sort
(cdr (assq 'money-in-accounts result))
account-full-name<?))
gnc:account-full-name<?))
(money-in-alist (cdr (assq 'money-in-alist result)))
(money-in-collector (cdr (assq 'money-in-collector result)))
(money-out-accounts (sort
(cdr (assq 'money-out-accounts result))
account-full-name<?))
gnc:account-full-name<?))
(money-out-alist (cdr (assq 'money-out-alist result)))
(money-out-collector (cdr (assq 'money-out-collector result))))