Skip to content

Commit

Permalink
[reports] use gnc_date_interval_format
Browse files Browse the repository at this point in the history
  • Loading branch information
christopherlam committed Sep 14, 2024
1 parent 0f2b613 commit d634902
Show file tree
Hide file tree
Showing 14 changed files with 27 additions and 54 deletions.
5 changes: 1 addition & 4 deletions gnucash/report/reports/example/daily-reports.scm
Original file line number Diff line number Diff line change
Expand Up @@ -256,10 +256,7 @@
chart (list
report-title
(string-append
(format #f
(G_ "~a to ~a")
(qof-print-date from-date)
(qof-print-date to-date))
(gnc-date-interval-format from-date to-date)
(if show-total?
(let ((total (apply + daily-totals)))
(format
Expand Down
5 changes: 1 addition & 4 deletions gnucash/report/reports/standard/account-piecharts.scm
Original file line number Diff line number Diff line change
Expand Up @@ -510,10 +510,7 @@ balance at a given time"))
chart (list report-title
(string-append
(if do-intervals?
(format #f
(G_ "~a to ~a")
(qof-print-date from-date)
(qof-print-date to-date))
(gnc-date-interval-format from-date to-date)
(format #f
(G_ "Balance at ~a")
(qof-print-date to-date)))
Expand Down
4 changes: 1 addition & 3 deletions gnucash/report/reports/standard/balance-forecast.scm
Original file line number Diff line number Diff line change
Expand Up @@ -270,9 +270,7 @@ date point, a projected minimum balance including scheduled transactions."))
(gnc:html-chart-set-type! chart 'line)
;; Set the chart titles
(gnc:html-chart-set-title!
chart (list report-title
(format #f (G_ "~a to ~a")
(qof-print-date from-date) (qof-print-date to-date))))
chart (list report-title (gnc-date-interval-format from-date to-date)))
;; Set the chart size
(gnc:html-chart-set-width! chart plot-width)
(gnc:html-chart-set-height! chart plot-height)
Expand Down
3 changes: 1 addition & 2 deletions gnucash/report/reports/standard/balsheet-pnl.scm
Original file line number Diff line number Diff line change
Expand Up @@ -859,8 +859,7 @@ also show overall period profit & loss."))
(display report-title)
(display " ")
(if (or (not (eq? incr 'disabled)) (eq? report-type 'pnl))
(format #t (G_ "~a to ~a")
(qof-print-date startdate) (qof-print-date enddate))
(gnc-date-interval-format startdate enddate)
(display (qof-print-date enddate))))))

(if (eq? (get-option gnc:pagename-general optname-options-summary) 'always)
Expand Down
6 changes: 3 additions & 3 deletions gnucash/report/reports/standard/budget.scm
Original file line number Diff line number Diff line change
Expand Up @@ -465,9 +465,9 @@
((eq? (car column-list) 'total)
(G_ "Total"))
((list? (car column-list))
(format #f (G_ "~a to ~a")
(period-to-date-string (car (car column-list)))
(period-to-date-string (last (car column-list)))))
(gnc-date-interval-format
(gnc-budget-get-period-start-date budget (car (car column-list)))
(gnc-budget-get-period-start-date budget (last (car column-list)))))
(else
(period-to-date-string (car column-list)))))

Expand Down
3 changes: 1 addition & 2 deletions gnucash/report/reports/standard/cash-flow.scm
Original file line number Diff line number Diff line change
Expand Up @@ -180,8 +180,7 @@
doc (string-append
(get-option gnc:pagename-general gnc:optname-reportname)
" - "
(format #f (G_ "~a to ~a")
(qof-print-date from-date-t64) (qof-print-date to-date-t64))))
(gnc-date-interval-format from-date-t64 to-date-t64)))

(if (not (null? accounts))

Expand Down
6 changes: 1 addition & 5 deletions gnucash/report/reports/standard/cashflow-barchart.scm
Original file line number Diff line number Diff line change
Expand Up @@ -254,11 +254,7 @@
(gnc:report-percent-done 90)

(gnc:html-chart-set-title!
chart (list report-title
(format #f
(G_ "~a to ~a")
(qof-print-date from-date-t64)
(qof-print-date to-date-t64))))
chart (list report-title (gnc-date-interval-format from-date-t64 to-date-t64)))
(gnc:html-chart-set-width! chart width)
(gnc:html-chart-set-height! chart height)
(gnc:html-chart-set-y-axis-label!
Expand Down
8 changes: 2 additions & 6 deletions gnucash/report/reports/standard/category-barchart.scm
Original file line number Diff line number Diff line change
Expand Up @@ -518,12 +518,8 @@ Please deselect the accounts with negative balances."))

(gnc:html-chart-set-title!
chart (list report-title
(format #f
(if do-intervals?
(G_ "~a to ~a")
(G_ "Balances ~a to ~a"))
(qof-print-date from-date-t64)
(qof-print-date to-date-t64))))
(format #f (if do-intervals? "~a" (G_ "Balances ~a"))
(gnc-date-interval-format from-date-t64 to-date-t64))))

(gnc:html-chart-set-width! chart width)
(gnc:html-chart-set-height! chart height)
Expand Down
11 changes: 3 additions & 8 deletions gnucash/report/reports/standard/investment-lots.scm
Original file line number Diff line number Diff line change
Expand Up @@ -1960,10 +1960,9 @@
(gnc:html-document-set-title!
document
(format #f
(G_ "~a, ~a to ~a")
(G_ "~a, ~a")
(get-option gnc:pagename-general gnc:optname-reportname)
(qof-print-date from-date)
(qof-print-date to-date)))
(gnc-date-interval-format from-date to-date)))

