|
@@ -63,7 +63,7 @@
|
|
|
(unit-price (posting-unit-price posting))
|
|
(unit-price (posting-unit-price posting))
|
|
|
(total-price (posting-total-price posting)))
|
|
(total-price (posting-total-price posting)))
|
|
|
(if amount
|
|
(if amount
|
|
|
- (if cost
|
|
|
|
|
|
|
+ (if (eq cost :t)
|
|
|
(if total-price (list total-price)
|
|
(if total-price (list total-price)
|
|
|
(if unit-price
|
|
(if unit-price
|
|
|
(list (make-amount :commodity (amount-commodity unit-price)
|
|
(list (make-amount :commodity (amount-commodity unit-price)
|
|
@@ -77,20 +77,23 @@
|
|
|
(remove-if (lambda (e)
|
|
(remove-if (lambda (e)
|
|
|
(let ((postings (entry-postings e)))
|
|
(let ((postings (entry-postings e)))
|
|
|
(or (and predicate (not (member nil postings :key #'(lambda (p) (funcall predicate e p)) :test-not #'eql)))
|
|
(or (and predicate (not (member nil postings :key #'(lambda (p) (funcall predicate e p)) :test-not #'eql)))
|
|
|
- (and real (not (member nil (entry-postings e) :key #'posting-virtual))))))
|
|
|
|
|
|
|
+ (and (eq real :t) (not (member nil (entry-postings e) :key #'posting-virtual)))
|
|
|
|
|
+ (and (eq real :f) (not (member nil (entry-postings e) :key #'posting-virtual :test-not #'eql))))))
|
|
|
(mapcar #'cdr (remove :entry journal :key #'car :test-not #'eql))))
|
|
(mapcar #'cdr (remove :entry journal :key #'car :test-not #'eql))))
|
|
|
|
|
|
|
|
(defun select-postings (entry &key predicate real)
|
|
(defun select-postings (entry &key predicate real)
|
|
|
(labels ((valid (posting)
|
|
(labels ((valid (posting)
|
|
|
(and (or (null predicate)
|
|
(and (or (null predicate)
|
|
|
(funcall predicate entry posting))
|
|
(funcall predicate entry posting))
|
|
|
- (or (null real)
|
|
|
|
|
- (null (posting-virtual posting))))))
|
|
|
|
|
|
|
+ (or (ecase real
|
|
|
|
|
+ (:t (null (posting-virtual posting)))
|
|
|
|
|
+ (:f (posting-virtual posting))
|
|
|
|
|
+ (nil t))))))
|
|
|
(remove-if-not #'valid (entry-postings entry))))
|
|
(remove-if-not #'valid (entry-postings entry))))
|
|
|
|
|
|
|
|
(defun account-parents (account &key tree)
|
|
(defun account-parents (account &key tree)
|
|
|
(append
|
|
(append
|
|
|
- (when tree
|
|
|
|
|
|
|
+ (when (eq tree :t)
|
|
|
(loop for start = 0 then (1+ pos)
|
|
(loop for start = 0 then (1+ pos)
|
|
|
for pos = (position #\: account :start start)
|
|
for pos = (position #\: account :start start)
|
|
|
while pos collect (subseq account 0 pos)))
|
|
while pos collect (subseq account 0 pos)))
|
|
@@ -117,7 +120,7 @@
|
|
|
(dolist (account (account-parents (posting-account posting) :tree tree))
|
|
(dolist (account (account-parents (posting-account posting) :tree tree))
|
|
|
(setf (gethash account balance)
|
|
(setf (gethash account balance)
|
|
|
(add-amounts! (gethash account balance) amounts))))))
|
|
(add-amounts! (gethash account balance) amounts))))))
|
|
|
- (when tree
|
|
|
|
|
|
|
+ (when (eq tree :t)
|
|
|
(remove-extra-parents! balance))
|
|
(remove-extra-parents! balance))
|
|
|
balance))
|
|
balance))
|
|
|
|
|
|