1;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2;; general-ledger.scm: general ledger report
3;;
4;; By David Montenegro <sunrise2000@comcast.net> 2004.07.13
5;;
6;;  * BUGS:
7;;
8;;    See any "FIXME"s in the code.
9;;
10;; Largely borrowed from welcome-to-gnucash.scm by
11;;  Bill Gribble <grib@gnumatic.com>
12;;
13;; This program is free software; you can redistribute it and/or
14;; modify it under the terms of the GNU General Public License as
15;; published by the Free Software Foundation; either version 2 of
16;; the License, or (at your option) any later version.
17;;
18;; This program is distributed in the hope that it will be useful,
19;; but WITHOUT ANY WARRANTY; without even the implied warranty of
20;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
21;; GNU General Public License for more details.
22;;
23;; You should have received a copy of the GNU General Public License
24;; along with this program; if not, contact:
25;;
26;; Free Software Foundation           Voice:  +1-617-542-5942
27;; 51 Franklin Street, Fifth Floor    Fax:    +1-617-542-2652
28;; Boston, MA  02110-1301,  USA       gnu@gnu.org
29;;
30;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
31
32(define-module (gnucash reports standard general-ledger))
33(use-modules (gnucash engine))
34(use-modules (gnucash utilities))
35(use-modules (gnucash core-utils))
36(use-modules (gnucash app-utils))
37(use-modules (gnucash report))
38
39(define reportname (N_ "General Ledger"))
40(define xactrptguid "2fe3b9833af044abb929a88d5a59620f")
41(define xactrptname "Transaction Report")
42
43
44
45;; options generator
46
47(define (general-ledger-options-generator)
48  (let ((options (gnc:trep-options-generator)))
49
50    (define pagename-sorting (N_ "Sorting"))
51    (define (set-option! section name value)
52      (gnc:option-set-default-value
53       (gnc:lookup-option options section name) value))
54
55    ;; set options in the accounts tab...
56    (set-option! gnc:pagename-accounts "Filter Type" 'none)
57    (set-option! "Filter" "Void Transactions" 'non-void-only)
58
59    ;; set options in the display tab...
60    (for-each
61     (lambda (l)
62       (set-option! gnc:pagename-display (car l) (cadr l)))
63     ;; One list per option here with: option-name, default-value
64     (if (qof-book-use-split-action-for-num-field (gnc-get-current-book))
65         (list
66          (list (N_ "Date") #t)
67          (list (N_ "Reconciled Date") #f)
68          (list (N_ "Num/Action") #f)
69          (list (N_ "Trans Number") #f)
70          (list (N_ "Description") #t)
71          (list (N_ "Memo") #f)
72          (list (N_ "Account Name") #f)
73          (list (N_ "Use Full Account Name") #f)
74          (list (N_ "Account Code") #f)
75          (list (N_ "Other Account Name") #f)
76          (list (N_ "Use Full Other Account Name") #f)
77          (list (N_ "Other Account Code") #f)
78          (list (N_ "Shares") #f)
79          (list (N_ "Price") #f)
80          ;; note the "Amount" multichoice option here
81          (list (N_ "Amount") 'double)
82          (list (N_ "Running Balance") #t)
83          (list (N_ "Totals") #f)
84          (list (N_ "Sign Reverses") 'credit-accounts)
85         )
86         (list
87          (list (N_ "Date") #t)
88          (list (N_ "Reconciled Date") #f)
89          (list (N_ "Num") #f)
90          (list (N_ "Description") #t)
91          (list (N_ "Memo") #f)
92          (list (N_ "Account Name") #f)
93          (list (N_ "Use Full Account Name") #f)
94          (list (N_ "Account Code") #f)
95          (list (N_ "Other Account Name") #f)
96          (list (N_ "Use Full Other Account Name") #f)
97          (list (N_ "Other Account Code") #f)
98          (list (N_ "Shares") #f)
99          (list (N_ "Price") #f)
100          ;; note the "Amount" multichoice option here
101          (list (N_ "Amount") 'double)
102          (list (N_ "Running Balance") #t)
103          (list (N_ "Totals") #f)
104          (list (N_ "Sign Reverses") 'credit-accounts)
105         )
106     )
107    )
108
109    ;; set options in the general tab...
110    (set-option!
111     gnc:pagename-display (N_ "Detail Level") 'single)
112
113
114    ;; we can't (currently) set the Report name here
115    ;; because it is automatically set to the template
116    ;; name... :(
117
118    ;; set options in the sorting tab...
119    (for-each
120     (lambda (l)
121       (set-option! pagename-sorting (car l) (cadr l)))
122     ;; One list per option here with: option-name, default-value
123     (list
124      (list (N_ "Primary Key") 'account-code)
125      (list (N_ "Show Full Account Name") #f)
126      (list (N_ "Show Account Code") #t)
127      (list (N_ "Primary Subtotal") #t)
128      (list (N_ "Primary Subtotal for Date Key") 'none)
129      (list (N_ "Primary Sort Order") 'ascend)
130      (list (N_ "Secondary Key") 'register-order)
131      (list (N_ "Secondary Subtotal") #t)
132      (list (N_ "Secondary Subtotal for Date Key") 'none)
133      (list (N_ "Secondary Sort Order") 'ascend)
134      )
135     )
136
137    options)
138  )
139
140;; report renderer
141
142(define (general-ledger-renderer report-obj)
143  ;; just delegate rendering to the Transaction Report renderer...
144  (let ((document ((gnc:report-template-renderer/report-guid xactrptguid xactrptname)
145                   report-obj)))
146    (gnc:html-document-set-title! document (G_ reportname))
147    document))
148
149(gnc:define-report
150 'version 1
151 'name reportname
152 'report-guid "2e22929e5c5b4b769f615a815ef0c20f"
153 'menu-path (list gnc:menuname-asset-liability)
154 'options-generator general-ledger-options-generator
155 'renderer general-ledger-renderer
156 )
157
158;; END
159
160