Improves balance sheet, starts moving it to new layout
This commit is contained in:
@@ -5,6 +5,7 @@
|
||||
[auto-ap.logging :as alog]
|
||||
[clj-time.coerce :as c]
|
||||
[clj-time.core :as t]
|
||||
[iol-ion.query :refer [account-sets]]
|
||||
[com.brunobonacci.mulog :as mu]
|
||||
[com.unbounce.dogstatsd.core :as statsd]
|
||||
[datomic.api :as dc]
|
||||
@@ -410,6 +411,7 @@
|
||||
:bank-account/current-balance-synced (c/to-date (t/now))
|
||||
:bank-account/current-balance running-balance}])))))))
|
||||
|
||||
;; TODO using iol-ion query as the base, building running balance sets
|
||||
(defn upsert-running-balance []
|
||||
(mu/with-context {:service "upsert-running-balance"
|
||||
:source "upsert-running-balance" }
|
||||
@@ -424,14 +426,8 @@
|
||||
changes (for [c clients
|
||||
:let [client-id (:db/id c)
|
||||
account-lookup (build-account-lookup client-id)]
|
||||
running-balance-set (->> (dc/index-range db :journal-entry-line/running-balance-tuple [client-id] [(inc client-id)])
|
||||
(seq)
|
||||
(partition-by (fn [{[current-client current-account current-location current-date debit credit running-balance]
|
||||
:v}]
|
||||
[current-client current-account current-location])))
|
||||
running-balance-set (account-sets db client-id)
|
||||
running-balance-change (->> running-balance-set
|
||||
(sort-by (fn [{id :e [_ _ _ current-date] :v}]
|
||||
[current-date id]))
|
||||
(reduce
|
||||
(fn [{:keys [changes last-running-balance]}
|
||||
{id :e
|
||||
|
||||
Reference in New Issue
Block a user