|
|
@@ -122,10 +122,11 @@
|
|
|
(defun get-quote (symbol)
|
|
|
(poller-call :revolut "quote" :|symbol| symbol))
|
|
|
|
|
|
+
|
|
|
(defun get-transactions-last (&key (count 10) pocket to)
|
|
|
(poller-call :revolut "user/current/transactions/last"
|
|
|
:|count| count
|
|
|
- :|to| to
|
|
|
+ :|to| to ;; timestamp (startedDate) of last received transaction
|
|
|
:|internalPocketId| pocket))
|
|
|
|
|
|
(defun get-transactions-vault (&key id)
|
|
|
@@ -212,7 +213,7 @@
|
|
|
(agets tr "account" "id") pockets)))
|
|
|
(rcv-amount (get-amount (agets tr "amount")))
|
|
|
(rcv-currency (agets tr "currency"))
|
|
|
- (snd-account (agets *topup-accounts* description))
|
|
|
+ (snd-account (or (agets *topup-accounts* description) "income"))
|
|
|
(snd-amount (* -1 rcv-amount))
|
|
|
(snd-currency rcv-currency))
|
|
|
(values description nil
|
|
|
@@ -293,9 +294,15 @@
|
|
|
rcv-account rcv-amount rcv-currency
|
|
|
snd-account snd-amount snd-currency)))
|
|
|
|
|
|
+(defun default-account (currency)
|
|
|
+ (concatenate 'string "assets:revolut:" (string-downcase currency)))
|
|
|
+
|
|
|
(defun transaction->entry (tr pockets)
|
|
|
(let* ((date (get-date (agets tr "startedDate")))
|
|
|
- (type (keyify (agets tr "type"))))
|
|
|
+ (type (keyify (agets tr "type")))
|
|
|
+ (state (keyify (agets tr "state"))))
|
|
|
+ (case state ((:declined :failed :cancelled :reverted :deleted)
|
|
|
+ (return-from transaction->entry)))
|
|
|
(multiple-value-bind (description comment
|
|
|
rcv-account rcv-amount rcv-currency
|
|
|
snd-account snd-amount snd-currency)
|
|
|
@@ -307,14 +314,14 @@
|
|
|
(:fee (params-fee tr pockets))
|
|
|
(:card-payment (params-card-payment tr pockets))
|
|
|
(:card-refund (params-card-refund tr pockets)))
|
|
|
- (when snd-account
|
|
|
+ (when snd-amount
|
|
|
(pta-ledger:make-entry
|
|
|
:date date
|
|
|
:description description
|
|
|
:comment comment
|
|
|
:postings (list
|
|
|
(pta-ledger:make-posting
|
|
|
- :account rcv-account
|
|
|
+ :account (or rcv-account (default-account rcv-currency))
|
|
|
:amount (pta-ledger:make-amount
|
|
|
:quantity rcv-amount
|
|
|
:commodity rcv-currency)
|
|
|
@@ -323,7 +330,7 @@
|
|
|
:quantity (abs snd-amount)
|
|
|
:commodity snd-currency)))
|
|
|
(pta-ledger:make-posting
|
|
|
- :account snd-account
|
|
|
+ :account (or snd-account (default-account snd-currency))
|
|
|
:amount (pta-ledger:make-amount
|
|
|
:quantity snd-amount
|
|
|
:commodity snd-currency))))))))
|