Recalculates running balance as report is run

This commit is contained in:
2025-02-08 22:14:24 -08:00
parent d078fb8a15
commit 38ed981cba
3 changed files with 79 additions and 70 deletions

View File

@@ -4,7 +4,7 @@
[auto-ap.datomic
:refer [conn pull-many]]
[auto-ap.graphql.utils :refer [assert-can-see-client]]
[auto-ap.ledger :refer [build-account-lookup]]
[auto-ap.ledger :refer [build-account-lookup upsert-running-balance]]
[auto-ap.ledger.reports :as l-reports]
[auto-ap.logging :as alog]
[auto-ap.pdf.ledger :refer [table->pdf]]
@@ -33,8 +33,7 @@
[config.core :refer [env] :as env]
[datomic.api :as dc]
[iol-ion.utils :refer [by]]
[malli.core :as mc]
[medley.core :refer [map-vals]])
[malli.core :as mc])
(:import
[java.util UUID]
[org.apache.commons.io.output ByteArrayOutputStream]))
@@ -76,6 +75,7 @@
(when (and (seq periods) client)
(let [client (if (= :all client) (take 5 (:clients request)) client)
client-ids (map :db/id client)
_ (upsert-running-balance (into #{} client-ids))
_ (doseq [client-id client-ids]
(assert-can-see-client (:identity request) client-id))