From ad98cd9896895ebb8c5011b319fbf462c29b8590 Mon Sep 17 00:00:00 2001 From: Bryce Date: Mon, 21 Aug 2023 22:03:05 -0700 Subject: [PATCH] only including accounts that the client actually uses. --- src/clj/auto_ap/routes/exports.clj | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/src/clj/auto_ap/routes/exports.clj b/src/clj/auto_ap/routes/exports.clj index 309fe274..699dee9b 100644 --- a/src/clj/auto_ap/routes/exports.clj +++ b/src/clj/auto_ap/routes/exports.clj @@ -482,22 +482,12 @@ :in $ :where [?i :account/location ?l]] (dc/db conn)))) - used-accounts (->> (for [c clients - d (dc/index-range (dc/db conn) - :journal-entry-line/client+account+location+date - [(:db/id c)] - [(inc (:db/id c))]) - :let [[_ account] (:v d)]] - account) - (into #{}) - (sort-by account->numeric-code)) + dates (->> (range -365 0) (map (fn [delta] (atime/unparse-local (time/plus (time/floor (time/plus (atime/local-now) (time/days 1)) time/day) (time/days delta)) atime/iso-date))))] - (alog/info ::account-snapshot-report - :used-accounts (count used-accounts) - :date-count (count dates)) + {:status 200 :body (for [client clients @@ -510,6 +500,17 @@ (take-while (fn matches-client [curr] (= (first (:journal-entry-line/client+account+location+date curr)) (:db/id client))))) + used-accounts (->> (for [d (dc/index-range (dc/db conn) + :journal-entry-line/client+account+location+date + [(:db/id client)] + [(inc (:db/id client))]) + :let [[_ account] (:v d)]] + account) + (into #{}) + (sort-by account->numeric-code)) + _ (alog/info ::account-snapshot-report + :used-accounts (count used-accounts) + :date-count (count dates)) account-lookup (->> all-entries (reduce (fn build-account-lookup [acc curr]