maybe made ledger export wicked fast by comparison.
This commit is contained in:
@@ -9,6 +9,34 @@
|
|||||||
[clj-time.coerce :as c]
|
[clj-time.coerce :as c]
|
||||||
[clj-time.core :as time]))
|
[clj-time.core :as time]))
|
||||||
|
|
||||||
|
(def export-read
|
||||||
|
[:journal-entry/external-id
|
||||||
|
:journal-entry/cleared
|
||||||
|
:journal-entry/alternate-description
|
||||||
|
:journal-entry/date
|
||||||
|
:journal-entry/note
|
||||||
|
:journal-entry/amount
|
||||||
|
:journal-entry/source
|
||||||
|
:journal-entry/cleared-against
|
||||||
|
:journal-entry/original-entity
|
||||||
|
{:journal-entry/client [:client/name :client/code :db/id]
|
||||||
|
:journal-entry/vendor [:vendor/name :db/id]
|
||||||
|
:journal-entry/line-items [:journal-entry-line/location
|
||||||
|
:journal-entry-line/debit
|
||||||
|
:journal-entry-line/credit
|
||||||
|
{:journal-entry-line/account [:bank-account/include-in-reports
|
||||||
|
:bank-account/bank-name
|
||||||
|
:bank-account/code
|
||||||
|
:bank-account/visible
|
||||||
|
:bank-account/name
|
||||||
|
:bank-account/number
|
||||||
|
:account/code
|
||||||
|
:account/name
|
||||||
|
:account/numeric-code
|
||||||
|
:account/location
|
||||||
|
{:account/type [:db/ident :db/id]}
|
||||||
|
{:bank-account/type [:db/ident :db/id]}]}]}])
|
||||||
|
|
||||||
(defn raw-graphql-ids [db args]
|
(defn raw-graphql-ids [db args]
|
||||||
(log/info "ARGS" args)
|
(log/info "ARGS" args)
|
||||||
|
|
||||||
|
|||||||
@@ -185,6 +185,33 @@
|
|||||||
(list)
|
(list)
|
||||||
(first (d-ledger/get-graphql {:count Integer/MAX_VALUE
|
(first (d-ledger/get-graphql {:count Integer/MAX_VALUE
|
||||||
:client-code (query-params "client-code")})))))
|
: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]}
|
(GET "/accounts/export" {:keys [query-params identity]}
|
||||||
(assert-admin identity)
|
(assert-admin identity)
|
||||||
|
|||||||
@@ -108,6 +108,7 @@
|
|||||||
|
|
||||||
(add-shutdown-hook! shutdown-mount)
|
(add-shutdown-hook! shutdown-mount)
|
||||||
(start-server :port 9000 :bind "0.0.0.0" #_#_:handler (cider-nrepl-handler))
|
(start-server :port 9000 :bind "0.0.0.0" #_#_:handler (cider-nrepl-handler))
|
||||||
|
(set! nrepl.middleware.print/*print-fn* clojure.pprint/pprint)
|
||||||
(apply mount/start-without without)))
|
(apply mount/start-without without)))
|
||||||
|
|
||||||
(comment
|
(comment
|
||||||
|
|||||||
Reference in New Issue
Block a user