Skip to content

Commit

Permalink
Bug 773199 - Rename and rebuild Welcome to GnuCash Report
Browse files Browse the repository at this point in the history
- separate the multicolumn report into its own source file
- tweak it as suggested in the bug report
  • Loading branch information
gjanssens committed May 24, 2019
1 parent 7cc9d5c commit da4d72f
Show file tree
Hide file tree
Showing 5 changed files with 96 additions and 71 deletions.
10 changes: 5 additions & 5 deletions gnucash/report/report-gnome/report-gnome.scm
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
(use-modules (gnucash gnc-module))
(use-modules (gnucash gnome-utils))
(use-modules (gnucash gettext))
(use-modules (gnucash report reports sample welcome-to-gnucash))
(use-modules (gnucash report reports sample dashboard))

(eval-when (compile load eval expand)
(load-extension "libgncmod-gnome-utils" "scm_init_sw_gnome_utils_module")
Expand Down Expand Up @@ -110,12 +110,12 @@
;; push reports (new items added on top of menu)
(gnc:add-report-template-menu-items)

;; the Welcome to GnuCash "extravaganza" report
;; the dashboard report
(gnc-add-scm-extension
(gnc:make-menu-item
(N_ "Welcome Sample Report")
(N_ "Dashboard")
"ad80271c890b11dfa79f2dcedfd72085"
(N_ "Welcome-to-GnuCash report screen")
(N_ "A basic dashboard for your accounting data")
(list gnc:menuname-reports gnc:menuname-utility "")
(lambda (window)
(gnc-main-window-open-report (gnc:make-welcome-report) window)))))
(gnc-main-window-open-report (gnc:make-dashboard) window)))))
1 change: 1 addition & 0 deletions gnucash/report/reports/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ set (reports_standard_SCHEME
)

