|
@@ -22,7 +22,8 @@
|
|
|
("health" . "expenses:life:health")))
|
|
("health" . "expenses:life:health")))
|
|
|
|
|
|
|
|
(defvar *topup-accounts*
|
|
(defvar *topup-accounts*
|
|
|
- '(("Top-Up by *1508" . "assets:rbcz:czk")))
|
|
|
|
|
|
|
+ '(("Top-Up by *1508" . "assets:rbcz:czk")))
|
|
|
|
|
+(defvar *fee-account* "expenses:banking:fee")
|
|
|
|
|
|
|
|
(defun is-content (rest-method)
|
|
(defun is-content (rest-method)
|
|
|
(case rest-method
|
|
(case rest-method
|
|
@@ -73,7 +74,7 @@
|
|
|
:|tokenId| (agets sign-res "tokenId"))
|
|
:|tokenId| (agets sign-res "tokenId"))
|
|
|
when (listp res) do (return res)
|
|
when (listp res) do (return res)
|
|
|
unless (= (dex:response-status res) 422) do (return)
|
|
unless (= (dex:response-status res) 422) do (return)
|
|
|
- when (> (- (get-universal-time) start) 600) do (return)
|
|
|
|
|
|
|
+ when (> (- (get-universal-time) start) 30) do (return)
|
|
|
do (sleep 2)))))
|
|
do (sleep 2)))))
|
|
|
|
|
|
|
|
(defun refresh-token (user-id refresh-code)
|
|
(defun refresh-token (user-id refresh-code)
|
|
@@ -254,7 +255,7 @@
|
|
|
|
|
|
|
|
(defun params-fee (tr pockets)
|
|
(defun params-fee (tr pockets)
|
|
|
(let* ((description (agets tr "description"))
|
|
(let* ((description (agets tr "description"))
|
|
|
- (rcv-account "expenses:banking:fee")
|
|
|
|
|
|
|
+ (rcv-account *fee-account*)
|
|
|
(rcv-amount (* -1 (get-amount (agets tr "amount"))))
|
|
(rcv-amount (* -1 (get-amount (agets tr "amount"))))
|
|
|
(rcv-currency (agets tr "currency"))
|
|
(rcv-currency (agets tr "currency"))
|
|
|
(snd-account (format-pocket-account (find-pocket (agets tr "account" "id")
|
|
(snd-account (format-pocket-account (find-pocket (agets tr "account" "id")
|
|
@@ -300,7 +301,8 @@
|
|
|
(defun transaction->entry (tr pockets)
|
|
(defun transaction->entry (tr pockets)
|
|
|
(let* ((date (get-date (agets tr "startedDate")))
|
|
(let* ((date (get-date (agets tr "startedDate")))
|
|
|
(type (keyify (agets tr "type")))
|
|
(type (keyify (agets tr "type")))
|
|
|
- (state (keyify (agets tr "state"))))
|
|
|
|
|
|
|
+ (state (keyify (agets tr "state")))
|
|
|
|
|
+ (fee (get-amount (or (agets tr "fee") 0))))
|
|
|
(case state ((:declined :failed :cancelled :reverted :deleted)
|
|
(case state ((:declined :failed :cancelled :reverted :deleted)
|
|
|
(return-from transaction->entry)))
|
|
(return-from transaction->entry)))
|
|
|
(multiple-value-bind (description comment
|
|
(multiple-value-bind (description comment
|
|
@@ -319,7 +321,7 @@
|
|
|
:date date
|
|
:date date
|
|
|
:description description
|
|
:description description
|
|
|
:comment comment
|
|
:comment comment
|
|
|
- :postings (list
|
|
|
|
|
|
|
+ :postings (remove nil (list
|
|
|
(pta-ledger:make-posting
|
|
(pta-ledger:make-posting
|
|
|
:account (or rcv-account (default-account rcv-currency))
|
|
:account (or rcv-account (default-account rcv-currency))
|
|
|
:amount (pta-ledger:make-amount
|
|
:amount (pta-ledger:make-amount
|
|
@@ -329,11 +331,16 @@
|
|
|
(pta-ledger:make-amount
|
|
(pta-ledger:make-amount
|
|
|
:quantity (abs snd-amount)
|
|
:quantity (abs snd-amount)
|
|
|
:commodity snd-currency)))
|
|
:commodity snd-currency)))
|
|
|
|
|
+ (unless (zerop fee)
|
|
|
|
|
+ (pta-ledger:make-posting
|
|
|
|
|
+ :account *fee-account*
|
|
|
|
|
+ :amount (pta-ledger:make-amount
|
|
|
|
|
+ :quantity fee :commodity snd-currency)))
|
|
|
(pta-ledger:make-posting
|
|
(pta-ledger:make-posting
|
|
|
:account (or snd-account (default-account snd-currency))
|
|
:account (or snd-account (default-account snd-currency))
|
|
|
:amount (pta-ledger:make-amount
|
|
:amount (pta-ledger:make-amount
|
|
|
- :quantity snd-amount
|
|
|
|
|
- :commodity snd-currency))))))))
|
|
|
|
|
|
|
+ :quantity (- snd-amount fee)
|
|
|
|
|
+ :commodity snd-currency)))))))))
|
|
|
|
|
|
|
|
(defun handle-auth (login pass)
|
|
(defun handle-auth (login pass)
|
|
|
(handler-case
|
|
(handler-case
|