Makes multiple client selection somewhat possible via graphql.

This commit is contained in:
2023-08-31 13:05:06 -07:00
parent 9c472dfc8e
commit 1d82ec29e0
29 changed files with 274 additions and 139 deletions

View File

@@ -16,24 +16,21 @@
(defn raw-graphql-ids [db args]
(let [query
(if (:exact-match-id args)
(cond-> {:query {:find '[?e]
:in '[$ ?e]
:where '[[?e :journal-entry/client ?c]]}
:args [db
(:exact-match-id args)]}
(limited-clients (:id args))
(merge-query {:query {:in ['[?xx ...]]
:where ['[?e :journal-entry/client ?xx]]}
:args [(set (map :db/id (limited-clients (:id args))))]}))
{:query {:find '[?e]
:in '[$ ?e [?c ...]]
:where '[[?e :journal-entry/client ?c]]}
:args [db
(:exact-match-id args)
(map :db/id (:clients args))]}
(cond-> {:query {:find []
:in ['$ ]
:where []}
:args [db]}
(:client-id args)
(merge-query {:query {:in ['?client-id]
:where ['[?e :journal-entry/client ?client-id]]}
:args [(:client-id args)]})
(seq (:clients args))
(merge-query {:query {:in ['[?xx ...]]
:where ['[?e :journal-entry/client ?xx]]}
:args [(set (map :db/id (:clients args)))]})
(:only-external args)
(merge-query {:query {:where ['(not [?e :journal-entry/original-entity ])]}})
@@ -86,7 +83,7 @@
'[(>= ?c ?from-numeric-code)]
'[(<= ?c ?to-numeric-code)]]}
:args [(vec (for [{:keys [from to]} (:numeric-code args)]
[(or from 0) (or to 99999)]))]})
[(or from 0) (or to 99999)]))]})
(:amount-gte args)
@@ -127,10 +124,10 @@
:where ['[?e :journal-entry/client ?xx]]}
:args [(set (map :db/id (limited-clients (:id args))))]})
(:sort args) (add-sorter-fields {"client" ['[?e :journal-entry/client ?c]
'[?c :client/name ?sort-client]]
'[?c :client/name ?sort-client]]
"date" ['[?e :journal-entry/date ?sort-date]]
"vendor" ['[?e :journal-entry/vendor ?v]
'[?v :vendor/name ?sort-vendor]]
'[?v :vendor/name ?sort-vendor]]
"amount" ['[?e :journal-entry/amount ?sort-amount]]
"external-id" ['[?e :journal-entry/external-id ?sort-external-id]]
"source" ['[?e :journal-entry/source ?sort-source]]}