|
@@ -1,11 +1,15 @@
|
|
|
(in-package #:pta-ledger)
|
|
(in-package #:pta-ledger)
|
|
|
|
|
|
|
|
(defvar *posting-length* 46 "Length of posting without amount")
|
|
(defvar *posting-length* 46 "Length of posting without amount")
|
|
|
|
|
+(defvar *allowed-statuses* '(#\! #\*))
|
|
|
|
|
|
|
|
(defun render-date (universal-time)
|
|
(defun render-date (universal-time)
|
|
|
(when universal-time
|
|
(when universal-time
|
|
|
(format nil "~{~4,'0D/~2,'0D/~2,'0D~}" (get-date universal-time))))
|
|
(format nil "~{~4,'0D/~2,'0D/~2,'0D~}" (get-date universal-time))))
|
|
|
|
|
|
|
|
|
|
+(defun when-allowed (status)
|
|
|
|
|
+ (find status *allowed-statuses*))
|
|
|
|
|
+
|
|
|
(defgeneric render (object &optional stream)
|
|
(defgeneric render (object &optional stream)
|
|
|
(:documentation "Render OBJECT to STREAM in text format."))
|
|
(:documentation "Render OBJECT to STREAM in text format."))
|
|
|
|
|
|
|
@@ -18,7 +22,7 @@
|
|
|
(defmethod render ((posting posting) &optional stream)
|
|
(defmethod render ((posting posting) &optional stream)
|
|
|
(with-slots (status virtual account amount unit-price total-price comment) posting
|
|
(with-slots (status virtual account amount unit-price total-price comment) posting
|
|
|
(let* ((amount-text (render amount))
|
|
(let* ((amount-text (render amount))
|
|
|
- (status-text (format nil "~@[~A ~]" status))
|
|
|
|
|
|
|
+ (status-text (format nil "~@[~A ~]" (when-allowed status)))
|
|
|
(account (if virtual
|
|
(account (if virtual
|
|
|
(format nil "~A~A~A" virtual account
|
|
(format nil "~A~A~A" virtual account
|
|
|
(ecase virtual
|
|
(ecase virtual
|
|
@@ -44,7 +48,7 @@
|
|
|
(with-slots (date secondary-date status code description comment postings) entry
|
|
(with-slots (date secondary-date status code description comment postings) entry
|
|
|
(let* ((text (format nil "~A~@[=~A~]~@[ ~A~]~@[ (~A)~]~@[ ~A~]"
|
|
(let* ((text (format nil "~A~@[=~A~]~@[ ~A~]~@[ (~A)~]~@[ ~A~]"
|
|
|
(render-date date) (render-date secondary-date)
|
|
(render-date date) (render-date secondary-date)
|
|
|
- status code description))
|
|
|
|
|
|
|
+ (when-allowed status) code description))
|
|
|
(comments (split comment))
|
|
(comments (split comment))
|
|
|
(first-comment (first comments))
|
|
(first-comment (first comments))
|
|
|
(rest-comments (rest comments)))
|
|
(rest-comments (rest comments)))
|