Should fix most of the authentication issues
This commit is contained in:
@@ -6,31 +6,33 @@
|
||||
apply-sort-3
|
||||
conn
|
||||
merge-query
|
||||
pull-many
|
||||
query2]]
|
||||
observable-query
|
||||
pull-many]]
|
||||
[auto-ap.datomic.accounts :as d-accounts]
|
||||
[auto-ap.graphql.utils :refer [limited-clients]]
|
||||
[clj-time.coerce :as c]
|
||||
[auto-ap.graphql.utils :refer [extract-client-ids]]
|
||||
[clj-time.coerce :as coerce]
|
||||
[datomic.api :as dc]))
|
||||
|
||||
(defn raw-graphql-ids [db args]
|
||||
(let [query
|
||||
(let [valid-clients (extract-client-ids (:clients args)
|
||||
(:client-id args)
|
||||
(when (:client-code args)
|
||||
[:client/code (:client-code args)]))
|
||||
query
|
||||
(if (:exact-match-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))]}
|
||||
valid-clients]}
|
||||
(cond-> {:query {:find []
|
||||
:in ['$ ]
|
||||
:where []}
|
||||
:args [db]}
|
||||
|
||||
true
|
||||
(merge-query {:query {:in ['[?xx ...]]
|
||||
:where ['[?e :journal-entry/client ?xx]]}
|
||||
:args [(set (map :db/id (:clients args)))]})
|
||||
:in ['$ '[?clients ?start ?end]]
|
||||
:where '[[(iol-ion.query/scan-ledger $ ?clients ?start ?end) [[?e _ ?sort-default] ...]]]}
|
||||
:args [db
|
||||
[valid-clients
|
||||
(some-> (:start (:date-range args)) coerce/to-date)
|
||||
(some-> (:end (:date-range args)) coerce/to-date)]]}
|
||||
|
||||
(:only-external args)
|
||||
(merge-query {:query {:where ['(not [?e :journal-entry/original-entity ])]}})
|
||||
@@ -51,23 +53,6 @@
|
||||
:where ['[?e :journal-entry/vendor ?vendor-id]]}
|
||||
:args [(:vendor-id args)]})
|
||||
|
||||
(:client-code args)
|
||||
(merge-query {:query {:in ['?client-code]
|
||||
:where ['[?e :journal-entry/client ?client-id]
|
||||
'[?client-id :client/code ?client-code]]}
|
||||
:args [(:client-code args)]})
|
||||
|
||||
(:start (:date-range args))
|
||||
(merge-query {:query {:in ['?start-date]
|
||||
:where ['[?e :journal-entry/date ?date]
|
||||
'[(>= ?date ?start-date)]]}
|
||||
:args [(c/to-date (:start (:date-range args)))]})
|
||||
|
||||
(:end (:date-range args))
|
||||
(merge-query {:query {:in ['?end-date]
|
||||
:where ['[?e :journal-entry/date ?date]
|
||||
'[(<= ?date ?end-date)]]}
|
||||
:args [(c/to-date (:end (:date-range args)))]})
|
||||
|
||||
(or (seq (:numeric-code args))
|
||||
(:bank-account-id args)
|
||||
@@ -130,8 +115,8 @@
|
||||
args)
|
||||
|
||||
true
|
||||
(merge-query {:query {:find ['?sort-default '?e] :where ['[?e :journal-entry/date ?sort-default]]}})))]
|
||||
(->> (query2 query)
|
||||
(merge-query {:query {:find ['?sort-default '?e]}})))]
|
||||
(->> (observable-query query)
|
||||
(apply-sort-3 (update args :sort conj {:sort-key "default-2" :asc true}))
|
||||
(apply-pagination args))))
|
||||
|
||||
@@ -144,7 +129,7 @@
|
||||
{:account-client-override/client [:db/id]}]}
|
||||
{:bank-account/type [*]}]}]}]
|
||||
ids)
|
||||
(map #(update % :journal-entry/date c/from-date))
|
||||
(map #(update % :journal-entry/date coerce/from-date))
|
||||
(map (fn [je]
|
||||
(update je :journal-entry/line-items
|
||||
(fn [jels]
|
||||
|
||||
Reference in New Issue
Block a user