Check matching
This commit is contained in:
@@ -35,11 +35,11 @@
|
||||
;; EVENTS
|
||||
(re-frame/reg-event-fx
|
||||
::edited
|
||||
(fn [{:keys [db]} [_ edit-completed {:keys [edit-transaction]}]]
|
||||
(fn [{:keys [db]} [_ edit-completed {:keys [edit-transaction match-transaction]}]]
|
||||
{:db (-> db
|
||||
(forms/stop-form ::edit-transaction))
|
||||
|
||||
:dispatch (conj edit-completed edit-transaction)}))
|
||||
:dispatch (conj edit-completed (or edit-transaction match-transaction))}))
|
||||
|
||||
(re-frame/reg-event-db
|
||||
::editing
|
||||
@@ -87,6 +87,22 @@
|
||||
:on-success [::edited edit-completed]
|
||||
:on-error [::forms/save-error ::edit-transaction]}}))))
|
||||
|
||||
(re-frame/reg-event-fx
|
||||
::matching
|
||||
(fn [{:keys [db]} [_ edit-completed payment-id]]
|
||||
(let [{{:keys [id ]} :data :as data} @(re-frame/subscribe [::forms/form ::edit-transaction])]
|
||||
{:db (forms/loading db ::edit-transaction )
|
||||
:graphql
|
||||
{:token (-> db :user)
|
||||
:query-obj {:venia/operation {:operation/type :mutation
|
||||
:operation/name "MatchTransaction"}
|
||||
:venia/queries [{:query/data [:match-transaction
|
||||
{:transaction_id id
|
||||
:payment-id payment-id}
|
||||
transaction-read]}]}
|
||||
:on-success [::edited edit-completed]
|
||||
:on-error [::forms/save-error ::edit-transaction]}})))
|
||||
|
||||
(re-frame/reg-event-fx
|
||||
::change-account
|
||||
(fn [{:keys [db]} [_ f a]]
|
||||
@@ -162,12 +178,13 @@
|
||||
|
||||
[:table.table.compact.is-borderless
|
||||
(list
|
||||
(for [{:keys [memo vendor]} (:potential-payment-matches data)]
|
||||
(for [{:keys [memo check-number vendor id]} (:potential-payment-matches data)]
|
||||
[:tr
|
||||
[:td.no-border (:name vendor)]
|
||||
[:td.no-border memo]
|
||||
[:td.no-border (when check-number (str "Check " check-number " ")) memo]
|
||||
[:td.no-border
|
||||
[:a.button.is-primary.is-small "Match"]]]))]
|
||||
[:a.button.is-primary.is-small {:on-click (dispatch-event [::matching edit-completed id])}
|
||||
"Match"]]]))]
|
||||
]
|
||||
[:div
|
||||
[:div.field
|
||||
|
||||
@@ -9,16 +9,12 @@
|
||||
(re-frame/reg-event-fx
|
||||
::editing-matches-found
|
||||
(fn [{:keys [db]} [_ which payment-matches]]
|
||||
(println "FOUND" payment-matches)
|
||||
|
||||
{:dispatch
|
||||
[::edit/editing which (:potential-payment-matches payment-matches)]}))
|
||||
|
||||
(re-frame/reg-event-fx
|
||||
::editing-matches-failed
|
||||
(fn [{:keys [db]} [_ which payment-matches]]
|
||||
(println "FAILED" payment-matches)
|
||||
|
||||
{:dispatch
|
||||
[::edit/editing which payment-matches]}))
|
||||
|
||||
@@ -29,7 +25,7 @@
|
||||
{:token (-> db :user)
|
||||
:query-obj {:venia/queries [{:query/data [:potential-payment-matches
|
||||
{:transaction_id (:id which)}
|
||||
[:id :memo [:vendor [:name]]]]}]}
|
||||
[:id :memo :check-number [:vendor [:name]]]]}]}
|
||||
:on-success [::editing-matches-found which]
|
||||
:on-error [::editing-matches-failed which]}} ))
|
||||
|
||||
|
||||
Reference in New Issue
Block a user