* src/scm/report/register.scm: convert to guile module.

git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@4746 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
Rob Browning 2001-06-18 17:47:03 +00:00
parent c05661c7d2
commit cdbe6074ad

View File

@ -1,55 +1,57 @@
;; -*-scheme-*-
;; register.scm
(use-modules (ice-9 syncase))
;; depends must be outside module scope -- and should eventually go away.
(require 'record)
(gnc:support "report/register.scm")
(gnc:depend "report-html.scm")
(gnc:depend "date-utilities.scm")
(let-syntax ((addto!
(syntax-rules ()
((_ alist element) (set! alist (cons element alist))))))
(define-module (gnucash report register))
(define (set-last-row-style! table tag . rest)
(use-modules (ice-9 slib))
(require 'record)
(define-macro (addto! alist element)
`(set! ,alist (cons ,element ,alist)))
(define (set-last-row-style! table tag . rest)
(let ((arg-list
(cons table
(cons (- (gnc:html-table-num-rows table) 1)
(cons tag rest)))))
(apply gnc:html-table-set-row-style! arg-list)))
(define (date-col columns-used)
(define (date-col columns-used)
(vector-ref columns-used 0))
(define (num-col columns-used)
(define (num-col columns-used)
(vector-ref columns-used 1))
(define (description-col columns-used)
(define (description-col columns-used)
(vector-ref columns-used 2))
(define (account-col columns-used)
(define (account-col columns-used)
(vector-ref columns-used 3))
(define (shares-col columns-used)
(define (shares-col columns-used)
(vector-ref columns-used 4))
(define (price-col columns-used)
(define (price-col columns-used)
(vector-ref columns-used 5))
(define (amount-single-col columns-used)
(define (amount-single-col columns-used)
(vector-ref columns-used 6))
(define (debit-col columns-used)
(define (debit-col columns-used)
(vector-ref columns-used 7))
(define (credit-col columns-used)
(define (credit-col columns-used)
(vector-ref columns-used 8))
(define (balance-col columns-used)
(define (balance-col columns-used)
(vector-ref columns-used 9))
(define columns-used-size 10)
(define columns-used-size 10)
(define (num-columns-required columns-used)
(define (num-columns-required columns-used)
(do ((i 0 (+ i 1))
(col-req 0 col-req))
((>= i columns-used-size) col-req)
(if (vector-ref columns-used i)
(set! col-req (+ col-req 1)))))
(define (build-column-used options)
(define (build-column-used options)
(define (opt-val section name)
(gnc:option-value
(gnc:lookup-option options section name)))
@ -81,7 +83,7 @@
col-vector))
(define (make-heading-list column-vector
(define (make-heading-list column-vector
debit-string credit-string amount-string
multi-rows?)
(let ((heading-list '()))
@ -110,14 +112,14 @@
(addto! heading-list (_ "Balance")))
(reverse heading-list)))
(define (gnc:split-get-balance-display split)
(define (gnc:split-get-balance-display split)
(let ((account (gnc:split-get-account split))
(balance (gnc:split-get-balance split)))
(if (and account (gnc:account-reverse-balance? account))
(gnc:numeric-neg balance)
balance)))
(define (add-split-row table split column-vector row-style
(define (add-split-row table split column-vector row-style
transaction-info? split-info? double?)
(let* ((row-contents '())
(parent (gnc:split-get-parent split))
@ -230,12 +232,12 @@
(reverse row-contents)))))
split-value))
(define (lookup-sort-key sort-option)
(define (lookup-sort-key sort-option)
(vector-ref (cdr (assq sort-option comp-funcs-assoc-list)) 0))
(define (lookup-subtotal-pred sort-option)
(define (lookup-subtotal-pred sort-option)
(vector-ref (cdr (assq sort-option comp-funcs-assoc-list)) 1))
(define (options-generator)
(define (options-generator)
(define gnc:*report-options* (gnc:new-options))
@ -328,7 +330,7 @@
gnc:*report-options*)
(define (make-split-table splits options
(define (make-split-table splits options
debit-string credit-string amount-string)
(define (opt-val section name)
(gnc:option-value (gnc:lookup-option options section name)))
@ -472,7 +474,7 @@
(gnc:make-commodity-collector))
table))
(define (string-expand string character replace-string)
(define (string-expand string character replace-string)
(define (car-line chars)
(take-while (lambda (c) (not (eqv? c character))) chars))
(define (cdr-line chars)
@ -490,7 +492,7 @@
(line-helper rest)))))
(line-helper (string->list string)))
(define (make-client-table address)
(define (make-client-table address)
(let ((table (gnc:make-html-table)))
(gnc:html-table-set-style!
table "table"
@ -507,7 +509,7 @@
'attribute (list "valign" "top"))
table))
(define (make-info-table address)
(define (make-info-table address)
(let ((table (gnc:make-html-table)))
(gnc:html-table-set-style!
table "table"
@ -527,7 +529,7 @@
'attribute (list "valign" "top"))
table))
(define (reg-renderer report-obj)
(define (reg-renderer report-obj)
(define (opt-val section name)
(gnc:option-value
(gnc:lookup-option (gnc:report-options report-obj) section name)))
@ -596,23 +598,20 @@
document))
(gnc:define-report
(gnc:define-report
'version 1
'name (N_ "Register")
'options-generator options-generator
'renderer reg-renderer
'in-menu? #f)
(gnc:define-report
(gnc:define-report
'version 1
'name (N_ "Invoice")
'options-generator options-generator
'renderer reg-renderer
'in-menu? #f)
#t)
(define (gnc:apply-register-report func invoice? query journal? double?
title debit-string credit-string)
(let* ((options (gnc:make-report-options "Register"))