Almost finished with invoice page
This commit is contained in:
@@ -176,18 +176,18 @@
|
||||
(re-frame/reg-event-fx
|
||||
::add-and-print
|
||||
[with-user (forms/in-form ::form)]
|
||||
(fn [{:keys [user] {:keys [data]} :db} [_ params bank-account-id type]]
|
||||
(fn [{:keys [user] {:keys [data]} :db} [_ bank-account-id type]]
|
||||
{:graphql
|
||||
{:token user
|
||||
:owns-state {:single ::form}
|
||||
:query-obj @(re-frame/subscribe [::add-and-print-query bank-account-id type])
|
||||
:on-success [::added-and-printed params]
|
||||
:on-success [::added-and-printed]
|
||||
:on-error [::forms/save-error ::form]}}))
|
||||
|
||||
(re-frame/reg-event-fx
|
||||
::saving
|
||||
[with-user (forms/in-form ::form)]
|
||||
(fn [{:keys [user] {:keys [data]} :db} [_ params]]
|
||||
(fn [{:keys [user] {:keys [data]} :db} _]
|
||||
(let [command (if (:id data)
|
||||
:edit
|
||||
:create)]
|
||||
@@ -206,10 +206,15 @@
|
||||
|
||||
(re-frame/reg-event-fx
|
||||
::added-and-printed
|
||||
(fn [{:keys [db]} [_ {:keys [invoice-printed]} result]]
|
||||
(fn [{:keys [db]} [_ result]]
|
||||
(let [invoice (first (:invoices (:add-and-print-invoice result)))]
|
||||
{:dispatch-n [[::updated (assoc invoice :class "live-added")]
|
||||
(conj invoice-printed (:pdf-url (:add-and-print-invoice result)))]})))
|
||||
[::checks-printed [invoice] (:pdf-url (:add-and-print-invoice result))]]})))
|
||||
|
||||
(re-frame/reg-event-db
|
||||
::checks-printed
|
||||
(fn [db [_ invoices pdf-url]]
|
||||
db))
|
||||
|
||||
|
||||
|
||||
@@ -331,10 +336,10 @@
|
||||
(list
|
||||
(for [{:keys [id number name type]} (->> (:bank-accounts (:client data)) (filter :visible) (sort-by :sort-order))]
|
||||
(if (= :cash type)
|
||||
^{:key id} [:a.dropdown-item {:on-click (dispatch-event [::add-and-print params id :cash])} "With cash"]
|
||||
^{:key id} [:a.dropdown-item {:on-click (dispatch-event [::add-and-print id :cash])} "With cash"]
|
||||
(list
|
||||
^{:key (str id "-check")} [:a.dropdown-item {:on-click (dispatch-event [::add-and-print params id :check])} "Print checks from " name]
|
||||
^{:key (str id "-debit")} [:a.dropdown-item {:on-click (dispatch-event [::add-and-print params id :debit])} "Debit from " name]))))]]])
|
||||
^{:key (str id "-check")} [:a.dropdown-item {:on-click (dispatch-event [::add-and-print id :check])} "Print checks from " name]
|
||||
^{:key (str id "-debit")} [:a.dropdown-item {:on-click (dispatch-event [::add-and-print id :debit])} "Debit from " name]))))]]])
|
||||
[:div.column
|
||||
|
||||
(submit-button "Save")]]])
|
||||
|
||||
Reference in New Issue
Block a user