Makes multiple client selection somewhat possible via graphql.
This commit is contained in:
@@ -40,15 +40,13 @@
|
||||
([db args]
|
||||
(let [check-number-like (try (Long/parseLong (:check-number-like args)) (catch Exception _ nil))
|
||||
query (if (:exact-match-id args)
|
||||
(cond-> {:query {:find '[?e]
|
||||
:in '[$ ?e]
|
||||
:where '[[?e :payment/client ?c]]}
|
||||
:args [db
|
||||
(:exact-match-id args)]}
|
||||
(limited-clients (:id args))
|
||||
(merge-query {:query {:in ['[?xx ...]]
|
||||
:where ['[?e :payment/client ?xx]]}
|
||||
:args [(set (map :db/id (limited-clients (:id args))))]}))
|
||||
{:query {:find '[?e]
|
||||
:in '[$ ?e [?c ...]]
|
||||
:where '[[?e :payment/client ?c]]}
|
||||
:args [db
|
||||
(:exact-match-id args)
|
||||
(map :db/id (:clients args))]
|
||||
}
|
||||
(cond-> {:query {:find []
|
||||
:in ['$]
|
||||
:where []}
|
||||
@@ -69,10 +67,10 @@
|
||||
:where []}
|
||||
:args [(:exact-match-id args)]})
|
||||
|
||||
(limited-clients (:id args))
|
||||
(seq (:clients args))
|
||||
(merge-query {:query {:in ['[?xx ...]]
|
||||
:where ['[?e :payment/client ?xx]]}
|
||||
:args [(set (map :db/id (limited-clients (:id args))))]})
|
||||
:args [(map :db/id (:clients args))]})
|
||||
|
||||
|
||||
(:client-id args)
|
||||
|
||||
@@ -165,18 +165,20 @@
|
||||
|
||||
:else
|
||||
nil)
|
||||
valid-ids (cond
|
||||
matching-ids (cond
|
||||
(and name-like-ids (limited-clients (:id args)))
|
||||
(set/intersection name-like-ids (limited-clients (:id args)))
|
||||
|
||||
(limited-clients (:id args))
|
||||
(limited-clients (:id args))
|
||||
|
||||
name-like-ids
|
||||
name-like-ids
|
||||
|
||||
:else
|
||||
nil)
|
||||
valid-ids (if matching-ids
|
||||
(set/intersection (set (map :db/id (:clients args)))
|
||||
matching-ids)
|
||||
(set (map :db/id (:clients args))))
|
||||
|
||||
|
||||
query (cond-> {:query {:find []
|
||||
:in ['$ ]
|
||||
|
||||
@@ -38,10 +38,10 @@
|
||||
"fee" ['[?e :expected-deposit/fee ?sort-fee]]}
|
||||
args)
|
||||
|
||||
(limited-clients (:id args))
|
||||
(merge-query {:query {:in ['[?xx ...]]
|
||||
(seq (:clients args))
|
||||
(merge-query {:query {:in ['[?xx ...]]
|
||||
:where ['[?e :expected-deposit/client ?xx]]}
|
||||
:args [(set (map :db/id (limited-clients (:id args))))]})
|
||||
:args [(set (map :db/id (:clients args)))]})
|
||||
|
||||
(:exact-match-id args)
|
||||
(merge-query {:query {:in ['?e]
|
||||
|
||||
@@ -49,24 +49,21 @@
|
||||
([db args]
|
||||
(let [query
|
||||
(if (:exact-match-id args)
|
||||
(cond-> {:query {:find '[?e]
|
||||
:in '[$ ?e]
|
||||
:where '[[?e :invoice/client ?c]]}
|
||||
:args [db
|
||||
(:exact-match-id args)]}
|
||||
(limited-clients (:id args))
|
||||
(merge-query {:query {:in ['[?xx ...]]
|
||||
:where ['[?e :invoice/client ?xx]]}
|
||||
:args [(set (map :db/id (limited-clients (:id args))))]}))
|
||||
{:query {:find '[?e]
|
||||
:in '[$ ?e [?c ...]]
|
||||
:where '[[?e :invoice/client ?c]]}
|
||||
:args [db
|
||||
(:exact-match-id args)
|
||||
(map :db/id (:clients args))]}
|
||||
(cond-> {:query {:find []
|
||||
:in ['$]
|
||||
:where ['[?e :invoice/client]]}
|
||||
:args [db]}
|
||||
|
||||
(limited-clients (:id args))
|
||||
(seq (:clients args))
|
||||
(merge-query {:query {:in ['[?xx ...]]
|
||||
:where ['[?e :invoice/client ?xx]]}
|
||||
:args [ (set (map :db/id (limited-clients (:id args))))]})
|
||||
:args [ (map :db/id (:clients args))]})
|
||||
(:client-id args)
|
||||
(merge-query {:query {:in ['?client-id]
|
||||
:where ['[?e :invoice/client ?client-id]]}
|
||||
@@ -87,14 +84,14 @@
|
||||
(string? (:original-id args)) Long/parseLong )]})
|
||||
|
||||
(:start (:date-range args)) (merge-query {:query {:in '[?start-date]
|
||||
:where ['[?e :invoice/date ?date]
|
||||
'[(>= ?date ?start-date)]]}
|
||||
:args [(coerce/to-date (:start (:date-range args)))]})
|
||||
:where ['[?e :invoice/date ?date]
|
||||
'[(>= ?date ?start-date)]]}
|
||||
:args [(coerce/to-date (:start (:date-range args)))]})
|
||||
|
||||
(:end (:date-range args)) (merge-query {:query {:in '[?end-date]
|
||||
:where ['[?e :invoice/date ?date]
|
||||
'[(<= ?date ?end-date)]]}
|
||||
:args [(coerce/to-date (:end (:date-range args)))]})
|
||||
:where ['[?e :invoice/date ?date]
|
||||
'[(<= ?date ?end-date)]]}
|
||||
:args [(coerce/to-date (:end (:date-range args)))]})
|
||||
|
||||
(:start (:due-range args)) (merge-query {:query {:in '[?start-due]
|
||||
:where ['[?e :invoice/due ?due]
|
||||
|
||||
@@ -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]]}
|
||||
|
||||
@@ -21,10 +21,10 @@
|
||||
:args [db]}
|
||||
|
||||
|
||||
(:client-id args)
|
||||
(merge-query {:query {:in ['?client-id]
|
||||
:where ['[?e :report/client ?client-id]]}
|
||||
:args [(:client-id args)]})
|
||||
(seq (:clients args))
|
||||
(merge-query {:query {:in ['[?xx ...]]
|
||||
:where ['[?e :report/client ?xx]]}
|
||||
:args [(set (map :db/id (:clients args)))]})
|
||||
|
||||
(limited-clients (:id args))
|
||||
(merge-query {:query {:in ['[?xx ...]]
|
||||
|
||||
@@ -57,7 +57,7 @@
|
||||
{:charge/processor [:db/ident]} {:expected-deposit/_charges [:db/id]}]}])
|
||||
|
||||
(defn raw-graphql-ids [db args]
|
||||
(let [visible-clients (visible-clients (:id args))
|
||||
(let [visible-clients (set (map :db/id (:clients args)))
|
||||
selected-clients (->> (cond
|
||||
(:client-id args)
|
||||
(set/intersection #{(:client-id args)}
|
||||
|
||||
@@ -50,15 +50,10 @@
|
||||
"amount-gte" ['[?e :transaction-rule/amount-gte ?sort-amount-gte]]}
|
||||
args)
|
||||
|
||||
(limited-clients (:id args))
|
||||
(merge-query {:query {:in ['[?xx ...]]
|
||||
(seq (:clients args))
|
||||
(merge-query {:query {:in ['[?xx ...]]
|
||||
:where ['[?e :transaction-rule/client ?xx]]}
|
||||
:args [(set (map :db/id (limited-clients (:id args))))]})
|
||||
|
||||
(:client-id args)
|
||||
(merge-query {:query {:in ['?client-id]
|
||||
:where ['[?e :transaction-rule/client ?client-id]]}
|
||||
:args [(:client-id args)]})
|
||||
:args [(set (map :db/id (:clients args)))]})
|
||||
|
||||
(:vendor-id args)
|
||||
(merge-query {:query {:in ['?vendor-id]
|
||||
|
||||
@@ -45,14 +45,11 @@
|
||||
query
|
||||
(if (:exact-match-id args)
|
||||
(cond-> {:query {:find '[?e]
|
||||
:in '[$ ?e]
|
||||
:in '[$ ?e [?c ...]]
|
||||
:where '[[?e :transaction/client ?c]]}
|
||||
:args [db
|
||||
(:exact-match-id args)]}
|
||||
(limited-clients (:id args))
|
||||
(merge-query {:query {:in ['[?xx ...]]
|
||||
:where ['[?e :transaction/client ?xx]]}
|
||||
:args [(set (map :db/id (limited-clients (:id args))))]}))
|
||||
(:exact-match-id args)
|
||||
(map :db/id (:clients args))]})
|
||||
(cond-> {:query {:find []
|
||||
:in ['$ ]
|
||||
:where []}
|
||||
@@ -62,10 +59,10 @@
|
||||
(merge-query {:query {:in '[[?e ...]]}
|
||||
:args [potential-duplicates]})
|
||||
|
||||
(limited-clients (:id args))
|
||||
(seq (:clients args))
|
||||
(merge-query {:query {:in ['[?xx ...]]
|
||||
:where ['[?e :transaction/client ?xx]]}
|
||||
:args [(set (map :db/id (limited-clients (:id args))))]})
|
||||
:args [(set (map :db/id (:clients args)))]})
|
||||
|
||||
(:bank-account-id args)
|
||||
(merge-query {:query {:in ['?bank-account-id]
|
||||
|
||||
@@ -23,10 +23,10 @@
|
||||
:where ['[?e :yodlee-provider-account/id]]}
|
||||
:args [db]}
|
||||
|
||||
(limited-clients (:id args))
|
||||
(merge-query {:query {:in ['[?xx ...]]
|
||||
(seq (:clients args))
|
||||
(merge-query {:query {:in ['[?xx ...]]
|
||||
:where ['[?e :yodlee-provider-account/client ?xx]]}
|
||||
:args [ (set (map :db/id (limited-clients (:id args))))]})
|
||||
:args [(set (map :db/id (:clients args)))]})
|
||||
|
||||
(:client-id args)
|
||||
(merge-query {:query {:in ['?client-id]
|
||||
|
||||
Reference in New Issue
Block a user