various fixes.

This commit is contained in:
2023-09-06 13:34:08 -07:00
parent 558fc58371
commit 766be867f7
4 changed files with 32 additions and 10 deletions

View File

@@ -66,13 +66,19 @@
(.atZone (java.time.ZoneId/of "US/Pacific"))
(.get java.time.temporal.ChronoField/DAY_OF_MONTH)))
(defn next-day [d]
(some-> d
coerce/to-date-time
(time/plus (time/days 1))
coerce/to-date))
(defn scan-invoices [db clients start end]
(for [c clients
:let [c (entid db c)]
r (seq (dc/index-range db
:invoice/client+date
[c (or start #inst "2001-01-01T08:00:00.000-00:00") ]
[c (or end #inst "2030-03-05T08:00:00.000-00:00") ]))]
[c (or (next-day end) #inst "2030-03-05T08:00:00.000-00:00") ]))]
[(:e r) (first (:v r)) (second (:v r))]))
(defn scan-transactions [db clients start end]
@@ -81,7 +87,7 @@
r (seq (dc/index-range db
:transaction/client+date
[c (or start #inst "2001-01-01T08:00:00.000-00:00") ]
[c (or end #inst "2030-03-05T08:00:00.000-00:00") ]))]
[c (or (next-day end) #inst "2030-03-05T08:00:00.000-00:00") ]))]
[(:e r) (first (:v r)) (second (:v r))]))
(defn scan-ledger [db clients start end]
@@ -90,7 +96,7 @@
r (seq (dc/index-range db
:journal-entry/client+date
[c (or start #inst "2001-01-01T08:00:00.000-00:00") ]
[c (or end #inst "2030-03-05T08:00:00.000-00:00") ]))]
[c (or (next-day end) #inst "2030-03-05T08:00:00.000-00:00") ]))]
[(:e r) (first (:v r)) (second (:v r))]))
(defn scan-payments [db clients start end]
@@ -99,5 +105,5 @@
r (seq (dc/index-range db
:payment/client+date
[c (or start #inst "2001-01-01T08:00:00.000-00:00") ]
[c (or end #inst "2030-03-05T08:00:00.000-00:00") ]))]
[c (or (next-day end) #inst "2030-03-05T08:00:00.000-00:00") ]))]
[(:e r) (first (:v r)) (second (:v r))]))

View File

@@ -29,7 +29,8 @@
[com.brunobonacci.mulog :as mu]
[datomic.api :as dc]
[iol-ion.tx :refer [random-tempid]]
[auto-ap.solr :as solr])
[auto-ap.solr :as solr]
[auto-ap.logging :as alog])
(:import
(org.apache.commons.codec.binary Base64)))
@@ -341,11 +342,15 @@
(let [_ (assert-admin (:id context))
args (assoc args :clients (:clients context))
ids (some-> (:filters args)
(assoc :clients (:clients context))
(assoc :only-external true)
(<-graphql)
(assoc :per-page Integer/MAX_VALUE)
(#(l/raw-graphql-ids (dc/db conn) %))
:ids)
_ (alog/info ::trying-to-delete
:count (count ids)
:sample (take 3 ids))
specific-ids (l/filter-ids (:ids args))
all-ids (all-ids-not-locked (into (set ids) specific-ids))]
(if (> (count all-ids) 1000)

View File

@@ -28,7 +28,8 @@
[datomic.api :as dc]
[iol-ion.tx :refer [random-tempid]]
[com.brunobonacci.mulog :as mu]
[auto-ap.solr :as solr]))
[auto-ap.solr :as solr]
[auto-ap.logging :as alog]))
(def approval-status->graphql (ident->enum-f :transaction/approval-status))
@@ -65,7 +66,11 @@
:end (+ (:start args 0) (count transactions))}))
(defn get-ids-matching-filters [args]
(alog/info ::getting-ids-matching-filters
:args args)
(let [ids (some-> (:filters args)
(assoc :clients (:clients args))
(assoc :id (:id args))
(<-graphql)
(update :approval-status enum->keyword "transaction-approval-status")
(assoc :per-page Integer/MAX_VALUE)
@@ -87,7 +92,7 @@
(map first)))
(defn bulk-change-status [context args _]
(let [_ (assert-admin (:id context))
args (assoc args :clients (:clients context))
args (assoc args :clients (:clients context) :id (:id context))
all-ids (->> (get-ids-matching-filters args)
all-ids-not-locked)]
@@ -139,17 +144,20 @@
(defn bulk-code-transactions [context args _]
(assert-admin (:id context))
(when-not (seq (:client_id args))
(when-not (:client_id args)
(throw (ex-info "Client is required"
{:validation-error "client is required"})))
(let [args (assoc args :clients [{:db/id [(:client_id args)]}])
(let [args (assoc args :clients [(:client_id args)] :id (:id context))
locations (pull-attr (dc/db conn)
:client/locations
(:client_id args))
all-ids (all-ids-not-locked (get-ids-matching-filters args))
transactions (pull-many (dc/db conn) [:db/id :transaction/amount] (vec all-ids))
account-total (reduce + 0 (map (fn [x] (:percentage x)) (:accounts args)))]
(log/info "client is" locations)
(alog/info ::bulk-coding-transactions
:count (count transactions)
:sample (take 3 transactions))
(when
(and

View File

@@ -7,6 +7,7 @@
(defn wrap-secure [handler]
(fn [request]
#_(println "AUTHENTICATE" (authenticated? request))
(cond (authenticated? request)
(handler request)
@@ -22,6 +23,7 @@
(defn wrap-admin [handler]
(fn [request]
#_(println "ADMIN " (is-admin? (:identity request)) (:identity request))
(if (is-admin? (:identity request))
(handler request)
(do
@@ -33,6 +35,7 @@
(defn wrap-client-redirect-unauthenticated [handler]
(fn [request]
(let [response (handler request)]
#_(println "HEREEEEE" (get response :status))
(if (= 401 (get response :status))
(-> response
(assoc-in [:headers "hx-redirect"] (str "/login?"