Adds ability to query for snapshots

This commit is contained in:
2024-10-02 09:28:05 -07:00
parent 41167a24a7
commit cf81e3999c
5 changed files with 145 additions and 5 deletions

View File

@@ -1,7 +1,63 @@
(in-ns 'auto-ap.yodlee.core2)
(map :postDate (get-specific-transactions "NGGG" 17203328))
(get-specific-transactions "SCCB" 14356804)
(get-transactions "SCCB")
(get-accounts "SCCB")
(user/init-repl)
(let [start
(->> (get-specific-transactions "SCCB" 20130531)
(reduce
(fn [acc tx]
(-> acc
(update-in [(:postDate tx) :amount] (fnil + 0.0) (:amount (:amount tx)))
(update-in [(:postDate tx) :count] (fnil inc 0))))
{}))
final (reduce
(fn [acc [id a c]]
(-> acc
(assoc-in [id :iol-amount] a)
(assoc-in [id :iol-count] c)))
start
(dc/q '[:find ?id (sum ?a2) (count ?tx)
:in $ ?ba
:where [?tx :transaction/bank-account ?ba]
[?tx :transaction/date ?d]
[(>= ?d #inst "2024-08-26")]
[(iol-ion.query/iso-date ?d) ?id]
[?tx :transaction/amount ?a]
[(Math/abs ?a) ?a2]]
(dc/db conn)
[:bank-account/code "SCCB-USB9598"]))]
(filter
(fn [x]
(not (auto-ap.utils/dollars= (or (:amount x) 0.0)
(or (:iol-amount x) 0.0)
)))
(vals final)))
(map (juxt (comp :amount :amount) :postDate :status)
)
(- 264112 (reduce + 0.0 (map first [
[4538.11 "2024-09-25" "POSTED"]
[3129.85 "2024-09-25" "POSTED"]
[4782.11 "2024-09-25" "POSTED"]
[28380.29 "2024-09-25" "POSTED"]
[10000.0 "2024-09-25" "POSTED"]
[2352.82 "2024-09-25" "PENDING"]
[1012.18 "2024-09-25" "PENDING"]
[30996.0 "2024-09-24" "POSTED"]
[275.0 "2024-09-24" "POSTED"]
[7353.78 "2024-09-24" "POSTED"]
])))
(->> (dc/q '[:find ?ba (count ?ya)
:in $