unpaid and paid invoices use the same underlying page, now.
This commit is contained in:
@@ -78,7 +78,7 @@
|
||||
(assoc-in [:status :loading] true)
|
||||
(assoc-in [::params] params))
|
||||
:graphql {:token (-> cofx :db :user)
|
||||
:query-obj (invoice-table/query (doto (assoc params :imported true :status "unpaid") println))
|
||||
:query-obj (invoice-table/query (doto (assoc params :imported true) println))
|
||||
:on-success [::received]}}))
|
||||
|
||||
(re-frame/reg-event-db
|
||||
@@ -614,7 +614,7 @@
|
||||
:step "0.01"}]]]]]
|
||||
]))
|
||||
|
||||
(defn edit-invoice-modal []
|
||||
(defn edit-invoice-modal [{:keys [can-change-amount?]}]
|
||||
(let [data @(re-frame/subscribe [::edit-invoice])
|
||||
change-event [::events/change-form [::edit-invoice]]
|
||||
locations (get-in @(re-frame/subscribe [::subs/clients-by-id]) [(:client-id data) :locations])
|
||||
@@ -659,12 +659,12 @@
|
||||
[bind-field
|
||||
[:input.input {:type "number"
|
||||
:field [:total]
|
||||
:disabled (if can-change-amount? "" "disabled")
|
||||
:event change-event
|
||||
:min min-total
|
||||
:subscription data
|
||||
:spec ::invoice/total
|
||||
:step "0.01"}]]]]]
|
||||
]))
|
||||
:step "0.01"}]]]]]]))
|
||||
|
||||
(re-frame/reg-event-db
|
||||
::change-selected-vendor
|
||||
@@ -702,88 +702,94 @@
|
||||
(re-frame/dispatch [::params-change (assoc params :invoice-number-like (.. x -target -value)) ])
|
||||
)} ]]]))
|
||||
|
||||
(def unpaid-invoices-content
|
||||
(with-meta
|
||||
(fn [_]
|
||||
(let [{:keys [checked print-checks-shown? print-checks-loading? advanced-print-shown? vendor-filter]} @(re-frame/subscribe [::invoice-page])
|
||||
current-client @(re-frame/subscribe [::subs/client])
|
||||
{check-results-shown? :shown? pdf-url :pdf-url} @(re-frame/subscribe [::check-results])]
|
||||
[:div
|
||||
[:h1.title "Unpaid invoices"]
|
||||
(defn pay-button [{:keys [print-checks-shown? checked-invoices print-checks-loading?]}]
|
||||
(let [current-client @(re-frame/subscribe [::subs/client])]
|
||||
[:div.is-pulled-right
|
||||
[:button.button.is-danger {:on-click (dispatch-event [::new-invoice])} "New Invoice"]
|
||||
(when current-client
|
||||
[:div.dropdown.is-right {:class (if print-checks-shown?
|
||||
"is-active"
|
||||
"")}
|
||||
[:div.dropdown-trigger
|
||||
[:button.button.is-success {:aria-haspopup true
|
||||
:on-click (dispatch-event [::print-checks-clicked ])
|
||||
:disabled (if (seq checked-invoices)
|
||||
""
|
||||
"disabled")
|
||||
|
||||
[:div.is-pulled-right
|
||||
[:button.button.is-danger {:on-click (dispatch-event [::new-invoice])} "New Invoice"]
|
||||
(when current-client
|
||||
[:div.dropdown.is-right {:class (if print-checks-shown?
|
||||
"is-active"
|
||||
"")}
|
||||
[:div.dropdown-trigger
|
||||
[:button.button.is-success {:aria-haspopup true
|
||||
:on-click (dispatch-event [::print-checks-clicked ])
|
||||
:disabled (if (seq checked)
|
||||
""
|
||||
"disabled")
|
||||
|
||||
:class (if print-checks-loading?
|
||||
"is-loading"
|
||||
"")}
|
||||
"Pay "
|
||||
[:span " "]
|
||||
[:span.icon.is-small [:i.fa.fa-angle-down {:aria-hidden "true"}]]]]
|
||||
[:div.dropdown-menu {:role "menu"}
|
||||
[:div.dropdown-content
|
||||
:class (if print-checks-loading?
|
||||
"is-loading"
|
||||
"")}
|
||||
"Pay "
|
||||
[:span " "]
|
||||
[:span.icon.is-small [:i.fa.fa-angle-down {:aria-hidden "true"}]]]]
|
||||
[:div.dropdown-menu {:role "menu"}
|
||||
[:div.dropdown-content
|
||||
(list
|
||||
(for [{:keys [id number name type]} (:bank-accounts current-client)]
|
||||
(if (= :cash type)
|
||||
^{:key id} [:a.dropdown-item {:on-click (dispatch-event [::print-checks id :cash])} "With cash"]
|
||||
(list
|
||||
(for [{:keys [id number name type]} (:bank-accounts current-client)]
|
||||
(if (= :cash type)
|
||||
^{:key id} [:a.dropdown-item {:on-click (dispatch-event [::print-checks id :cash])} "With cash"]
|
||||
(list
|
||||
^{:key (str id "-check")} [:a.dropdown-item {:on-click (dispatch-event [::print-checks id :check])} "Print checks from " name]
|
||||
^{:key (str id "-debit")} [:a.dropdown-item {:on-click (dispatch-event [::print-checks id :debit])} "Debit from " name])))
|
||||
^{:key "advanced-divider"} [:hr.dropdown-divider]
|
||||
^{:key (str id "-check")} [:a.dropdown-item {:on-click (dispatch-event [::print-checks id :check])} "Print checks from " name]
|
||||
^{:key (str id "-debit")} [:a.dropdown-item {:on-click (dispatch-event [::print-checks id :debit])} "Debit from " name])))
|
||||
^{:key "advanced-divider"} [:hr.dropdown-divider]
|
||||
|
||||
(when (= 1 (count checked))
|
||||
^{:key "handwritten"} [:a.dropdown-item {:on-click (dispatch-event [::handwrite-checks])} "Handwritten Check..."])
|
||||
^{:key "advanced"} [:a.dropdown-item {:on-click (dispatch-event [::advanced-print-checks])} "Advanced..."])]]])]
|
||||
[invoice-table {:id :unpaid
|
||||
:params (re-frame/subscribe [::params])
|
||||
:invoice-page (re-frame/subscribe [::invoice-page])
|
||||
:status (re-frame/subscribe [::subs/status])
|
||||
:on-edit-invoice (fn [which]
|
||||
(re-frame/dispatch [::edit-invoice which]))
|
||||
(when (= 1 (count checked-invoices))
|
||||
^{:key "handwritten"} [:a.dropdown-item {:on-click (dispatch-event [::handwrite-checks])} "Handwritten Check..."])
|
||||
^{:key "advanced"} [:a.dropdown-item {:on-click (dispatch-event [::advanced-print-checks])} "Advanced..."])]]])]))
|
||||
|
||||
: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
|
||||
:checked checked
|
||||
:on-check-changed (fn [which]
|
||||
(re-frame/dispatch [::toggle-check which]))
|
||||
:expense-event [::expense-accounts-dialog/change-expense-accounts]}]
|
||||
(defn unpaid-invoices-content [{:keys [status]}]
|
||||
(r/create-class {:display-name "unpaid-invoices-content"
|
||||
:reagent-render (fn [{:keys [status]}]
|
||||
(let [{:keys [checked print-checks-shown? print-checks-loading? advanced-print-shown? vendor-filter]} @(re-frame/subscribe [::invoice-page])
|
||||
current-client @(re-frame/subscribe [::subs/client])
|
||||
{check-results-shown? :shown? pdf-url :pdf-url} @(re-frame/subscribe [::check-results])]
|
||||
[:div
|
||||
[:h1.title (str (str/capitalize status) " invoices")]
|
||||
(when (= status "unpaid")
|
||||
[pay-button {:print-checks-shown? print-checks-shown? :checked-invoices checked :print-checks-loading? print-checks-loading?}])
|
||||
|
||||
[print-checks-modal]
|
||||
[new-invoice-modal]
|
||||
[edit-invoice-modal]
|
||||
[handwrite-checks-modal]
|
||||
[change-expense-accounts-modal {:updated-event [::expense-accounts-updated]}]
|
||||
(when check-results-shown?
|
||||
(if pdf-url
|
||||
[modal
|
||||
{:title "Your checks are ready!"
|
||||
:hide-event [::close-check-results]}
|
||||
[:div "Click " [:a {:href pdf-url :target "_new"} "here"] " to print them."]
|
||||
[:div [:em "Remember to turn off all scaling and margins."]]
|
||||
]
|
||||
[modal
|
||||
{:title "Payment created!"
|
||||
:hide-event [::close-check-results]}
|
||||
[:div [:em "Your payment was created."]]
|
||||
]))
|
||||
|
||||
[invoice-table {:id :unpaid
|
||||
:params (re-frame/subscribe [::params])
|
||||
:invoice-page (re-frame/subscribe [::invoice-page])
|
||||
:status (re-frame/subscribe [::subs/status])
|
||||
:on-edit-invoice (fn [which]
|
||||
(re-frame/dispatch [::edit-invoice which]))
|
||||
|
||||
]))
|
||||
{:component-will-mount #(re-frame/dispatch-sync [::params-change {}]) }))
|
||||
:on-void-invoice (fn [which]
|
||||
(re-frame/dispatch [::void-invoice which]))
|
||||
:on-params-change (fn [params]
|
||||
(re-frame/dispatch [::params-change params]))
|
||||
:check-boxes (= status "unpaid")
|
||||
:checked checked
|
||||
:on-check-changed (fn [which]
|
||||
(re-frame/dispatch [::toggle-check which]))
|
||||
:expense-event [::expense-accounts-dialog/change-expense-accounts]}]
|
||||
|
||||
(defn unpaid-invoices-page []
|
||||
[print-checks-modal]
|
||||
[new-invoice-modal]
|
||||
[edit-invoice-modal {:can-change-amount? (= status "unpaid")}]
|
||||
[handwrite-checks-modal]
|
||||
[change-expense-accounts-modal {:updated-event [::expense-accounts-updated]}]
|
||||
(when check-results-shown?
|
||||
(if pdf-url
|
||||
[modal
|
||||
{:title "Your checks are ready!"
|
||||
:hide-event [::close-check-results]}
|
||||
[:div "Click " [:a {:href pdf-url :target "_new"} "here"] " to print them."]
|
||||
[:div [:em "Remember to turn off all scaling and margins."]]
|
||||
]
|
||||
[modal
|
||||
{:title "Payment created!"
|
||||
:hide-event [::close-check-results]}
|
||||
[:div [:em "Your payment was created."]]
|
||||
]))
|
||||
|
||||
]))
|
||||
:component-will-mount #(re-frame/dispatch-sync [::params-change {:status status}]) }))
|
||||
|
||||
(defn unpaid-invoices-page [{:keys [status]}]
|
||||
[side-bar-layout {:side-bar [invoices-side-bar {}
|
||||
^{:key "extra-filter"}
|
||||
[:div
|
||||
@@ -791,10 +797,8 @@
|
||||
[:div [vendor-filter]]
|
||||
[:p.menu-label "Invoice #"]
|
||||
[:div
|
||||
[invoice-number-filter]
|
||||
]]
|
||||
]
|
||||
:main [unpaid-invoices-content]
|
||||
[invoice-number-filter]]]]
|
||||
:main [unpaid-invoices-content {:status status}]
|
||||
:bottom [vendor-dialog {:vendor @(re-frame/subscribe [::subs/user-editing-vendor])
|
||||
:save-event [::events/save-vendor]
|
||||
:change-event [::events/change-nested-form-state [:user-editing-vendor]] :id :auto-ap.views.main/user-editing-vendor}]}])
|
||||
|
||||
Reference in New Issue
Block a user