Add the ability to unautopay
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
(:require [auto-ap.events :as events]
|
||||
[auto-ap.routes :as routes]
|
||||
[auto-ap.subs :as subs]
|
||||
[auto-ap.status :as status]
|
||||
[auto-ap.views.components.buttons :as buttons]
|
||||
[auto-ap.views.components.dropdown
|
||||
:refer
|
||||
@@ -90,6 +91,21 @@
|
||||
invoice-read]}]}
|
||||
:on-success (fn [result]
|
||||
[::invoice-updated (:unvoid-invoice result)])}}))
|
||||
(re-frame/reg-event-fx
|
||||
::unautopay
|
||||
(fn [{:keys [db]} [_ {id :id}]]
|
||||
{:graphql
|
||||
{:token (-> db :user)
|
||||
:owns-state {:multi ::unautopay
|
||||
:which id}
|
||||
:query-obj {:venia/operation {:operation/type :mutation
|
||||
:operation/name "UnautopayInvoice"}
|
||||
|
||||
:venia/queries [{:query/data [:unautopay-invoice
|
||||
{:invoice-id id}
|
||||
invoice-read]}]}
|
||||
:on-success (fn [result]
|
||||
[::invoice-updated (:unautopay-invoice result)])}}))
|
||||
|
||||
(re-frame/reg-event-fx
|
||||
::invoice-updated
|
||||
@@ -99,6 +115,7 @@
|
||||
(defn row [{:keys [invoice check-boxes selected-client overrides checkable? expense-event actions]}]
|
||||
(let [{:keys [client status payments expense-accounts invoice-number date due total outstanding-balance id vendor] :as i} invoice
|
||||
accounts-by-id @(re-frame/subscribe [::subs/accounts-by-id client])
|
||||
unautopay-states @(re-frame/subscribe [::status/multi ::unautopay])
|
||||
account->name #(:name (accounts-by-id (:id %)))]
|
||||
[grid/row {:class (:class i) :id id :checkable? checkable? :entity invoice}
|
||||
(when-not selected-client
|
||||
@@ -121,7 +138,11 @@
|
||||
[grid/cell {} (str/join ", " (set (map :location expense-accounts)))]
|
||||
|
||||
[grid/cell {:class "has-text-right"} (nf total )]
|
||||
[grid/cell {:class "has-text-right"} (nf outstanding-balance )]
|
||||
[grid/cell {:class "has-text-right"}
|
||||
(if (:scheduled-payment i)
|
||||
[:<> [:div.tag.is-info.is-light "Autopay"] " "]
|
||||
)
|
||||
(nf outstanding-balance )]
|
||||
[grid/button-cell {}
|
||||
[:div.buttons
|
||||
(when (seq expense-accounts)
|
||||
@@ -185,7 +206,13 @@
|
||||
(when (and (get actions :void)
|
||||
(= ":voided" (:status i)))
|
||||
[buttons/fa-icon {:icon "fa-undo"
|
||||
:event [::unvoid-invoice i]}])]]]))
|
||||
:event [::unvoid-invoice i]}])
|
||||
(when (and (get actions :void)
|
||||
(= ":paid" (:status i))
|
||||
(:scheduled-payment i))
|
||||
[buttons/fa-icon {:icon "fa-undo"
|
||||
:class (status/class-for (get unautopay-states (:id i)))
|
||||
:event [::unautopay i]}])]]]))
|
||||
|
||||
(defn invoice-table [{:keys [id check-boxes overrides actions data-page checkable-fn]}]
|
||||
(let [selected-client @(re-frame/subscribe [::subs/client])
|
||||
|
||||
Reference in New Issue
Block a user