adding day of month.
This commit is contained in:
@@ -4,7 +4,8 @@
|
||||
[datomic.api :as d]
|
||||
[auto-ap.datomic :refer [remove-nils uri merge-query]]
|
||||
[auto-ap.graphql.utils :refer [->graphql <-graphql limited-clients assert-admin result->page]]
|
||||
[clj-time.coerce :as c]))
|
||||
[clj-time.coerce :as c])
|
||||
(:import [java.time.temporal ChronoField]))
|
||||
|
||||
(defn get-transaction-rule-page [context args value]
|
||||
(let [args (assoc args :id (:id context))
|
||||
@@ -31,7 +32,8 @@
|
||||
(defn tr [z x]
|
||||
(re-find (re-pattern z) x))
|
||||
|
||||
(defn test-transaction-rule [{:keys [id]} {{:keys [description note client_id bank_account_id amount_lte amount_gte ]} :transaction_rule :as z} value]
|
||||
(defn test-transaction-rule [{:keys [id]} {{:keys [description note client_id bank_account_id amount_lte amount_gte dom_lte dom_gte]} :transaction_rule :as z} value]
|
||||
(prn z)
|
||||
(->>
|
||||
(d/query
|
||||
(cond-> {:query {:find ['(pull ?e [* {:transaction/client [:client/name]
|
||||
@@ -69,6 +71,24 @@
|
||||
'[(<= ?ta ?amount-lte)]]}
|
||||
:args [amount_lte]})
|
||||
|
||||
dom_lte
|
||||
(merge-query {:query {:in ['?dom-lte]
|
||||
:where ['[?e :transaction/date ?transaction-date]
|
||||
'[(.toInstant ^java.util.Date ?transaction-date ) ?transaction-instant]
|
||||
'[(.atZone ^java.time.Instant ?transaction-instant (java.time.ZoneId/of "US/Pacific")) ?transaction-local]
|
||||
'[(.get ?transaction-local java.time.temporal.ChronoField/DAY_OF_MONTH) ?dom]
|
||||
'[(<= ?dom ?dom-lte)]]}
|
||||
:args [dom_lte]})
|
||||
|
||||
dom_gte
|
||||
(merge-query {:query {:in ['?dom-gte]
|
||||
:where ['[?e :transaction/date ?transaction-date]
|
||||
'[(.toInstant ^java.util.Date ?transaction-date ) ?transaction-instant]
|
||||
'[(.atZone ^java.time.Instant ?transaction-instant (java.time.ZoneId/of "US/Pacific")) ?transaction-local]
|
||||
'[(.get ?transaction-local java.time.temporal.ChronoField/DAY_OF_MONTH) ?dom]
|
||||
'[(>= ?dom ?dom-gte)]]}
|
||||
:args [dom_gte]})
|
||||
|
||||
client_id
|
||||
(merge-query {:query {:in ['?client-id]
|
||||
:where ['[?e :transaction/client ?client-id]]}
|
||||
|
||||
Reference in New Issue
Block a user