started on assertions bit
This commit is contained in:
parent
9c5507523f
commit
b5c4e9b594
|
@ -4,11 +4,11 @@ Muneem
|
|||
|
||||
TODO
|
||||
----
|
||||
- [ ] Create assertion for each ingest to ensure we're tracking correctly
|
||||
- [ ] Download NAB trade transactions and value
|
||||
- [ ] Download spaceship returns
|
||||
- [ ] MAYBE Mention uncategorized transactions in matrix chat so that i can categorize it
|
||||
- [ ] Post weekly spending in matrix chat
|
||||
- [ ] Create assertion for each ingest to ensure we're tracking correctly
|
||||
|
||||
|
||||
DONE
|
||||
|
|
|
@ -4,12 +4,14 @@
|
|||
[cljc.java-time.local-date :as jt]
|
||||
[cljc.java-time.format.date-time-formatter :as pt]
|
||||
[clojure.java.shell :refer [sh]]
|
||||
[clojure.string :as string]
|
||||
[clojure.string]))
|
||||
|
||||
(def beancount-file "./documents/ledger.beancount")
|
||||
|
||||
(def transaction-details (partial #(nth % 5)))
|
||||
(def category (partial #(nth % 7)))
|
||||
(def balance (partial #(nth % 6)))
|
||||
(defn merchant-name [trans]
|
||||
(if (= (count trans) 9)
|
||||
(nth trans 8)
|
||||
|
@ -365,6 +367,17 @@
|
|||
[]
|
||||
(sh "cp" beancount-file "/home/anish/usr/finance/"))
|
||||
|
||||
(defn assert-balance
|
||||
[transaction checking?]
|
||||
(let [b (balance transaction)
|
||||
account (if checking?
|
||||
"Assets:Checking"
|
||||
"Assets:Savings")
|
||||
date (-> (sh "date" "+%Y-%m-%d")
|
||||
:out
|
||||
(string/trim-newline))]
|
||||
(write-statement (str date " balance " account " " b " AUD"))))
|
||||
|
||||
(defn main
|
||||
[csv checking? & _args]
|
||||
(read-accounts beancount-file)
|
||||
|
@ -372,4 +385,5 @@
|
|||
(mapv write-transaction-to-file (drop-last (take-csv csv)))
|
||||
(mapv write-transaction-to-file-savings (drop-last (take-csv csv))))
|
||||
(write-accounts beancount-file)
|
||||
(assert-balance (last (take-csv csv)) checking?)
|
||||
(reset! new-accounts #{}))
|
||||
|
|
Loading…
Reference in a new issue