changes for running.
This commit is contained in:
@@ -188,7 +188,12 @@
|
||||
:color :primary}
|
||||
"New Transaction Rule")])
|
||||
:row-buttons (fn [request entity]
|
||||
[(com/icon-button {:hx-get (str (bidi/path-for ssr-routes/only-routes
|
||||
[
|
||||
(com/icon-button {:hx-get (str (bidi/path-for ssr-routes/only-routes
|
||||
:admin-transaction-rule-execute-results
|
||||
:db/id (:db/id entity)))}
|
||||
svg/play)
|
||||
(com/icon-button {:hx-get (str (bidi/path-for ssr-routes/only-routes
|
||||
:admin-transaction-rule-edit-dialog
|
||||
:db/id (:db/id entity)))}
|
||||
svg/pencil)])
|
||||
@@ -304,15 +309,18 @@
|
||||
:transaction/description-original
|
||||
[:transaction/date :xform clj-time.coerce/from-date]])
|
||||
|
||||
(defn transaction-rule-test [{:keys [form-params request-method identity] :as request
|
||||
{:transaction-rule/keys [description client bank-account amount-lte amount-gte dom-lte dom-gte yodlee-merchant]} :form-params}]
|
||||
(validate-transaction-rule form-params)
|
||||
(let [valid-clients (extract-client-ids (:clients request)
|
||||
|
||||
(defn transaction-rule-test-table* [{{:transaction-rule/keys [description client bank-account amount-lte amount-gte dom-lte dom-gte yodlee-merchant]}
|
||||
:entity
|
||||
clients :clients
|
||||
checkboxes? :checkboxes?}]
|
||||
(let [valid-clients (extract-client-ids clients
|
||||
client)
|
||||
|
||||
query (cond-> {:query {:find ['(pull ?e read)]
|
||||
:in ['$ 'read]
|
||||
:where []}
|
||||
:args [(dc/db conn) transaction-read]}
|
||||
:in ['$ 'read]
|
||||
:where []}
|
||||
:args [(dc/db conn) transaction-read]}
|
||||
description
|
||||
(merge-query {:query {:in ['?descr]
|
||||
:where ['[(iol-ion.query/->pattern ?descr) ?description-regex]]}
|
||||
@@ -358,52 +366,60 @@
|
||||
'[(>= ?dom ?dom-gte)]]}
|
||||
:args [dom-gte]})
|
||||
|
||||
client
|
||||
(merge-query {:query {:in ['?client-id]
|
||||
:where ['[?e :transaction/client ?client-id]]}
|
||||
:args [client]})
|
||||
|
||||
|
||||
true
|
||||
(merge-query {:query {:where ['[?e :transaction/id]]}}))
|
||||
results (->>
|
||||
(query2 query)
|
||||
(map first))]
|
||||
|
||||
(html-response
|
||||
(com/stacked-modal-card
|
||||
1
|
||||
{}
|
||||
[:div.p-2.flex.space-x-4 [:div "Transaction Rule"] [:div ">"] [:div "Results"] [:div.ml-4.relative (com/badge {} (count results))]]
|
||||
(com/data-grid
|
||||
{:headers [(com/data-grid-header {} "Client")
|
||||
(com/data-grid-header {} "Bank")
|
||||
(com/data-grid-header {} "Date")
|
||||
(com/data-grid-header {} "Description")]}
|
||||
(for [r (take 15 results)]
|
||||
(com/data-grid-row
|
||||
{}
|
||||
(com/data-grid-cell {} (-> r :transaction/client :client/name))
|
||||
(com/data-grid-cell {} (-> r :transaction/bank-account :bank-account/name))
|
||||
(com/data-grid-cell {} (some-> r :transaction/date (atime/unparse-local atime/normal-date)))
|
||||
(com/data-grid-cell {} (some-> r :transaction/description-original )))))
|
||||
[:div.flex.justify-between
|
||||
|
||||
(com/button {"@click" "$dispatch('modalpop')"
|
||||
:class "w-32"}
|
||||
"Back")
|
||||
(com/button (cond-> {:color :primary
|
||||
:hx-vals (hx/json (:raw-form-params request))
|
||||
:class "w-32"
|
||||
}
|
||||
(:db/id form-params) (assoc :hx-put (bidi/path-for ssr-routes/only-routes :admin-transaction-rule-save))
|
||||
(not (:db/id form-params)) (assoc :hx-post (bidi/path-for ssr-routes/only-routes :admin-transaction-rule-save)))
|
||||
"Save rule")
|
||||
])
|
||||
:headers (-> {}
|
||||
(assoc "hx-trigger-after-settle" "modalnext")
|
||||
(assoc "hx-retarget" ".modal-stack")
|
||||
(assoc "hx-reswap" "beforeend")))))
|
||||
[:div
|
||||
[:h2.my-4.text-lg.flex "Matching transactions" [:div.ml-4.relative (com/badge {:class "text-[0.6rem]"} (let [cnt (count results)]
|
||||
(if (>= cnt 99)
|
||||
"99+"
|
||||
cnt)))]]
|
||||
(com/data-grid
|
||||
{:headers [(when checkboxes?
|
||||
(com/data-grid-checkbox-header {}))
|
||||
(com/data-grid-header {} "Client")
|
||||
(com/data-grid-header {} "Bank")
|
||||
(com/data-grid-header {} "Date")
|
||||
(com/data-grid-header {} "Description")]}
|
||||
(for [r (take 15 results)]
|
||||
(com/data-grid-row
|
||||
{}
|
||||
(when checkboxes?
|
||||
(com/data-grid-cell {} (com/checkbox {})))
|
||||
(com/data-grid-cell {} (-> r :transaction/client :client/name))
|
||||
(com/data-grid-cell {} (-> r :transaction/bank-account :bank-account/name))
|
||||
(com/data-grid-cell {} (some-> r :transaction/date (atime/unparse-local atime/normal-date)))
|
||||
(com/data-grid-cell {} (some-> r :transaction/description-original )))))]))
|
||||
|
||||
(defn transaction-rule-test [{:keys [form-params request-method identity] :as request
|
||||
entity :form-params}]
|
||||
(validate-transaction-rule form-params)
|
||||
(html-response
|
||||
(com/stacked-modal-card
|
||||
1
|
||||
{}
|
||||
[:div.p-2.flex.space-x-4 [:div "Transaction Rule"] [:div ">"] [:div "Results"] [:div.ml-4.relative (com/badge {} 100 #_(count results))]]
|
||||
(transaction-rule-test-table* {:entity entity
|
||||
:clients (:clients request)})
|
||||
[:div.flex.justify-between
|
||||
|
||||
(com/button {"@click" "$dispatch('modalpop')"
|
||||
:class "w-32"}
|
||||
"Back")
|
||||
(com/button (cond-> {:color :primary
|
||||
:hx-vals (hx/json (:raw-form-params request))
|
||||
:class "w-32"
|
||||
}
|
||||
(:db/id form-params) (assoc :hx-put (bidi/path-for ssr-routes/only-routes :admin-transaction-rule-save))
|
||||
(not (:db/id form-params)) (assoc :hx-post (bidi/path-for ssr-routes/only-routes :admin-transaction-rule-save)))
|
||||
"Save rule")])
|
||||
:headers (-> {}
|
||||
(assoc "hx-trigger-after-settle" "modalnext")
|
||||
(assoc "hx-retarget" ".modal-stack")
|
||||
(assoc "hx-reswap" "beforeend"))))
|
||||
|
||||
|
||||
|
||||
@@ -502,18 +518,20 @@
|
||||
(fc/start-form form-params form-errors
|
||||
(com/modal
|
||||
{:modal-class "max-w-2xl"
|
||||
:hx-target "this"}
|
||||
:hx-target "this"
|
||||
}
|
||||
|
||||
(com/stacked-modal-card
|
||||
0
|
||||
{}
|
||||
[:div.flex [:div.p-2 "Transaction Rule"]]
|
||||
[:form#my-form {:hx-ext "response-targets"
|
||||
:hx-target-400 "#form-errors .error-content"
|
||||
:x-trap "true"
|
||||
(if (:db/id entity)
|
||||
:hx-put
|
||||
:hx-post) (str (bidi/path-for ssr-routes/only-routes :admin-transaction-rule-edit-save))}
|
||||
:hx-target-400 "#form-errors .error-content"
|
||||
:hx-indicator "#submit"
|
||||
:x-trap "true"
|
||||
(if (:db/id entity)
|
||||
:hx-put
|
||||
:hx-post) (str (bidi/path-for ssr-routes/only-routes :admin-transaction-rule-edit-save))}
|
||||
[:fieldset {:class "hx-disable"
|
||||
:x-data (hx/json {:clientId (or (:db/id (:transaction-rule/client form-params))
|
||||
(:transaction-rule/client form-params)
|
||||
@@ -671,6 +689,7 @@
|
||||
|
||||
"Test rule")
|
||||
(com/validated-save-button {:errors form-errors
|
||||
:id "submit"
|
||||
:form "my-form"} "Save rule")]]))))
|
||||
|
||||
|
||||
@@ -732,6 +751,22 @@
|
||||
{})
|
||||
:form-errors form-errors})))
|
||||
|
||||
(defn transaction-rule-execute-results [{:keys [entity clients]}]
|
||||
(modal-response
|
||||
(com/modal{}
|
||||
(com/stacked-modal-card
|
||||
0
|
||||
{}
|
||||
[:div.p-2.flex.space-x-4 [:div "Transaction Rule"] [:div ">"] [:div "Results"]]
|
||||
(transaction-rule-test-table* {:entity entity
|
||||
:clients clients
|
||||
:checkboxes? true})
|
||||
[:div.flex.justify-end (com/validated-save-button {:form "my-form"} "Code transactions")]))
|
||||
:headers (-> {}
|
||||
(assoc "hx-trigger-after-settle" "modalnext")
|
||||
(assoc "hx-retarget" ".modal-stack")
|
||||
(assoc "hx-reswap" "beforeend"))))
|
||||
|
||||
|
||||
|
||||
(def key->handler
|
||||
@@ -773,6 +808,10 @@
|
||||
(wrap-nested-form-params)
|
||||
(wrap-form-4xx-2 (-> transaction-dialog
|
||||
(wrap-entity [:form-params :db/id] default-read))))
|
||||
|
||||
:admin-transaction-rule-execute-results (-> transaction-rule-execute-results
|
||||
(wrap-entity [:route-params :db/id] default-read)
|
||||
(wrap-schema-decode :route-schema [:map [:db/id entity-id]]))
|
||||
:admin-transaction-rule-filled-account (-> transaction-dialog
|
||||
(wrap-entity [:form-params :db/id] default-read)
|
||||
(wrap-schema-decode :form-schema form-schema)
|
||||
|
||||
Reference in New Issue
Block a user