mirror of https://github.com/Gnucash/gnucash
using the GtkPrint API when compiled against gtk+ 2.10 or later. Add support for reading check description files instead of hard coding check descriptions. git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@15709 57a11ea4-9604-0410-9ed3-97b8803252fdzzzoldfeatures/gobject-engine-dev1
parent
5246632fb4
commit
2af48fcb16
@ -0,0 +1,17 @@
|
||||
|
||||
checksdir = ${GNC_CHECKS_DIR}
|
||||
|
||||
if HAVE_GTK_2_10
|
||||
checks_DATA = \
|
||||
deluxe.chk \
|
||||
quicken.chk \
|
||||
quicken_wallet.chk
|
||||
else
|
||||
checks_DATA = \
|
||||
gnomeprint/deluxe.chk \
|
||||
gnomeprint/quicken.chk \
|
||||
gnomeprint/quicken_wallet.chk
|
||||
endif
|
||||
|
||||
EXTRA_DIST = \
|
||||
${checks_DATA}
|
||||
@ -0,0 +1,22 @@
|
||||
[Top]
|
||||
Title = Deluxe(tm) Personal Checks US-Letter
|
||||
Rotation = -90.0
|
||||
Translation = 4;492
|
||||
Show_Grid = 0
|
||||
Show_Boxes = 0
|
||||
|
||||
[Check Items]
|
||||
Type_1 = PAYEE
|
||||
Coords_1 = 126.0;85.0
|
||||
|
||||
Type_2 = AMOUNT_WORDS
|
||||
Coords_2 = 90.0;107.0
|
||||
|
||||
Type_3 = AMOUNT_NUMBER
|
||||
Coords_3 = 395.0;85.0
|
||||
|
||||
Type_4 = DATE
|
||||
Coords_4 = 343.0;54.0
|
||||
|
||||
Type_5 = MEMO
|
||||
Coords_5 = 100.0;159.0
|
||||
@ -0,0 +1,22 @@
|
||||
[Top]
|
||||
Title = Deluxe(tm) Personal Checks US-Letter
|
||||
Rotation = 90
|
||||
Translation = 232;300
|
||||
Show_Grid = 0
|
||||
Show_Boxes = 0
|
||||
|
||||
[Check Items]
|
||||
Type_1 = PAYEE
|
||||
Coords_1 = 126.0;147.0
|
||||
|
||||
Type_2 = AMOUNT_WORDS
|
||||
Coords_2 = 90.0;125.0
|
||||
|
||||
Type_3 = AMOUNT_NUMBER
|
||||
Coords_3 = 395.0;147.0
|
||||
|
||||
Type_4 = DATE
|
||||
Coords_4 = 343.0;178.0
|
||||
|
||||
Type_5 = MEMO
|
||||
Coords_5 = 100.0;73.0
|
||||
@ -0,0 +1,28 @@
|
||||
[Top]
|
||||
Title = Quicken/QuickBooks (tm) US-Letter
|
||||
Rotation = 0.0
|
||||
Translation = 0.0;0.0
|
||||
Show_Grid = 0
|
||||
Show_Boxes = 0
|
||||
|
||||
[Check Positions]
|
||||
Height = 252.0
|
||||
Name_1 = Top
|
||||
Name_2 = Middle
|
||||
Name_3 = Bottom
|
||||
|
||||
[Check Items]
|
||||
Type_1 = PAYEE
|
||||
Coords_1 = 90.0;150.0;400.0;20.0
|
||||
|
||||
Type_2 = AMOUNT_WORDS
|
||||
Coords_2 = 90.0;120.0
|
||||
|
||||
Type_3 = AMOUNT_NUMBER
|
||||
Coords_3 = 500.0;150.0
|
||||
|
||||
Type_4 = DATE
|
||||
Coords_4 = 500.0;185.0
|
||||
|
||||
Type_5 = MEMO
|
||||
Coords_5 = 50.0;40.0
|
||||
@ -0,0 +1,40 @@
|
||||
[Top]
|
||||
Title = Quicken(tm) Wallet Checks w/ side stub
|
||||
Rotation = 0.0
|
||||
Translation = 0.0;0.0
|
||||
Show_Grid = 0
|
||||
Show_Boxes = 0
|
||||
|
||||
[Check Positions]
|
||||
Height = 204.0
|
||||
Name_1 = Top
|
||||
Name_2 = Middle
|
||||
Name_3 = Bottom
|
||||
|
||||
[Check Items]
|
||||
Type_1 = PAYEE
|
||||
Coords_1 = 231.0;140.0
|
||||
|
||||
Type_2 = AMOUNT_WORDS
|
||||
Coords_2 = 195.0;125.0
|
||||
|
||||
Type_3 = AMOUNT_NUMBER
|
||||
Coords_3 = 518.0;137.0
|
||||
|
||||
Type_4 = DATE
|
||||
Coords_4 = 504.0;151.0
|
||||
|
||||
Type_5 = MEMO
|
||||
Coords_5 = 216.0;37.0
|
||||
|
||||
Type_6 = DATE
|
||||
Coords_6 = 36.0;151.0
|
||||
|
||||
Type_7 = PAYEE
|
||||
Coords_7 = 26.0;126.0
|
||||
|
||||
Type_8 = AMOUNT_NUMBER
|
||||
Coords_8 = 50.0;90.0
|
||||
|
||||
Type_9 = MEMO
|
||||
Coords_9 = 28.0;65.0
|
||||
@ -0,0 +1,28 @@
|
||||
[Top]
|
||||
Title = Quicken/QuickBooks (tm) US-Letter
|
||||
Rotation = 0.0
|
||||
Translation = 0.0;4.0
|
||||
Show_Grid = 0
|
||||
Show_Boxes = 0
|
||||
|
||||
[Check Positions]
|
||||
Height = 252.0
|
||||
Name_1 = Top
|
||||
Name_2 = Middle
|
||||
Name_3 = Bottom
|
||||
|
||||
[Check Items]
|
||||
Type_1 = PAYEE
|
||||
Coords_1 = 90.0;102.0;400.0;20.0
|
||||
|
||||
Type_2 = AMOUNT_WORDS
|
||||
Coords_2 = 90.0;132.0
|
||||
|
||||
Type_3 = AMOUNT_NUMBER
|
||||
Coords_3 = 500.0;102.0
|
||||
|
||||
Type_4 = DATE
|
||||
Coords_4 = 500.0;67.0
|
||||
|
||||
Type_5 = MEMO
|
||||
Coords_5 = 50.0;212.0
|
||||
@ -0,0 +1,40 @@
|
||||
[Top]
|
||||
Title = Quicken(tm) Wallet Checks w/ side stub
|
||||
Rotation = 0.0
|
||||
Translation = 0.0;4.0
|
||||
Show_Grid = 0
|
||||
Show_Boxes = 0
|
||||
|
||||
[Check Positions]
|
||||
Height = 204.0
|
||||
Name_1 = Top
|
||||
Name_2 = Middle
|
||||
Name_3 = Bottom
|
||||
|
||||
[Check Items]
|
||||
Type_1 = PAYEE
|
||||
Coords_1 = 231.0;64.0
|
||||
|
||||
Type_2 = AMOUNT_WORDS
|
||||
Coords_2 = 195.0;79.0
|
||||
|
||||
Type_3 = AMOUNT_NUMBER
|
||||
Coords_3 = 518.0;67.0
|
||||
|
||||
Type_4 = DATE
|
||||
Coords_4 = 504.0;53.0
|
||||
|
||||
Type_5 = MEMO
|
||||
Coords_5 = 216.0;167.0
|
||||
|
||||
Type_6 = DATE
|
||||
Coords_6 = 36.0;53.0
|
||||
|
||||
Type_7 = PAYEE
|
||||
Coords_7 = 26.0;78.0
|
||||
|
||||
Type_8 = AMOUNT_NUMBER
|
||||
Coords_8 = 50.0;114.0
|
||||
|
||||
Type_9 = MEMO
|
||||
Coords_9 = 28.0;139.0
|
||||
File diff suppressed because it is too large
Load Diff
@ -1,25 +0,0 @@
|
||||
gncscmdir = ${GNC_SCM_INSTALL_DIR}/printing
|
||||
gncscm_DATA = print-check.scm
|
||||
|
||||
gncscmmoddir = ${GNC_SHAREDIR}/guile-modules/gnucash/printing
|
||||
gncscmmod_DATA = number-to-words.scm
|
||||
|
||||
if GNUCASH_SEPARATE_BUILDDIR
|
||||
SCM_FILE_LINKS = \
|
||||
${gncscmmod_DATA} \
|
||||
${gncscm_DATA}
|
||||
endif
|
||||
|
||||
.scm-links:
|
||||
if GNUCASH_SEPARATE_BUILDDIR
|
||||
for X in ${SCM_FILE_LINKS} ; do \
|
||||
$(LN_S) -f ${srcdir}/$$X . ; \
|
||||
done
|
||||
endif
|
||||
touch .scm-links
|
||||
|
||||
noinst_DATA = .scm-links
|
||||
|
||||
EXTRA_DIST = ${gncscmmod_DATA} ${gncscm_DATA}
|
||||
CLEANFILES = .scm-links
|
||||
DISTCLEANFILES = ${SCM_FILE_LINKS}
|
||||
@ -1,113 +0,0 @@
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;;; number-to-words.scm
|
||||
;;; convert a number into a sentence for check printing
|
||||
;;;
|
||||
;;; Copyright 2000 Bill Gribble <grib@billgribble.com>
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
|
||||
(define-module (gnucash printing number-to-words))
|
||||
(export integer-to-words)
|
||||
(export printable-value)
|
||||
(export number-to-words)
|
||||
|
||||
(define (integer-to-words val)
|
||||
(let ((current-string "")
|
||||
(small-numbers
|
||||
#("zero" "one" "two" "three" "four" "five"
|
||||
"six" "seven" "eight" "nine" "ten"
|
||||
"eleven" "twelve" "thirteen" "fourteen" "fifteen"
|
||||
"sixteen" "seventeen" "eighteen" "nineteen" "twenty"))
|
||||
(medium-numbers
|
||||
#("zero" "ten" "twenty" "thirty" "forty" "fifty"
|
||||
"sixty" "seventy" "eighty" "ninety"))
|
||||
(big-numbers
|
||||
#("hundred" "thousand" "million" "billion" "trillion"
|
||||
"quadrillion" "quintillion")))
|
||||
(cond
|
||||
((< val 20)
|
||||
(vector-ref small-numbers val))
|
||||
|
||||
((< val 100)
|
||||
(let ((this-part (quotient val 10))
|
||||
(that-part (remainder val 10)))
|
||||
(set! current-string (vector-ref medium-numbers this-part))
|
||||
(if (> that-part 0)
|
||||
(set! current-string
|
||||
(string-append current-string "-"
|
||||
(vector-ref small-numbers that-part))))
|
||||
current-string))
|
||||
((< val 1000)
|
||||
(let ((this-part (quotient val 100))
|
||||
(that-part (remainder val 100)))
|
||||
(set! current-string
|
||||
(string-append current-string
|
||||
(vector-ref small-numbers this-part) " "
|
||||
(vector-ref big-numbers 0)))
|
||||
(if (> that-part 0)
|
||||
(set! current-string
|
||||
(string-append current-string
|
||||
" " (integer-to-words that-part))))
|
||||
current-string))
|
||||
(#t
|
||||
(let* ((log-val (inexact->exact
|
||||
(truncate (+ .00001 (/ (log10 val) 3)))))
|
||||
(this-part (quotient val
|
||||
(inexact->exact
|
||||
(truncate
|
||||
(+ .00001 (expt 10 (* 3 log-val)))))))
|
||||
(that-part (remainder val
|
||||
(inexact->exact
|
||||
(truncate
|
||||
(+ .00001 (expt 10 (* 3 log-val))))))))
|
||||
(if (> this-part 0)
|
||||
(set! current-string
|
||||
(string-append (integer-to-words this-part)
|
||||
" " (vector-ref big-numbers log-val))))
|
||||
(if (> that-part 0)
|
||||
(set! current-string
|
||||
(string-append current-string
|
||||
" " (integer-to-words that-part))))
|
||||
current-string)))))
|
||||
|
||||
;; return a string with the number properly truncated and zero padded
|
||||
;; for check printing
|
||||
(define (printable-value val frac-denom)
|
||||
(let* ((int-part (inexact->exact (truncate val)))
|
||||
(frac-part (inexact->exact
|
||||
(truncate
|
||||
(+ (/ .5 frac-denom) (* frac-denom
|
||||
(- val int-part)))))))
|
||||
(with-output-to-string
|
||||
(lambda ()
|
||||
(write int-part) (display ".")
|
||||
(if (< frac-part 10) (display "0"))
|
||||
(write frac-part)))))
|
||||
|
||||
|
||||
(define (number-to-words val frac-denom)
|
||||
(let* ((negative?
|
||||
(if (< val 0)
|
||||
(begin (set! val (- val))
|
||||
#t)
|
||||
#f))
|
||||
(int-part (inexact->exact (truncate val)))
|
||||
(frac-part (inexact->exact
|
||||
(truncate
|
||||
(+ (/ .5 frac-denom) (* frac-denom (- val int-part))))))
|
||||
(result-string ""))
|
||||
(set! result-string
|
||||
(string-append (integer-to-words int-part) " and "
|
||||
(with-output-to-string
|
||||
(lambda ()
|
||||
(write frac-part)
|
||||
(display "/")
|
||||
(write frac-denom)))))
|
||||
(string-set! result-string 0
|
||||
(char-upcase (string-ref result-string 0)))
|
||||
result-string))
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@ -1,216 +0,0 @@
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;;; print-check.scm
|
||||
;;; print a check from a transaction.
|
||||
;;;
|
||||
;;; Copyright 2000 Bill Gribble <grib@billgribble.com>
|
||||
;;; June 2004 - D. Reiser - added capability to print wallet checks
|
||||
;;; with left-side stubs
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
|
||||
(use-modules (gnucash printing number-to-words))
|
||||
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;; <print-check-format> class
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
|
||||
(define <print-check-format>
|
||||
(make-simple-class
|
||||
'print-check-format
|
||||
'(format
|
||||
position
|
||||
date-format
|
||||
custom-info)))
|
||||
|
||||
(define print-check-format?
|
||||
(record-predicate <print-check-format>))
|
||||
|
||||
(define print-check-format:format
|
||||
(simple-obj-getter <print-check-format> 'format))
|
||||
|
||||
(define print-check-format:set-format!
|
||||
(simple-obj-setter <print-check-format> 'format))
|
||||
|
||||
(define print-check-format:position
|
||||
(simple-obj-getter <print-check-format> 'position))
|
||||
|
||||
(define print-check-format:set-position!
|
||||
(simple-obj-setter <print-check-format> 'position))
|
||||
|
||||
(define print-check-format:date-format
|
||||
(simple-obj-getter <print-check-format> 'date-format))
|
||||
|
||||
(define print-check-format:set-date-format!
|
||||
(simple-obj-setter <print-check-format> 'date-format))
|
||||
|
||||
(define print-check-format:custom-info
|
||||
(simple-obj-getter <print-check-format> 'custom-info))
|
||||
|
||||
(define print-check-format:set-custom-info!
|
||||
(simple-obj-setter <print-check-format> 'custom-info))
|
||||
|
||||
(define (make-print-check-format fmt pos dateformat cust)
|
||||
(let ((retval (make-simple-obj <print-check-format>)))
|
||||
(print-check-format:set-format! retval fmt)
|
||||
(print-check-format:set-position! retval pos)
|
||||
(print-check-format:set-date-format! retval dateformat)
|
||||
(print-check-format:set-custom-info! retval cust)
|
||||
retval))
|
||||
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;; stock formats
|
||||
;; units for stock formats and positions are points (72/inch)
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
|
||||
(define gnc:*stock-check-formats*
|
||||
'((deluxe . ((payee . (126.0 147.0))
|
||||
(amount-words . (90.0 125.0))
|
||||
(amount-number . (395.0 147.0))
|
||||
(date . (343.0 178.0))
|
||||
(memo . (100.0 73.0))
|
||||
(rotate . 90.0)
|
||||
(translate . (232.0 300.0))
|
||||
(offset . 0.0))) ;;declaration of offset preempts top/middle/bottom dialog choice
|
||||
(quicken . ((payee . (90.0 150.0))
|
||||
(amount-words . (90.0 120.0))
|
||||
(amount-number . (500.0 150.0))
|
||||
(date . (500.0 185.0))
|
||||
(memo . (50.0 40.0))
|
||||
(top . 540.0)
|
||||
(middle . 288.0)
|
||||
(bottom . 36.0)))
|
||||
(wallet . ((payee . (231.0 140.0)) ;;these coord. for placement above amount-word line
|
||||
;;use 202.0 94.0 for placement in address area
|
||||
(amount-words . (195.0 125.0))
|
||||
(amount-number . (518.0 137.0))
|
||||
(date . (504.0 151.0))
|
||||
(memo . (216.0 37.0))
|
||||
(date-stub . (36.0 151.0))
|
||||
(payee-stub . (28.0 126.0))
|
||||
(amount-stub . (50.0 90.0))
|
||||
(memo-stub . (28.0 65.0))
|
||||
(top . 588.0)
|
||||
(middle . 384.0)
|
||||
(bottom . 180.0)))
|
||||
(custom . ((top . 540.0) ;;set default perforation location for custom print layout
|
||||
(middle . 288.0)
|
||||
(bottom . 36.0)))
|
||||
))
|
||||
|
||||
(define (gnc:print-check format-info payee amount date memo)
|
||||
(let* ((int-part (inexact->exact (truncate amount)))
|
||||
(frac-part (inexact->exact
|
||||
(truncate
|
||||
(+ (/ .5 100) (* 100 (- amount int-part))))))
|
||||
(ps (gnc-print-session-create #t))
|
||||
(format #f)
|
||||
(offset #f)
|
||||
(date-string "")
|
||||
(payee-stub-text "")
|
||||
(memo-stub-text ""))
|
||||
|
||||
(if (not (null? ps))
|
||||
(begin
|
||||
(if (not (eq? (print-check-format:format format-info) 'custom))
|
||||
(begin
|
||||
(set! format (assq (print-check-format:format format-info)
|
||||
gnc:*stock-check-formats*))
|
||||
(if (pair? format)
|
||||
(begin
|
||||
(set! format (cdr format))
|
||||
(let ((off (assq 'offset format)))
|
||||
(if off (set! offset (cdr off)))))))
|
||||
(set! format (print-check-format:custom-info format-info)))
|
||||
|
||||
(if (not (eq? (print-check-format:format format-info) 'custom))
|
||||
(begin
|
||||
(if (not (or offset (eq? (print-check-format:position format-info) 'custom)))
|
||||
(begin
|
||||
(set! offset
|
||||
(cdr (assq (print-check-format:position format-info)
|
||||
(cdr (assq (print-check-format:format format-info)
|
||||
gnc:*stock-check-formats*)))))
|
||||
(if (pair? offset)
|
||||
(set! offset (cdr offset))))
|
||||
(set! offset
|
||||
(caddr (assq 'translate
|
||||
(print-check-format:custom-info format-info))))))
|
||||
(set! offset 0.0))
|
||||
|
||||
(let ((fmt (print-check-format:date-format format-info)))
|
||||
(begin
|
||||
(set! date-string (strftime fmt (localtime date)))))
|
||||
|
||||
(display "offset is ") (display offset) (newline)
|
||||
(let ((translate-pos (assq 'translate format)))
|
||||
(if translate-pos
|
||||
(begin
|
||||
(display "translate by ") (display (cadr translate-pos))
|
||||
(display " ") (display (caddr translate-pos)) (newline)
|
||||
(gnc-print-session-translate ps (cadr translate-pos)
|
||||
(caddr translate-pos)))))
|
||||
|
||||
(let ((rotate-angle (assq 'rotate format)))
|
||||
(if rotate-angle (gnc-print-session-rotate ps (cdr rotate-angle))))
|
||||
|
||||
(let ((date-pos (assq 'date format)))
|
||||
(gnc-print-session-moveto ps (cadr date-pos)
|
||||
(+ offset (caddr date-pos)))
|
||||
(gnc-print-session-text ps date-string))
|
||||
|
||||
(let ((payee-pos (assq 'payee format)))
|
||||
(gnc-print-session-moveto ps (cadr payee-pos)
|
||||
(+ offset (caddr payee-pos)))
|
||||
(gnc-print-session-text ps payee))
|
||||
|
||||
(let ((number-pos (assq 'amount-number format)))
|
||||
(gnc-print-session-moveto ps (cadr number-pos)
|
||||
(+ offset (caddr number-pos)))
|
||||
(gnc-print-session-text ps (printable-value amount 100)))
|
||||
|
||||
(let ((words-pos (assq 'amount-words format)))
|
||||
(gnc-print-session-moveto ps (cadr words-pos)
|
||||
(+ offset (caddr words-pos)))
|
||||
(gnc-print-session-text ps (number-to-words amount 100)))
|
||||
|
||||
(if (not (eq? (print-check-format:format format-info) 'wallet))
|
||||
(let ((memo-pos (assq 'memo format)))
|
||||
(gnc-print-session-moveto ps (cadr memo-pos)
|
||||
(+ offset (caddr memo-pos)))
|
||||
(gnc-print-session-text ps memo)))
|
||||
|
||||
(if (eq? (print-check-format:format format-info) 'wallet)
|
||||
(begin
|
||||
(let ((memo-pos (assq 'memo format)))
|
||||
(gnc-print-session-moveto ps (cadr memo-pos)
|
||||
(+ offset (caddr memo-pos)))
|
||||
(if (< (string-length memo) 28)
|
||||
(gnc-print-session-text ps memo)
|
||||
(gnc-print-session-text ps (substring memo 0 27))))
|
||||
(let ((memostub-pos (assq 'memo-stub format)))
|
||||
(gnc-print-session-moveto ps (cadr memostub-pos)
|
||||
(+ offset (caddr memostub-pos)))
|
||||
(if (< (string-length memo) 22)
|
||||
(set! memo-stub-text memo)
|
||||
(set! memo-stub-text (substring memo 0 20)))
|
||||
(gnc-print-session-text ps memo-stub-text))
|
||||
|
||||
(let ((datestub-pos (assq 'date-stub format)))
|
||||
(gnc-print-session-moveto ps (cadr datestub-pos)
|
||||
(+ offset (caddr datestub-pos)))
|
||||
(gnc-print-session-text ps date-string))
|
||||
|
||||
(let ((payeestub-pos (assq 'payee-stub format)))
|
||||
(gnc-print-session-moveto ps (cadr payeestub-pos)
|
||||
(+ offset (caddr payeestub-pos)))
|
||||
(if (< (string-length payee) 22)
|
||||
(set! payee-stub-text payee)
|
||||
(set! payee-stub-text (substring payee 0 20)))
|
||||
(gnc-print-session-text ps payee-stub-text))
|
||||
|
||||
(let ((amountstub-pos (assq 'amount-stub format)))
|
||||
(gnc-print-session-moveto ps (cadr amountstub-pos)
|
||||
(+ offset (caddr amountstub-pos)))
|
||||
(gnc-print-session-text ps (printable-value amount 100)))))
|
||||
|
||||
(gnc-print-session-done ps)))))
|
||||
|
||||
Loading…
Reference in new issue