mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
Christian Stimming's report patch.
* src/scm/report/income-expense-graph.scm, income-or-expense-pie.scm: Fixed account choosing, fixed default report currency, added currency exchange calculation. git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@3812 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
parent
75ee724948
commit
629d05e08a
@ -1,3 +1,9 @@
|
||||
2001-03-20 Christian Stimming <stimming@tuhh.de>
|
||||
|
||||
* src/scm/report/income-expense-graph.scm,
|
||||
income-or-expense-pie.scm: Fixed account choosing, fixed default
|
||||
report currency, added currency exchange calculation.
|
||||
|
||||
2001-03-20 Dave Peticolas <dave@krondo.com>
|
||||
|
||||
* src/gnome/dialog-progress.c
|
||||
|
@ -8,7 +8,17 @@
|
||||
(gnc:depend "report-html.scm")
|
||||
(gnc:depend "date-utilities.scm")
|
||||
|
||||
(let ()
|
||||
(let ((pagename-general (N_ "General"))
|
||||
(optname-from-date (N_ "From"))
|
||||
(optname-to-date (N_ "To"))
|
||||
(optname-accounts (N_ "Accounts"))
|
||||
(optname-stepsize (N_ "Step Size"))
|
||||
(optname-report-currency (N_ "Report's currency"))
|
||||
|
||||
(pagename-display (N_ "Display Format"))
|
||||
(optname-plot-width (N_ "Plot Width"))
|
||||
(optname-plot-height (N_ "Plot Height")))
|
||||
|
||||
|
||||
(define (options-generator)
|
||||
(let* ((options (gnc:new-options))
|
||||
@ -19,34 +29,13 @@
|
||||
(gnc:register-option options new-option))))
|
||||
|
||||
(gnc:options-add-date-interval!
|
||||
options "Report Options"
|
||||
(N_ "From") (N_ "To")
|
||||
"d")
|
||||
options pagename-general
|
||||
optname-from-date optname-to-date "a")
|
||||
|
||||
(add-option
|
||||
(gnc:make-account-list-option
|
||||
(N_ "Report Options") (N_ "Accounts")
|
||||
"b"
|
||||
"Select accounts to calculate income on"
|
||||
(lambda ()
|
||||
(filter
|
||||
gnc:account-is-inc-exp?
|
||||
(gnc:group-get-subaccounts (gnc:get-current-group))))
|
||||
gnc:account-is-inc-exp?
|
||||
#t))
|
||||
|
||||
(add-option
|
||||
(gnc:make-currency-option
|
||||
"Report Options"
|
||||
"Report Currency"
|
||||
"c"
|
||||
"Select the display value for the currency"
|
||||
(gnc:locale-default-currency)))
|
||||
|
||||
(add-option
|
||||
(gnc:make-multichoice-option
|
||||
(N_ "Report Options") (N_ "Step Size")
|
||||
"e" (N_ "The amount of time between data points") 'MonthDelta
|
||||
pagename-general optname-stepsize
|
||||
"b" (_ "The amount of time between data points") 'MonthDelta
|
||||
(list #(WeekDelta "Week" "Week")
|
||||
#(TwoWeekDelta "Two Week" "Two Weeks")
|
||||
#(MonthDelta "Month" "Month")
|
||||
@ -54,19 +43,42 @@
|
||||
#(YearDelta "Year" "Year")
|
||||
)))
|
||||
|
||||
(add-option
|
||||
(add-option
|
||||
(gnc:make-account-list-option
|
||||
pagename-general optname-accounts
|
||||
"c"
|
||||
(_ "Select accounts to calculate income on")
|
||||
(lambda ()
|
||||
(filter
|
||||
gnc:account-is-inc-exp?
|
||||
(gnc:group-get-subaccounts (gnc:get-current-group))))
|
||||
(lambda (accounts)
|
||||
(list #t
|
||||
(filter gnc:account-is-inc-exp? accounts)))
|
||||
#t))
|
||||
|
||||
(add-option
|
||||
(gnc:make-currency-option
|
||||
pagename-general optname-report-currency
|
||||
"d"
|
||||
(_ "Select the display value for the currency")
|
||||
(gnc:option-value
|
||||
(gnc:lookup-global-option "International"
|
||||
"Default Currency"))))
|
||||
|
||||
(add-option
|
||||
(gnc:make-number-range-option
|
||||
(N_ "Display Format") (N_ "Plot Width")
|
||||
"a" (N_ "Width of plot in pixels.") 400
|
||||
pagename-display optname-plot-width
|
||||
"a" (_ "Width of plot in pixels.") 400
|
||||
100 1000 0 1))
|
||||
|
||||
(add-option
|
||||
(gnc:make-number-range-option
|
||||
(N_ "Display Format") (N_ "Plot Height")
|
||||
"b" (N_ "Height of plot in pixels.") 400
|
||||
pagename-display optname-plot-height
|
||||
"b" (_ "Height of plot in pixels.") 400
|
||||
100 1000 0 1))
|
||||
|
||||
(gnc:options-set-default-section options "Report Options")
|
||||
(gnc:options-set-default-section options pagename-general)
|
||||
|
||||
options))
|
||||
|
||||
@ -85,24 +97,26 @@
|
||||
(define (op-value section name)
|
||||
(gnc:option-value (get-op section name)))
|
||||
|
||||
(let* ((report-currency (op-value "Report Options" "Report Currency"))
|
||||
(height (op-value "Display Format" "Plot Height"))
|
||||
(width (op-value "Display Format" "Plot Width"))
|
||||
(accounts (op-value "Report Options" "Accounts"))
|
||||
(to-date-tp (gnc:timepair-end-day-time
|
||||
(vector-ref (op-value "Report Options"
|
||||
"To") 1)))
|
||||
(let* ((to-date-tp (gnc:timepair-end-day-time
|
||||
(vector-ref (op-value pagename-general
|
||||
optname-to-date) 1)))
|
||||
(from-date-tp (gnc:timepair-start-day-time
|
||||
(vector-ref (op-value "Report Options"
|
||||
"From") 1)))
|
||||
(interval (op-value "Report Options" "Step Size"))
|
||||
(vector-ref (op-value pagename-general
|
||||
optname-from-date) 1)))
|
||||
(interval (op-value pagename-general optname-stepsize))
|
||||
(accounts (op-value pagename-general optname-accounts))
|
||||
(report-currency (op-value pagename-general optname-report-currency))
|
||||
|
||||
(height (op-value pagename-display optname-plot-height))
|
||||
(width (op-value pagename-display optname-plot-width))
|
||||
|
||||
(document (gnc:make-html-document))
|
||||
(chart (gnc:make-html-barchart))
|
||||
(exchange-alist (gnc:make-exchange-alist
|
||||
report-currency to-date-tp))
|
||||
(exchange-fn-internal (gnc:make-exchange-function exchange-alist))
|
||||
(exchange-fn (lambda (foriegn)
|
||||
(exchange-fn-internal foriegn report-currency)))
|
||||
(exchange-fn (lambda (foreign)
|
||||
(exchange-fn-internal foreign report-currency)))
|
||||
(dates-list (gnc:dateloop
|
||||
(gnc:timepair-start-day-time from-date-tp)
|
||||
(gnc:timepair-end-day-time
|
||||
@ -124,9 +138,12 @@
|
||||
(map profit-collector-fn dates-list))
|
||||
(double-list
|
||||
(map (lambda (commodity-collector)
|
||||
(- (gnc:numeric-to-double
|
||||
(cadr (commodity-collector 'getpair
|
||||
report-currency #t)))))
|
||||
;;(-
|
||||
(gnc:numeric-to-double
|
||||
(gnc:gnc-monetary-amount
|
||||
(gnc:sum-collector-commodity
|
||||
commodity-collector report-currency
|
||||
exchange-fn-internal))));;)
|
||||
profit-collector-list))
|
||||
(date-string-list
|
||||
(map (lambda (date-list-item)
|
||||
@ -134,7 +151,7 @@
|
||||
(car date-list-item)))
|
||||
dates-list)))
|
||||
|
||||
(gnc:html-barchart-set-title! chart (N_ "Income/Expense Chart"))
|
||||
(gnc:html-barchart-set-title! chart (_ "Income/Expense Chart"))
|
||||
(gnc:html-barchart-set-subtitle!
|
||||
chart (sprintf #f
|
||||
(_ "%s to %s")
|
||||
|
@ -8,7 +8,16 @@
|
||||
(gnc:depend "report-html.scm")
|
||||
(gnc:depend "date-utilities.scm")
|
||||
|
||||
(let ()
|
||||
(let ((pagename-general (N_ "General"))
|
||||
(optname-from-date (N_ "From"))
|
||||
(optname-to-date (N_ "To"))
|
||||
(optname-accounts (N_ "Accounts"))
|
||||
(optname-report-currency (N_ "Report's currency"))
|
||||
|
||||
(pagename-display (N_ "Display Format"))
|
||||
(optname-slices (N_ "Maximum Slices"))
|
||||
(optname-plot-width (N_ "Plot Width"))
|
||||
(optname-plot-height (N_ "Plot Height")))
|
||||
|
||||
;; Note the options-generator has a boolean argument, which
|
||||
;; is true for income piecharts. We use a lambda to wrap
|
||||
@ -20,17 +29,15 @@
|
||||
(lambda (new-option)
|
||||
(gnc:register-option options new-option))))
|
||||
|
||||
(add-option
|
||||
(gnc:make-number-range-option
|
||||
(N_ "Report Options") (N_ "Maximum Slices")
|
||||
"a" (N_ "Maximum number of slices in pie") 7
|
||||
2 20 0 1))
|
||||
(gnc:options-add-date-interval!
|
||||
options pagename-general
|
||||
optname-from-date optname-to-date "a")
|
||||
|
||||
(add-option
|
||||
(gnc:make-account-list-option
|
||||
(N_ "Report Options") (N_ "Accounts")
|
||||
pagename-general optname-accounts
|
||||
"b"
|
||||
(N_ "Select accounts to calculate income on")
|
||||
(_ "Select accounts to calculate income on")
|
||||
(lambda ()
|
||||
(gnc:filter-accountlist-type
|
||||
(if is-income? '(income) '(expense))
|
||||
@ -44,28 +51,33 @@
|
||||
|
||||
(add-option
|
||||
(gnc:make-currency-option
|
||||
(N_ "Report Options") (N_ "Report Currency")
|
||||
pagename-general optname-report-currency
|
||||
"c"
|
||||
(N_ "Select the display value for the currency")
|
||||
(gnc:locale-default-currency)))
|
||||
|
||||
(gnc:options-add-date-interval!
|
||||
options "Report Options"
|
||||
(N_ "From") (N_ "To")
|
||||
"d")
|
||||
(_ "Select the display value for the currency")
|
||||
(gnc:option-value
|
||||
(gnc:lookup-global-option "International"
|
||||
"Default Currency"))))
|
||||
|
||||
(add-option
|
||||
(gnc:make-number-range-option
|
||||
(N_ "Display Format") (N_ "Plot Width")
|
||||
"a" (N_ "Width of plot in pixels.") 500
|
||||
pagename-display optname-slices
|
||||
"a" (N_ "Maximum number of slices in pie") 7
|
||||
2 20 0 1))
|
||||
|
||||
(add-option
|
||||
(gnc:make-number-range-option
|
||||
pagename-display optname-plot-width
|
||||
"b" (N_ "Width of plot in pixels.") 500
|
||||
100 1000 0 1))
|
||||
|
||||
(add-option
|
||||
(gnc:make-number-range-option
|
||||
(N_ "Display Format") (N_ "Plot Height")
|
||||
"b" (N_ "Height of plot in pixels.") 250
|
||||
pagename-display optname-plot-height
|
||||
"c" (N_ "Height of plot in pixels.") 250
|
||||
100 1000 0 1))
|
||||
(gnc:options-set-default-section options "Report Options")
|
||||
|
||||
(gnc:options-set-default-section options pagename-general)
|
||||
|
||||
options))
|
||||
|
||||
;; Similar arrangement to the options-generator.
|
||||
@ -78,17 +90,19 @@
|
||||
(define (op-value section name)
|
||||
(gnc:option-value (get-op section name)))
|
||||
|
||||
(let* ((max-slices (op-value "Report Options" "Maximum Slices"))
|
||||
(report-currency (op-value "Report Options" "Report Currency"))
|
||||
(height (op-value "Display Format" "Plot Height"))
|
||||
(width (op-value "Display Format" "Plot Width"))
|
||||
(accounts (op-value "Report Options" "Accounts"))
|
||||
(to-date-tp (gnc:timepair-end-day-time
|
||||
(vector-ref (op-value "Report Options"
|
||||
"To") 1)))
|
||||
(let* ((to-date-tp (gnc:timepair-end-day-time
|
||||
(vector-ref (op-value pagename-general
|
||||
optname-to-date) 1)))
|
||||
(from-date-tp (gnc:timepair-start-day-time
|
||||
(vector-ref (op-value "Report Options"
|
||||
"From") 1)))
|
||||
(vector-ref (op-value pagename-general
|
||||
optname-from-date) 1)))
|
||||
(accounts (op-value pagename-general optname-accounts))
|
||||
(report-currency (op-value pagename-general optname-report-currency))
|
||||
|
||||
(max-slices (op-value pagename-display optname-slices))
|
||||
(height (op-value pagename-display optname-plot-height))
|
||||
(width (op-value pagename-display optname-plot-width))
|
||||
|
||||
(document (gnc:make-html-document))
|
||||
(chart (gnc:make-html-piechart))
|
||||
(exchange-alist (gnc:make-exchange-alist
|
||||
@ -104,13 +118,21 @@
|
||||
(profit-collector-list
|
||||
(map profit-collector-fn accounts))
|
||||
|
||||
;;; FIXME: better currency handling here
|
||||
;; Future improvement: Let the user choose which kind of
|
||||
;; currency combining she want to be done. Right now
|
||||
;; everything foreign gets converted
|
||||
;; (gnc:sum-collector-commodity) based on the weighted
|
||||
;; average of all past transactions.
|
||||
|
||||
(double-list
|
||||
(map (lambda (commodity-collector)
|
||||
(abs (gnc:numeric-to-double
|
||||
(cadr (commodity-collector 'getpair
|
||||
report-currency #t)))))
|
||||
(gnc:gnc-monetary-amount
|
||||
(gnc:sum-collector-commodity
|
||||
commodity-collector report-currency
|
||||
exchange-fn-internal)))))
|
||||
;;(cadr (commodity-collector 'getpair
|
||||
;; report-currency #t)))))
|
||||
profit-collector-list))
|
||||
(combined (zip double-list accounts))
|
||||
(accounts-or-names '())
|
||||
@ -134,11 +156,12 @@
|
||||
(set! combined
|
||||
(append start
|
||||
(list (list sum (_ "Other")))))
|
||||
(let* ((name (if is-income? "Income Piechart" "Expense Piechart"))
|
||||
(let* ((name (if is-income? (N_ "Income Piechart")
|
||||
(N_ "Expense Piechart")))
|
||||
(options (gnc:make-report-options name))
|
||||
(account-op (gnc:lookup-option options
|
||||
"Report Options"
|
||||
"Accounts")))
|
||||
pagename-general
|
||||
optname-accounts)))
|
||||
(call-with-values (lambda () (unzip2 finish))
|
||||
(lambda (ds as)
|
||||
(gnc:option-set-value account-op as)))
|
||||
@ -153,8 +176,8 @@
|
||||
|
||||
(gnc:html-piechart-set-title!
|
||||
chart (if is-income?
|
||||
(N_ "Income by Account")
|
||||
(N_ "Expenses by Account")))
|
||||
(_ "Income by Account")
|
||||
(_ "Expenses by Account")))
|
||||
|
||||
(gnc:html-piechart-set-subtitle!
|
||||
chart (sprintf #f
|
||||
|
Loading…
Reference in New Issue
Block a user