Supports editing the approval status.
This commit is contained in:
@@ -9,10 +9,16 @@
|
||||
[clojure.set :as set])
|
||||
(:import [java.time.temporal ChronoField]))
|
||||
|
||||
(defn ident->enum-f [k]
|
||||
#(update % k
|
||||
(fn [value] (some-> value :db/ident name keyword))))
|
||||
|
||||
(defn get-transaction-rule-page [context args value]
|
||||
(let [args (assoc args :id (:id context))
|
||||
[journal-entries journal-entries-count] (tr/get-graphql (<-graphql args))]
|
||||
(result->page journal-entries journal-entries-count :transaction_rules args)))
|
||||
(result->page (->> journal-entries
|
||||
(map (ident->enum-f :transaction-rule/transaction-approval-status)))
|
||||
journal-entries-count :transaction_rules args)))
|
||||
|
||||
(defn deleted-accounts [transaction accounts]
|
||||
(let [current-accounts (:transaction-rule/accounts transaction)
|
||||
@@ -30,7 +36,7 @@
|
||||
:account account_id
|
||||
:location location}))
|
||||
;; TODO ASSERT ADMIN
|
||||
(defn upsert-transaction-rule [context {{:keys [id description note client_id bank_account_id amount_lte amount_gte vendor_id accounts ]} :transaction_rule :as z} value]
|
||||
(defn upsert-transaction-rule [context {{:keys [id description note client_id bank_account_id amount_lte amount_gte vendor_id accounts transaction_approval_status ]} :transaction_rule :as z} value]
|
||||
#_(assert-admin (:id context))
|
||||
(let [existing-transaction (tr/get-by-id id)
|
||||
deleted (deleted-accounts existing-transaction accounts)
|
||||
@@ -50,6 +56,7 @@
|
||||
:amount-lte amount_lte
|
||||
:amount-gte amount_gte
|
||||
:vendor vendor_id
|
||||
:transaction-approval-status (keyword "transaction-approval-status" (name (<-graphql transaction_approval_status)))
|
||||
:accounts (map transaction-rule-account->entity accounts)})]
|
||||
|
||||
transaction (into transaction
|
||||
@@ -59,6 +66,7 @@
|
||||
transaction-result @(d/transact (d/connect uri) transaction)]
|
||||
(-> (tr/get-by-id (or (-> transaction-result :tempids (get "transaction-rule"))
|
||||
id))
|
||||
((ident->enum-f :transaction-rule/transaction-approval-status))
|
||||
(->graphql))))
|
||||
|
||||
(defn tr [z x]
|
||||
|
||||
Reference in New Issue
Block a user