|
@@ -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 ()
|
|
(defun find-last-backup ()
|
|
|
(first (sort (mapcar #'namestring
|
|
(first (sort (mapcar #'namestring
|
|
@@ -51,22 +51,22 @@
|
|
|
(currencies (gethash "currency" db))
|
|
(currencies (gethash "currency" db))
|
|
|
(from-account (gethash (parse-integer (getf e :from-account-id)) accounts))
|
|
(from-account (gethash (parse-integer (getf e :from-account-id)) accounts))
|
|
|
(from-currency (gethash (parse-integer (getf from-account :currency-id)) currencies))
|
|
(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))
|
|
(spend (< from-amount 0))
|
|
|
(original-currency (gethash (parse-integer (getf e :original-currency-id)) currencies))
|
|
(original-currency (gethash (parse-integer (getf e :original-currency-id)) currencies))
|
|
|
(original-from-amount (and original-currency
|
|
(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)))
|
|
(payee (gethash (parse-integer (getf e :payee-id)) (gethash "payee" db)))
|
|
|
(category (gethash (parse-integer (getf e :category-id)) (gethash "category" db)))
|
|
(category (gethash (parse-integer (getf e :category-id)) (gethash "category" db)))
|
|
|
|
|
|
|
|
(to-account (gethash (parse-integer (getf e :to-account-id)) accounts))
|
|
(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-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
|
|
(transfer (cond
|
|
|
((and to-account (equal (getf from-account :type)
|
|
((and to-account (equal (getf from-account :type)
|
|
@@ -133,7 +133,7 @@
|
|
|
(kv "original_amount" original-from-amount)
|
|
(kv "original_amount" original-from-amount)
|
|
|
(kv "original_currency" (getf original-currency :name)))))))
|
|
(kv "original_currency" (getf original-currency :name)))))))
|
|
|
(kv
|
|
(kv
|
|
|
- (kv "ts" (parse-integer (getf e :datetime)))
|
|
|
|
|
|
|
+ (kv "ts" (ms->ts (parse-integer (getf e :datetime))))
|
|
|
(kv "type" "finance")
|
|
(kv "type" "finance")
|
|
|
(kv "title" title)
|
|
(kv "title" title)
|
|
|
(kv "financisto"
|
|
(kv "financisto"
|
|
@@ -170,7 +170,8 @@
|
|
|
(new-ts (parse-integer datetime)))
|
|
(new-ts (parse-integer datetime)))
|
|
|
(cl-mongo::kv-container-add
|
|
(cl-mongo::kv-container-add
|
|
|
(kv "loc"
|
|
(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)
|
|
(get-element "loc" existing-doc)
|
|
|
(point->doc (find-location-at new-ts))))
|
|
(point->doc (find-location-at new-ts))))
|
|
|
new-doc)
|
|
new-doc)
|