|
@@ -95,19 +95,18 @@
|
|
|
(add-amounts! (gethash "TOTALS" balance) amounts))))))))
|
|
(add-amounts! (gethash "TOTALS" balance) amounts))))))))
|
|
|
|
|
|
|
|
(defun format-balance (balance)
|
|
(defun format-balance (balance)
|
|
|
- (let* ((accounts (alexandria:hash-table-keys balance))
|
|
|
|
|
- (max-account-length (if accounts (apply #'max (mapcar #'length accounts)) 20)))
|
|
|
|
|
|
|
+ (let* ((accounts (alexandria:hash-table-keys balance)))
|
|
|
(with-output-to-string (s)
|
|
(with-output-to-string (s)
|
|
|
(loop for account in (sort accounts #'string<)
|
|
(loop for account in (sort accounts #'string<)
|
|
|
- for amounts = (gethash account balance)
|
|
|
|
|
- when (find 0 amounts :test-not #'= :key #'amount-quantity)
|
|
|
|
|
- do (format s "~vA ~$ ~A~{~%~va ~$ ~A~}~%" max-account-length account
|
|
|
|
|
- (amount-quantity (car amounts)) (amount-commodity (car amounts))
|
|
|
|
|
- (apply #'append (mapcar #'(lambda (a)
|
|
|
|
|
- (list max-account-length ""
|
|
|
|
|
- (amount-quantity a)
|
|
|
|
|
- (amount-commodity a)))
|
|
|
|
|
- (rest amounts))))))))
|
|
|
|
|
|
|
+ for amounts = (remove 0 (gethash account balance) :test #'equal :key #'amount-quantity)
|
|
|
|
|
+ do (loop for amount in amounts
|
|
|
|
|
+ for first = t then nil
|
|
|
|
|
+ for amount-text = (render amount)
|
|
|
|
|
+ do (format s "~vA ~A~%"
|
|
|
|
|
+ (- *posting-length*
|
|
|
|
|
+ (position #\Space amount-text))
|
|
|
|
|
+ (if first account "")
|
|
|
|
|
+ amount-text))))))
|
|
|
|
|
|
|
|
(defun journal-balance (journal &optional query)
|
|
(defun journal-balance (journal &optional query)
|
|
|
(format-balance (balance (entries journal)
|
|
(format-balance (balance (entries journal)
|