makes check voiding work correctly
This commit is contained in:
@@ -4,6 +4,13 @@
|
||||
[clojure.set :refer [rename-keys]]
|
||||
[clj-time.coerce :as c]))
|
||||
|
||||
(defn <-datomic [results]
|
||||
(->> results
|
||||
(map first)
|
||||
(map #(update % :payment/date c/from-date))
|
||||
(map #(update % :payment/status :db/ident))
|
||||
(map #(rename-keys % {:invoice-payment/_payment :payment/invoices}))))
|
||||
|
||||
(defn add-arg [query name value where & rest]
|
||||
(let [query (-> query
|
||||
(update :args conj value)
|
||||
@@ -11,12 +18,14 @@
|
||||
(update-in [:query :where] conj where))]
|
||||
(reduce #(update-in %1 [:query :where] conj %2) query rest)))
|
||||
|
||||
(def default-read '(pull ?e [*
|
||||
{:invoice-payment/_payment [* {:invoice-payment/invoice [*]}]}
|
||||
{:payment/client [:client/name :db/id]}
|
||||
{:payment/vendor [:vendor/name :db/id]}
|
||||
{:payment/status [:db/ident]}]))
|
||||
|
||||
(defn raw-graphql [args]
|
||||
(let [query (cond-> {:query {:find ['(pull ?e [*
|
||||
{:invoice-payment/_payment [* {:invoice-payment/invoice [*]}]}
|
||||
{:payment/client [:client/name :db/id]}
|
||||
{:payment/vendor [:vendor/name :db/id]}
|
||||
{:payment/status [:db/ident]}])]
|
||||
(let [query (cond-> {:query {:find [default-read]
|
||||
:in ['$]
|
||||
:where ['[?e :payment/original-id]]}
|
||||
:args [(d/db (d/connect uri))]}
|
||||
@@ -29,12 +38,7 @@
|
||||
|
||||
(->> (d/query
|
||||
query)
|
||||
(map first)
|
||||
|
||||
(map #(update % :payment/date c/from-date))
|
||||
(map #(update % :payment/status :db/ident))
|
||||
(map #(rename-keys % {:invoice-payment/_payment :payments/invoices}))
|
||||
#_(map #(update % :transaction/post-date c/from-date)))))
|
||||
(<-datomic))))
|
||||
|
||||
(defn sort-fn [args]
|
||||
(cond
|
||||
@@ -53,6 +57,15 @@
|
||||
true (take (:count args 20)))))
|
||||
|
||||
(defn count-graphql [args]
|
||||
|
||||
(->> (raw-graphql args)
|
||||
(count)))
|
||||
|
||||
(defn get-by-id [id]
|
||||
(->>
|
||||
(d/query (-> {:query {:find [default-read]
|
||||
:in ['$]
|
||||
:where []}
|
||||
:args [(d/db (d/connect uri))]}
|
||||
(add-arg '?e (cond-> id (string? id) Long/parseLong) ['?e])))
|
||||
(<-datomic)
|
||||
(first)))
|
||||
|
||||
Reference in New Issue
Block a user