You can now run the rule on a bunch of transactions.
This commit is contained in:
@@ -178,7 +178,7 @@
|
||||
[(forms/triggers-stop-loading ::form)]
|
||||
(fn [{:keys [db]} [_ result]]
|
||||
|
||||
{:dispatch [::results-modal/opening (:test-transaction-rule result) false]}))
|
||||
{:dispatch [::results-modal/opening (:test-transaction-rule result) nil false]}))
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -2,7 +2,8 @@
|
||||
(:require [auto-ap.events :as events]
|
||||
[auto-ap.subs :as subs]
|
||||
[auto-ap.views.components.modal :refer [modal]]
|
||||
[auto-ap.views.utils :refer [date->str dispatch-event]]
|
||||
[auto-ap.views.utils :refer [date->str dispatch-event with-user]]
|
||||
[auto-ap.views.pages.transactions.common :refer [transaction-read]]
|
||||
[re-frame.core :as re-frame]))
|
||||
|
||||
|
||||
@@ -30,9 +31,10 @@
|
||||
|
||||
(re-frame/reg-event-fx
|
||||
::opening
|
||||
(fn [{:keys [db]} [_ results runnable?]]
|
||||
(fn [{:keys [db]} [_ results transaction-rule-id runnable?]]
|
||||
{:db (-> db
|
||||
(assoc ::test-results results)
|
||||
(assoc ::transaction-rule-id transaction-rule-id)
|
||||
(assoc ::checked #{})
|
||||
(assoc ::runnable? runnable?))
|
||||
:dispatch [::events/modal-status ::test-results {:visible? true}]}))
|
||||
@@ -46,8 +48,23 @@
|
||||
(disj checked which)
|
||||
(conj checked which)))))
|
||||
|
||||
(re-frame/reg-event-fx
|
||||
::apply-rule
|
||||
[with-user]
|
||||
(fn [{:keys [db user]} [_ params]]
|
||||
{:graphql
|
||||
{:token user
|
||||
:query-obj {:venia/operation {:operation/type :mutation
|
||||
:operation/name "MatchTransactionRules"}
|
||||
:venia/queries [{:query/data [:match-transaction-rules
|
||||
{:transaction-ids (seq @(re-frame/subscribe [::checked]))
|
||||
:transaction-rule-id (::transaction-rule-id db)}
|
||||
transaction-read]}]}
|
||||
#_#_:on-success [:edited params]
|
||||
#_#_:on-error [:forms/save-error ::form]}}))
|
||||
|
||||
(defn test-results-modal []
|
||||
|
||||
(defn test-results-modal [params]
|
||||
(let [runnable? @(re-frame/subscribe [::runnable?])
|
||||
checked @(re-frame/subscribe [::checked])
|
||||
checked-count @(re-frame/subscribe [::checked-count])]
|
||||
@@ -55,7 +72,8 @@
|
||||
[modal {:title "Rule results"
|
||||
:hide-event [::events/modal-status ::test-results {:visible? false}]
|
||||
:foot (when runnable?
|
||||
[:button.button.is-primary {:disabled (boolean (= checked-count 0))}
|
||||
[:button.button.is-primary {:disabled (boolean (= checked-count 0))
|
||||
:on-click (dispatch-event [::apply-rule params])}
|
||||
(str "Apply to " checked-count " transactions")])}
|
||||
[:table.table.is-fullwidth.compact
|
||||
[:tr
|
||||
|
||||
@@ -23,14 +23,14 @@
|
||||
[:client [:name]]
|
||||
[:bank-account [:name]]
|
||||
:description-original]]}]}
|
||||
:on-success [::succeeded-run]
|
||||
:on-success [::succeeded-run (:id which)]
|
||||
#_#_:on-error [:forms/save-error ::form]}}))
|
||||
|
||||
|
||||
(re-frame/reg-event-fx
|
||||
::succeeded-run
|
||||
(fn [{:keys [db]} [_ result]]
|
||||
{:dispatch [::results-modal/opening (:run-transaction-rule result) true]}))
|
||||
(fn [{:keys [db]} [_ transaction-rule-id result]]
|
||||
{:dispatch [::results-modal/opening (:run-transaction-rule result) transaction-rule-id true]}))
|
||||
|
||||
(defn table [{:keys [id rule-page on-params-change params status]}]
|
||||
(let [opc (fn [p]
|
||||
|
||||
@@ -107,9 +107,9 @@
|
||||
{:graphql
|
||||
{:token user
|
||||
:query-obj {:venia/operation {:operation/type :mutation
|
||||
:operation/name "MatchTransactionRule"}
|
||||
:venia/queries [{:query/data [:match-transaction-rule
|
||||
{:transaction-id id
|
||||
:operation/name "MatchTransactionRules"}
|
||||
:venia/queries [{:query/data [:match-transaction-rules
|
||||
{:transaction-ids [id]
|
||||
:transaction-rule-id transaction-rule-id}
|
||||
transaction-read]}]}
|
||||
:on-success [::edited params]
|
||||
@@ -118,8 +118,8 @@
|
||||
(re-frame/reg-event-fx
|
||||
::edited
|
||||
[(forms/triggers-stop ::form)]
|
||||
(fn [{:keys [db]} [_ {:keys [edit-completed]} {:keys [edit-transaction match-transaction match-transaction-rule]}]]
|
||||
{:dispatch (conj edit-completed (or edit-transaction match-transaction match-transaction-rule))}))
|
||||
(fn [{:keys [db]} [_ {:keys [edit-completed]} {:keys [edit-transaction match-transaction match-transaction-rules]}]]
|
||||
{:dispatch (conj edit-completed (or edit-transaction match-transaction (first match-transaction-rules)))}))
|
||||
|
||||
(re-frame/reg-event-db
|
||||
::manual-match
|
||||
|
||||
Reference in New Issue
Block a user