mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
various reports: use more efficient report-utilities.scm functions
instead of delete-duplicates
This commit is contained in:
parent
ae4b7e1582
commit
aa95d61c6c
@ -292,9 +292,7 @@
|
|||||||
(expense-accounts (opt-val pagename-expenseaccounts optname-expenseaccounts))
|
(expense-accounts (opt-val pagename-expenseaccounts optname-expenseaccounts))
|
||||||
(sales-accounts (opt-val pagename-incomeaccounts optname-incomeaccounts))
|
(sales-accounts (opt-val pagename-incomeaccounts optname-incomeaccounts))
|
||||||
(all-accounts (append sales-accounts expense-accounts))
|
(all-accounts (append sales-accounts expense-accounts))
|
||||||
(commodities (delete-duplicates
|
(commodities (gnc:accounts-get-commodities all-accounts #f))
|
||||||
(map xaccAccountGetCommodity all-accounts)
|
|
||||||
gnc-commodity-equiv))
|
|
||||||
(commodities>1? (> (length commodities) 1))
|
(commodities>1? (> (length commodities) 1))
|
||||||
(book (gnc-get-current-book))
|
(book (gnc-get-current-book))
|
||||||
(date-format (gnc:options-fancy-date book))
|
(date-format (gnc:options-fancy-date book))
|
||||||
|
@ -167,8 +167,7 @@ date point, a projected minimum balance including scheduled transactions."))
|
|||||||
(accum (gnc:make-commodity-collector))
|
(accum (gnc:make-commodity-collector))
|
||||||
(exchange-fn (gnc:case-exchange-time-fn
|
(exchange-fn (gnc:case-exchange-time-fn
|
||||||
price currency
|
price currency
|
||||||
(delete-duplicates! (map xaccAccountGetCommodity accounts)
|
(gnc:accounts-get-commodities accounts #f)
|
||||||
gnc-commodity-equiv)
|
|
||||||
to-date #f #f))
|
to-date #f #f))
|
||||||
(accounts-balancelist
|
(accounts-balancelist
|
||||||
(map
|
(map
|
||||||
|
@ -802,12 +802,7 @@ also show overall period profit & loss."))
|
|||||||
;; missing price, say so.
|
;; missing price, say so.
|
||||||
(get-exchange-rates-fn
|
(get-exchange-rates-fn
|
||||||
(lambda (accounts col-idx)
|
(lambda (accounts col-idx)
|
||||||
(let ((commodities (delete
|
(let ((commodities (gnc:accounts-get-commodities accounts common-currency))
|
||||||
common-currency
|
|
||||||
(delete-duplicates
|
|
||||||
(map xaccAccountGetCommodity accounts)
|
|
||||||
gnc-commodity-equal)
|
|
||||||
gnc-commodity-equal))
|
|
||||||
(cell (gnc:make-html-text)))
|
(cell (gnc:make-html-text)))
|
||||||
(for-each
|
(for-each
|
||||||
(lambda (commodity)
|
(lambda (commodity)
|
||||||
|
@ -375,8 +375,7 @@ developing over time"))
|
|||||||
(xaccSplitGetAmount s))))))))
|
(xaccSplitGetAmount s))))))))
|
||||||
;; all selected accounts (of report-specific type), *and*
|
;; all selected accounts (of report-specific type), *and*
|
||||||
;; their descendants (of any type) need to be scanned.
|
;; their descendants (of any type) need to be scanned.
|
||||||
(delete-duplicates
|
(gnc:accounts-and-all-descendants accounts)))
|
||||||
(append accounts (gnc:acccounts-get-all-subaccounts accounts)))))
|
|
||||||
|
|
||||||
;; Creates the <balance-list> to be used in the function
|
;; Creates the <balance-list> to be used in the function
|
||||||
;; below.
|
;; below.
|
||||||
|
@ -226,21 +226,9 @@
|
|||||||
;; add accounts to the query (include subaccounts
|
;; add accounts to the query (include subaccounts
|
||||||
;; if requested)
|
;; if requested)
|
||||||
(gnc:report-percent-done 25)
|
(gnc:report-percent-done 25)
|
||||||
(if dosubs?
|
(if dosubs?
|
||||||
(let ((subaccts '()))
|
(set! accounts
|
||||||
(for-each
|
(gnc:accounts-and-all-descendants accounts)))
|
||||||
(lambda (acct)
|
|
||||||
(let ((this-acct-subs
|
|
||||||
(gnc-account-get-descendants-sorted acct)))
|
|
||||||
(if (list? this-acct-subs)
|
|
||||||
(set! subaccts
|
|
||||||
(append subaccts this-acct-subs)))))
|
|
||||||
accounts)
|
|
||||||
;; Beware: delete-duplicates is an O(n^2)
|
|
||||||
;; algorithm. More efficient method: sort the list,
|
|
||||||
;; then use a linear algorithm.
|
|
||||||
(set! accounts
|
|
||||||
(delete-duplicates (append accounts subaccts)))))
|
|
||||||
(gnc:report-percent-done 30)
|
(gnc:report-percent-done 30)
|
||||||
|
|
||||||
(xaccQueryAddAccountMatch query accounts QOF-GUID-MATCH-ANY QOF-QUERY-AND)
|
(xaccQueryAddAccountMatch query accounts QOF-GUID-MATCH-ANY QOF-QUERY-AND)
|
||||||
|
Loading…
Reference in New Issue
Block a user