Makes it possible to bulk change invoices
This commit is contained in:
@@ -6,6 +6,7 @@
|
||||
[auto-ap.status :as status]
|
||||
[auto-ap.subs :as subs]
|
||||
[auto-ap.views.components.buttons :as buttons]
|
||||
[auto-ap.views.pages.invoices.bulk-change :as bulk-change]
|
||||
[auto-ap.views.components.dropdown :refer [drop-down]]
|
||||
[auto-ap.views.components.expense-accounts-dialog
|
||||
:as expense-accounts-dialog]
|
||||
@@ -208,18 +209,32 @@
|
||||
"Void"])))
|
||||
|
||||
|
||||
(defn pay-button []
|
||||
(defn pay-button [status]
|
||||
(let [current-client @(re-frame/subscribe [::subs/client])
|
||||
checked-invoices @(re-frame/subscribe [::data-page/checked :invoices])
|
||||
print-checks-status @(re-frame/subscribe [::status/single ::print-checks])]
|
||||
is-admin? @(re-frame/subscribe [::subs/is-admin?])
|
||||
print-checks-status @(re-frame/subscribe [::status/single ::print-checks])
|
||||
params @(re-frame/subscribe [::data-page/params :invoices])
|
||||
{:keys [total]} @(re-frame/subscribe [::data-page/data :invoices])
|
||||
]
|
||||
[:div.buttons
|
||||
[void-selected-button]
|
||||
(when (and (= :unpaid status)
|
||||
is-admin?)
|
||||
[void-selected-button])
|
||||
|
||||
[buttons/new-button {:event [::new-invoice-clicked]
|
||||
:name "Invoice"
|
||||
:class "is-primary"}]
|
||||
|
||||
(when current-client
|
||||
|
||||
(when (and is-admin?
|
||||
current-client)
|
||||
[buttons/event-button {:event [::bulk-change/bulk-change-requested checked-invoices params total]
|
||||
:name "Bulk Edit"
|
||||
:class "is-secondary"
|
||||
:disabled (not (seq checked-invoices))}])
|
||||
|
||||
(when (and current-client
|
||||
(= :unpaid status))
|
||||
(let [balance (->> checked-invoices
|
||||
vals
|
||||
(map (comp js/parseFloat :outstanding-balance))
|
||||
@@ -284,11 +299,10 @@
|
||||
|
||||
[table/invoice-table {:id (:id page)
|
||||
:data-page :invoices
|
||||
:check-boxes (= status :unpaid)
|
||||
:check-boxes true
|
||||
:checkable-fn (fn [i] (not (:scheduled-payment i)))
|
||||
:actions #{:edit :void :expense-accounts}
|
||||
:action-buttons (when (= status :unpaid)
|
||||
[pay-button])}]]))
|
||||
:action-buttons [pay-button status]}]]))
|
||||
|
||||
(defn layout [params]
|
||||
(let [{invoice-bar-active? :active?} @(re-frame/subscribe [::forms/form ::form/form])]
|
||||
|
||||
Reference in New Issue
Block a user