allows manually matching rules.

This commit is contained in:
Bryce Covert
2019-05-16 21:39:28 -07:00
parent 93ef07f4b1
commit 486f09fd94
8 changed files with 135 additions and 132 deletions

View File

@@ -7,7 +7,10 @@
[auto-ap.graphql.utils :refer [->graphql <-graphql limited-clients assert-admin result->page snake->kebab]]
[clj-time.coerce :as c]
[clojure.set :as set]
[clojure.string :as str])
[clojure.string :as str]
[auto-ap.datomic.transactions :as d-transactions]
[auto-ap.rule-matching :as rm]
[clj-time.coerce :as coerce])
(:import [java.time.temporal ChronoField]))
(defn ident->enum-f [k]
@@ -21,6 +24,13 @@
(map (ident->enum-f :transaction-rule/transaction-approval-status)))
journal-entries-count :transaction_rules args)))
(defn get-transaction-rule-matches [context args value]
(if (= "admin" (:user/role (:id context)))
(let [all-rules (tr/get-all)
transaction (update (d-transactions/get-by-id (:transaction_id args)) :transaction/date coerce/to-date)]
(map ->graphql (rm/get-matching-rules transaction all-rules)))
nil))
(defn deleted-accounts [transaction accounts]
(let [current-accounts (:transaction-rule/accounts transaction)
specified-ids (->> accounts