mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
*** empty log message ***
git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@2066 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
parent
14b0d47c54
commit
74465a8726
@ -8,11 +8,11 @@
|
|||||||
* important functions:
|
* important functions:
|
||||||
* -- an array of strings, one for each cell of the displayed table.
|
* -- an array of strings, one for each cell of the displayed table.
|
||||||
* These strings are kept in sync with what the user sees in
|
* These strings are kept in sync with what the user sees in
|
||||||
* the GUI (although they may be out of sync in currently
|
* the GUI (although they may be out of sync in currently
|
||||||
* edited row(s)).
|
* edited row(s)).
|
||||||
* -- an array of cell-block handlers. The handlers provide
|
* -- an array of cell-block handlers. The handlers provide
|
||||||
* the actual GUI editing infrastructure: the handlers
|
* the actual GUI editing infrastructure: the handlers
|
||||||
* ake sure that only allowed edits are made to a block
|
* make sure that only allowed edits are made to a block
|
||||||
* of cells.
|
* of cells.
|
||||||
* -- The "cursor", which defines the region of cells that
|
* -- The "cursor", which defines the region of cells that
|
||||||
* are currently being edited.
|
* are currently being edited.
|
||||||
@ -20,7 +20,7 @@
|
|||||||
* to the cellblock handlers that know how to handle edits
|
* to the cellblock handlers that know how to handle edits
|
||||||
* to the physical, display cells.
|
* to the physical, display cells.
|
||||||
* -- A table of user-defined data hooks that can be associated
|
* -- A table of user-defined data hooks that can be associated
|
||||||
* with each cell block. By "user" we ean the prograer who
|
* with each cell block. By "user" we mean the programmer who
|
||||||
* makes use of this object.
|
* makes use of this object.
|
||||||
* -- Tab-traversing mechanism so that operator can tab in a
|
* -- Tab-traversing mechanism so that operator can tab in a
|
||||||
* predefined order between cells.
|
* predefined order between cells.
|
||||||
|
@ -1,7 +1,9 @@
|
|||||||
;; -*-scheme-*-
|
;; -*-scheme-*-
|
||||||
|
;; $ID$
|
||||||
;; dateutils.scm
|
;; dateutils.scm
|
||||||
;; date utility functions. mainly used by budget
|
;; date utility functions. mainly used by budget
|
||||||
;; Bryan Larsen (blarsen@ada-works.com)
|
;; Bryan Larsen (blarsen@ada-works.com)
|
||||||
|
;; Revised by Christopher Browne
|
||||||
|
|
||||||
(gnc:support "dateutils.scm")
|
(gnc:support "dateutils.scm")
|
||||||
|
|
||||||
@ -80,3 +82,121 @@
|
|||||||
((gnc:budget-month) "months")
|
((gnc:budget-month) "months")
|
||||||
((gnc:budget-year) "years")))
|
((gnc:budget-year) "years")))
|
||||||
|
|
||||||
|
;; Modify a date
|
||||||
|
(define (moddate op adate delta)
|
||||||
|
(let ((newtm (localtime (car adate))))
|
||||||
|
(begin
|
||||||
|
(set-tm:sec newtm (op (tm:sec newtm) (tm:sec delta)))
|
||||||
|
(set-tm:min newtm (op (tm:min newtm) (tm:min delta)))
|
||||||
|
(set-tm:hour newtm (op (tm:hour newtm) (tm:hour delta)))
|
||||||
|
(set-tm:mday newtm (op (tm:mday newtm) (tm:mday delta)))
|
||||||
|
(set-tm:mon newtm (op (tm:mon newtm) (tm:mon delta)))
|
||||||
|
(set-tm:year newtm (op (tm:year newtm) (tm:year delta)))
|
||||||
|
|
||||||
|
(let ((time (car (mktime newtm))))
|
||||||
|
(cons time 0)))))
|
||||||
|
|
||||||
|
;; Add or subtract time from a date
|
||||||
|
(define (decdate adate delta)(moddate - adate delta ))
|
||||||
|
(define (incdate adate delta)(moddate + adate delta ))
|
||||||
|
|
||||||
|
;; Time comparison, true if t2 is later than t1
|
||||||
|
(define (gnc:timepair-later t1 t2)
|
||||||
|
(< (car t1) (car t2)))
|
||||||
|
|
||||||
|
;; Build a list of time intervals
|
||||||
|
(define (dateloop curd endd incr)
|
||||||
|
(cond ((gnc:timepair-later curd endd)
|
||||||
|
(let ((nextd (incdate curd incr)))
|
||||||
|
(cons (list curd (decdate nextd SecDelta) '())
|
||||||
|
(dateloop nextd endd incr))))
|
||||||
|
(else '())))
|
||||||
|
|
||||||
|
; A reference zero date - the Beginning Of The Epoch
|
||||||
|
; Note: use of eval is evil... by making this a generator function,
|
||||||
|
; each delta function gets its own instance of Zero Date
|
||||||
|
(define (make-zdate)
|
||||||
|
(let ((zd (localtime 0)))
|
||||||
|
(set-tm:hour zd 0)
|
||||||
|
(set-tm:min zd 0)
|
||||||
|
(set-tm:sec zd 0)
|
||||||
|
(set-tm:mday zd 0)
|
||||||
|
(set-tm:mon zd 0)
|
||||||
|
(set-tm:year zd 0)
|
||||||
|
(set-tm:yday zd 0)
|
||||||
|
(set-tm:wday zd 0)
|
||||||
|
zd))
|
||||||
|
|
||||||
|
(define SecDelta
|
||||||
|
(let ((ddt (make-zdate)))
|
||||||
|
(set-tm:sec ddt 1)
|
||||||
|
ddt))
|
||||||
|
|
||||||
|
(define YearDelta
|
||||||
|
(let ((ddt (make-zdate)))
|
||||||
|
(set-tm:year ddt 1)
|
||||||
|
ddt))
|
||||||
|
|
||||||
|
(define DayDelta
|
||||||
|
(let ((ddt (make-zdate)))
|
||||||
|
(set-tm:mday ddt 1)
|
||||||
|
ddt))
|
||||||
|
|
||||||
|
(define WeekDelta
|
||||||
|
(let ((ddt (make-zdate)))
|
||||||
|
(set-tm:mday ddt 7)
|
||||||
|
ddt))
|
||||||
|
|
||||||
|
(define TwoWeekDelta
|
||||||
|
(let ((ddt (make-zdate)))
|
||||||
|
(set-tm:mday ddt 14)
|
||||||
|
ddt))
|
||||||
|
|
||||||
|
(define MonthDelta
|
||||||
|
(let ((ddt (make-zdate)))
|
||||||
|
(set-tm:mon ddt 1)
|
||||||
|
ddt))
|
||||||
|
|
||||||
|
(define (gnc:timepair-to-ldatestring tp)
|
||||||
|
(let ((bdtime (localtime (car tp))))
|
||||||
|
(strftime "%m/%d/%Y" bdtime)))
|
||||||
|
|
||||||
|
;; Find difference in seconds (?) between time 1 and time2
|
||||||
|
(define (gnc:timepair-delta t1 t2)
|
||||||
|
(- (car t2) (car t1)))
|
||||||
|
|
||||||
|
;; timepair manipulation functions
|
||||||
|
;; hack alert - these should probably be put somewhere else
|
||||||
|
;; and be implemented PROPERLY rather than hackily
|
||||||
|
;;; Added from transaction-report.scm
|
||||||
|
|
||||||
|
(define (gnc:timepair-to-datestring tp)
|
||||||
|
(let ((bdtime (localtime (car tp))))
|
||||||
|
(strftime "%x" bdtime)))
|
||||||
|
|
||||||
|
;; given a timepair contains any time on a certain day (local time)
|
||||||
|
;; converts it to be midday that day.
|
||||||
|
|
||||||
|
(define (gnc:timepair-canonical-day-time tp)
|
||||||
|
(let ((bdt (localtime (car tp))))
|
||||||
|
(set-tm:sec bdt 0)
|
||||||
|
(set-tm:min bdt 0)
|
||||||
|
(set-tm:hour bdt 12)
|
||||||
|
(let ((newtime (car (mktime bdt))))
|
||||||
|
; alert - blarsen@ada-works.com fixed this. you may want to
|
||||||
|
; revert if I'm wrong.
|
||||||
|
(cons newtime 0))))
|
||||||
|
|
||||||
|
(define (gnc:timepair-earlier-or-eq-date t1 t2)
|
||||||
|
(let ((time1 (car (gnc:timepair-canonical-day-time t1)))
|
||||||
|
(time2 (car (gnc:timepair-canonical-day-time t2))))
|
||||||
|
(<= time1 time2)))
|
||||||
|
|
||||||
|
(define (gnc:timepair-later-date t1 t2)
|
||||||
|
(let ((time1 (car (gnc:timepair-canonical-day-time t1)))
|
||||||
|
(time2 (car (gnc:timepair-canonical-day-time t2))))
|
||||||
|
(< time1 time2)))
|
||||||
|
|
||||||
|
(define (gnc:timepair-later-or-eq-date t1 t2)
|
||||||
|
(gnc:timepair-earlier-or-eq-date t2 t1))
|
||||||
|
|
||||||
|
@ -98,3 +98,50 @@
|
|||||||
(define (html-end-table)
|
(define (html-end-table)
|
||||||
(list "</table>"))
|
(list "</table>"))
|
||||||
|
|
||||||
|
;;;; Here's functions defined in average-balance.scm
|
||||||
|
;;;; The point to this is twofold:
|
||||||
|
;;;; 1. It doesn't break anything because if the functions get
|
||||||
|
;;;; redefined somewhere here, things were *already broken.*
|
||||||
|
;;;; 2. It pushes all HTML stuff into *this* file, and encourages
|
||||||
|
;;;; fixing any resulting mess.
|
||||||
|
;;;;;;;;;;;;;;;;;;;;
|
||||||
|
;; HTML Table
|
||||||
|
;;;;;;;;;;;;;;;;;;;;
|
||||||
|
|
||||||
|
; Convert to string
|
||||||
|
(define (tostring val)
|
||||||
|
(if (number? val)
|
||||||
|
(sprintf #f "%.2f" val)
|
||||||
|
(call-with-output-string
|
||||||
|
(lambda (p)
|
||||||
|
(display val p)))))
|
||||||
|
|
||||||
|
; Create a column entry
|
||||||
|
(define (html-table-col val)
|
||||||
|
(sprintf #f "<TD align=right> %s </TD>" (tostring val)))
|
||||||
|
|
||||||
|
; Create an html table row from a list of entries
|
||||||
|
(define (html-table-row lst)
|
||||||
|
(cond ((string? lst) lst)
|
||||||
|
(else
|
||||||
|
(string-append
|
||||||
|
(sprintf #f "<TR>")
|
||||||
|
(apply string-append (map html-table-col lst))
|
||||||
|
(sprintf #f "</TR>\n")))))
|
||||||
|
|
||||||
|
; Create an html table from a list of rows, each containing
|
||||||
|
; a list of column entries
|
||||||
|
(define (html-table hdrlst llst)
|
||||||
|
(string-append
|
||||||
|
(html-table-header hdrlst)
|
||||||
|
(apply string-append (map html-table-row llst))
|
||||||
|
(html-table-footer)))
|
||||||
|
|
||||||
|
(define (html-table-headcol val)
|
||||||
|
(sprintf #f "<TH justify=center> %s </TH>" (tostring val)))
|
||||||
|
|
||||||
|
(define (html-table-header vec)
|
||||||
|
(apply string-append "<TABLE cellspacing=10 rules=\"rows\">\n" (map html-table-headcol vec)))
|
||||||
|
|
||||||
|
(define (html-table-footer)
|
||||||
|
(sprintf #f "</TABLE>"))
|
||||||
|
@ -1,4 +1,7 @@
|
|||||||
;; $Id$
|
;; $Id$
|
||||||
|
(gnc:support "qifs/dates-qif.scm")
|
||||||
|
(gnc:depend "substring-search.scm")
|
||||||
|
|
||||||
;;;;;;; Date-related code
|
;;;;;;; Date-related code
|
||||||
(define findspace (substring-search-maker " "))
|
(define findspace (substring-search-maker " "))
|
||||||
|
|
@ -1,4 +1,8 @@
|
|||||||
;;; $Id$
|
;;; $Id$
|
||||||
|
(gnc:support "qifs/gc-import-qifs.scm")
|
||||||
|
(gnc:depend "qifs/qifcats.scm")
|
||||||
|
(gnc:depend "qifs/qif2gc.scm")
|
||||||
|
|
||||||
(display "Started gc-impor.scm")
|
(display "Started gc-impor.scm")
|
||||||
(newline)
|
(newline)
|
||||||
(define (gnc:get-account-list account-group)
|
(define (gnc:get-account-list account-group)
|
||||||
@ -13,7 +17,6 @@
|
|||||||
(newline)
|
(newline)
|
||||||
(filteroutnulls fullacclist))))
|
(filteroutnulls fullacclist))))
|
||||||
|
|
||||||
|
|
||||||
(define (gnc:import-file-into-account-group account-group)
|
(define (gnc:import-file-into-account-group account-group)
|
||||||
;(sample-dialog)
|
;(sample-dialog)
|
||||||
(let ((file-name
|
(let ((file-name
|
@ -1,4 +1,7 @@
|
|||||||
;;; $Id$
|
;;; $Id$
|
||||||
|
(gnc:support "qifs/guess-category-qif.scm")
|
||||||
|
(gnc:depend "substring-search.scm")
|
||||||
|
|
||||||
;;; Need a bunch of metrics, and probably to vectorize this...
|
;;; Need a bunch of metrics, and probably to vectorize this...
|
||||||
;;; 1. Braces --> pick gnucash entries from account list
|
;;; 1. Braces --> pick gnucash entries from account list
|
||||||
;;; No braces --> pick gnucash entries from category list
|
;;; No braces --> pick gnucash entries from category list
|
||||||
@ -100,4 +103,4 @@
|
|||||||
(guess-corresponding-categories
|
(guess-corresponding-categories
|
||||||
kept-categories
|
kept-categories
|
||||||
(gnc:get-incomes-list account-group)
|
(gnc:get-incomes-list account-group)
|
||||||
(gnc:get-account-list account-group)))
|
(gnc:get-account-list account-group)))
|
@ -1,7 +1,7 @@
|
|||||||
;;; $Id$
|
;;; $Id$
|
||||||
;;; Import QIF File
|
;;; Import QIF File
|
||||||
|
|
||||||
(gnc:support "importqif.scm")
|
(gnc:support "importqif.scm")
|
||||||
|
(gnc:depend "qifs/gc-import-qifs.scm")
|
||||||
|
|
||||||
(define testing? #f) ;;; Should we do testing?
|
(define testing? #f) ;;; Should we do testing?
|
||||||
|
|
||||||
@ -15,7 +15,7 @@
|
|||||||
(begin
|
(begin
|
||||||
(display "account-group:")
|
(display "account-group:")
|
||||||
(display account-group) (newline)
|
(display account-group) (newline)
|
||||||
(let ((loadfun (lambda (x) (gnc:load x)))
|
(let ((loadfun (lambda (x) (gnc:load (string-append "qifs/" x))))
|
||||||
(loadlist '("testbed.scm" "analytical-qifs.scm"
|
(loadlist '("testbed.scm" "analytical-qifs.scm"
|
||||||
"gc-import-qifs.scm"
|
"gc-import-qifs.scm"
|
||||||
"qifutils.scm" "acc-create.scm")))
|
"qifutils.scm" "acc-create.scm")))
|
||||||
@ -35,7 +35,7 @@
|
|||||||
(begin
|
(begin
|
||||||
(display "account-group:")
|
(display "account-group:")
|
||||||
(display account-group) (newline)
|
(display account-group) (newline)
|
||||||
(let ((loadfun (lambda (x) (gnc:load x)))
|
(let ((loadfun (lambda (x) (gnc:load (string-append "qifs/" x))))
|
||||||
(loadlist '("testbed.scm" "analytical-qifs.scm"
|
(loadlist '("testbed.scm" "analytical-qifs.scm"
|
||||||
"gc-import-qifs.scm" "qifutils.scm"
|
"gc-import-qifs.scm" "qifutils.scm"
|
||||||
"acc-create.scm" "txn-create.scm")))
|
"acc-create.scm" "txn-create.scm")))
|
||||||
@ -55,8 +55,8 @@
|
|||||||
(begin
|
(begin
|
||||||
(display "account-group:")
|
(display "account-group:")
|
||||||
(display account-group) (newline)
|
(display account-group) (newline)
|
||||||
(let ((loadfun (lambda (x) (gnc:load x)))
|
(let ((loadfun (lambda (x) (gnc:load (string-append "qifs/" x))))
|
||||||
(loadlist '("testbed.scm" "sstring-qif.scm"
|
(loadlist '("testbed.scm"
|
||||||
"qifutils.scm" "dates-qif.scm"
|
"qifutils.scm" "dates-qif.scm"
|
||||||
"acc-create.scm"
|
"acc-create.scm"
|
||||||
"txn-create.scm"
|
"txn-create.scm"
|
@ -1,7 +1,12 @@
|
|||||||
;;; $Id$
|
;;; $Id$
|
||||||
;;;;;;;;;;; QIF Parsing ;;;;;;;;;;;;;;
|
|
||||||
|
|
||||||
(require 'hash-table)
|
(require 'hash-table)
|
||||||
|
(gnc:support "qifs/parseqif.scm")
|
||||||
|
(gnc:depend "qifs/qifcats.scm")
|
||||||
|
(gnc:depend "qifs/dates-qif.scm")
|
||||||
|
(gnc:depend "qifs/gc-import-qifs.scm")
|
||||||
|
(gnc:depend "qifs/qifstate.scm")
|
||||||
|
(gnc:depend "qifs/split-qif.scm")
|
||||||
|
(gnc:depend "qifs/guess-category-qif.scm")
|
||||||
|
|
||||||
(define qif-txn-list '())
|
(define qif-txn-list '())
|
||||||
|
|
@ -1,4 +1,6 @@
|
|||||||
;;; $Id$
|
;;; $Id$
|
||||||
|
(gnc:support "qifs/qif2gc.scm")
|
||||||
|
(gnc:depend "qifs/guess-category-qif.scm")
|
||||||
;;;; Take the set of stuff from a QIF file, and turn it into the
|
;;;; Take the set of stuff from a QIF file, and turn it into the
|
||||||
;;;; structures expected by GnuCash.
|
;;;; structures expected by GnuCash.
|
||||||
|
|
@ -1,5 +1,6 @@
|
|||||||
;;; $Id$
|
;;; $Id$
|
||||||
;;;;; Category management
|
;;;;; Category management
|
||||||
|
(gnc:support "qifs/qifcats.scm")
|
||||||
|
|
||||||
(define qif-cat-list (initialize-hashtable))
|
(define qif-cat-list (initialize-hashtable))
|
||||||
|
|
@ -1,4 +1,5 @@
|
|||||||
;;; $Id$
|
;;; $Id$
|
||||||
|
(gnc:support "qifs/qifstate.scm")
|
||||||
;;;;; - Transactions should not be marked off as being finally reconciled on
|
;;;;; - Transactions should not be marked off as being finally reconciled on
|
||||||
;;;;; the GnuCash side, as the reconciliation hasn't been done there.
|
;;;;; the GnuCash side, as the reconciliation hasn't been done there.
|
||||||
;;;;;
|
;;;;;
|
@ -1,75 +1,6 @@
|
|||||||
;;; $Id$
|
;;; $Id$
|
||||||
(define (directory? path)
|
(gnc:support "qifs/qifutils.scm")
|
||||||
;; This follows symlinks normally.
|
(gnc:depend "utilities.scm")
|
||||||
(let* ((status (false-if-exception (stat path)))
|
|
||||||
(type (if status (stat:type status) #f)))
|
|
||||||
(eq? type 'directory)))
|
|
||||||
|
|
||||||
(define (filteroutnulls lst)
|
|
||||||
(cond
|
|
||||||
((null? lst) '())
|
|
||||||
((eq? (car lst) #f) (filteroutnulls (cdr lst)))
|
|
||||||
(else
|
|
||||||
(cons (car lst) (filteroutnulls (cdr lst))))))
|
|
||||||
|
|
||||||
(if testing?
|
|
||||||
(let ((i1 '(a b #f f g h #f #f (c d e #f #f) #f))
|
|
||||||
(i2 '(#f #f #f #f)))
|
|
||||||
(testing "filteroutnulls"
|
|
||||||
i1
|
|
||||||
'(a b f g h (c d e #f #f))
|
|
||||||
(filteroutnulls i1))
|
|
||||||
|
|
||||||
(testing "filteroutnulls"
|
|
||||||
i2
|
|
||||||
'()
|
|
||||||
(filteroutnulls i2))))
|
|
||||||
|
|
||||||
(define (atom? x)
|
|
||||||
(and
|
|
||||||
(not (pair? x))
|
|
||||||
(not (null? x))))
|
|
||||||
|
|
||||||
(define (flatten lst)
|
|
||||||
(cond
|
|
||||||
((null? lst) '())
|
|
||||||
((atom? lst) (list lst))
|
|
||||||
((list? lst)
|
|
||||||
(append (flatten (car lst))
|
|
||||||
(flatten (cdr lst))))
|
|
||||||
(else lst)))
|
|
||||||
|
|
||||||
(if testing?
|
|
||||||
(let ((input '(a b (c d (e (f) (g) (h i (j k))) l m no p))))
|
|
||||||
(testing "flatten"
|
|
||||||
input
|
|
||||||
'(a b c d e f g h i j k l m no p)
|
|
||||||
(flatten input))))
|
|
||||||
|
|
||||||
(define (striptrailingwhitespace line)
|
|
||||||
(let
|
|
||||||
((stringsize (string-length line)))
|
|
||||||
(if
|
|
||||||
(< stringsize 1)
|
|
||||||
""
|
|
||||||
(let*
|
|
||||||
((lastchar (string-ref line (- stringsize 1))))
|
|
||||||
(if
|
|
||||||
(char-whitespace? lastchar)
|
|
||||||
(striptrailingwhitespace (substring line 0 (- stringsize 1)))
|
|
||||||
line)))))
|
|
||||||
|
|
||||||
(if testing?
|
|
||||||
(begin
|
|
||||||
(newline)
|
|
||||||
(display "Test striptrailingwhitespace") (newline)
|
|
||||||
(let ((tstring "Here's a string
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
"))
|
|
||||||
(display tstring) (newline)
|
|
||||||
(display "Result:") (display (striptrailingwhitespace tstring)) (newline))))
|
|
||||||
|
|
||||||
(define (strip-qif-header line)
|
(define (strip-qif-header line)
|
||||||
(substring line 1 (string-length line)))
|
(substring line 1 (string-length line)))
|
||||||
@ -130,16 +61,6 @@
|
|||||||
#\.
|
#\.
|
||||||
(thousands-separator num)))))
|
(thousands-separator num)))))
|
||||||
|
|
||||||
(define (string-join lst joinstr)
|
|
||||||
(let ((len (length lst)))
|
|
||||||
(cond
|
|
||||||
((< 1 len)
|
|
||||||
(string-append (car lst) joinstr (string-join (cdr lst) joinstr)))
|
|
||||||
((= 1 len)
|
|
||||||
(car lst))
|
|
||||||
(else
|
|
||||||
""))))
|
|
||||||
|
|
||||||
(define (numerizeamount amount-as-string)
|
(define (numerizeamount amount-as-string)
|
||||||
(let*
|
(let*
|
||||||
(
|
(
|
||||||
@ -215,11 +136,3 @@
|
|||||||
'(d a e)
|
'(d a e)
|
||||||
(shorten-to-best! 3 alist))))
|
(shorten-to-best! 3 alist))))
|
||||||
|
|
||||||
;;;; Simple lookup scheme; can be turned into a hash table If Need Be.
|
|
||||||
;;; Initialize lookup table
|
|
||||||
(define (initialize-hashtable . size)
|
|
||||||
(make-vector
|
|
||||||
(if (null? size)
|
|
||||||
313
|
|
||||||
(car size))
|
|
||||||
'()))
|
|
@ -3,6 +3,9 @@
|
|||||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
;;;; Variables used to handle splits ;;;;
|
;;;; Variables used to handle splits ;;;;
|
||||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
|
(gnc:support "qifs/split-qif.scm")
|
||||||
|
(gnc:depend "structure.scm")
|
||||||
|
|
||||||
(define splits? #f)
|
(define splits? #f)
|
||||||
(define splitlist '())
|
(define splitlist '())
|
||||||
(define qif-split-structure
|
(define qif-split-structure
|
@ -1,6 +1,5 @@
|
|||||||
;;; $Id$
|
;;; $Id$
|
||||||
;;; Reporting utilities
|
;;; Reporting utilities
|
||||||
|
|
||||||
(gnc:support "report-utilities.scm")
|
(gnc:support "report-utilities.scm")
|
||||||
|
|
||||||
(define (gnc:account-separator-char)
|
(define (gnc:account-separator-char)
|
||||||
@ -197,4 +196,127 @@
|
|||||||
(vector-N-ref vector ref-list))
|
(vector-N-ref vector ref-list))
|
||||||
(loop (+ 1 i))))))))))
|
(loop (+ 1 i))))))))))
|
||||||
|
|
||||||
|
;;; applies thunk to each split in account account
|
||||||
|
(define (gnc:for-each-split-in-account account thunk)
|
||||||
|
(gnc:for-loop (lambda (x)
|
||||||
|
(thunk (gnc:account-get-split account x)))
|
||||||
|
0 (gnc:account-get-split-count account) 1))
|
||||||
|
|
||||||
|
;; register a configuration option for the transaction report
|
||||||
|
(define (trep-options-generator)
|
||||||
|
(define gnc:*transaction-report-options* (gnc:new-options))
|
||||||
|
(define (gnc:register-trep-option new-option)
|
||||||
|
(gnc:register-option gnc:*transaction-report-options* new-option))
|
||||||
|
;; from date
|
||||||
|
;; hack alert - could somebody set this to an appropriate date?
|
||||||
|
(gnc:register-trep-option
|
||||||
|
(gnc:make-date-option
|
||||||
|
"Report Options" "From"
|
||||||
|
"a" "Report Items from this date"
|
||||||
|
(lambda ()
|
||||||
|
(let ((bdtime (localtime (current-time))))
|
||||||
|
(set-tm:sec bdtime 0)
|
||||||
|
(set-tm:min bdtime 0)
|
||||||
|
(set-tm:hour bdtime 0)
|
||||||
|
(set-tm:mday bdtime 1)
|
||||||
|
(set-tm:mon bdtime 0)
|
||||||
|
(let ((time (car (mktime bdtime))))
|
||||||
|
(cons time 0))))
|
||||||
|
#f))
|
||||||
|
|
||||||
|
;; to-date
|
||||||
|
(gnc:register-trep-option
|
||||||
|
(gnc:make-date-option
|
||||||
|
"Report Options" "To"
|
||||||
|
"b" "Report items up to and including this date"
|
||||||
|
(lambda () (cons (current-time) 0))
|
||||||
|
#f))
|
||||||
|
|
||||||
|
;; account to do report on
|
||||||
|
(gnc:register-trep-option
|
||||||
|
(gnc:make-account-list-option
|
||||||
|
"Report Options" "Account"
|
||||||
|
"c" "Do transaction report on this account"
|
||||||
|
(lambda ()
|
||||||
|
(let ((current-accounts (gnc:get-current-accounts))
|
||||||
|
(num-accounts (gnc:group-get-num-accounts (gnc:get-current-group)))
|
||||||
|
(first-account (gnc:group-get-account (gnc:get-current-group) 0)))
|
||||||
|
(cond ((not (null? current-accounts)) (list (car current-accounts)))
|
||||||
|
((> num-accounts 0) (list first-account))
|
||||||
|
(else ()))))
|
||||||
|
#f #f))
|
||||||
|
|
||||||
|
;; primary sorting criterion
|
||||||
|
(gnc:register-trep-option
|
||||||
|
(gnc:make-multichoice-option
|
||||||
|
"Sorting" "Primary Key"
|
||||||
|
"a" "Sort by this criterion first"
|
||||||
|
'date
|
||||||
|
(list #(date
|
||||||
|
"Date"
|
||||||
|
"Sort by date")
|
||||||
|
#(time
|
||||||
|
"Time"
|
||||||
|
"Sort by EXACT entry time")
|
||||||
|
#(corresponding-acc
|
||||||
|
"Transfer from/to"
|
||||||
|
"Sort by account transferred from/to's name")
|
||||||
|
#(amount
|
||||||
|
"Amount"
|
||||||
|
"Sort by amount")
|
||||||
|
#(description
|
||||||
|
"Description"
|
||||||
|
"Sort by description")
|
||||||
|
#(number
|
||||||
|
"Number"
|
||||||
|
"Sort by check/transaction number")
|
||||||
|
#(memo
|
||||||
|
"Memo"
|
||||||
|
"Sort by memo"))))
|
||||||
|
|
||||||
|
(gnc:register-trep-option
|
||||||
|
(gnc:make-multichoice-option
|
||||||
|
"Sorting" "Primary Sort Order"
|
||||||
|
"b" "Order of primary sorting"
|
||||||
|
'ascend
|
||||||
|
(list #(ascend "Ascending" "smallest to largest, earliest to latest")
|
||||||
|
#(descend "Descending" "largest to smallest, latest to earliest"))))
|
||||||
|
|
||||||
|
(gnc:register-trep-option
|
||||||
|
(gnc:make-multichoice-option
|
||||||
|
"Sorting" "Secondary Key"
|
||||||
|
"c"
|
||||||
|
"Sort by this criterion second"
|
||||||
|
'corresponding-acc
|
||||||
|
(list #(date
|
||||||
|
"Date"
|
||||||
|
"Sort by date")
|
||||||
|
#(time
|
||||||
|
"Time"
|
||||||
|
"Sort by EXACT entry time")
|
||||||
|
#(corresponding-acc
|
||||||
|
"Transfer from/to"
|
||||||
|
"Sort by account transferred from/to's name")
|
||||||
|
#(amount
|
||||||
|
"Amount"
|
||||||
|
"Sort by amount")
|
||||||
|
#(description
|
||||||
|
"Description"
|
||||||
|
"Sort by description")
|
||||||
|
#(number
|
||||||
|
"Number"
|
||||||
|
"Sort by check/transaction number")
|
||||||
|
#(memo
|
||||||
|
"Memo"
|
||||||
|
"Sort by memo"))))
|
||||||
|
|
||||||
|
(gnc:register-trep-option
|
||||||
|
(gnc:make-multichoice-option
|
||||||
|
"Sorting" "Secondary Sort Order"
|
||||||
|
"d" "Order of Secondary sorting"
|
||||||
|
'ascend
|
||||||
|
(list #(ascend "Ascending" "smallest to largest, earliest to latest")
|
||||||
|
#(descend "Descending" "largest to smallest, latest to earliest"))))
|
||||||
|
|
||||||
|
gnc:*transaction-report-options*)
|
||||||
|
|
||||||
|
@ -10,47 +10,12 @@
|
|||||||
;; Matt Martin <matt.martin@ieee.org>
|
;; Matt Martin <matt.martin@ieee.org>
|
||||||
|
|
||||||
(gnc:support "report/average-balance.scm")
|
(gnc:support "report/average-balance.scm")
|
||||||
|
|
||||||
(use-modules (ice-9 regex))
|
(use-modules (ice-9 regex))
|
||||||
(require 'hash-table)
|
(require 'hash-table)
|
||||||
|
|
||||||
(gnc:depend "structure.scm")
|
(gnc:depend "structure.scm")
|
||||||
(gnc:depend "report/transaction-report.scm")
|
(gnc:depend "html-generator.scm")
|
||||||
|
(gnc:depend "date-utilities.scm")
|
||||||
;; Modify a date
|
|
||||||
(define (moddate op adate delta)
|
|
||||||
(let ((newtm (localtime (car adate))))
|
|
||||||
(begin
|
|
||||||
(set-tm:sec newtm (op (tm:sec newtm) (tm:sec delta)))
|
|
||||||
(set-tm:min newtm (op (tm:min newtm) (tm:min delta)))
|
|
||||||
(set-tm:hour newtm (op (tm:hour newtm) (tm:hour delta)))
|
|
||||||
(set-tm:mday newtm (op (tm:mday newtm) (tm:mday delta)))
|
|
||||||
(set-tm:mon newtm (op (tm:mon newtm) (tm:mon delta)))
|
|
||||||
(set-tm:year newtm (op (tm:year newtm) (tm:year delta)))
|
|
||||||
|
|
||||||
(let ((time (car (mktime newtm))))
|
|
||||||
(cons time 0))
|
|
||||||
))
|
|
||||||
)
|
|
||||||
|
|
||||||
;; Add or subtract time from a date
|
|
||||||
(define (decdate adate delta)(moddate - adate delta ))
|
|
||||||
(define (incdate adate delta)(moddate + adate delta ))
|
|
||||||
|
|
||||||
;; Time comparison, true if t2 is later than t1
|
|
||||||
(define (gnc:timepair-later t1 t2)
|
|
||||||
(< (car t1) (car t2)))
|
|
||||||
|
|
||||||
;; Build a list of time intervals
|
|
||||||
(define (dateloop curd endd incr)
|
|
||||||
(cond ((gnc:timepair-later curd endd)
|
|
||||||
(let ((nextd (incdate curd incr)))
|
|
||||||
(cons (list curd (decdate nextd SecDelta) '())
|
|
||||||
(dateloop nextd endd incr))))
|
|
||||||
(else '())
|
|
||||||
)
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
;; Options
|
;; Options
|
||||||
(define (runavg-options-generator)
|
(define (runavg-options-generator)
|
||||||
@ -73,9 +38,8 @@
|
|||||||
(set-tm:hour bdtime 0)
|
(set-tm:hour bdtime 0)
|
||||||
(set-tm:mday bdtime 1)
|
(set-tm:mday bdtime 1)
|
||||||
(set-tm:mon bdtime 0)
|
(set-tm:mon bdtime 0)
|
||||||
(let ((time (car (mktime bdtime))))
|
(cons (car (mktime bdtime)) 0))))
|
||||||
(cons time 0))))
|
#f))
|
||||||
#f))
|
|
||||||
|
|
||||||
;; to-date
|
;; to-date
|
||||||
(gnc:register-runavg-option
|
(gnc:register-runavg-option
|
||||||
@ -135,45 +99,10 @@
|
|||||||
(list #(NoPlot "Nothing" "Make No Plot")
|
(list #(NoPlot "Nothing" "Make No Plot")
|
||||||
#(AvgBalPlot "Average" "Average Balance")
|
#(AvgBalPlot "Average" "Average Balance")
|
||||||
#(GainPlot "Net Gain" "Net Gain")
|
#(GainPlot "Net Gain" "Net Gain")
|
||||||
#(GLPlot "Gain/Loss" "Gain And Loss")
|
#(GLPlot "Gain/Loss" "Gain And Loss"))))
|
||||||
)))
|
|
||||||
|
|
||||||
gnc:*runavg-track-options*)
|
gnc:*runavg-track-options*)
|
||||||
|
|
||||||
; A reference zero date
|
|
||||||
(define zdate (let ((zd (localtime 0)))
|
|
||||||
(set-tm:hour zd 0)
|
|
||||||
(set-tm:min zd 0)
|
|
||||||
(set-tm:sec zd 0)
|
|
||||||
(set-tm:mday zd 0)
|
|
||||||
(set-tm:mon zd 0)
|
|
||||||
(set-tm:year zd 0)
|
|
||||||
(set-tm:yday zd 0)
|
|
||||||
(set-tm:wday zd 0)
|
|
||||||
zd
|
|
||||||
))
|
|
||||||
|
|
||||||
(define SecDelta (let ((ddt (eval zdate)))
|
|
||||||
(set-tm:sec ddt 1)
|
|
||||||
ddt))
|
|
||||||
(define YearDelta (let ((ddt (eval zdate)))
|
|
||||||
(set-tm:year ddt 1)
|
|
||||||
ddt))
|
|
||||||
|
|
||||||
(define DayDelta (let ((ddt (eval zdate)))
|
|
||||||
(set-tm:mday ddt 1)
|
|
||||||
ddt))
|
|
||||||
(define WeekDelta (let ((ddt (eval zdate)))
|
|
||||||
(set-tm:mday ddt 7)
|
|
||||||
ddt))
|
|
||||||
(define TwoWeekDelta (let ((ddt (eval zdate)))
|
|
||||||
(set-tm:mday ddt 14)
|
|
||||||
ddt))
|
|
||||||
|
|
||||||
(define MonthDelta (let ((ddt (eval zdate)))
|
|
||||||
(set-tm:mon ddt 1)
|
|
||||||
ddt))
|
|
||||||
|
|
||||||
;; Plot strings
|
;; Plot strings
|
||||||
(define AvgBalPlot "using 2:3:4:5 t 'Average Balance' with errorbars, '' using 2:3 smooth sbezier t '' with lines")
|
(define AvgBalPlot "using 2:3:4:5 t 'Average Balance' with errorbars, '' using 2:3 smooth sbezier t '' with lines")
|
||||||
(define GainPlot "using 2:6 t 'Net Gain' with linespoints, '' using 2:6 smooth sbezier t '' with lines" )
|
(define GainPlot "using 2:6 t 'Net Gain' with linespoints, '' using 2:6 smooth sbezier t '' with lines" )
|
||||||
@ -199,64 +128,6 @@
|
|||||||
(define (gnc:split-get-account-name split)
|
(define (gnc:split-get-account-name split)
|
||||||
(gnc:account-get-name (gnc:split-get-account split)))
|
(gnc:account-get-name (gnc:split-get-account split)))
|
||||||
|
|
||||||
(define (gnc:timepair-to-ldatestring tp)
|
|
||||||
(let ((bdtime (localtime (car tp))))
|
|
||||||
(strftime "%m/%d/%Y" bdtime)))
|
|
||||||
|
|
||||||
|
|
||||||
;; Find difference in seconds (?) between time 1 and time2
|
|
||||||
(define (gnc:timepair-delta t1 t2)
|
|
||||||
(- (car t2) (car t1)))
|
|
||||||
|
|
||||||
; Convert to string
|
|
||||||
(define (tostring val)
|
|
||||||
(cond ((number? val) (sprintf #f "%.2f" val))
|
|
||||||
(else (call-with-output-string (lambda (p)(display val p))))
|
|
||||||
))
|
|
||||||
|
|
||||||
;;;;;;;;;;;;;;;;;;;;
|
|
||||||
;; HTML Table
|
|
||||||
;;;;;;;;;;;;;;;;;;;;
|
|
||||||
|
|
||||||
; Create a column entry
|
|
||||||
(define (html-table-col val)
|
|
||||||
(sprintf #f "<TD align=right> %s </TD>" (tostring val))
|
|
||||||
)
|
|
||||||
|
|
||||||
; Create an html table row from a list of entries
|
|
||||||
(define (html-table-row lst)
|
|
||||||
(cond ((string? lst) lst)
|
|
||||||
(else
|
|
||||||
(string-append
|
|
||||||
(sprintf #f "<TR>")
|
|
||||||
(apply string-append (map html-table-col lst))
|
|
||||||
(sprintf #f "</TR>\n")
|
|
||||||
)))
|
|
||||||
)
|
|
||||||
|
|
||||||
; Create an html table from a list of rows, each containing
|
|
||||||
; a list of column entries
|
|
||||||
(define (html-table hdrlst llst)
|
|
||||||
(string-append
|
|
||||||
(html-table-header hdrlst)
|
|
||||||
(apply string-append (map html-table-row llst))
|
|
||||||
(html-table-footer)
|
|
||||||
)
|
|
||||||
)
|
|
||||||
|
|
||||||
(define (html-table-headcol val)
|
|
||||||
(sprintf #f "<TH justify=center> %s </TH>" (tostring val))
|
|
||||||
)
|
|
||||||
|
|
||||||
(define (html-table-header vec)
|
|
||||||
(apply string-append "<TABLE cellspacing=10 rules=\"rows\">\n" (map html-table-headcol vec))
|
|
||||||
)
|
|
||||||
|
|
||||||
(define (html-table-footer)
|
|
||||||
(sprintf #f "</TABLE>")
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
;; Text table
|
;; Text table
|
||||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
@ -489,6 +360,120 @@
|
|||||||
(gnc:account-get-children (car accounts)))
|
(gnc:account-get-children (car accounts)))
|
||||||
(allsubaccounts (cdr accounts))))))
|
(allsubaccounts (cdr accounts))))))
|
||||||
|
|
||||||
|
(define (average-balance-renderer options)
|
||||||
|
(let* ((begindate (gnc:option-value
|
||||||
|
(gnc:lookup-option options "Report Options" "From")))
|
||||||
|
(enddate (gnc:option-value
|
||||||
|
(gnc:lookup-option options "Report Options" "To")))
|
||||||
|
(stepsize (gnc:option-value
|
||||||
|
(gnc:lookup-option options "Report Options" "Step Size")))
|
||||||
|
|
||||||
|
(plotstr (gnc:option-value
|
||||||
|
(gnc:lookup-option options "Report Options" "Plot Type")))
|
||||||
|
|
||||||
|
(accounts (gnc:option-value
|
||||||
|
(gnc:lookup-option options
|
||||||
|
"Report Options" "Account")))
|
||||||
|
|
||||||
|
(dosubs (gnc:option-value
|
||||||
|
(gnc:lookup-option options
|
||||||
|
"Report Options" "Sub-Accounts")))
|
||||||
|
|
||||||
|
(prefix (list "<HTML>" "<BODY>"))
|
||||||
|
(suffix (list "</BODY>" "</HTML>"))
|
||||||
|
(collist
|
||||||
|
(list "Beginning" "Ending" "Average" "Max" "Min" "Net Gain" "Gain" "Loss"))
|
||||||
|
|
||||||
|
(report-lines '())
|
||||||
|
(rept-data '())
|
||||||
|
(sum-data '())
|
||||||
|
(tempstruct '())
|
||||||
|
(rept-text "")
|
||||||
|
(gncq (gnc:malloc-query))
|
||||||
|
|
||||||
|
(slist '()))
|
||||||
|
|
||||||
|
(gnc:init-query gncq)
|
||||||
|
|
||||||
|
(if (null? accounts)
|
||||||
|
(set! rept-text
|
||||||
|
(list "<TR><TD>You have not selected an account.</TD></TR>"))
|
||||||
|
(begin
|
||||||
|
; Grab account names
|
||||||
|
(set! acctname (string-join
|
||||||
|
(map gnc-account-getname accounts)
|
||||||
|
" , "))
|
||||||
|
(cond ((equal? dosubs #t)
|
||||||
|
(map (lambda (a)
|
||||||
|
(set! accounts (addunique accounts a)))
|
||||||
|
(allsubaccounts accounts))
|
||||||
|
|
||||||
|
(set! acctname (string-append acctname " and sub-accounts"))))
|
||||||
|
|
||||||
|
(map (lambda(acct) (gnc:query-add-account gncq acct)) accounts)
|
||||||
|
|
||||||
|
(set! tempstruct
|
||||||
|
(build-mystruct-instance
|
||||||
|
(define-mystruct
|
||||||
|
(gnc:acctnames-from-list accounts))))
|
||||||
|
|
||||||
|
(set! acctcurrency (gnc:account-get-currency (car accounts)))
|
||||||
|
|
||||||
|
(set! report-lines
|
||||||
|
(gnc:convert-split-list (gnc:query-get-splits gncq)))
|
||||||
|
|
||||||
|
(gnc:free-query gncq)
|
||||||
|
|
||||||
|
(display (length report-lines))
|
||||||
|
(display " Splits\n")
|
||||||
|
|
||||||
|
; Set initial balances to zero
|
||||||
|
(map (lambda(an) (tempstruct 'put an 0))
|
||||||
|
(gnc:acctnames-from-list accounts))
|
||||||
|
|
||||||
|
(dateloop begindate
|
||||||
|
enddate
|
||||||
|
(eval stepsize))
|
||||||
|
(set! rept-data
|
||||||
|
(reduce-split-list
|
||||||
|
(dateloop begindate
|
||||||
|
enddate
|
||||||
|
(eval stepsize))
|
||||||
|
report-lines zdate tempstruct))
|
||||||
|
|
||||||
|
(set! sum-data (get-averages rept-data))
|
||||||
|
|
||||||
|
;; Create HTML
|
||||||
|
(set! rept-text
|
||||||
|
(html-table
|
||||||
|
collist
|
||||||
|
(append rept-data
|
||||||
|
(list "<TR cellspacing=0><TD><TD><TD colspan=3><HR size=2 noshade><TD colspan=3><HR size=2 noshade></TR>" sum-data))))
|
||||||
|
|
||||||
|
;; Do a plot
|
||||||
|
(if (not (equal? NoPlot (eval plotstr)))
|
||||||
|
(let* ((fn "/tmp/gncplot.dat")
|
||||||
|
(preplot (string-append
|
||||||
|
"set xdata time\n"
|
||||||
|
"set timefmt '%m/%d/%Y'\n"
|
||||||
|
"set pointsize 2\n"
|
||||||
|
"set title '" acctname "'\n"
|
||||||
|
"set ylabel '" acctcurrency "'\n"
|
||||||
|
"set xlabel 'Period Ending'\n"
|
||||||
|
)))
|
||||||
|
|
||||||
|
(data-to-gpfile collist rept-data fn (eval plotstr))
|
||||||
|
(system
|
||||||
|
(string-append "echo \"" preplot "plot '"
|
||||||
|
fn "'" (eval plotstr)
|
||||||
|
"\"|gnuplot -persist " ))))))
|
||||||
|
|
||||||
|
(append prefix
|
||||||
|
(if (null? accounts)
|
||||||
|
()
|
||||||
|
(list "Report for " acctname "<p>\n"))
|
||||||
|
(list rept-text) suffix))))
|
||||||
|
|
||||||
(gnc:define-report
|
(gnc:define-report
|
||||||
;; version
|
;; version
|
||||||
1
|
1
|
||||||
@ -497,128 +482,4 @@
|
|||||||
;; Options
|
;; Options
|
||||||
runavg-options-generator
|
runavg-options-generator
|
||||||
;; renderer
|
;; renderer
|
||||||
(lambda (options)
|
average-balance-renderer)
|
||||||
(let* (
|
|
||||||
(begindate (gnc:option-value
|
|
||||||
(gnc:lookup-option options "Report Options" "From")))
|
|
||||||
(enddate (gnc:option-value
|
|
||||||
(gnc:lookup-option options "Report Options" "To")))
|
|
||||||
(stepsize (gnc:option-value
|
|
||||||
(gnc:lookup-option options "Report Options" "Step Size")))
|
|
||||||
|
|
||||||
(plotstr (gnc:option-value
|
|
||||||
(gnc:lookup-option options "Report Options" "Plot Type")))
|
|
||||||
|
|
||||||
(accounts (gnc:option-value
|
|
||||||
(gnc:lookup-option options
|
|
||||||
"Report Options" "Account")))
|
|
||||||
|
|
||||||
(dosubs (gnc:option-value
|
|
||||||
(gnc:lookup-option options
|
|
||||||
"Report Options" "Sub-Accounts")))
|
|
||||||
|
|
||||||
(prefix (list "<HTML>" "<BODY>"))
|
|
||||||
(suffix (list "</BODY>" "</HTML>"))
|
|
||||||
(collist
|
|
||||||
(list "Beginning" "Ending" "Average" "Max" "Min" "Net Gain" "Gain" "Loss"))
|
|
||||||
|
|
||||||
(report-lines '())
|
|
||||||
(rept-data '())
|
|
||||||
(sum-data '())
|
|
||||||
(tempstruct '())
|
|
||||||
(rept-text "")
|
|
||||||
(gncq (gnc:malloc-query))
|
|
||||||
|
|
||||||
(slist '())
|
|
||||||
|
|
||||||
)
|
|
||||||
|
|
||||||
(gnc:init-query gncq)
|
|
||||||
|
|
||||||
(if (null? accounts)
|
|
||||||
(set! rept-text
|
|
||||||
(list "<TR><TD>You have not selected an account.</TD></TR>"))
|
|
||||||
(begin
|
|
||||||
; Grab account names
|
|
||||||
(set! acctname (gnc:account-get-name (car accounts)))
|
|
||||||
(map (lambda(an)
|
|
||||||
(set! acctname
|
|
||||||
(string-append
|
|
||||||
acctname
|
|
||||||
" , "
|
|
||||||
(gnc:account-get-name an))))
|
|
||||||
(cdr accounts) )
|
|
||||||
|
|
||||||
(cond ((equal? dosubs #t)
|
|
||||||
(map (lambda (a)
|
|
||||||
(set! accounts (addunique accounts a)))
|
|
||||||
(allsubaccounts accounts))
|
|
||||||
|
|
||||||
(set! acctname (string-append acctname " and sub-accounts"))
|
|
||||||
))
|
|
||||||
|
|
||||||
(map (lambda(acct) (gnc:query-add-account gncq acct)) accounts)
|
|
||||||
|
|
||||||
(set! tempstruct
|
|
||||||
(build-mystruct-instance
|
|
||||||
(define-mystruct
|
|
||||||
(gnc:acctnames-from-list accounts))))
|
|
||||||
|
|
||||||
(set! acctcurrency (gnc:account-get-currency (car accounts)))
|
|
||||||
|
|
||||||
(set! report-lines
|
|
||||||
(gnc:convert-split-list (gnc:query-get-splits gncq)))
|
|
||||||
|
|
||||||
(gnc:free-query gncq)
|
|
||||||
|
|
||||||
(display (length report-lines))
|
|
||||||
(display " Splits\n")
|
|
||||||
|
|
||||||
; Set initial balances to zero
|
|
||||||
(map (lambda(an) (tempstruct 'put an 0))
|
|
||||||
(gnc:acctnames-from-list accounts))
|
|
||||||
|
|
||||||
(dateloop begindate
|
|
||||||
enddate
|
|
||||||
(eval stepsize))
|
|
||||||
(set! rept-data
|
|
||||||
(reduce-split-list
|
|
||||||
(dateloop begindate
|
|
||||||
enddate
|
|
||||||
(eval stepsize))
|
|
||||||
report-lines zdate tempstruct))
|
|
||||||
|
|
||||||
(set! sum-data (get-averages rept-data))
|
|
||||||
|
|
||||||
;; Create HTML
|
|
||||||
(set! rept-text
|
|
||||||
(html-table
|
|
||||||
collist
|
|
||||||
(append rept-data
|
|
||||||
(list "<TR cellspacing=0><TD><TD><TD colspan=3><HR size=2 noshade><TD colspan=3><HR size=2 noshade></TR>" sum-data))))
|
|
||||||
|
|
||||||
;; Do a plot
|
|
||||||
(if (not (equal? NoPlot (eval plotstr)))
|
|
||||||
(let* ((fn "/tmp/gncplot.dat")
|
|
||||||
(preplot (string-append
|
|
||||||
"set xdata time\n"
|
|
||||||
"set timefmt '%m/%d/%Y'\n"
|
|
||||||
"set pointsize 2\n"
|
|
||||||
"set title '" acctname "'\n"
|
|
||||||
"set ylabel '" acctcurrency "'\n"
|
|
||||||
"set xlabel 'Period Ending'\n"
|
|
||||||
)))
|
|
||||||
|
|
||||||
(data-to-gpfile collist rept-data fn (eval plotstr))
|
|
||||||
(system
|
|
||||||
(string-append "echo \"" preplot "plot '"
|
|
||||||
fn "'" (eval plotstr)
|
|
||||||
"\"|gnuplot -persist " ))))
|
|
||||||
))
|
|
||||||
|
|
||||||
(append prefix
|
|
||||||
(if (null? accounts)
|
|
||||||
()
|
|
||||||
(list "Report for " acctname "<p>\n"))
|
|
||||||
(list rept-text) suffix)))
|
|
||||||
)
|
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
;; -*-scheme-*-
|
;; -*-scheme-*-
|
||||||
|
|
||||||
(gnc:support "report/balance-and-pnl.scm")
|
(gnc:support "report/balance-and-pnl.scm")
|
||||||
|
|
||||||
(gnc:depend "text-export.scm")
|
(gnc:depend "text-export.scm")
|
||||||
|
|
||||||
(let ()
|
(let ()
|
||||||
@ -94,7 +93,6 @@
|
|||||||
|
|
||||||
;; Ignore
|
;; Ignore
|
||||||
'()
|
'()
|
||||||
|
|
||||||
(let ((childrens-output (gnc:group-map-accounts
|
(let ((childrens-output (gnc:group-map-accounts
|
||||||
handle-level-2-account
|
handle-level-2-account
|
||||||
(gnc:account-get-children account)))
|
(gnc:account-get-children account)))
|
||||||
@ -107,13 +105,13 @@
|
|||||||
(set! level-1-balance (+ level-1-balance account-balance))
|
(set! level-1-balance (+ level-1-balance account-balance))
|
||||||
(set! level-0-balance (+ level-0-balance level-1-balance))
|
(set! level-0-balance (+ level-0-balance level-1-balance))
|
||||||
|
|
||||||
(let ((level-1-output (render-level-1-account account
|
(let ((level-1-output
|
||||||
level-1-balance
|
(render-level-1-account account
|
||||||
level-2-balance)))
|
level-1-balance
|
||||||
|
level-2-balance)))
|
||||||
(set! level-1-balance 0)
|
(set! level-1-balance 0)
|
||||||
(set! level-2-balance 0)
|
(set! level-2-balance 0)
|
||||||
(list childrens-output level-1-output))))))
|
(list childrens-output level-1-output))))))
|
||||||
|
|
||||||
(if (not (pointer-token-null? current-group))
|
(if (not (pointer-token-null? current-group))
|
||||||
(set! output
|
(set! output
|
||||||
(list
|
(list
|
||||||
|
@ -15,7 +15,6 @@
|
|||||||
(gnc:depend "html-generator.scm")
|
(gnc:depend "html-generator.scm")
|
||||||
(gnc:depend "date-utilities.scm")
|
(gnc:depend "date-utilities.scm")
|
||||||
|
|
||||||
|
|
||||||
;; time values
|
;; time values
|
||||||
;(define gnc:budget-day 1)
|
;(define gnc:budget-day 1)
|
||||||
;(define gnc:budget-week 2)
|
;(define gnc:budget-week 2)
|
||||||
@ -38,10 +37,21 @@
|
|||||||
;; 3 - period: the time span of the budget line in #4
|
;; 3 - period: the time span of the budget line in #4
|
||||||
;; 4 - period-type:
|
;; 4 - period-type:
|
||||||
;; 5 - triggers: as yet undefined
|
;; 5 - triggers: as yet undefined
|
||||||
(define gnc:budget
|
|
||||||
#(#("lunch" 8 ("Food:Lunch") 1 gnc:budget-day gnc:budget-recurring)
|
(define (make-budget-entry desc amt acct per ptype trigger)
|
||||||
#("junk food" 0.50 ("Food:Junk") 1 gnc:budget-day gnc:budget-recurring)
|
(list->vector desc amt acct per ptype trigger))
|
||||||
#("car repairs" 2500 ("Car:Repairs") 5 gnc:budget-year gnc:budget-contingency)))
|
|
||||||
|
(define gnc:budget
|
||||||
|
(list->vector
|
||||||
|
(make-budget-entry "lunch" 8 ("Food:Lunch") 1
|
||||||
|
gnc:budget-day gnc:budget-recurring)
|
||||||
|
(make-budget-entry "junk food" 0.50 ("Food:Junk") 1
|
||||||
|
gnc:budget-day gnc:budget-recurring)
|
||||||
|
(make-budget-entry "car repairs" 2500 ("Car:Repairs") 5
|
||||||
|
gnc:budget-year gnc:budget-contingency)))
|
||||||
|
|
||||||
|
;;; For future: make-budget-entry should create a structure.
|
||||||
|
;;; And gnc:budget should be a list, not a vector.
|
||||||
|
|
||||||
(define gnc:budget-headers
|
(define gnc:budget-headers
|
||||||
#(("" "Description")
|
#(("" "Description")
|
||||||
@ -239,12 +249,8 @@
|
|||||||
#(status
|
#(status
|
||||||
"Status"
|
"Status"
|
||||||
"How are you doing on your budget?"))))
|
"How are you doing on your budget?"))))
|
||||||
|
|
||||||
|
|
||||||
gnc:*budget-report-options*)
|
gnc:*budget-report-options*)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
(gnc:define-report
|
(gnc:define-report
|
||||||
;; version
|
;; version
|
||||||
1
|
1
|
||||||
@ -254,7 +260,11 @@
|
|||||||
budget-report-options-generator
|
budget-report-options-generator
|
||||||
;; renderer
|
;; renderer
|
||||||
(lambda (options)
|
(lambda (options)
|
||||||
(let* ((begindate (gnc:lookup-option options "Report Options" "From"))
|
(let* ((maxrow (vector-length gnc:budget))
|
||||||
|
;;; Note that by using maxrow, *all* references to
|
||||||
|
;;; (vector-length gnc:budget) disappear, and this notably
|
||||||
|
;;; takes some code out of at least 3 loops...
|
||||||
|
(begindate (gnc:lookup-option options "Report Options" "From"))
|
||||||
(enddate (gnc:lookup-option options "Report Options" "To"))
|
(enddate (gnc:lookup-option options "Report Options" "To"))
|
||||||
(date-filter-pred (gnc:tr-report-make-filter-predicate
|
(date-filter-pred (gnc:tr-report-make-filter-predicate
|
||||||
(gnc:option-value begindate)
|
(gnc:option-value begindate)
|
||||||
@ -263,13 +273,13 @@
|
|||||||
(gnc:option-value begindate))))
|
(gnc:option-value begindate))))
|
||||||
(end-date-secs (car (gnc:timepair-canonical-day-time
|
(end-date-secs (car (gnc:timepair-canonical-day-time
|
||||||
(gnc:option-value enddate))))
|
(gnc:option-value enddate))))
|
||||||
(budget-report (make-vector (vector-length gnc:budget)))
|
(budget-report (make-vector maxrow))
|
||||||
(budget-order #())
|
(budget-order #())
|
||||||
(budget-report-order #()))
|
(budget-report-order #()))
|
||||||
(gnc:debug gnc:budget)
|
(gnc:debug gnc:budget)
|
||||||
|
|
||||||
(do ((i 0 (+ i 1)))
|
(do ((i 0 (+ i 1)))
|
||||||
((= i (vector-length gnc:budget)))
|
((= i maxrow))
|
||||||
(vector-set! budget-report i (vector 0 0 0 0 0 0)))
|
(vector-set! budget-report i (vector 0 0 0 0 0 0)))
|
||||||
|
|
||||||
(let loop ((group (gnc:get-current-group)))
|
(let loop ((group (gnc:get-current-group)))
|
||||||
@ -291,8 +301,10 @@
|
|||||||
(loop children)))
|
(loop children)))
|
||||||
group)))
|
group)))
|
||||||
|
|
||||||
|
;;; Note: This shouldn't need to use a set of vectors...
|
||||||
|
|
||||||
(do ((i 0 (+ i 1)))
|
(do ((i 0 (+ i 1)))
|
||||||
((= i (vector-length gnc:budget)))
|
((= i maxrow))
|
||||||
(let ((budget-line (vector-ref gnc:budget i))
|
(let ((budget-line (vector-ref gnc:budget i))
|
||||||
(budget-report-line (vector-ref budget-report i)))
|
(budget-report-line (vector-ref budget-report i)))
|
||||||
(gnc:budget-calculate-periods!
|
(gnc:budget-calculate-periods!
|
||||||
@ -316,9 +328,8 @@
|
|||||||
(set! budget-report-order #(10 #f #f 4 5 2)))
|
(set! budget-report-order #(10 #f #f 4 5 2)))
|
||||||
(else
|
(else
|
||||||
(gnc:debug "Invalid view option")))
|
(gnc:debug "Invalid view option")))
|
||||||
|
|
||||||
(let ((order (find-vector-mappings
|
(let ((order (find-vector-mappings
|
||||||
(vector budget-order budget-report-order))))
|
(vector budget-order budget-report-order))))
|
||||||
(list
|
(list
|
||||||
(html-start-document)
|
(html-start-document)
|
||||||
"<p>This is a budget report. It is very preliminary, but you may find it useful. To actually change the budget, currently you have to edit budget-report.scm.</p>"
|
"<p>This is a budget report. It is very preliminary, but you may find it useful. To actually change the budget, currently you have to edit budget-report.scm.</p>"
|
||||||
@ -333,17 +344,18 @@
|
|||||||
(lambda (item) (html-cell-header (cadr item)))
|
(lambda (item) (html-cell-header (cadr item)))
|
||||||
(vector gnc:budget-headers gnc:budget-report-headers)
|
(vector gnc:budget-headers gnc:budget-report-headers)
|
||||||
order))
|
order))
|
||||||
|
;;; This loop ought not to need to use a vector
|
||||||
(let loop ((row 0))
|
(let loop ((row 0))
|
||||||
(cond ((= row (vector-length gnc:budget)) '())
|
(if (= row maxrow)
|
||||||
(else
|
'()
|
||||||
(cons
|
(cons
|
||||||
(html-table-row-manual
|
(html-table-row-manual
|
||||||
(vector-map-in-specified-order-uniquely
|
(vector-map-in-specified-order-uniquely
|
||||||
(vector (gnc:budget-html-cell-pred)
|
(vector (gnc:budget-html-cell-pred)
|
||||||
(gnc:budget-report-html-cell-pred))
|
(gnc:budget-report-html-cell-pred))
|
||||||
(vector (vector-ref gnc:budget row)
|
(vector (vector-ref gnc:budget row)
|
||||||
(vector-ref budget-report row))
|
(vector-ref budget-report row))
|
||||||
order))
|
order))
|
||||||
(loop (+ row 1))))))
|
(loop (+ row 1)))))
|
||||||
(html-end-table)
|
(html-end-table)
|
||||||
(html-end-document))))))
|
(html-end-document))))))
|
@ -1,7 +1,6 @@
|
|||||||
;; Index file to load all of the releavant reports.
|
;; Index file to load all of the releavant reports.
|
||||||
|
|
||||||
(gnc:support "report/report-list.scm")
|
(gnc:support "report/report-list.scm")
|
||||||
|
|
||||||
(gnc:depend "report/average-balance.scm")
|
(gnc:depend "report/average-balance.scm")
|
||||||
(gnc:depend "report/balance-and-pnl.scm")
|
(gnc:depend "report/balance-and-pnl.scm")
|
||||||
(gnc:depend "report/folio.scm")
|
(gnc:depend "report/folio.scm")
|
||||||
|
@ -3,23 +3,20 @@
|
|||||||
;; Report on all transactions in an account
|
;; Report on all transactions in an account
|
||||||
;; Robert Merkel (rgmerk@mira.net)
|
;; Robert Merkel (rgmerk@mira.net)
|
||||||
|
|
||||||
(gnc:support "report/transaction-report.scm")
|
|
||||||
|
|
||||||
(require 'sort)
|
(require 'sort)
|
||||||
|
(gnc:support "report/transaction-report.scm")
|
||||||
;hack alert - is this line necessary?
|
;hack alert - is this line necessary?
|
||||||
(gnc:depend "text-export.scm")
|
(gnc:depend "text-export.scm")
|
||||||
(gnc:depend "report-utilities.scm")
|
(gnc:depend "report-utilities.scm")
|
||||||
|
(gnc:depend "date-utilities.scm")
|
||||||
|
(gnc:depend "html-generator.scm")
|
||||||
|
|
||||||
;; hack alert - possibly unecessary globals
|
;; hack alert - possibly unecessary globals
|
||||||
|
|
||||||
|
|
||||||
;; functions for manipulating total inflow and outflow counts.
|
;; functions for manipulating total inflow and outflow counts.
|
||||||
|
|
||||||
(define gnc:total-inflow 0)
|
(define gnc:total-inflow 0)
|
||||||
(define gnc:total-outflow 0)
|
(define gnc:total-outflow 0)
|
||||||
|
|
||||||
|
|
||||||
(define (gnc:set-total-inflow! x)
|
(define (gnc:set-total-inflow! x)
|
||||||
(set! gnc:total-inflow x))
|
(set! gnc:total-inflow x))
|
||||||
|
|
||||||
@ -53,128 +50,6 @@
|
|||||||
(else (cons (fn (car the-list))
|
(else (cons (fn (car the-list))
|
||||||
(gnc:inorder-map (cdr the-list) fn)))))
|
(gnc:inorder-map (cdr the-list) fn)))))
|
||||||
|
|
||||||
;; register a configuration option for the transaction report
|
|
||||||
(define (trep-options-generator)
|
|
||||||
|
|
||||||
(define gnc:*transaction-report-options* (gnc:new-options))
|
|
||||||
|
|
||||||
(define (gnc:register-trep-option new-option)
|
|
||||||
(gnc:register-option gnc:*transaction-report-options* new-option))
|
|
||||||
|
|
||||||
;; from date
|
|
||||||
;; hack alert - could somebody set this to an appropriate date?
|
|
||||||
(gnc:register-trep-option
|
|
||||||
(gnc:make-date-option
|
|
||||||
"Report Options" "From"
|
|
||||||
"a" "Report Items from this date"
|
|
||||||
(lambda ()
|
|
||||||
(let ((bdtime (localtime (current-time))))
|
|
||||||
(set-tm:sec bdtime 0)
|
|
||||||
(set-tm:min bdtime 0)
|
|
||||||
(set-tm:hour bdtime 0)
|
|
||||||
(set-tm:mday bdtime 1)
|
|
||||||
(set-tm:mon bdtime 0)
|
|
||||||
(let ((time (car (mktime bdtime))))
|
|
||||||
(cons time 0))))
|
|
||||||
#f))
|
|
||||||
|
|
||||||
;; to-date
|
|
||||||
(gnc:register-trep-option
|
|
||||||
(gnc:make-date-option
|
|
||||||
"Report Options" "To"
|
|
||||||
"b" "Report items up to and including this date"
|
|
||||||
(lambda () (cons (current-time) 0))
|
|
||||||
#f))
|
|
||||||
|
|
||||||
;; account to do report on
|
|
||||||
(gnc:register-trep-option
|
|
||||||
(gnc:make-account-list-option
|
|
||||||
"Report Options" "Account"
|
|
||||||
"c" "Do transaction report on this account"
|
|
||||||
(lambda ()
|
|
||||||
(let ((current-accounts (gnc:get-current-accounts))
|
|
||||||
(num-accounts (gnc:group-get-num-accounts (gnc:get-current-group)))
|
|
||||||
(first-account (gnc:group-get-account (gnc:get-current-group) 0)))
|
|
||||||
(cond ((not (null? current-accounts)) (list (car current-accounts)))
|
|
||||||
((> num-accounts 0) (list first-account))
|
|
||||||
(else ()))))
|
|
||||||
#f #f))
|
|
||||||
|
|
||||||
;; primary sorting criterion
|
|
||||||
(gnc:register-trep-option
|
|
||||||
(gnc:make-multichoice-option
|
|
||||||
"Sorting" "Primary Key"
|
|
||||||
"a" "Sort by this criterion first"
|
|
||||||
'date
|
|
||||||
(list #(date
|
|
||||||
"Date"
|
|
||||||
"Sort by date")
|
|
||||||
#(time
|
|
||||||
"Time"
|
|
||||||
"Sort by EXACT entry time")
|
|
||||||
#(corresponding-acc
|
|
||||||
"Transfer from/to"
|
|
||||||
"Sort by account transferred from/to's name")
|
|
||||||
#(amount
|
|
||||||
"Amount"
|
|
||||||
"Sort by amount")
|
|
||||||
#(description
|
|
||||||
"Description"
|
|
||||||
"Sort by description")
|
|
||||||
#(number
|
|
||||||
"Number"
|
|
||||||
"Sort by check/transaction number")
|
|
||||||
#(memo
|
|
||||||
"Memo"
|
|
||||||
"Sort by memo"))))
|
|
||||||
|
|
||||||
(gnc:register-trep-option
|
|
||||||
(gnc:make-multichoice-option
|
|
||||||
"Sorting" "Primary Sort Order"
|
|
||||||
"b" "Order of primary sorting"
|
|
||||||
'ascend
|
|
||||||
(list #(ascend "Ascending" "smallest to largest, earliest to latest")
|
|
||||||
#(descend "Descending" "largest to smallest, latest to earliest"))))
|
|
||||||
|
|
||||||
(gnc:register-trep-option
|
|
||||||
(gnc:make-multichoice-option
|
|
||||||
"Sorting" "Secondary Key"
|
|
||||||
"c"
|
|
||||||
"Sort by this criterion second"
|
|
||||||
'corresponding-acc
|
|
||||||
(list #(date
|
|
||||||
"Date"
|
|
||||||
"Sort by date")
|
|
||||||
#(time
|
|
||||||
"Time"
|
|
||||||
"Sort by EXACT entry time")
|
|
||||||
#(corresponding-acc
|
|
||||||
"Transfer from/to"
|
|
||||||
"Sort by account transferred from/to's name")
|
|
||||||
#(amount
|
|
||||||
"Amount"
|
|
||||||
"Sort by amount")
|
|
||||||
#(description
|
|
||||||
"Description"
|
|
||||||
"Sort by description")
|
|
||||||
#(number
|
|
||||||
"Number"
|
|
||||||
"Sort by check/transaction number")
|
|
||||||
#(memo
|
|
||||||
"Memo"
|
|
||||||
"Sort by memo"))))
|
|
||||||
|
|
||||||
(gnc:register-trep-option
|
|
||||||
(gnc:make-multichoice-option
|
|
||||||
"Sorting" "Secondary Sort Order"
|
|
||||||
"d" "Order of Secondary sorting"
|
|
||||||
'ascend
|
|
||||||
(list #(ascend "Ascending" "smallest to largest, earliest to latest")
|
|
||||||
#(descend "Descending" "largest to smallest, latest to earliest"))))
|
|
||||||
|
|
||||||
gnc:*transaction-report-options*)
|
|
||||||
|
|
||||||
|
|
||||||
;; extract fields out of the scheme split representation
|
;; extract fields out of the scheme split representation
|
||||||
|
|
||||||
(define (gnc:tr-report-get-memo split-scm)
|
(define (gnc:tr-report-get-memo split-scm)
|
||||||
@ -210,26 +85,11 @@
|
|||||||
(define (gnc:tr-report-get-other-splits split-scm)
|
(define (gnc:tr-report-get-other-splits split-scm)
|
||||||
(vector-ref split-scm 10))
|
(vector-ref split-scm 10))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
(define (gnc:tr-report-get-first-acc-name split-scm)
|
(define (gnc:tr-report-get-first-acc-name split-scm)
|
||||||
(let ((other-splits (gnc:tr-report-get-other-splits split-scm)))
|
(let ((other-splits (gnc:tr-report-get-other-splits split-scm)))
|
||||||
(cond ((= (length other-splits) 0) "-")
|
(cond ((= (length other-splits) 0) "-")
|
||||||
(else (caar other-splits)))))
|
(else (caar other-splits)))))
|
||||||
|
|
||||||
;;; something like
|
|
||||||
;;; for(i = first; i < last; i+= step) { thunk(i);}
|
|
||||||
|
|
||||||
(define (gnc:for-loop thunk first last step)
|
|
||||||
(cond ((< first last) (thunk first)
|
|
||||||
(gnc:for-loop thunk (+ first step) last step))
|
|
||||||
(else #f)))
|
|
||||||
|
|
||||||
;;; applies thunk to each split in account account
|
|
||||||
(define (gnc:for-each-split-in-account account thunk)
|
|
||||||
(gnc:for-loop (lambda (x) (thunk (gnc:account-get-split account x)))
|
|
||||||
0 (gnc:account-get-split-count account) 1))
|
|
||||||
|
|
||||||
;; get transactions date from split - needs to be done indirectly
|
;; get transactions date from split - needs to be done indirectly
|
||||||
;; as it's stored in the parent transaction
|
;; as it's stored in the parent transaction
|
||||||
|
|
||||||
@ -284,39 +144,8 @@
|
|||||||
(gnc:split-get-corresponding-account-name-and-values split
|
(gnc:split-get-corresponding-account-name-and-values split
|
||||||
split-filter)))
|
split-filter)))
|
||||||
|
|
||||||
;; timepair manipulation functions
|
;;;; Note: This can be turned into a lookup table which will
|
||||||
;; hack alert - these should probably be put somewhere else
|
;;;; *massively* simplify it...
|
||||||
;; and be implemented PROPERLY rather than hackily
|
|
||||||
|
|
||||||
(define (gnc:timepair-to-datestring tp)
|
|
||||||
(let ((bdtime (localtime (car tp))))
|
|
||||||
(strftime "%x" bdtime)))
|
|
||||||
|
|
||||||
;; given a timepair contains any time on a certain day (local time)
|
|
||||||
;; converts it to be midday that day.
|
|
||||||
|
|
||||||
(define (gnc:timepair-canonical-day-time tp)
|
|
||||||
(let ((bdt (localtime (car tp))))
|
|
||||||
(set-tm:sec bdt 0)
|
|
||||||
(set-tm:min bdt 0)
|
|
||||||
(set-tm:hour bdt 12)
|
|
||||||
(let ((newtime (car (mktime bdt))))
|
|
||||||
; alert - blarsen@ada-works.com fixed this. you may want to
|
|
||||||
; revert if I'm wrong.
|
|
||||||
(cons newtime 0))))
|
|
||||||
|
|
||||||
(define (gnc:timepair-earlier-or-eq-date t1 t2)
|
|
||||||
(let ((time1 (car (gnc:timepair-canonical-day-time t1)))
|
|
||||||
(time2 (car (gnc:timepair-canonical-day-time t2))))
|
|
||||||
(<= time1 time2)))
|
|
||||||
|
|
||||||
(define (gnc:timepair-later-date t1 t2)
|
|
||||||
(let ((time1 (car (gnc:timepair-canonical-day-time t1)))
|
|
||||||
(time2 (car (gnc:timepair-canonical-day-time t2))))
|
|
||||||
(< time1 time2)))
|
|
||||||
|
|
||||||
(define (gnc:timepair-later-or-eq-date t1 t2)
|
|
||||||
(gnc:timepair-earlier-or-eq-date t2 t1))
|
|
||||||
|
|
||||||
(define (gnc:sort-predicate-component component order)
|
(define (gnc:sort-predicate-component component order)
|
||||||
(let ((ascending-order-comparator
|
(let ((ascending-order-comparator
|
||||||
@ -439,7 +268,8 @@
|
|||||||
(gnc:tr-report-get-value split-scm))))
|
(gnc:tr-report-get-value split-scm))))
|
||||||
(else
|
(else
|
||||||
(gnc:set-total-outflow! (+ gnc:total-outflow
|
(gnc:set-total-outflow! (+ gnc:total-outflow
|
||||||
(- (gnc:tr-report-get-value split-scm))))))
|
(- (gnc:tr-report-get-value
|
||||||
|
split-scm))))))
|
||||||
(for-each
|
(for-each
|
||||||
(lambda (split-sub first last)
|
(lambda (split-sub first last)
|
||||||
(set! report-string
|
(set! report-string
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
;;; $Id$
|
;;; $Id$
|
||||||
|
(gnc:support "substring-search.scm")
|
||||||
; IMPLEMENTS Substring search
|
; IMPLEMENTS Substring search
|
||||||
; AUTHOR Ken Dickey
|
; AUTHOR Ken Dickey
|
||||||
; DATE 1991 August 6
|
; DATE 1991 August 6
|
@ -27,16 +27,12 @@
|
|||||||
; (gnc:transaction-set-write-flag transaction 2)))
|
; (gnc:transaction-set-write-flag transaction 2)))
|
||||||
; (loop num-splits (+ i 1))))))
|
; (loop num-splits (+ i 1))))))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
(define (gnc:main-win-export-data-as-text win)
|
(define (gnc:main-win-export-data-as-text win)
|
||||||
(let ((account-group (gnc:get-current-group)))
|
(let ((account-group (gnc:get-current-group)))
|
||||||
(if (not account-group)
|
(if (not account-group)
|
||||||
(gnc:error-dialog "No account group available for text export.")
|
(gnc:error-dialog "No account group available for text export.")
|
||||||
(gnc:account-group-export-as-text account-group))))
|
(gnc:account-group-export-as-text account-group))))
|
||||||
|
|
||||||
|
|
||||||
(define (gnc:account->output-form a)
|
(define (gnc:account->output-form a)
|
||||||
(list
|
(list
|
||||||
'account
|
'account
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
|
;;;; $Id$
|
||||||
|
;;;; These utilities are loaded straight off
|
||||||
(define (directory? path)
|
(define (directory? path)
|
||||||
;; This follows symlinks normally.
|
;; This follows symlinks normally.
|
||||||
(let* ((status (false-if-exception (stat path)))
|
(let* ((status (false-if-exception (stat path)))
|
||||||
@ -7,8 +8,7 @@
|
|||||||
|
|
||||||
(define (gnc:directory-subdirectories dir-name)
|
(define (gnc:directory-subdirectories dir-name)
|
||||||
;; Return a recursive list of the subdirs of dir-name, including
|
;; Return a recursive list of the subdirs of dir-name, including
|
||||||
;; dir-name. Follow symlinks.
|
;; dir-name. Follow symlinks.
|
||||||
|
|
||||||
(let ((dir-port (opendir dir-name)))
|
(let ((dir-port (opendir dir-name)))
|
||||||
(if (not dir-port)
|
(if (not dir-port)
|
||||||
#f
|
#f
|
||||||
@ -48,3 +48,56 @@ string and 'directories' must be a list of strings."
|
|||||||
(gnc:debug "found file " file-name)
|
(gnc:debug "found file " file-name)
|
||||||
(set! finished? #t)
|
(set! finished? #t)
|
||||||
(set! result file-name))))))
|
(set! result file-name))))))
|
||||||
|
|
||||||
|
(define (filteroutnulls lst)
|
||||||
|
(cond
|
||||||
|
((null? lst) '())
|
||||||
|
((eq? (car lst) #f) (filteroutnulls (cdr lst)))
|
||||||
|
(else
|
||||||
|
(cons (car lst) (filteroutnulls (cdr lst))))))
|
||||||
|
|
||||||
|
(define (atom? x)
|
||||||
|
(and
|
||||||
|
(not (pair? x))
|
||||||
|
(not (null? x))))
|
||||||
|
|
||||||
|
(define (flatten lst)
|
||||||
|
(cond
|
||||||
|
((null? lst) '())
|
||||||
|
((atom? lst) (list lst))
|
||||||
|
((list? lst)
|
||||||
|
(append (flatten (car lst))
|
||||||
|
(flatten (cdr lst))))
|
||||||
|
(else lst)))
|
||||||
|
|
||||||
|
(define (striptrailingwhitespace line)
|
||||||
|
(let
|
||||||
|
((stringsize (string-length line)))
|
||||||
|
(if
|
||||||
|
(< stringsize 1)
|
||||||
|
""
|
||||||
|
(let*
|
||||||
|
((lastchar (string-ref line (- stringsize 1))))
|
||||||
|
(if
|
||||||
|
(char-whitespace? lastchar)
|
||||||
|
(striptrailingwhitespace (substring line 0 (- stringsize 1)))
|
||||||
|
line)))))
|
||||||
|
|
||||||
|
(define (string-join lst joinstr)
|
||||||
|
(let ((len (length lst)))
|
||||||
|
(cond
|
||||||
|
((< 1 len)
|
||||||
|
(string-append (car lst) joinstr (string-join (cdr lst) joinstr)))
|
||||||
|
((= 1 len)
|
||||||
|
(car lst))
|
||||||
|
(else
|
||||||
|
""))))
|
||||||
|
|
||||||
|
;;;; Simple lookup scheme; can be turned into a hash table If Need Be.
|
||||||
|
;;; Initialize lookup table
|
||||||
|
(define (initialize-hashtable . size)
|
||||||
|
(make-vector
|
||||||
|
(if (null? size)
|
||||||
|
313
|
||||||
|
(car size))
|
||||||
|
'()))
|
Loading…
Reference in New Issue
Block a user