Should make reloading AND aot work again
This commit is contained in:
@@ -27,22 +27,22 @@
|
||||
query (format "_text_:(%s) AND %s" (cleanse-query query) client-part)]
|
||||
(mu/log ::searching :search-query query)
|
||||
(for [{:keys [account_id name] :as g} (solr/query solr/impl "accounts"
|
||||
{"query" query
|
||||
"fields" "id, name, client_id, numeric_code, applicability, account_id"})]
|
||||
|
||||
{"query" query
|
||||
"fields" "id, name, client_id, numeric_code, applicability, account_id"})]
|
||||
|
||||
{:account_id (first account_id)
|
||||
:name (first name)})))
|
||||
:name (first name)})))
|
||||
|
||||
|
||||
(defn account-search [{{:keys [q client-id allowance vendor-id] :as qp} :query-params id :identity}]
|
||||
|
||||
|
||||
(when client-id
|
||||
(assert-can-see-client id client-id))
|
||||
(assert-can-see-client id client-id))
|
||||
(let [num (some-> (re-find #"([0-9]+)" q)
|
||||
second
|
||||
(not-empty )
|
||||
(not-empty)
|
||||
Integer/parseInt)
|
||||
|
||||
|
||||
valid-allowances (cond-> #{:allowance/allowed
|
||||
:allowance/warn}
|
||||
(is-admin? id) (conj :allowance/admin-only))
|
||||
@@ -55,23 +55,23 @@
|
||||
|
||||
vendor-account (when vendor-id
|
||||
(-> (dc/q '[:find ?da
|
||||
:in $ ?v
|
||||
:where [?v :vendor/default-account ?da]]
|
||||
(dc/db conn)
|
||||
vendor-id)
|
||||
:in $ ?v
|
||||
:where [?v :vendor/default-account ?da]]
|
||||
(dc/db conn)
|
||||
vendor-id)
|
||||
ffirst))
|
||||
xform (comp
|
||||
(filter (fn [[_ a]]
|
||||
(or
|
||||
(valid-allowances (-> a allowance :db/ident))
|
||||
(= (:db/id a) vendor-account))))
|
||||
(map (fn [[n a]]
|
||||
{:label (str (:account/numeric-code a) " - " n)
|
||||
:value (:db/id a)
|
||||
:location (:account/location a)
|
||||
:warning (when (= :allowance/warn (-> a allowance :db/ident))
|
||||
"This account is not typically used for this purpose.")})))]
|
||||
{:body (take 10 (if q
|
||||
(filter (fn [[_ a]]
|
||||
(or
|
||||
(valid-allowances (-> a allowance :db/ident))
|
||||
(= (:db/id a) vendor-account))))
|
||||
(map (fn [[n a]]
|
||||
{:label (str (:account/numeric-code a) " - " n)
|
||||
:value (:db/id a)
|
||||
:location (:account/location a)
|
||||
:warning (when (= :allowance/warn (-> a allowance :db/ident))
|
||||
"This account is not typically used for this purpose.")})))]
|
||||
{:body (take 10 (if q
|
||||
(if num
|
||||
(->> (dc/q '[:find ?n (pull ?i pattern)
|
||||
:in $ ?numeric-code ?allowance pattern
|
||||
@@ -87,18 +87,18 @@
|
||||
(sequence xform))
|
||||
(->> (search- id q client-id)
|
||||
(sequence
|
||||
(comp (map (fn [i] [(:name i) (dc/pull (dc/db conn) search-pattern (:account_id i))]))
|
||||
xform))))
|
||||
(comp (map (fn [i] [(:name i) (dc/pull (dc/db conn) search-pattern (:account_id i))]))
|
||||
xform))))
|
||||
[]))}))
|
||||
|
||||
(def account-search (wrap-json-response (wrap-schema-enforce account-search
|
||||
:query-schema [:map
|
||||
[:q :string]
|
||||
[:client-id {:optional true
|
||||
:default nil}
|
||||
[:maybe entity-id]]
|
||||
[:vendor-id {:optional true}
|
||||
[:maybe entity-id]]
|
||||
[:allowance {:optional true}
|
||||
[:maybe (ref->enum-schema "allowance")]]])))
|
||||
:query-schema [:map
|
||||
[:q :string]
|
||||
[:client-id {:optional true
|
||||
:default nil}
|
||||
[:maybe entity-id]]
|
||||
[:vendor-id {:optional true}
|
||||
[:maybe entity-id]]
|
||||
[:allowance {:optional true}
|
||||
[:maybe (ref->enum-schema "allowance")]]])))
|
||||
|
||||
|
||||
@@ -40,6 +40,7 @@
|
||||
[manifold.deferred :as de])
|
||||
(:import [java.util UUID]))
|
||||
|
||||
|
||||
;; TODO make more reusable malli schemas, use unions if it would be helpful
|
||||
;; TODO copy save logic from graphql version
|
||||
;; TODO cash drawer shift
|
||||
@@ -1416,8 +1417,7 @@
|
||||
(first step-key)))))
|
||||
(form-schema [_] form-schema-2)
|
||||
(submit [_ {:keys [multi-form-state request-method identity] :as request}]
|
||||
(let [
|
||||
snapshot (mc/decode
|
||||
(let [snapshot (mc/decode
|
||||
form-schema-2
|
||||
(:snapshot multi-form-state)
|
||||
mt/strip-extra-keys-transformer)
|
||||
|
||||
Reference in New Issue
Block a user