check printing
This commit is contained in:
36
src/clj/auto_ap/datomic/bank_accounts.clj
Normal file
36
src/clj/auto_ap/datomic/bank_accounts.clj
Normal file
@@ -0,0 +1,36 @@
|
||||
(ns auto-ap.datomic.bank-accounts
|
||||
(:require [datomic.api :as d]
|
||||
[auto-ap.datomic :refer [uri]]
|
||||
[clj-time.coerce :as c]
|
||||
[clojure.set :refer [rename-keys]]))
|
||||
|
||||
(defn add-arg [query name value where & rest]
|
||||
(let [query (-> query
|
||||
(update :args conj value)
|
||||
(update-in [:query :in] conj name)
|
||||
(update-in [:query :where] conj where))]
|
||||
(reduce #(update-in %1 [:query :where] conj %2) query rest)))
|
||||
|
||||
(def default-read '(pull ?e [*]))
|
||||
|
||||
(defn <-datomic [x]
|
||||
(->> x
|
||||
(map #(update % :bank-account/type :db/ident))
|
||||
))
|
||||
|
||||
|
||||
|
||||
(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])))
|
||||
(map first)
|
||||
(<-datomic)
|
||||
(first)))
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -14,3 +14,16 @@
|
||||
(map (fn [ba]
|
||||
(update ba :bank-account/type :db/ident ))
|
||||
bas)))))))
|
||||
|
||||
(defn get-by-id [id]
|
||||
(->>
|
||||
(d/query (-> {:query {:find ['(pull ?e [*])]
|
||||
:in ['$ '?e]
|
||||
:where [['?e]]}
|
||||
:args [(d/db (d/connect uri)) (cond-> id (string? id) Long/parseLong)]}
|
||||
))
|
||||
(first)
|
||||
(first)
|
||||
#_(map first)
|
||||
|
||||
#_(first)))
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
|
||||
(defn <-datomic [x]
|
||||
(->> x
|
||||
(map first)
|
||||
|
||||
|
||||
(map #(update % :invoice/date c/from-date))
|
||||
(map #(update % :invoice/status :db/ident))
|
||||
@@ -42,6 +42,7 @@
|
||||
'[?c :client/original-id ?original-id])
|
||||
(:status args) (add-arg '?status (keyword "invoice-status" (:status args))
|
||||
'[?e :invoice/status ?status])))
|
||||
(map first)
|
||||
(<-datomic)))
|
||||
|
||||
(defn sort-fn [args]
|
||||
@@ -75,9 +76,23 @@
|
||||
:where []}
|
||||
:args [(d/db (d/connect uri))]}
|
||||
(add-arg '?e (cond-> id (string? id) Long/parseLong) ['?e])))
|
||||
(map first)
|
||||
(<-datomic)
|
||||
(first)))
|
||||
|
||||
(defn get-multi [ids]
|
||||
(->>
|
||||
(d/query {:query {:find [[default-read '...]]
|
||||
:in ['$ ['?e '...]]
|
||||
:where [['?e]]}
|
||||
:args [(d/db (d/connect uri))
|
||||
(mapv #(cond-> % (string? %) Long/parseLong)
|
||||
ids)] }
|
||||
|
||||
|
||||
)
|
||||
(<-datomic)))
|
||||
|
||||
(defn find-conflicting [{:keys [:invoice/invoice-number :invoice/vendor :invoice/client]}]
|
||||
(->> (d/query
|
||||
(cond-> {:query {:find [default-read]
|
||||
|
||||
Reference in New Issue
Block a user