set(reports_sample_SCHEME
sample/dashboard.scm
sample/hello-world.scm
sample/view-column.scm
sample/welcome-to-gnucash.scm
Expand Down
72 changes: 72 additions & 0 deletions gnucash/report/reports/sample/dashboard.scm
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; dashboard.scm : dasboard style report based on Bill's welcome
;; to gnucash demo report
;; Copyright 2001 Bill Gribble <grib@gnumatic.com>
;; Copyright 2019 Geert Janssens <geert@kobaltwit.be>
;;
;; This program is free software; you can redistribute it and/or
;; modify it under the terms of the GNU General Public License as
;; published by the Free Software Foundation; either version 2 of
;; the License, or (at your option) any later version.
;;
;; This program is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;;
;; You should have received a copy of the GNU General Public License
;; along with this program; if not, contact:
;;
;; Free Software Foundation Voice: +1-617-542-5942
;; 51 Franklin Street, Fifth Floor Fax: +1-617-542-2652
;; Boston, MA 02110-1301, USA gnu@gnu.org
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

(define-module (gnucash report reports sample dashboard))
(export gnc:make-dashboard)

(use-modules (gnucash utilities))
(use-modules (gnucash core-utils)) ; for gnc:version
(use-modules (gnucash gettext))
(use-modules (gnucash gnc-module))
(eval-when
(compile load eval expand)
(load-extension "libgncmod-report-system" "scm_init_sw_report_system_module"))
(use-modules (sw_report_system))

(gnc:module-load "gnucash/report/report-system" 0)

(define multicolumn-guid "d8ba4a2e89e8479ca9f6eccdeb164588")
(define acct-summary-guid "3298541c236b494998b236dfad6ad752")
(define exp-piechart-guid "9bf1892805cb4336be6320fe48ce5446")
(define inc-piechart-guid "e1bd09b8a1dd49dd85760db9d82b045c")
(define inc-exp-chart-guid "80769921e87943adade887b9835a7685")

(define (gnc:make-dashboard)
(let* ((view (gnc:make-report multicolumn-guid))
(sub-accounts (gnc:make-report acct-summary-guid))
(sub-expense-pie (gnc:make-report exp-piechart-guid))
(sub-income-pie (gnc:make-report inc-piechart-guid))
(sub-bar (gnc:make-report inc-exp-chart-guid))
(options #f))

(define (set-option! section name value)
(gnc:option-set-value
(gnc:lookup-option options section name) value))

(set! options (gnc:report-options (gnc-report-find view)))
(set-option! "General" "Report name" (_ "Dashboard"))
(set-option! "General" "Number of columns" 2)

;; mark the reports as needing to be saved
(gnc:report-set-needs-save?! (gnc-report-find sub-accounts) #t)
(gnc:report-set-needs-save?! (gnc-report-find sub-expense-pie) #t)
(gnc:report-set-needs-save?! (gnc-report-find sub-income-pie) #t)
(gnc:report-set-needs-save?! (gnc-report-find sub-bar) #t)

(set-option! "__general" "report-list"
(list (list sub-expense-pie 1 1 #f)
(list sub-income-pie 1 1 #f)
(list sub-bar 2 1 #f)
(list sub-accounts 2 1 #f)))
view))
83 changes: 17 additions & 66 deletions gnucash/report/reports/sample/welcome-to-gnucash.scm
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; welcome-to-gnucash.scm : introductory report for new users
;; welcome-to-gnucash.scm : very minimalistic sampe report
;; can be used as skeleton to make new reports
;; Copyright 2001 Bill Gribble <grib@gnumatic.com>
;;
;; This program is free software; you can redistribute it and/or
;; modify it under the terms of the GNU General Public License as
;; published by the Free Software Foundation; either version 2 of
;; the License, or (at your option) any later version.
;;
;; This program is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;;
;; This program is free software; you can redistribute it and/or
;; modify it under the terms of the GNU General Public License as
;; published by the Free Software Foundation; either version 2 of
;; the License, or (at your option) any later version.
;;
;; This program is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;;
;; You should have received a copy of the GNU General Public License
;; along with this program; if not, contact:
;;
Expand All @@ -21,9 +22,8 @@
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

(define-module (gnucash report reports sample welcome-to-gnucash))
(export gnc:make-welcome-report)

(use-modules (gnucash utilities))
(use-modules (gnucash utilities))
(use-modules (gnucash core-utils)) ; for gnc:version
(use-modules (gnucash gettext))
(use-modules (gnucash gnc-module))
Expand All @@ -34,63 +34,14 @@

(gnc:module-load "gnucash/report/report-system" 0)

(define multicolumn-guid "d8ba4a2e89e8479ca9f6eccdeb164588")
(define welcome-guid "65135608f2014c6ca8412793a8cdf169")
(define acct-summary-guid "3298541c236b494998b236dfad6ad752")
(define exp-piechart-guid "9bf1892805cb4336be6320fe48ce5446")
(define inc-piechart-guid "e1bd09b8a1dd49dd85760db9d82b045c")
(define inc-exp-chart-guid "80769921e87943adade887b9835a7685")

(define (gnc:make-welcome-report)
(let* ((view (gnc:make-report multicolumn-guid))
(sub-welcome (gnc:make-report welcome-guid))
(sub-accounts (gnc:make-report acct-summary-guid))
(sub-expense-pie (gnc:make-report exp-piechart-guid))
(sub-income-pie (gnc:make-report inc-piechart-guid))
(sub-bar (gnc:make-report inc-exp-chart-guid))
(options #f))

(define (set-option! section name value)
(gnc:option-set-value
(gnc:lookup-option options section name) value))

(set! options (gnc:report-options (gnc-report-find view)))
(set-option! "General" "Report name" (_ "Welcome to GnuCash"))
(set-option! "General" "Number of columns" 2)

;; mark the reports as needing to be saved
(gnc:report-set-needs-save?! (gnc-report-find sub-welcome) #t)
(gnc:report-set-needs-save?! (gnc-report-find sub-accounts) #t)
(gnc:report-set-needs-save?! (gnc-report-find sub-expense-pie) #t)
(gnc:report-set-needs-save?! (gnc-report-find sub-income-pie) #t)
(gnc:report-set-needs-save?! (gnc-report-find sub-bar) #t)

(set-option! "__general" "report-list"
(list (list sub-welcome 1 1 #f)
(list sub-accounts 1 1 #f)
(list sub-expense-pie 1 1 #f)
(list sub-income-pie 1 1 #f)
(list sub-bar 2 1 #f)))

(set! options (gnc:report-options (gnc-report-find sub-expense-pie)))
(set-option! "Display" "Plot Width" 400)

(set! options (gnc:report-options (gnc-report-find sub-income-pie)))
(set-option! "Display" "Plot Width" 400)

(set! options (gnc:report-options (gnc-report-find sub-bar)))
(set-option! "Display" "Plot Width" 800)

view))

(define (options)
(define (options)
(gnc:new-options))

(define (renderer report-obj)
(let ((doc (gnc:make-html-document)))
(gnc:html-document-add-object!
(gnc:html-document-add-object!
doc
(gnc:make-html-text
(gnc:make-html-text
(gnc:html-markup-h2
(format #f (_ "Welcome to GnuCash ~a !")
gnc:version))
Expand All @@ -99,7 +50,7 @@
gnc:version))))
doc))

(gnc:define-report
(gnc:define-report
'name (N_ "Welcome to GnuCash")
'version 1
'report-guid "65135608f2014c6ca8412793a8cdf169"
Expand Down
1 change: 1 addition & 0 deletions po/POTFILES.in
Original file line number Diff line number Diff line change
Expand Up @@ -425,6 +425,7 @@ gnucash/report/report-gnome/report-gnome.scm
gnucash/report/report-gnome/window-report.c
gnucash/report/reports/aging.scm
gnucash/report/reports/reports.scm
gnucash/report/reports/sample/dashboard.scm
gnucash/report/reports/sample/hello-world.scm
gnucash/report/reports/sample/view-column.scm
gnucash/report/reports/sample/welcome-to-gnucash.scm
Expand Down

0 comments on commit da4d72f

Please sign in to comment.