From 52bd8b567112f26efef7c055bdc7735575eb6686 Mon Sep 17 00:00:00 2001 From: Bryce Covert Date: Sun, 3 Apr 2022 08:05:57 -0700 Subject: [PATCH] fix for touching broken ledger being noisy. --- src/clj/auto_ap/ledger.clj | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/clj/auto_ap/ledger.clj b/src/clj/auto_ap/ledger.clj index c4479775..bc4f602c 100644 --- a/src/clj/auto_ap/ledger.clj +++ b/src/clj/auto_ap/ledger.clj @@ -3,6 +3,8 @@ [auto-ap.datomic :refer [conn remove-nils]] [auto-ap.logging :refer [info-event]] [auto-ap.utils :refer [dollars-0? dollars=]] + [clj-time.core :as t] + [clj-time.coerce :as c] [clojure.tools.logging :as log] [com.unbounce.dogstatsd.core :as statsd] [datomic.api :as d] @@ -293,7 +295,17 @@ ] (filter (fn [[e accounts]] (not= accounts (get jel-accounts e))) - transaction-accounts))) + transaction-accounts) + (filter (fn [[e]] + (let [[tx-date] (d/q '[:find [(max ?d) ...] + :in $ ?t + :where + [?t _ _ ?tx] + [?tx :db/txInstant ?d]] + (d/history (d/db auto-ap.datomic/conn)) + e)] + (t/before? (c/to-date-time tx-date) + (t/minus (t/now) (t/hours 1)))))))) (defn unbalanced-transactions [] (->> (d/query {:query {:find ['?je '?a '(sum ?debit) '(sum ?credit)]