fixes more background jobs.
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
(ns auto-ap.import.plaid
|
||||
(:require
|
||||
[auto-ap.datomic :refer [conn]]
|
||||
[auto-ap.datomic :refer [conn random-tempid]]
|
||||
[auto-ap.import.common :refer [wrap-integration]]
|
||||
[auto-ap.import.transactions :as t]
|
||||
[auto-ap.plaid.core :as p]
|
||||
@@ -27,6 +27,7 @@
|
||||
(defn plaid->transaction [t]
|
||||
#:transaction {:description-original (:name t)
|
||||
:raw-id (:transaction_id t)
|
||||
:db/id (random-tempid)
|
||||
:id #_{:clj-kondo/ignore [:unresolved-var]}
|
||||
(di/sha-256 (:transaction_id t))
|
||||
:amount (if (= "credit" (:type (:account t)))
|
||||
|
||||
@@ -6,26 +6,28 @@
|
||||
[datomic.api :as dc]))
|
||||
|
||||
(defn refresh-vendor-usages []
|
||||
@(dc/transact conn (->> (dc/q '[:find ?v ?c (count ?e)
|
||||
:in $
|
||||
:where
|
||||
[?v :vendor/name]
|
||||
(or-join [?v ?c ?e]
|
||||
(and
|
||||
[?e :invoice/vendor ?v]
|
||||
[?e :invoice/client ?c])
|
||||
(and
|
||||
[?e :transaction/vendor ?v]
|
||||
[?e :transaction/client ?c])
|
||||
(and
|
||||
[?e :journal-entry/vendor ?v]
|
||||
[?e :journal-entry/client ?c]))]
|
||||
(dc/db conn))
|
||||
(map (fn [[v c cnt]]
|
||||
#:vendor-usage {:vendor v
|
||||
:client c
|
||||
:key (str v "-" c)
|
||||
:count cnt})))))
|
||||
@(dc/transact-async
|
||||
conn
|
||||
(->> (dc/q '[:find ?v ?c (count ?e)
|
||||
:in $
|
||||
:where
|
||||
[?v :vendor/name]
|
||||
(or-join [?v ?c ?e]
|
||||
(and
|
||||
[?e :invoice/vendor ?v]
|
||||
[?e :invoice/client ?c])
|
||||
(and
|
||||
[?e :transaction/vendor ?v]
|
||||
[?e :transaction/client ?c])
|
||||
(and
|
||||
[?e :journal-entry/vendor ?v]
|
||||
[?e :journal-entry/client ?c]))]
|
||||
(dc/db conn))
|
||||
(map (fn [[v c cnt]]
|
||||
#:vendor-usage {:vendor v
|
||||
:client c
|
||||
:key (str v "-" c)
|
||||
:count cnt})))))
|
||||
|
||||
(defn -main [& _]
|
||||
(execute "vendor-usages" refresh-vendor-usages))
|
||||
|
||||
Reference in New Issue
Block a user