fixes a bug with manual import

This commit is contained in:
2023-05-02 10:52:39 -07:00
parent f3be9bc5d2
commit 23a9a8039e
2 changed files with 25 additions and 7 deletions

View File

@@ -266,13 +266,13 @@
(defn get-existing [bank-account]
(log/info "looking up bank account data for" bank-account)
(into {}
(dc/q {:query {:find ['?tid '?as2]
:in ['$ '?ba]
:where ['[?e :transaction/bank-account ?ba]
'[?e :transaction/id ?tid]
'[?e :transaction/approval-status ?as]
'[?as :db/ident ?as2]]}
:args [(dc/db conn) bank-account]})))
(dc/q '[:find ?tid ?as2
:in $ ?ba
:where [?e :transaction/bank-account ?ba]
[?e :transaction/id ?tid]
[?e :transaction/approval-status ?as]
[?as :db/ident ?as2]]
(dc/db conn) bank-account)))
(defprotocol ImportBatch
(import-transaction! [this transaction])

View File

@@ -533,3 +533,21 @@
[(str id) client-code "synthetic" v d a-2 (or a-2-location client-location) amount 0]]]
a)
:separator \tab))))
#_{:clj-kondo/ignore [:clojure-lsp/unused-public-var]}
(defn sample-manual-yodlee
([client-code]
(sample-ledger-import client-code 10))
([client-code n]
(let [bank-accounts (map first (d/q '[:find ?bac :in $ ?c :where [?c :client/bank-accounts ?b] [?b :bank-account/code ?bac]] (dc/db conn) [:client/code client-code]))]
(clojure.data.csv/write-csv
*out*
(for [n (range n)
:let [amount (rand-int 2000)
d (-> (t/now)
(t/minus (t/days (rand-int 60)))
(atime/unparse atime/normal-date))
id (rand-int 100000)]]
["posted" d (str "Random Description - " id) "Travel" nil nil (- amount) nil nil nil nil nil (rand-nth bank-accounts) client-code])
:separator \tab))))