summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCraig Earls <enderw88@gmail.com>2013-03-18 15:01:35 -0700
committerCraig Earls <enderw88@gmail.com>2013-03-18 15:01:35 -0700
commitadfd6bafc3e276b1e7266cf03e7ab54ac70f3f90 (patch)
tree1ec909c92caba50f788d0924d03228435494c081
parent5324afbd9b247cb6e6c4e079fb4ab9c02a66f2fd (diff)
downloadfork-ledger-adfd6bafc3e276b1e7266cf03e7ab54ac70f3f90.tar.gz
fork-ledger-adfd6bafc3e276b1e7266cf03e7ab54ac70f3f90.tar.bz2
fork-ledger-adfd6bafc3e276b1e7266cf03e7ab54ac70f3f90.zip
Have a working candidate search
-rw-r--r--lisp/ldg-auto.el19
1 files changed, 16 insertions, 3 deletions
diff --git a/lisp/ldg-auto.el b/lisp/ldg-auto.el
index 2a1a5b11..ffc6ee7d 100644
--- a/lisp/ldg-auto.el
+++ b/lisp/ldg-auto.el
@@ -264,7 +264,16 @@ returns true if the date meets the requirements"
(ledger-auto-split-constraints descriptor)))
-
+(defun ledger-auto-list-upcoming-xacts (candidate-items early horizon)
+ "Search CANDIDATE-ITEMS for xacts that occur within the perios today - EARLY to today + HORIZON"
+ (let ((start-date (time-subtract (current-time) (days-to-time early)))
+ test-date items)
+ (loop for day from 0 to (+ early horizon) by 1 do
+ (setq test-date (time-add start-date (days-to-time day)))
+ (dolist (candidate candidate-items items)
+ (if (funcall (car candidate) test-date)
+ (setq items (append items (list test-date (cdr candidate)))))))
+ items))
;;
;; Test harnesses for use in ielm
;;
@@ -277,11 +286,15 @@ returns true if the date meets the requirements"
(defun ledger-auto-test-predict ()
(let ((today (current-time))
- test-date)
+ test-date items)
(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)))))
+ ;;(message "date: %S" (decode-time test-date))
+ (dolist (item auto-items items)
+ (if (funcall (car item) test-date)
+ (setq items (append items (list (decode-time test-date) (cdr item)))))))
+ items))
(provide 'ldg-auto)