makes check voiding work correctly

This commit is contained in:
Bryce Covert
2018-08-16 18:51:58 -07:00
parent ad2dd386ee
commit 1208f972ef
5 changed files with 56 additions and 41 deletions

View File

@@ -51,15 +51,15 @@
:operation/name "VoidCheck"}
:venia/queries [{:query/data [:void-check
{:check-id (:id check)}
[:id :status :amount :check_number :s3_url :date [:vendor [:name :id]] [:company [:name :id]]]]}]}
{:payment-id (:id check)}
[:id :status :amount :check_number :s3_url :date [:vendor [:name :id]] [:client [:name :id]]]]}]}
:on-success [::check-voided]}}))
(re-frame/reg-event-db
::check-voided
(fn [db [_ {:keys [void-check]}]]
(-> db
(update-in [::check-page :checks] (fn [checks]
(update-in [::check-page :payments] (fn [checks]
(mapv (fn [c]
(if (= (:id c) (:id void-check))
(assoc void-check :class "live-removed")
@@ -162,8 +162,8 @@
[:td (gstring/format "$%.2f" amount )]
[:td status]
[:td
(when (or (= "pending" status)
(#{"cash" "debit"} type))
(when (or (= ":pending" status)
(#{":cash" ":debit"} type))
[:button.button.is-warning.is-outlined {:on-click (dispatch-event [::void-check i])} [:span [:span.icon [:i.fa.fa-minus-circle]]]])
(if s3-url
[:a.tag {:href s3-url :target "_new"} [:i.fa.fa-money-check] [:span.icon [:i.fa.fa-money]] (str " " check-number " (" (gstring/format "$%.2f" amount ) ")")]