transaction-report.scm

Birger =?iso-8859-1?q?Retterst=F8l=20Olaisen?= birgerro@student.matnat.uio.no
Mon, 29 Jan 2001 17:47:54 +0100


I've made some modifications to the file 
share/gnucash/scm/report/transaction-report.scm to add the posibility to sort 
by account number. These modifications may perhaps not be well coded (it's my 
first attempt to code in sceme, so I don't know the style) but they work.

;; -*-scheme-*-
;; transaction-report.scm
;; Report on all transactions in account(s)
;; original report by Robert Merkel (rgmerk@mira.net)
;; redone from scratch by Bryan Larsen (blarsen@ada-works.com)

(gnc:support "report/transaction-report.scm")
(gnc:depend "report-utilities.scm")
(gnc:depend "date-utilities.scm")
(gnc:depend "html-generator.scm")

(let ()
; ... The first modification goes here

 (define (make-account-num-subheading acc from-date)
   (let* (
                (separator (string-ref (gnc:account-separator-char) 0))
                (balance-at-start (gnc:account-get-balance-at-date
                                acc
                                from-date
                                #f))
                (ret-string (gnc:account-get-code acc)))
         (string-append ret-string
                " - "
                (gnc:account-get-name acc)
                " ("
                (string-db 'lookup 'open-bal-string)
                " "
                (gnc:amount->formatted-string balance-at-start #f)
                ")"
         )))



; ... and the next place is
  (define (split-report-get-sort-spec-entry key ascending? begindate)
    (case key

      ((account-num)
       (make-report-sort-spec
      ; get-value-proc:
       (lambda (split) (gnc:split-get-account split))
      ; sort-pred:
       (if ascending?
          (lambda (acc1 acc2)
             (string<? (gnc:account-get-code acc1)
                       (gnc:account-get-code acc2)))
          (lambda (acc1 acc2)
             (string>? (gnc:account-get-code acc1)
                       (gnc:account-get-code acc2))))
      ; equal-pred:
       (lambda (acc1 acc2)
          (= (gnc:account-get-id acc1)
             (gnc:account-get-id acc2)))
      ; subsection-pred:
       (lambda (acc1 acc2)
          (string-ci=? (gnc:account-get-code acc1)
                       (gnc:account-get-code acc2)))
      ; subsection-title-proc:
       (lambda (acc) (make-account-num-subheading acc begindate))
      ))


; ... and finally

    (let ((key-choice-list
	   (list #(account
		   "Account (w/subtotal)"
		   "Sort & subtotal by account")
                 #(account-num
                   "Account number (w/subtotal)"
                   "Sort & subtotal by account number")