From 7f19abaabd5223e6498eb863dac780ceb143b8f2 Mon Sep 17 00:00:00 2001 From: Christopher Lam Date: Mon, 24 Jun 2019 21:58:52 +0800 Subject: [PATCH] [customer-summary] remove unneeded sanity check for owner and all-accounts which will never be null? because it's made of income-accounts and expense-accounts, and (null? income-accounts) has already been handled by previous cond --- .../business-reports/customer-summary.scm | 54 +++++++++---------- 1 file changed, 26 insertions(+), 28 deletions(-) diff --git a/gnucash/report/business-reports/customer-summary.scm b/gnucash/report/business-reports/customer-summary.scm index 62cbb2d552..9230354709 100644 --- a/gnucash/report/business-reports/customer-summary.scm +++ b/gnucash/report/business-reports/customer-summary.scm @@ -383,43 +383,41 @@ ;; Loop over all owners (map (lambda (owner) - (if - (and (gncOwnerIsValid owner) - (> (length all-accounts) 0)) + ;; Now create the line for one single owner + (let ((total-income (gnc-numeric-zero)) + (total-expense (gnc-numeric-zero))) - ;; Now create the line for one single owner - (let ((total-income (gnc-numeric-zero)) - (total-expense (gnc-numeric-zero))) + (set! currency (xaccAccountGetCommodity (car all-accounts))) + (set! any-valid-owner? #t) - (set! currency (xaccAccountGetCommodity (car all-accounts))) - (set! any-valid-owner? #t) + ;; Run one query on all income accounts + (query-owner-setup owner-query owner) - ;; Run one query on all income accounts - (query-owner-setup owner-query owner) + (set! total-income + (query-split-value owner-query toplevel-income-query)) + (if reverse? + (set! total-income (gnc-numeric-neg total-income))) - (set! total-income (query-split-value owner-query toplevel-income-query)) - (if reverse? - (set! total-income (gnc-numeric-neg total-income))) + ;; Clean up the query + (qof-query-clear owner-query) - ;; Clean up the query - (qof-query-clear owner-query) + ;; And run one query on all expense accounts + (query-owner-setup owner-query owner) - ;; And run one query on all expense accounts - (query-owner-setup owner-query owner) + (set! total-expense + (query-split-value owner-query toplevel-expense-query)) + (if reverse? + (set! total-expense (gnc-numeric-neg total-expense))) - (set! total-expense (query-split-value owner-query toplevel-expense-query)) - (if reverse? - (set! total-expense (gnc-numeric-neg total-expense))) + ;; Clean up the query + (qof-query-clear owner-query) - ;; Clean up the query - (qof-query-clear owner-query) + ;; We print the summary now + (let* ((profit (gnc-numeric-add-fixed total-income total-expense)) + (markupfloat (markup-percent profit total-income))) - ;; We print the summary now - (let* ((profit (gnc-numeric-add-fixed total-income total-expense)) - (markupfloat (markup-percent profit total-income))) - - ;; Result of this customer - (list owner profit markupfloat total-income total-expense))))) + ;; Result of this customer + (list owner profit markupfloat total-income total-expense)))) ownerlist))) ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;