1
0
Эх сурвалжийг харах

[tinkoff] move aliases to settings

Innocenty Enikeew 8 жил өмнө
parent
commit
6acde3363d
1 өөрчлөгдсөн 16 нэмэгдсэн , 18 устгасан
  1. 16 18
      plugins/tinkoff.lisp

+ 16 - 18
plugins/tinkoff.lisp

@@ -6,6 +6,15 @@
 (eval-when (:compile-toplevel :load-toplevel :execute)
   (ql:quickload :pta-ledger))
 
+(defsetting *account-default-prefix* "assets:Tinkoff:")
+(defsetting *account-aliases* nil "tinkoff account to ledger account")
+(defsetting *category-aliases* '((60 . "expenses:Food:Fast-food")
+                                 (36 . "expenses:Transport")
+                                 (32 . "expenses:Food:Restaurant")
+                                 (20 . "expenses:Life:Wear")
+                                 (16 . "expenses:Transport:Car:Gas")
+                                 (10 . "expenses:Food:Grocery")) "tinkoff category to expense account mapping")
+
 (defsetting *ua* "OnePlus ONE A2003/android: 6.0.1/TCSMB/3.4.2" "User agent")
 (defsetting *device-id* "1df9bdeac787e08")
 (defsetting *app-version* "3.4.2")
@@ -104,26 +113,15 @@
         (agets op "brand" "name"))))))
 
 (defun get-op-account1 (op)
-  (case (parse-integer (agets op "account"))
-    (5001173482 "assets:Tinkoff:Debit")
-    (1850735 "assets:Raiffeisen:Debit")
-    (0047479860 "liabilities:Tinkoff:Credit:Platinum")
-    (8102961813 "assets:Tinkoff:Savings:For credit")
-    (t (concatenate 'string "assets:Tinkoff:" (agets op "account")))))
+  (or (agets *account-aliases* (parse-integer (agets op "account")))
+      (concatenate 'string *account-default-prefix* (agets op "account"))))
 
 (defun get-op-account2 (op)
-  (let ((cat (parse-integer (agets op "category" "id") :junk-allowed t)))
-    (case cat
-      (60 "expenses:Food:Fast-food")
-      (36 "expenses:Transport")
-      (32 "expenses:Food:Restaurant")
-      (20 "expenses:Life:Wear")
-      (16 "expenses:Transport:Car:Gas")
-      (10 "expenses:Food:Grocery")
-      (t (concatenate 'string
-                      (if (equal "Credit" (agets op "type"))
-                          "income:" "expenses:")
-                      (agets op "category" "name"))))))
+  (or (agets *category-aliases* (parse-integer (agets op "category" "id") :junk-allowed t))
+      (concatenate 'string
+                   (if (equal "Credit" (agets op "type"))
+                       "income:" "expenses:")
+                   (agets op "category" "name"))))
 
 (defun ops->entry (ops)
   (loop for op in ops