adds journal entry id.

This commit is contained in:
2022-01-14 09:46:41 -08:00
parent 2245a5f082
commit 3ec3718548

View File

@@ -179,53 +179,55 @@
(assert-admin identity) (assert-admin identity)
(statsd/time! [(str "export.time") {:tags #{(client-tag query-params) (statsd/time! [(str "export.time") {:tags #{(client-tag query-params)
"export:ledger2"}}] "export:ledger2"}}]
(let [results (->> (d/q '[:find (pull ?e [:journal-entry/external-id (let [results (->> (d/q '[:find (pull ?e [:db/id
:journal-entry/cleared :journal-entry/external-id
:journal-entry/alternate-description :journal-entry/cleared
:journal-entry/date :journal-entry/alternate-description
:journal-entry/note :journal-entry/date
:journal-entry/amount :journal-entry/note
:journal-entry/source :journal-entry/amount
:journal-entry/cleared-against :journal-entry/source
:journal-entry/original-entity :journal-entry/cleared-against
{:journal-entry/client [:client/name :client/code :db/id] :journal-entry/original-entity
:journal-entry/vendor [:vendor/name :db/id] {:journal-entry/client [:client/name :client/code :db/id]
:journal-entry/line-items [:journal-entry-line/location :journal-entry/vendor [:vendor/name :db/id]
:journal-entry-line/debit :journal-entry/line-items [:db/id
:journal-entry-line/credit :journal-entry-line/location
{:journal-entry-line/account [:bank-account/include-in-reports :journal-entry-line/debit
:bank-account/bank-name :journal-entry-line/credit
:bank-account/code {:journal-entry-line/account [:bank-account/include-in-reports
:bank-account/visible :bank-account/bank-name
:bank-account/name :bank-account/code
:bank-account/number :bank-account/visible
:account/code :bank-account/name
:account/name :bank-account/number
:account/numeric-code :account/code
:account/location :account/name
{:account/type [:db/ident :db/id]} :account/numeric-code
{:bank-account/type [:db/ident :db/id]}]}]}]) :account/location
:in $ ?c ?start-date {:account/type [:db/ident :db/id]}
:where [?e :journal-entry/client ?c] {:bank-account/type [:db/ident :db/id]}]}]}])
[?e :journal-entry/date ?date] :in $ ?c ?start-date
[(>= ?date ?start-date)]] :where [?e :journal-entry/client ?c]
(d/db conn) [?e :journal-entry/date ?date]
[:client/code (query-params "client-code")] [(>= ?date ?start-date)]]
(coerce/to-date start-date))) (d/db conn)
tf-result (transduce (comp [:client/code (query-params "client-code")]
(map first) (coerce/to-date start-date)))
(filter (fn [je] tf-result (transduce (comp
(every? (map first)
(fn [jel] (filter (fn [je]
(let [include-in-reports (-> jel :journal-entry-line/account :bank-account/include-in-reports)] (every?
(or (nil? include-in-reports) (fn [jel]
(true? include-in-reports)))) (let [include-in-reports (-> jel :journal-entry-line/account :bank-account/include-in-reports)]
(:journal-entry/line-items je)))) (or (nil? include-in-reports)
(map <-graphql)) (true? include-in-reports))))
conj (:journal-entry/line-items je))))
(list) (map <-graphql))
results)] conj
tf-result)))) (list)
results)]
tf-result))))