adding invoices works correctly again.

This commit is contained in:
Bryce Covert
2018-08-16 19:36:50 -07:00
parent 1208f972ef
commit bcb839aaa8
7 changed files with 123 additions and 79 deletions

View File

@@ -17,9 +17,9 @@
(re-frame/reg-sub
::check-page
::payment-page
(fn [db]
(-> db ::check-page)))
(-> db ::payment-page)))
(re-frame/reg-sub
::params
@@ -44,33 +44,33 @@
(re-frame/reg-event-fx
::void-check
(fn [{:keys [db]} [_ check]]
(fn [{:keys [db]} [_ payment]]
{:graphql
{:token (-> db :user)
:query-obj {:venia/operation {:operation/type :mutation
:operation/name "VoidCheck"}
:operation/name "VoidPayment"}
:venia/queries [{:query/data [:void-check
{:payment-id (:id check)}
:venia/queries [{:query/data [:void-payment
{:payment-id (:id payment)}
[:id :status :amount :check_number :s3_url :date [:vendor [:name :id]] [:client [:name :id]]]]}]}
:on-success [::check-voided]}}))
:on-success [::payment-voided]}}))
(re-frame/reg-event-db
::check-voided
(fn [db [_ {:keys [void-check]}]]
::payment-voided
(fn [db [_ {:keys [void-payment]}]]
(-> db
(update-in [::check-page :payments] (fn [checks]
(update-in [::payment-page :payments] (fn [payments]
(mapv (fn [c]
(if (= (:id c) (:id void-check))
(assoc void-check :class "live-removed")
(if (= (:id c) (:id void-payment))
(assoc void-payment :class "live-removed")
c))
checks))))))
payments))))))
(re-frame/reg-event-db
::received
(fn [db [_ data]]
(-> db
(assoc ::check-page (first (:payment-page data)))
(assoc ::payment-page (first (:payment-page data)))
(assoc-in [:status :loading] false))))
(re-frame/reg-event-fx
@@ -78,15 +78,15 @@
(fn [cofx [_ params]]
{:dispatch [::params-change @(re-frame/subscribe [::params])]}))
(defn check-table [{:keys [id check-page status on-params-change vendors params check-boxes checked on-check-changed expense-event]}]
(defn check-table [{:keys [id payment-page status on-params-change vendors params check-boxes checked on-check-changed expense-event]}]
(let [state (reagent/atom (or @params {}))
selected-company @(re-frame/subscribe [::subs/company])
opc (fn [p]
(swap! state merge p)
(on-params-change p))]
(fn [{:keys [id check-page status on-params-change vendors checked]}]
(fn [{:keys [id payment-page status on-params-change vendors checked]}]
(let [{:keys [sort-by asc]} @state
{:keys [payments start end count total]} @check-page
{:keys [payments start end count total]} @payment-page
selected-company @(re-frame/subscribe [::subs/company])
percentage-size (if selected-company "50%" "33%")]
[:div
@@ -147,7 +147,7 @@
[:tr
[:td {:col-span 5}
[:i.fa.fa-spin.fa-spinner]]]
(for [{:keys [client s3-url payments type check-number date amount id vendor status] :as i} (:payments @check-page)]
(for [{:keys [client s3-url payments type check-number date amount id vendor status] :as i} (:payments @payment-page)]
^{:key id}
[:tr {:class (:class i)}
@@ -179,9 +179,9 @@
(let [current-company @(re-frame/subscribe [::subs/company])]
[:div
[:h1.title "Checks"]
[check-table {:id :checks
[check-table {:id :payments
:params (re-frame/subscribe [::params])
:check-page (re-frame/subscribe [::check-page])
:payment-page (re-frame/subscribe [::payment-page])
:status (re-frame/subscribe [::subs/status])
:on-params-change (fn [params]
(re-frame/dispatch [::params-change params]))}]]))