Search by financial account
This commit is contained in:
@@ -35,7 +35,8 @@
|
|||||||
:name (first name)})))
|
:name (first name)})))
|
||||||
|
|
||||||
|
|
||||||
(defn account-search [{{:keys [q client-id purpose vendor-id] :as qp} :query-params id :identity}]
|
(defn account-search [{{:keys [q client-id purpose vendor-id] :as qp} :query-params id :identity :as request}]
|
||||||
|
(let [client-id (or client-id (:db/id (:client request)))]
|
||||||
(when client-id
|
(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)
|
(let [num (some-> (re-find #"([0-9]+)" q)
|
||||||
@@ -89,7 +90,7 @@
|
|||||||
(sequence
|
(sequence
|
||||||
(comp (map (fn [i] [(:name i) (dc/pull (dc/db conn) search-pattern (:account_id i))]))
|
(comp (map (fn [i] [(:name i) (dc/pull (dc/db conn) search-pattern (:account_id i))]))
|
||||||
xform))))
|
xform))))
|
||||||
[]))}))
|
[]))})))
|
||||||
|
|
||||||
(def account-search (wrap-json-response (wrap-schema-enforce account-search
|
(def account-search (wrap-json-response (wrap-schema-enforce account-search
|
||||||
:query-schema [:map
|
:query-schema [:map
|
||||||
|
|||||||
@@ -84,6 +84,14 @@
|
|||||||
:value (:vendor (:query-params request))
|
:value (:vendor (:query-params request))
|
||||||
:value-fn :db/id
|
:value-fn :db/id
|
||||||
:content-fn :vendor/name}))
|
:content-fn :vendor/name}))
|
||||||
|
(com/field {:label "Account"}
|
||||||
|
(com/typeahead {:name "account"
|
||||||
|
:id "account"
|
||||||
|
:url (bidi/path-for ssr-routes/only-routes :account-search)
|
||||||
|
:value (:account (:query-params request))
|
||||||
|
:value-fn :db/id
|
||||||
|
:content-fn #(:account/name (d-accounts/clientize (dc/pull (dc/db conn) d-accounts/default-read (:db/id %))
|
||||||
|
(:db/id (:client request))))}))
|
||||||
(date-range-field* request)
|
(date-range-field* request)
|
||||||
(com/field {:label "Check #"}
|
(com/field {:label "Check #"}
|
||||||
(com/text-input {:name "check-number"
|
(com/text-input {:name "check-number"
|
||||||
@@ -179,11 +187,11 @@
|
|||||||
:where ['[?e :invoice/vendor ?vendor-id]]}
|
:where ['[?e :invoice/vendor ?vendor-id]]}
|
||||||
:args [(:db/id (:vendor query-params))]})
|
:args [(:db/id (:vendor query-params))]})
|
||||||
|
|
||||||
(:account-id query-params)
|
(:account query-params)
|
||||||
(merge-query {:query {:in ['?account-id]
|
(merge-query {:query {:in ['?account-id]
|
||||||
:where ['[?e :invoice/expense-accounts ?iea ?]
|
:where ['[?e :invoice/expense-accounts ?iea ?]
|
||||||
'[?iea :invoice-expense-account/account ?account-id]]}
|
'[?iea :invoice-expense-account/account ?account-id]]}
|
||||||
:args [(:account-id query-params)]})
|
:args [(:db/id (:account query-params))]})
|
||||||
|
|
||||||
(:amount-gte query-params)
|
(:amount-gte query-params)
|
||||||
(merge-query {:query {:in ['?amount-gte]
|
(merge-query {:query {:in ['?amount-gte]
|
||||||
@@ -296,6 +304,7 @@
|
|||||||
[:amount-gte {:optional true} [:maybe :double]]
|
[:amount-gte {:optional true} [:maybe :double]]
|
||||||
[:amount-lte {:optional true} [:maybe :double]]
|
[:amount-lte {:optional true} [:maybe :double]]
|
||||||
[:vendor {:optional true :default nil} [:maybe [:entity-map {:pull [:db/id :vendor/name]}]]]
|
[:vendor {:optional true :default nil} [:maybe [:entity-map {:pull [:db/id :vendor/name]}]]]
|
||||||
|
[:account {:optional true :default nil} [:maybe [:entity-map {:pull [:db/id :account/name]}]]]
|
||||||
[:check-number {:optional true} [:maybe [:string {:decode/string strip}]]]
|
[:check-number {:optional true} [:maybe [:string {:decode/string strip}]]]
|
||||||
[:invoice-number {:optional true} [:maybe [:string {:decode/string strip}]]]
|
[:invoice-number {:optional true} [:maybe [:string {:decode/string strip}]]]
|
||||||
[:status {:optional true} [:maybe (ref->enum-schema "invoice-status")]]
|
[:status {:optional true} [:maybe (ref->enum-schema "invoice-status")]]
|
||||||
|
|||||||
Reference in New Issue
Block a user