added ability to void invoices.

This commit is contained in:
Bryce Covert
2018-07-25 16:28:24 -07:00
parent 2cb540c1fa
commit 581e5e8798
6 changed files with 69 additions and 5 deletions

View File

@@ -278,6 +278,25 @@
[:expense_account [:id :name [:parent [:id :name]]]]]]]]}]}
:on-success [::invoice-edited]}})))
(re-frame/reg-event-fx
::void-invoice
(fn [{:keys [db]} [_ {id :id}]]
{:graphql
{:token (-> db :user)
:query-obj {:venia/operation {:operation/type :mutation
:operation/name "VoidInvoice"}
:venia/queries [{:query/data [:void-invoice
{:invoice-id id}
[:id :total :outstanding-balance :date :invoice-number
[:company [:id :name :locations]]
[:vendor [:id :name]]
[:expense_accounts [:amount :id :expense_account_id
:location
[:expense_account [:id :name [:parent [:id :name]]]]]]]]}]}
:on-success [::invoice-voided]}}))
(re-frame/reg-event-fx
::handwrite-checks-save
(fn [{:keys [db]} _]
@@ -334,6 +353,17 @@
i)) is)))
(dissoc ::edit-invoice))}))
(re-frame/reg-event-fx
::invoice-voided
(fn [{:keys [db]} [_ {:keys [void-invoice]}]]
{:db (-> db
(update-in [::invoice-page :invoices]
(fn [is]
(mapv (fn [i]
(if (= (:id i) (:id void-invoice))
(assoc void-invoice :class "live-removed")
i)) is))))}))
(re-frame/reg-event-fx
::change-expense-accounts
(fn [{:keys [db]} [_ id]]
@@ -755,6 +785,9 @@
:status (re-frame/subscribe [::subs/status])
:on-edit-invoice (fn [which]
(re-frame/dispatch [::edit-invoice which]))
:on-void-invoice (fn [which]
(re-frame/dispatch [::void-invoice which]))
:on-params-change (fn [params]
(re-frame/dispatch [::params-change params]))
:check-boxes true