Ver código fonte

[raiffeisen] process and currencies fixes

OLIVER 7 anos atrás
pai
commit
1309467cdc
1 arquivos alterados com 11 adições e 7 exclusões
  1. 11 7
      plugins/raiffeisen.lisp

+ 11 - 7
plugins/raiffeisen.lisp

@@ -136,17 +136,17 @@
                 (pta-ledger:make-posting
                  :account account2
                  :amount (pta-ledger:make-amount
-                          :quantity (* bill-amount -1)
-                          :commodity bill-currency)
+                          :quantity (* amount -1)
+                          :commodity currency)
                  :total-price (unless (equal currency bill-currency)
                                 (pta-ledger:make-amount
-                                 :quantity (* amount -1)
-                                 :commodity currency)))
+                                 :quantity (* bill-amount -1)
+                                 :commodity bill-currency)))
                 (pta-ledger:make-posting
                  :account account1
                  :amount (pta-ledger:make-amount
-                          :quantity amount
-                          :commodity currency))))))
+                          :quantity bill-amount
+                          :commodity bill-currency))))))
 
 (defun account->balance (account)
   (let ((left-debt (agets account "leftDebt")))
@@ -204,7 +204,11 @@
                   (dolist (entry changes)
                     (funcall new-chat-entry chat-id (pta-ledger:clone-entry entry))))
                 (bot-send-message chat-id (format-entries changes) :parse-mode "markdown"))))
-        (setf (gethash chat-id *last-entries*) new)))))
+	(let ((merged (remove-duplicates
+		       (merge 'list old new #'< :key #'pta-ledger:entry-date)
+		       :test 'equalp)))
+	  (setf (gethash chat-id *last-entries*)
+		(subseq merged (max 0 (- (length merged) 40)))))))))
 
 (def-message-cmd-handler handler-raif (:raif)
   (let ((arg (car args)))