maybe made ledger export wicked fast by comparison.

This commit is contained in:
2022-01-07 07:34:44 -08:00
parent 634e4f4820
commit 75a08e1dc1
3 changed files with 56 additions and 0 deletions

View File

@@ -185,6 +185,33 @@
(list)
(first (d-ledger/get-graphql {:count Integer/MAX_VALUE
:client-code (query-params "client-code")})))))
(GET "/ledger2/export" {:keys [query-params identity]}
(log/info "exporting for " (query-params "client-code"))
(assert-admin identity)
(statsd/time! [(str "export.time") {:tags #{(client-tag query-params)
"export:ledger2"}}]
(let [results (->> (d/q `[:find (pull ?e ~d-ledger/export-read)
:in $ ?c
:where [?e :journal-entry/client ?c]]
(d/db conn)
[:client/code (query-params "client-code")])
)
tf-result (transduce (comp
(map first)
(filter (fn [je]
(every?
(fn [jel]
(let [include-in-reports (-> jel :journal-entry-line/account :bank-account/include-in-reports)]
(or (nil? include-in-reports)
(true? include-in-reports))))
(:journal-entry/line-items je))))
(map <-graphql))
conj
(list)
results)]
tf-result)))
(GET "/accounts/export" {:keys [query-params identity]}
(assert-admin identity)