mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
[category-barchart] add CSV export for table data
This commit is contained in:
parent
f8e976e913
commit
3296da001c
@ -212,7 +212,8 @@ developing over time"))
|
|||||||
;; *really* complicated.
|
;; *really* complicated.
|
||||||
|
|
||||||
(define (category-barchart-renderer report-obj reportname reportguid
|
(define (category-barchart-renderer report-obj reportname reportguid
|
||||||
account-types do-intervals? reverse-bal?)
|
account-types do-intervals? reverse-bal?
|
||||||
|
export-type)
|
||||||
;; A helper functions for looking up option values.
|
;; A helper functions for looking up option values.
|
||||||
(define (get-option section name)
|
(define (get-option section name)
|
||||||
(gnc:option-value
|
(gnc:option-value
|
||||||
@ -635,7 +636,38 @@ developing over time"))
|
|||||||
(list (G_ "Grand Total"))
|
(list (G_ "Grand Total"))
|
||||||
'())))
|
'())))
|
||||||
|
|
||||||
(gnc:html-document-add-object! document table))))
|
(gnc:html-document-add-object! document table)))
|
||||||
|
|
||||||
|
(cond
|
||||||
|
((eq? export-type 'csv)
|
||||||
|
(let ((old-fmt (qof-date-format-get)))
|
||||||
|
(qof-date-format-set QOF-DATE-FORMAT-ISO)
|
||||||
|
(gnc:html-document-set-export-string
|
||||||
|
document
|
||||||
|
(gnc:lists->csv
|
||||||
|
(cons (append
|
||||||
|
(list (G_ "Date"))
|
||||||
|
(map
|
||||||
|
(lambda (col)
|
||||||
|
(cond
|
||||||
|
((string? col) col)
|
||||||
|
(show-fullname? (gnc-account-get-full-name col))
|
||||||
|
(else (xaccAccountGetName col))))
|
||||||
|
(map car all-data))
|
||||||
|
(if (pair? (cdr all-data))
|
||||||
|
(list (G_ "Grand Total"))
|
||||||
|
'()))
|
||||||
|
(map
|
||||||
|
(lambda (date row)
|
||||||
|
(append
|
||||||
|
(list date)
|
||||||
|
row
|
||||||
|
(if (pair? (cdr all-data))
|
||||||
|
(list (apply gnc:monetary+ row))
|
||||||
|
'())))
|
||||||
|
(map qof-print-date dates-list)
|
||||||
|
(apply zip (map cadr all-data))))))
|
||||||
|
(qof-date-format-set old-fmt)))))
|
||||||
|
|
||||||
;; else if empty data
|
;; else if empty data
|
||||||
(gnc:html-document-add-object!
|
(gnc:html-document-add-object!
|
||||||
@ -649,6 +681,9 @@ developing over time"))
|
|||||||
(gnc:html-make-no-account-warning
|
(gnc:html-make-no-account-warning
|
||||||
report-title (gnc:report-id report-obj))))
|
report-title (gnc:report-id report-obj))))
|
||||||
|
|
||||||
|
(unless (gnc:html-document-export-string document)
|
||||||
|
(gnc:html-document-set-export-error document (G_ "No exportable data")))
|
||||||
|
|
||||||
(gnc:report-finished)
|
(gnc:report-finished)
|
||||||
document))
|
document))
|
||||||
|
|
||||||
@ -665,9 +700,15 @@ developing over time"))
|
|||||||
'menu-name menuname
|
'menu-name menuname
|
||||||
'menu-tip menutip
|
'menu-tip menutip
|
||||||
'options-generator (lambda () (options-generator account-types inc-exp?))
|
'options-generator (lambda () (options-generator account-types inc-exp?))
|
||||||
|
'export-types '(("CSV" . csv))
|
||||||
|
'export-thunk (lambda (report-obj export-type filename)
|
||||||
|
(category-barchart-renderer
|
||||||
|
report-obj reportname uuid account-types inc-exp? reverse-bal?
|
||||||
|
export-type))
|
||||||
'renderer (lambda (report-obj)
|
'renderer (lambda (report-obj)
|
||||||
(category-barchart-renderer
|
(category-barchart-renderer
|
||||||
report-obj reportname uuid account-types inc-exp? reverse-bal?)))))
|
report-obj reportname uuid account-types inc-exp? reverse-bal?
|
||||||
|
#f)))))
|
||||||
(list
|
(list
|
||||||
;; reportname, account-types, inc-exp?,
|
;; reportname, account-types, inc-exp?,
|
||||||
;; menu-reportname, menu-tip, reverse-bal?, uuid
|
;; menu-reportname, menu-tip, reverse-bal?, uuid
|
||||||
|
Loading…
Reference in New Issue
Block a user