Ver Fonte

Use bson.Date for ts

Innocenty Enikeew há 11 anos atrás
pai
commit
f4d3f959ab
2 ficheiros alterados com 16 adições e 14 exclusões
  1. 12 11
      process-financisto.lisp
  2. 4 3
      process-locations.lisp

+ 12 - 11
process-financisto.lisp

@@ -1,4 +1,4 @@
-(defvar *financisto-backup-path* #P"/home/enikesha/dev/lisp/timeliner/")
+(defvar *financisto-backup-path* #P"/home/enikesha/Documents/backups/financisto/")
 
 (defun find-last-backup ()
   (first (sort (mapcar #'namestring
@@ -51,22 +51,22 @@
          (currencies (gethash "currency" db))
          (from-account (gethash (parse-integer (getf e :from-account-id)) accounts))
          (from-currency (gethash (parse-integer (getf from-account :currency-id)) currencies))
-         (from-decimals (expt 10 (parse-integer (getf from-currency :decimals))))
-         (from-amount (float (/ (parse-integer (getf e :from-amount)) from-decimals)))
-         (from-balance (float (/ (gethash (parse-integer (getf from-account :-id)) balances 0) from-decimals)))
+         (from-decimals (expt 10d0 (parse-integer (getf from-currency :decimals))))
+         (from-amount (/ (parse-integer (getf e :from-amount)) from-decimals))
+         (from-balance (/ (gethash (parse-integer (getf from-account :-id)) balances 0) from-decimals))
          (spend (< from-amount 0))         
          (original-currency (gethash (parse-integer (getf e :original-currency-id)) currencies))
          (original-from-amount (and original-currency
-                                    (float (/ (parse-integer (getf e :original-from-amount))
-                                              (expt 10 (parse-integer (getf original-currency :decimals)))))))
+                                    (/ (parse-integer (getf e :original-from-amount))
+                                       (expt 10d0 (parse-integer (getf original-currency :decimals))))))
          (payee (gethash (parse-integer (getf e :payee-id)) (gethash "payee" db)))
          (category (gethash (parse-integer (getf e :category-id)) (gethash "category" db)))
          
          (to-account (gethash (parse-integer (getf e :to-account-id)) accounts))
          (to-currency (and to-account (gethash (parse-integer (getf to-account :currency-id)) currencies)))
-         (to-decimals (and to-account (expt 10 (parse-integer (getf to-currency :decimals)))))
-         (to-amount (and to-account (float (/ (parse-integer (getf e :to-amount)) to-decimals))))
-         (to-balance (and to-account (float (/ (gethash (parse-integer (getf to-account :-id)) balances 0) to-decimals))))
+         (to-decimals (and to-account (expt 10d0 (parse-integer (getf to-currency :decimals)))))
+         (to-amount (and to-account (/ (parse-integer (getf e :to-amount)) to-decimals)))
+         (to-balance (and to-account (/ (gethash (parse-integer (getf to-account :-id)) balances 0) to-decimals)))
 
          (transfer (cond
                      ((and to-account (equal (getf from-account :type)
@@ -133,7 +133,7 @@
                                             (kv "original_amount" original-from-amount)
                                             (kv "original_currency" (getf original-currency :name)))))))
     (kv
-     (kv "ts" (parse-integer (getf e :datetime)))
+     (kv "ts" (ms->ts (parse-integer (getf e :datetime))))
      (kv "type" "finance")
      (kv "title" title)
      (kv "financisto"
@@ -170,7 +170,8 @@
                (new-ts (parse-integer datetime)))
           (cl-mongo::kv-container-add
            (kv "loc"
-               (if (and existing-doc (= new-ts (get-element "ts" existing-doc)))
+               (if (and existing-doc (= new-ts (cl-mongo::raw
+                                                (get-element "ts" existing-doc))))
                    (get-element "loc" existing-doc)
                    (point->doc (find-location-at new-ts))))
            new-doc)

Diff do ficheiro suprimidas por serem muito extensas
+ 4 - 3
process-locations.lisp


Alguns ficheiros não foram mostrados porque muitos ficheiros mudaram neste diff