Break circular dependency between owner-report.scm and reports.scm

That is:
* move the account lookup from report.scm to owner-report.scm so
there's no need any more to call into reports.scm from within owner-report.scm
* fix the cmake dependency tree to reflect the new changes:
only customer-overview depends directly on code in reports.scm
All other reports don't. reports.scm however does depend on three
standard reports. So:
standard-reports <- reports <- customer-overview
This commit is contained in:
Geert Janssens 2019-08-26 18:50:33 +02:00
parent 1fc831002d
commit d7e66f9649
3 changed files with 35 additions and 25 deletions

View File

@ -6,10 +6,6 @@ set (reports_common_SCHEME
aging.scm
)
set (reports_SCHEME
reports.scm
)
set (reports_standard_SCHEME
standard/account-piecharts.scm
standard/account-summary.scm
@ -40,7 +36,6 @@ set (reports_standard_SCHEME
standard/transaction.scm
standard/trial-balance.scm
standard/view-column.scm
standard/customer-summary.scm
standard/taxinvoice.scm
standard/receipt.scm
standard/invoice.scm
@ -49,7 +44,11 @@ set (reports_standard_SCHEME
standard/payables.scm
standard/receivables.scm
standard/balsheet-eg.scm
)
)
set (reports_standard_SCHEME_2
standard/customer-summary.scm # Depends on owner-report
)
set(reports_example_SCHEME
example/average-balance.scm
@ -67,6 +66,10 @@ set(reports_de_DE_SCHEME
locale-specific/de_DE/taxtxf.scm
)
set (reports_SCHEME
reports.scm
)
set(scm_rpts_GUILE_DEPENDS
gncmod-html
scm-core-utils
@ -109,24 +112,17 @@ set(scm_rpt_std_GUILE_DEPENDS
scm-reports-standard-links
)
gnc_add_scheme_targets(scm-rpt-reports
"${reports_SCHEME}"
"gnucash"
"${scm_rpts_GUILE_DEPENDS}"
TRUE
)
gnc_add_scheme_targets(scm-reports-common
"${reports_common_SCHEME}"
"gnucash/reports"
"scm-reports-common-links;scm-rpt-reports;${scm_rpt_std_GUILE_DEPENDS}"
"scm-reports-common-links;${scm_rpt_std_GUILE_DEPENDS}"
TRUE
)
gnc_add_scheme_targets(scm-reports-standard
"${reports_standard_SCHEME}"
"gnucash/reports/standard"
"scm-rpt-reports;${scm_rpt_std_GUILE_DEPENDS}"
"scm-reports-common;${scm_rpt_std_GUILE_DEPENDS}"
TRUE
)
@ -151,8 +147,23 @@ gnc_add_scheme_targets(scm-reports-de_DE
TRUE
)
gnc_add_scheme_targets(scm-rpt-reports
"${reports_SCHEME}"
"gnucash"
"scm-reports-standard;scm-reports-example;scm-reports-us;scm-reports-de_DE;${scm_rpts_GUILE_DEPENDS};"
TRUE
)
gnc_add_scheme_targets(scm-reports-standard-2
"${reports_standard_SCHEME_2}"
"gnucash/reports/standard"
"scm-rpt-reports"
TRUE
)
add_custom_target(scm-reports ALL DEPENDS
scm-reports-standard
scm-reports-standard-2
scm-reports-example
scm-reports-common
scm-rpt-reports
@ -210,7 +221,7 @@ gnc_add_scheme_deprecated_module ("gnucash report standard-reports trial-balance
gnc_add_scheme_deprecated_module ("gnucash report view-column" "gnucash reports standard view-column" "scm-reports-standard" "")
set_local_dist(reports_DIST_local CMakeLists.txt ${reports_SCHEME}
${reports_common_SCHEME} ${reports_standard_SCHEME} ${reports_example_SCHEME}
${reports_us_SCHEME} ${reports_de_DE_SCHEME})
${reports_common_SCHEME} ${reports_standard_SCHEME} ${reports_standard_SCHEME_2}
${reports_example_SCHEME} ${reports_us_SCHEME} ${reports_de_DE_SCHEME})
set(reports_DIST ${reports_DIST_local} ${reports_support_DIST}
${test_reports_standard_DIST} PARENT_SCOPE)

View File

@ -90,7 +90,4 @@
(use-modules (gnucash reports standard owner-report))
(define* (gnc:owner-report-create owner account #:key currency)
; Figure out an account to use if nothing exists here.
(if (null? account)
(set! account (find-first-account-for-owner owner #:currency currency)))
(owner-report-create owner account))
(owner-report-create owner account #:currency currency))

View File

@ -32,7 +32,6 @@
(use-modules (gnucash gnc-module))
(use-modules (gnucash utilities)) ; for gnc:debug
(use-modules (gnucash gettext))
(use-modules (gnucash reports))
(gnc:module-load "gnucash/report" 0)
@ -881,8 +880,11 @@
(gnc:option-set-value account-op account)
(gnc:make-report report-guid options)))
(define (owner-report-create owner account)
(define* (owner-report-create owner account #:key currency)
(let ((type (gncOwnerGetType (gncOwnerGetEndOwner owner))))
; Figure out an account to use if nothing exists here.
(if (null? account)
(set! account (find-first-account-for-owner owner #:currency currency)))
(cond
((eqv? type GNC-OWNER-CUSTOMER)
(owner-report-create-internal customer-report-guid owner account type)) ;; Not sure whether to pass type, or to use the guid in the report function
@ -904,7 +906,7 @@
(res -1)) ;; XXX -- in this case we should create an error report
(if (not (null? owner))
(set! res (gnc:owner-report-create owner account)))
(set! res (owner-report-create owner account)))
(gncOwnerFree temp-owner)
res))
@ -915,4 +917,4 @@
(gnc:register-report-hook ACCT-TYPE-PAYABLE #t
gnc:owner-report-create-internal)
(export find-first-account-for-owner owner-report-create)
(export owner-report-create)