you can choose a bank account to print.
This commit is contained in:
@@ -46,18 +46,27 @@
|
||||
(disj x data)
|
||||
(conj x data)))))))
|
||||
|
||||
(re-frame/reg-event-db
|
||||
::print-checks-clicked
|
||||
(fn [db _]
|
||||
(update-in db [::invoice-page :print-checks-shown?] #(not %) )))
|
||||
|
||||
(re-frame/reg-event-fx
|
||||
::print-checks
|
||||
(fn [{:keys [db]} [_ data]]
|
||||
{:graphql
|
||||
(fn [{:keys [db]} [_ bank-account-id]]
|
||||
{
|
||||
:db (assoc-in db [::invoice-page :print-checks-shown?] false )
|
||||
:graphql
|
||||
{:token (-> db :user)
|
||||
|
||||
:query-obj {:venia/operation {:operation/type :mutation
|
||||
:operation/name "PrintChecks"}
|
||||
|
||||
:venia/queries [[:print-checks
|
||||
{:invoice_ids (vec (get-in db [::invoice-page :checked]))}
|
||||
[[:invoices [:id [:checks [:amount [:check [:amount :s3_url :check_number ]]]]]
|
||||
]
|
||||
{:invoice_ids (vec (get-in db [::invoice-page :checked]))
|
||||
:bank_account_id bank-account-id
|
||||
:company_id (:company db)}
|
||||
[[:invoices [:id [:checks [:amount [:check [:amount :s3_url :check_number ]]]]]]
|
||||
:pdf_url]]]}
|
||||
|
||||
:on-success [::checks-created]}}))
|
||||
@@ -88,17 +97,27 @@
|
||||
(def unpaid-invoices-page
|
||||
(with-meta
|
||||
(fn []
|
||||
(let [checked (:checked @(re-frame/subscribe [::invoice-page]))
|
||||
(let [{:keys [checked print-checks-shown?]} @(re-frame/subscribe [::invoice-page])
|
||||
current-company @(re-frame/subscribe [::subs/company])]
|
||||
[:div
|
||||
[:h1.title "Unpaid invoices"]
|
||||
[:div.is-pulled-right
|
||||
(when current-company
|
||||
[:button.button.is-primary {:on-click (dispatch-event [::print-checks ])
|
||||
:disabled (if (seq checked)
|
||||
""
|
||||
"disabled")
|
||||
} "Print check(s)"])]
|
||||
[:div.dropdown {:class (if print-checks-shown?
|
||||
"is-active"
|
||||
"")}
|
||||
[:div.dropdown-trigger
|
||||
[:button.button {:aria-haspopup true
|
||||
:on-click (dispatch-event [::print-checks-clicked ])
|
||||
:disabled (if (seq checked)
|
||||
""
|
||||
"disabled")
|
||||
} "Print checks "
|
||||
[:span.icon.is-small [:i.fa.fa-angle-down {:aria-hidden "true"}]]]]
|
||||
[:div.dropdown-menu {:role "menu"}
|
||||
[:div.dropdown-content
|
||||
(for [{:keys [id number]} (:bank-accounts current-company)]
|
||||
^{:key id} [:a.dropdown-item {:on-click (dispatch-event [::print-checks id])} number])]]])]
|
||||
|
||||
[invoice-table {:id :unpaid
|
||||
:params (re-frame/subscribe [::params])
|
||||
|
||||
Reference in New Issue
Block a user