(cond
((not (null? accounts))
Expand All @@ -1986,11 +1985,7 @@
(list colname-unrealized-gain))
'()))))
(gnc:html-chart-set-title! chart
(list (N_ "Account Lot Gains")
(format #f
(G_ "~a to ~a")
(qof-print-date from-date)
(qof-print-date to-date))))
(list (N_ "Account Lot Gains") (gnc-date-interval-format from-date to-date)))
(gnc:html-chart-set-type! chart 'bar)
(gnc:html-chart-set-width! chart chart-width)
(gnc:html-chart-set-height! chart chart-height)
Expand Down
5 changes: 1 addition & 4 deletions gnucash/report/reports/standard/net-charts.scm
Original file line number Diff line number Diff line change
Expand Up @@ -312,10 +312,7 @@
(gnc:html-chart-set-width! chart width)
(gnc:html-chart-set-height! chart height)
(gnc:html-chart-set-title!
chart (list report-title
(format #f (G_ "~a to ~a")
(qof-print-date from-date-t64)
(qof-print-date to-date-t64))))
chart (list report-title (gnc-date-interval-format from-date-t64 to-date-t64)))
(gnc:html-chart-set-y-axis-label!
chart (gnc-commodity-get-mnemonic report-currency))
(gnc:html-chart-set-grid?! chart y-grid)
Expand Down
4 changes: 2 additions & 2 deletions gnucash/report/reports/standard/new-owner-report.scm
Original file line number Diff line number Diff line change
Expand Up @@ -1128,8 +1128,8 @@ and do not match the transaction."))))))))

(gnc:html-document-add-object!
document (gnc:make-html-text
(string-append (G_ "Date Range") ": " (qof-print-date start-date)
" - " (qof-print-date end-date))))
(string-append (G_ "Date Range") ": "
(gnc-date-interval-format start-date end-date))))

(make-break! document)

Expand Down
5 changes: 1 addition & 4 deletions gnucash/report/reports/standard/price-scatter.scm
Original file line number Diff line number Diff line change
Expand Up @@ -182,10 +182,7 @@
(string-append
(gnc-commodity-get-mnemonic base-commodity)
" - "
(format #f
(G_ "~a to ~a")
(qof-print-date from-date)
(qof-print-date to-date)))))
(gnc-date-interval-format from-date to-date))))
(gnc:html-chart-set-width! chart width)
(gnc:html-chart-set-height! chart height)
(gnc:html-chart-set! chart
Expand Down
2 changes: 1 addition & 1 deletion gnucash/report/reports/standard/txn-columns.scm
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ Select a different subset of transactions, or increase the limit in the options.
1 3 "total-label-cell"
(gnc:make-html-text
(G_ "Total For ")
(format #f "~a to ~a" (qof-print-date from-date) (qof-print-date to-date))))
(gnc-date-interval-format from-date to-date)))
(map (lambda (acc total)
(gnc:make-html-table-cell/markup
"total-number-cell"
Expand Down
14 changes: 8 additions & 6 deletions gnucash/report/trep-engine.scm
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,12 @@ in the Options panel."))
(define (split->time64 s)
(xaccTransGetDate (xaccSplitGetParent s)))


(define (date-get-week-year-string date)
(let ((beginweekt64 (* (gnc:time64-get-week (gnc-mktime date)) 7 86400)))
(gnc-date-interval-format (+ beginweekt64 (* 3 86400))
(+ beginweekt64 (* 9 86400)))))

(define date-subtotal-list
;; List for date option.
;; Defines the different date sorting keys, as an association-list. Each entry:
Expand All @@ -316,7 +322,7 @@ in the Options panel."))
(cons 'split-sortvalue (lambda (s) (time64-week (split->time64 s))))
(cons 'date-sortvalue time64-week)
(cons 'text (G_ "Weekly"))
(cons 'renderer-fn (compose gnc:date-get-week-year-string
(cons 'renderer-fn (compose date-get-week-year-string
gnc-localtime
split->time64)))

Expand Down Expand Up @@ -2542,11 +2548,7 @@ be excluded from periodic reporting.")
document
(gnc:make-html-text
(gnc:html-markup-h3
(format #f
;; Translators: Both ~a's are dates
(G_ "From ~a to ~a")
(qof-print-date begindate)
(qof-print-date enddate)))))
(gnc-date-interval-format begindate enddate))))

(when (eq? infobox-display 'always)
(gnc:html-document-add-object!
Expand Down

0 comments on commit d634902

Please sign in to comment.