summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCraig Earls <enderw88@gmail.com>2013-03-16 21:55:09 -0700
committerCraig Earls <enderw88@gmail.com>2013-03-16 21:55:09 -0700
commitc2999a70f237cbdf8f666d80c4468898d94fd6ec (patch)
tree2ba3c32f3ca6e8eb9cef68656dd804083070bbc1
parent720a73dec30fbab08f5233894b879d1fb26083c8 (diff)
downloadfork-ledger-c2999a70f237cbdf8f666d80c4468898d94fd6ec.tar.gz
fork-ledger-c2999a70f237cbdf8f666d80c4468898d94fd6ec.tar.bz2
fork-ledger-c2999a70f237cbdf8f666d80c4468898d94fd6ec.zip
Starting on forecast handling for the auto mode
-rw-r--r--lisp/ldg-auto.el35
1 files changed, 35 insertions, 0 deletions
diff --git a/lisp/ldg-auto.el b/lisp/ldg-auto.el
index 33a2cdba..2a1a5b11 100644
--- a/lisp/ldg-auto.el
+++ b/lisp/ldg-auto.el
@@ -30,6 +30,16 @@
;; function slot of the symbol VARNAME. Then use VARNAME as the
;; function without have to use funcall.
+(defgroup ledger-auto nil
+ "Support for automatically recommendation transactions."
+ :group 'ledger)
+
+(defcustom ledger-auto-look-forward 14
+ "Number of days auto look forward to recommend transactions"
+ :type 'integer
+ :group 'ledger-auto)
+
+
(defsubst between (val low high)
(and (>= val low) (<= val high)))
@@ -132,6 +142,9 @@ For example every second Friday, regardless of month."
"Return true if DATE is a holiday.")
(defun ledger-auto-scan-transactions (auto-file)
+ "Scans AUTO_FILE and returns a list of transactions with date predicates.
+The car of each item is a fuction of date that returns true if
+the transaction should be logged for that day."
(interactive "fFile name: ")
(let ((xact-list (list)))
(with-current-buffer
@@ -211,6 +224,8 @@ returns true if the date meets the requirements"
(push newcar result)
(push (ledger-auto-parse-date-descriptor newcar) result)) )
(setq tree (cdr tree)))
+
+ ;; tie up all the clauses in a big or and lambda
`(lambda (date)
,(nconc (list 'or) (nreverse result) tree)))))
@@ -248,6 +263,26 @@ returns true if the date meets the requirements"
(ledger-auto-compile-constraints
(ledger-auto-split-constraints descriptor)))
+
+
+;;
+;; Test harnesses for use in ielm
+;;
+(defvar auto-items)
+
+(defun ledger-auto-test-setup ()
+ (setq auto-items
+ (ledger-auto-scan-transactions "~/FinanceData/ledger-auto.ledger")))
+
+
+(defun ledger-auto-test-predict ()
+ (let ((today (current-time))
+ test-date)
+
+ (loop for day from 0 to ledger-auto-look-forward by 1 do
+ (setq test-date (time-add today (days-to-time day)))
+ (message "date: %S" (decode-time test-date)))))
+
(provide 'ldg-auto)
;;; ldg-auto.el ends here