Search by financial account

This commit is contained in:
2024-05-02 20:05:19 -07:00
parent 2a94bcc509
commit 6ca4a1b045
2 changed files with 66 additions and 56 deletions

View File

@@ -84,6 +84,14 @@
:value (:vendor (:query-params request))
:value-fn :db/id
: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)
(com/field {:label "Check #"}
(com/text-input {:name "check-number"
@@ -99,7 +107,7 @@
:value (:invoice-number (:query-params request))
:placeholder "e.g., ABC-456"
:size :small}))
(com/field {:label "Amount"}
[:div.flex.space-x-4.items-baseline
(com/money-input {:name "amount-gte"
@@ -179,11 +187,11 @@
:where ['[?e :invoice/vendor ?vendor-id]]}
:args [(:db/id (:vendor query-params))]})
(:account-id query-params)
(:account query-params)
(merge-query {:query {:in ['?account-id]
:where ['[?e :invoice/expense-accounts ?iea ?]
'[?iea :invoice-expense-account/account ?account-id]]}
:args [(:account-id query-params)]})
:args [(:db/id (:account query-params))]})
(:amount-gte query-params)
(merge-query {:query {:in ['?amount-gte]
@@ -296,6 +304,7 @@
[:amount-gte {:optional true} [:maybe :double]]
[:amount-lte {:optional true} [:maybe :double]]
[: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}]]]
[:invoice-number {:optional true} [:maybe [:string {:decode/string strip}]]]
[:status {:optional true} [:maybe (ref->enum-schema "invoice-status")]]