瀏覽代碼

swap accounts

Innocenty Enikeev 8 年之前
父節點
當前提交
6315498f45
共有 2 個文件被更改,包括 10 次插入9 次删除
  1. 2 2
      raif.lisp
  2. 8 7
      tinkoff.lisp

+ 2 - 2
raif.lisp

@@ -189,8 +189,8 @@
        for expense = (equal "0" (aget move :type))
        do (push (format nil "~A~@[ (~A)~] ~A~@[ ; ~A~]~%    ~37A  ~A~,2F ~A~%    ~37A  ~A~,2F ~A"
                         date nil payee description
-                        account1 (if expense "-" " ") amount currency
-                        account2 (if expense " " "-") amount currency)
+                        account2 (if expense " " "-") amount currency
+                        account1 (if expense "-" " ") amount currency)
                 entries))
     ;; Total account balance
     (push (format nil "; balance ~A ~A  = ~,2F ~A"

+ 8 - 7
tinkoff.lisp

@@ -113,10 +113,10 @@
    "-"))
 
 (defun get-op-description (op)
-  (let ((cat (parse-integer (aget op "category" "id"))))
+  (let ((cat (parse-integer (aget op "category" "id") :junk-allowed t)))
     (cond
-      ((= cat 16) (if (> (aget op "accountAmount" "value")
-                         1500)
+      ((equal cat 16) (if (> (aget op "accountAmount" "value")
+                             1500)
                       "project: Volvo" "project: Smart"))
       (:otherwise
        (or
@@ -132,7 +132,7 @@
     (t (concatenate 'string "assets:Tinkoff:" (aget op "account")))))
 
 (defun get-op-account2 (op)
-  (let ((cat (parse-integer (aget op "category" "id"))))
+  (let ((cat (parse-integer (aget op "category" "id") :junk-allowed t)))
     (case cat
       (60 "expenses:Food:Fast-food")
       (36 "expenses:Transport")
@@ -157,11 +157,12 @@
      for account1 = (get-op-account1 op)
      for account2 = (get-op-account2 op)
      for expense = (equal "Debit" (aget op "type"))
-     collect (format nil "~A ~A~@[ ; ~A~]~%    ~38A  ~A~,2F ~A~%    ~38A  ~A~,2F ~A~[ @@ ~A~,2F ~A~]"
+     collect (format nil "~A ~A~@[ ; ~A~]~%    ~38A  ~A~,2F ~A~@[ @@ ~{~A~,2F ~A~}~]~%    ~38A  ~A~,2F ~A"
                      date payee (unless (equal payee description) description)
-                     account1 (if expense "-" " ") account-amount account-currency
                      account2 (if expense " " "-") account-amount account-currency
-                     (not (equal currency account-currency)) (if expense " " "-") amount currency)))
+                     (unless (equal currency account-currency)
+                       (list (if expense " " "-") amount currency))
+                     account1 (if expense "-" " ") account-amount account-currency)))
 
 (defparameter +day+ (* 24 60 60) "Seconds in day")