cleaning up invoice pagination.
This commit is contained in:
@@ -69,7 +69,7 @@
|
|||||||
(:status args)
|
(:status args)
|
||||||
(merge-query {:query {:in ['?status]
|
(merge-query {:query {:in ['?status]
|
||||||
:where ['[?e :invoice/status ?status]]}
|
:where ['[?e :invoice/status ?status]]}
|
||||||
:args [ (keyword "invoice-status" (:status args))]})
|
:args [ (:status args)]})
|
||||||
(:vendor-id args)
|
(:vendor-id args)
|
||||||
(merge-query {:query {:in ['?vendor-id]
|
(merge-query {:query {:in ['?vendor-id]
|
||||||
:where ['[?e :invoice/vendor ?vendor-id]]}
|
:where ['[?e :invoice/vendor ?vendor-id]]}
|
||||||
|
|||||||
@@ -381,7 +381,7 @@
|
|||||||
:invoice_page {:type '(list :invoice_page)
|
:invoice_page {:type '(list :invoice_page)
|
||||||
:args {:import_status {:type 'String}
|
:args {:import_status {:type 'String}
|
||||||
:date_range {:type :date_range}
|
:date_range {:type :date_range}
|
||||||
:status {:type 'String}
|
:status {:type :invoice_status}
|
||||||
:client_id {:type :id}
|
:client_id {:type :id}
|
||||||
:vendor_id {:type :id}
|
:vendor_id {:type :id}
|
||||||
:invoice_number_like {:type 'String}
|
:invoice_number_like {:type 'String}
|
||||||
@@ -624,6 +624,9 @@
|
|||||||
:enums {:payment_type {:values [{:enum-value :check}
|
:enums {:payment_type {:values [{:enum-value :check}
|
||||||
{:enum-value :cash}
|
{:enum-value :cash}
|
||||||
{:enum-value :debit}]}
|
{:enum-value :debit}]}
|
||||||
|
:invoice_status {:values [{:enum-value :paid}
|
||||||
|
{:enum-value :unpaid}
|
||||||
|
{:enum-value :voided}]}
|
||||||
:bank_account_type {:values [{:enum-value :check}
|
:bank_account_type {:values [{:enum-value :check}
|
||||||
{:enum-value :credit}
|
{:enum-value :credit}
|
||||||
{:enum-value :cash}]}
|
{:enum-value :cash}]}
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
(ns auto-ap.graphql.invoices
|
(ns auto-ap.graphql.invoices
|
||||||
(:require [auto-ap.graphql.utils :refer [->graphql <-graphql assert-can-see-client assert-admin]]
|
(:require [auto-ap.graphql.utils :refer [->graphql <-graphql assert-can-see-client assert-admin enum->keyword]]
|
||||||
|
|
||||||
[auto-ap.datomic.vendors :as d-vendors]
|
[auto-ap.datomic.vendors :as d-vendors]
|
||||||
[auto-ap.datomic.clients :as d-clients]
|
[auto-ap.datomic.clients :as d-clients]
|
||||||
@@ -17,7 +17,7 @@
|
|||||||
(defn get-invoice-page [context args value]
|
(defn get-invoice-page [context args value]
|
||||||
|
|
||||||
(let [args (assoc args :id (:id context))
|
(let [args (assoc args :id (:id context))
|
||||||
[invoices invoice-count] (d-invoices/get-graphql (<-graphql (assoc args :id (:id context))))]
|
[invoices invoice-count] (d-invoices/get-graphql (update (<-graphql (assoc args :id (:id context))) :status enum->keyword "invoice-status"))]
|
||||||
[{:invoices (map ->graphql invoices)
|
[{:invoices (map ->graphql invoices)
|
||||||
:total invoice-count
|
:total invoice-count
|
||||||
:count (count invoices)
|
:count (count invoices)
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
(ns auto-ap.graphql.transactions
|
(ns auto-ap.graphql.transactions
|
||||||
(:require [auto-ap.graphql.utils :refer [->graphql <-graphql assert-can-see-client assert-admin ident->enum-f snake->kebab]]
|
(:require [auto-ap.graphql.utils :refer [->graphql <-graphql assert-can-see-client assert-admin ident->enum-f snake->kebab enum->keyword]]
|
||||||
[auto-ap.datomic.transactions :as d-transactions]
|
[auto-ap.datomic.transactions :as d-transactions]
|
||||||
[auto-ap.datomic.vendors :as d-vendors]
|
[auto-ap.datomic.vendors :as d-vendors]
|
||||||
[auto-ap.datomic.checks :as d-checks]
|
[auto-ap.datomic.checks :as d-checks]
|
||||||
@@ -27,11 +27,7 @@
|
|||||||
|
|
||||||
(defn get-transaction-page [context args value]
|
(defn get-transaction-page [context args value]
|
||||||
(let [args (assoc args :id (:id context))
|
(let [args (assoc args :id (:id context))
|
||||||
[transactions transactions-count] (d-transactions/get-graphql (update (<-graphql args) :approval-status
|
[transactions transactions-count] (d-transactions/get-graphql (update (<-graphql args) :approval-status enum->keyword "transaction-approval-status"))
|
||||||
#(some->> %
|
|
||||||
name
|
|
||||||
snake->kebab
|
|
||||||
(keyword "transaction-approval-status"))))
|
|
||||||
transactions (map ->graphql (map approval-status->graphql transactions))]
|
transactions (map ->graphql (map approval-status->graphql transactions))]
|
||||||
[{:transactions transactions
|
[{:transactions transactions
|
||||||
:total transactions-count
|
:total transactions-count
|
||||||
@@ -41,11 +37,7 @@
|
|||||||
|
|
||||||
(defn unapprove-transactions [context args value]
|
(defn unapprove-transactions [context args value]
|
||||||
(let [args (assoc args :id (:id context))
|
(let [args (assoc args :id (:id context))
|
||||||
ids (:ids (d-transactions/raw-graphql-ids (update (<-graphql args) :approval-status
|
ids (:ids (d-transactions/raw-graphql-ids (update (<-graphql args) :approval-status enum->keyword "transaction-approval-status")))]
|
||||||
#(some->> %
|
|
||||||
name
|
|
||||||
snake->kebab
|
|
||||||
(keyword "transaction-approval-status")))))]
|
|
||||||
(d-transactions/unapprove ids)
|
(d-transactions/unapprove ids)
|
||||||
(get-transaction-page context args value)))
|
(get-transaction-page context args value)))
|
||||||
|
|
||||||
|
|||||||
@@ -85,3 +85,6 @@
|
|||||||
(defn ident->enum-f [k]
|
(defn ident->enum-f [k]
|
||||||
#(update % k
|
#(update % k
|
||||||
(fn [value] (some-> value :db/ident name keyword))))
|
(fn [value] (some-> value :db/ident name keyword))))
|
||||||
|
|
||||||
|
(defn enum->keyword [e namespace]
|
||||||
|
(some->> e name snake->kebab (keyword namespace)))
|
||||||
|
|||||||
@@ -41,8 +41,6 @@
|
|||||||
(fn [db]
|
(fn [db]
|
||||||
(::visible-expense-accounts db)))
|
(::visible-expense-accounts db)))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
(defn query [params]
|
(defn query [params]
|
||||||
{:venia/queries [[:invoice_page
|
{:venia/queries [[:invoice_page
|
||||||
(-> params
|
(-> params
|
||||||
@@ -59,174 +57,191 @@
|
|||||||
:start
|
:start
|
||||||
:end]]]})
|
:end]]]})
|
||||||
|
|
||||||
(defn invoice-table [{:keys [id invoice-page status on-params-change vendors params check-boxes checked on-check-changed on-edit-invoice on-void-invoice on-unvoid-invoice expense-event overrides]}]
|
(re-frame/reg-sub
|
||||||
(let [visible-checks @(re-frame/subscribe [::visible-checks])
|
::table-params
|
||||||
|
(fn [db]
|
||||||
|
(::table-params db)))
|
||||||
|
|
||||||
|
(re-frame/reg-event-fx
|
||||||
|
::params-changed
|
||||||
|
[(re-frame/path [::table-params])]
|
||||||
|
(fn [{table-params :db} [_ params :as z]]
|
||||||
|
{:db (merge table-params params)
|
||||||
|
:dispatch [:auto-ap.views.pages.unpaid-invoices/params-change]}))
|
||||||
|
|
||||||
|
(defn row [{:keys [invoice check-boxes checked on-check-changed selected-client overrides expense-event on-edit-invoice on-void-invoice on-unvoid-invoice]}]
|
||||||
|
(let [{:keys [client payments expense-accounts invoice-number date due total outstanding-balance id vendor] :as i} invoice]
|
||||||
|
[:tr {:class (:class i)}
|
||||||
|
(when check-boxes
|
||||||
|
[:td [:input.checkbox {:type "checkbox"
|
||||||
|
:checked (if (get checked id)
|
||||||
|
"checked"
|
||||||
|
"")
|
||||||
|
:on-change (fn [x e] (when on-check-changed
|
||||||
|
(on-check-changed id i)))} ]])
|
||||||
|
(when-not selected-client
|
||||||
|
[:td (if-let [client-override (:client overrides)]
|
||||||
|
(client-override i)
|
||||||
|
(:name client))])
|
||||||
|
[:td (:name vendor)]
|
||||||
|
[:td invoice-number]
|
||||||
|
[:td (date->str date) ]
|
||||||
|
[:td (date->str due) ]
|
||||||
|
[:td (str/join ", " (set (map :location expense-accounts)))]
|
||||||
|
|
||||||
|
[:td.has-text-right (nf total )]
|
||||||
|
[:td.has-text-right (nf outstanding-balance )]
|
||||||
|
[:td.expandable
|
||||||
|
[:div.buttons
|
||||||
|
(when (seq expense-accounts)
|
||||||
|
[drop-down {:id [::expense-accounts id ]
|
||||||
|
:header [:a.button.badge {:data-badge (str (clojure.core/count expense-accounts))
|
||||||
|
:aria-haspopup true
|
||||||
|
:on-click (dispatch-event [::events/toggle-menu [::expense-accounts id]])
|
||||||
|
:tab-index "0"
|
||||||
|
} "Accounts"]}
|
||||||
|
[drop-down-contents
|
||||||
|
[:div
|
||||||
|
(for [e expense-accounts]
|
||||||
|
^{:key (:id e)}
|
||||||
|
[:span.dropdown-item (:name (:account e)) " " (gstring/format "$%.2f" (:amount e) ) ])
|
||||||
|
|
||||||
|
[:hr.dropdown-divider]
|
||||||
|
|
||||||
|
(when expense-event
|
||||||
|
[:a.dropdown-item.is-primary {:on-click (dispatch-event (conj expense-event i))} "Change"])]]])
|
||||||
|
[:span {:style {:margin-left "1em"}}]
|
||||||
|
(when (and on-edit-invoice (not= ":voided" (:status i)))
|
||||||
|
[:a.button {:on-click (fn [] (on-edit-invoice i))} [:span.icon [:i.fa.fa-pencil]]])
|
||||||
|
(when (and on-void-invoice (= (:outstanding-balance i) (:total i)) (not= ":voided" (:status i)))
|
||||||
|
[:a.button {:on-click (fn [] (on-void-invoice i))} [:span.icon [:span.icon-bin-2 {:style {:font-weight "400"}}]]])
|
||||||
|
(when (and on-unvoid-invoice (= ":voided" (:status i)))
|
||||||
|
[:a.button {:on-click (fn [] (on-unvoid-invoice i))} [:span [:span.icon [:i.fa.fa-undo]]]])
|
||||||
|
(when (seq payments)
|
||||||
|
[drop-down {:id [::payments id]
|
||||||
|
:header [:button.button.badge {:data-badge (str (clojure.core/count payments))
|
||||||
|
:aria-haspopup true
|
||||||
|
:tab-index "0"
|
||||||
|
:on-click (dispatch-event [::events/toggle-menu [::payments id]])
|
||||||
|
} "Payments"]}
|
||||||
|
[:div
|
||||||
|
(for [payment payments]
|
||||||
|
(if (:s3-url (:payment payment))
|
||||||
|
^{:key (:id payment)}
|
||||||
|
[:a.dropdown-item {:href (:s3-url (:payment payment))
|
||||||
|
:target "_new"}
|
||||||
|
[:i.fa.fa-money-check]
|
||||||
|
[:span.icon [:i.fa.fa-money]]
|
||||||
|
(str " " (:check-number (:payment payment)) " (" (gstring/format "$%.2f" (:amount payment) ) ")")]
|
||||||
|
|
||||||
|
^{:key (:id payment)}
|
||||||
|
[:span.dropdown-item [:span.icon {:class [(when (= :cleared (:status (:payment payment)))
|
||||||
|
"has-text-success")]}
|
||||||
|
[:i.fa.fa-money]] (str " " (:check-number (:payment payment)) " (" (gstring/format "$%.2f" (:amount payment) ) ") "
|
||||||
|
(when (= :cleared (:status (:payment payment)))
|
||||||
|
(str " - " (:post-date (:transaction (:payment payment))))))]))]])]]]))
|
||||||
|
|
||||||
|
(defn invoice-table [{:keys [id invoice-page status vendors check-boxes checked on-check-changed on-edit-invoice on-void-invoice on-unvoid-invoice expense-event overrides]}]
|
||||||
|
(let [opc (fn [p]
|
||||||
|
(re-frame/dispatch [::params-changed p]))
|
||||||
|
visible-checks @(re-frame/subscribe [::visible-checks])
|
||||||
visible-expense-accounts @(re-frame/subscribe [::visible-expense-accounts])
|
visible-expense-accounts @(re-frame/subscribe [::visible-expense-accounts])
|
||||||
selected-client @(re-frame/subscribe [::subs/client])
|
selected-client @(re-frame/subscribe [::subs/client])
|
||||||
opc (fn [p]
|
{:keys [sort]} @(re-frame/subscribe [::table-params])
|
||||||
(on-params-change (merge @params p)))]
|
{:keys [invoices start end count total]} @invoice-page
|
||||||
(fn [{:keys [id invoice-page status on-params-change vendors checked params]}]
|
visible-checks @(re-frame/subscribe [::visible-checks])
|
||||||
(let [{:keys [sort asc]} @params
|
visible-expense-accounts @(re-frame/subscribe [::visible-expense-accounts])
|
||||||
{:keys [invoices start end count total]} @invoice-page
|
selected-client @(re-frame/subscribe [::subs/client])
|
||||||
visible-checks @(re-frame/subscribe [::visible-checks])
|
percentage-size (if selected-client "%50%" "33%")]
|
||||||
visible-expense-accounts @(re-frame/subscribe [::visible-expense-accounts])
|
[:div
|
||||||
selected-client @(re-frame/subscribe [::subs/client])
|
[:div.level
|
||||||
percentage-size (if selected-client "%50%" "33%")]
|
[:div.level-left
|
||||||
[:div
|
[:div.level-item
|
||||||
[:div.level
|
[paginator {:start start :end end :count count :total total
|
||||||
[:div.level-left
|
:on-change opc}]]
|
||||||
[:div.level-item
|
[:div.level-item
|
||||||
[paginator {:start start :end end :count count :total total
|
[sort-by-list {:sort sort
|
||||||
:on-change (fn [p ]
|
:on-change opc}]]]]
|
||||||
(on-params-change (merge @params p) ))}]]
|
[:table.table.is-fullwidth
|
||||||
[:div.level-item
|
[:thead
|
||||||
[sort-by-list {:sort sort
|
[:tr
|
||||||
:on-change opc}]]]]
|
(when check-boxes
|
||||||
[:table.table.is-fullwidth
|
[:th {:style {"width" "20px"}}])
|
||||||
[:thead
|
(when-not selected-client
|
||||||
[:tr
|
[sorted-column {:on-sort opc
|
||||||
(when check-boxes
|
:style {:width percentage-size :cursor "pointer"}
|
||||||
[:th {:style {"width" "20px"}}])
|
:sort-name "Client"
|
||||||
|
:sort-key "client"
|
||||||
|
:sort sort}
|
||||||
|
"Client"])
|
||||||
|
[sorted-column {:on-sort opc
|
||||||
|
:style {:width percentage-size :cursor "pointer"}
|
||||||
|
:sort-name "Vendor"
|
||||||
|
:sort-key "vendor"
|
||||||
|
:sort sort}
|
||||||
|
"Vendor"]
|
||||||
|
[sorted-column {:on-sort opc
|
||||||
|
:style {:width percentage-size :cursor "pointer"}
|
||||||
|
:sort-name "Invoice Number"
|
||||||
|
:sort-key "invoice-number"
|
||||||
|
:sort sort}
|
||||||
|
"Invoice #"]
|
||||||
|
[sorted-column {:on-sort opc
|
||||||
|
:style {:width "8em" :cursor "pointer"}
|
||||||
|
:sort-name "Date"
|
||||||
|
:sort-key "date"
|
||||||
|
:sort sort}
|
||||||
|
"Date"]
|
||||||
|
[sorted-column {:on-sort opc
|
||||||
|
:style {:width "8em" :cursor "pointer"}
|
||||||
|
:sort-name "Due"
|
||||||
|
:sort-key "due"
|
||||||
|
:sort sort}
|
||||||
|
"Due"]
|
||||||
|
[sorted-column {:on-sort opc
|
||||||
|
:style {:width "5em" :cursor "pointer"}
|
||||||
|
:sort-name "Location"
|
||||||
|
:sort-key "location"
|
||||||
|
:sort sort}
|
||||||
|
"Loc"]
|
||||||
|
[sorted-column {:on-sort opc
|
||||||
|
:style {:width "8em" :cursor "pointer"}
|
||||||
|
:sort-name "Total"
|
||||||
|
:sort-key "total"
|
||||||
|
:class "has-text-right"
|
||||||
|
:sort sort}
|
||||||
|
"Amount"]
|
||||||
|
|
||||||
(when-not selected-client
|
[sorted-column {:on-sort opc
|
||||||
[sorted-column {:on-sort opc
|
:style {:width "10em" :cursor "pointer"}
|
||||||
:style {:width percentage-size :cursor "pointer"}
|
:sort-name "Outstanding"
|
||||||
:sort-name "Client"
|
:sort-key "outstanding-balance"
|
||||||
:sort-key "client"
|
:class "has-text-right"
|
||||||
:sort sort
|
:sort sort}
|
||||||
:asc asc}
|
"Outstanding"]
|
||||||
"Client"])
|
|
||||||
[sorted-column {:on-sort opc
|
|
||||||
:style {:width percentage-size :cursor "pointer"}
|
|
||||||
:sort-name "Vendor"
|
|
||||||
:sort-key "vendor"
|
|
||||||
:sort sort
|
|
||||||
:asc asc}
|
|
||||||
"Vendor"]
|
|
||||||
[sorted-column {:on-sort opc
|
|
||||||
:style {:width percentage-size :cursor "pointer"}
|
|
||||||
:sort-name "Invoice Number"
|
|
||||||
:sort-key "invoice-number"
|
|
||||||
:sort sort
|
|
||||||
:asc asc}
|
|
||||||
"Invoice #"]
|
|
||||||
[sorted-column {:on-sort opc
|
|
||||||
:style {:width "8em" :cursor "pointer"}
|
|
||||||
:sort-name "Date"
|
|
||||||
:sort-key "date"
|
|
||||||
:sort sort
|
|
||||||
:asc asc}
|
|
||||||
"Date"]
|
|
||||||
[sorted-column {:on-sort opc
|
|
||||||
:style {:width "8em" :cursor "pointer"}
|
|
||||||
:sort-name "Due"
|
|
||||||
:sort-key "due"
|
|
||||||
:sort sort
|
|
||||||
:asc asc}
|
|
||||||
"Due"]
|
|
||||||
[sorted-column {:on-sort opc
|
|
||||||
:style {:width "5em" :cursor "pointer"}
|
|
||||||
:sort-name "Location"
|
|
||||||
:sort-key "location"
|
|
||||||
:sort sort
|
|
||||||
:asc asc}
|
|
||||||
"Loc"]
|
|
||||||
[sorted-column {:on-sort opc
|
|
||||||
:style {:width "8em" :cursor "pointer"}
|
|
||||||
:sort-name "Total"
|
|
||||||
:sort-key "total"
|
|
||||||
:class "has-text-right"
|
|
||||||
:sort sort
|
|
||||||
:asc asc}
|
|
||||||
"Amount"]
|
|
||||||
|
|
||||||
[sorted-column {:on-sort opc
|
[:th {
|
||||||
:style {:width "10em" :cursor "pointer"}
|
:style {:width "20rem" :cursor "pointer"}
|
||||||
:sort-name "Outstanding"
|
|
||||||
:sort-key "outstanding-balance"
|
|
||||||
:class "has-text-right"
|
|
||||||
:sort sort
|
|
||||||
:asc asc}
|
|
||||||
"Outstanding"]
|
|
||||||
|
|
||||||
[:th {
|
|
||||||
:style {:width "20rem" :cursor "pointer"}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
""]]]
|
""]]]
|
||||||
[:tbody
|
[:tbody
|
||||||
|
|
||||||
(if (:loading @status)
|
(if (:loading @status)
|
||||||
[:tr
|
[:tr
|
||||||
[:td {:col-span 5}
|
[:td {:col-span 5}
|
||||||
[:i.fa.fa-spin.fa-spinner]]]
|
[:i.fa.fa-spin.fa-spinner]]]
|
||||||
|
|
||||||
(for [{:keys [client payments expense-accounts invoice-number date due total outstanding-balance id vendor] :as i} (:invoices @invoice-page)]
|
(for [{:keys [client payments expense-accounts invoice-number date due total outstanding-balance id vendor] :as i} (:invoices @invoice-page)]
|
||||||
^{:key id}
|
^{:key id}
|
||||||
[:tr {:class (:class i)}
|
[row {:invoice i
|
||||||
(when check-boxes
|
:check-boxes check-boxes
|
||||||
[:td [:input.checkbox {:type "checkbox"
|
:checked checked
|
||||||
:checked (if (get checked id)
|
:on-check-changed on-check-changed
|
||||||
"checked"
|
:selected-client selected-client
|
||||||
"")
|
:overrides overrides
|
||||||
:on-change (fn [x e] (when on-check-changed
|
:expense-event expense-event
|
||||||
|
:on-edit-invoice on-edit-invoice
|
||||||
(on-check-changed id i)))} ]])
|
:on-void-invoice on-void-invoice
|
||||||
(when-not selected-client
|
:on-unvoid-invoice on-unvoid-invoice}]))]]]))
|
||||||
[:td (if-let [client-override (:client overrides)]
|
|
||||||
(client-override i)
|
|
||||||
(:name client))])
|
|
||||||
[:td (:name vendor)]
|
|
||||||
[:td invoice-number]
|
|
||||||
[:td (date->str date) ]
|
|
||||||
[:td (date->str due) ]
|
|
||||||
[:td (str/join ", " (set (map :location expense-accounts)))]
|
|
||||||
|
|
||||||
[:td.has-text-right (nf total )]
|
|
||||||
[:td.has-text-right (nf outstanding-balance )]
|
|
||||||
[:td.expandable
|
|
||||||
[:div.buttons
|
|
||||||
(when (seq expense-accounts)
|
|
||||||
[drop-down {:id [::expense-accounts id ]
|
|
||||||
:header [:a.button.badge {:data-badge (str (clojure.core/count expense-accounts))
|
|
||||||
:aria-haspopup true
|
|
||||||
:on-click (dispatch-event [::events/toggle-menu [::expense-accounts id]])
|
|
||||||
:tab-index "0"
|
|
||||||
} "Accounts"]}
|
|
||||||
[drop-down-contents
|
|
||||||
[:div
|
|
||||||
(for [e expense-accounts]
|
|
||||||
^{:key (:id e)}
|
|
||||||
[:span.dropdown-item (:name (:account e)) " " (gstring/format "$%.2f" (:amount e) ) ])
|
|
||||||
|
|
||||||
[:hr.dropdown-divider]
|
|
||||||
|
|
||||||
(when expense-event
|
|
||||||
[:a.dropdown-item.is-primary {:on-click (dispatch-event (conj expense-event i))} "Change"])]]])
|
|
||||||
[:span {:style {:margin-left "1em"}}]
|
|
||||||
(when (and on-edit-invoice (not= ":voided" (:status i)))
|
|
||||||
[:a.button {:on-click (fn [] (on-edit-invoice i))} [:span.icon [:i.fa.fa-pencil]]])
|
|
||||||
(when (and on-void-invoice (= (:outstanding-balance i) (:total i)) (not= ":voided" (:status i)))
|
|
||||||
[:a.button {:on-click (fn [] (on-void-invoice i))} [:span.icon [:span.icon-bin-2 {:style {:font-weight "400"}}]]])
|
|
||||||
(when (and on-unvoid-invoice (= ":voided" (:status i)))
|
|
||||||
[:a.button {:on-click (fn [] (on-unvoid-invoice i))} [:span [:span.icon [:i.fa.fa-undo]]]])
|
|
||||||
(when (seq payments)
|
|
||||||
[drop-down {:id [::payments id]
|
|
||||||
:header [:button.button.badge {:data-badge (str (clojure.core/count payments))
|
|
||||||
:aria-haspopup true
|
|
||||||
:tab-index "0"
|
|
||||||
:on-click (dispatch-event [::events/toggle-menu [::payments id]])
|
|
||||||
} "Payments"]}
|
|
||||||
[:div
|
|
||||||
(for [payment payments]
|
|
||||||
(if (:s3-url (:payment payment))
|
|
||||||
^{:key (:id payment)}
|
|
||||||
[:a.dropdown-item {:href (:s3-url (:payment payment)) :target "_new"} [:i.fa.fa-money-check] [:span.icon [:i.fa.fa-money]] (str " " (:check-number (:payment payment)) " (" (gstring/format "$%.2f" (:amount payment) ) ")")]
|
|
||||||
|
|
||||||
^{:key (:id payment)}
|
|
||||||
[:span.dropdown-item [:span.icon {:class [(when (= :cleared (:status (:payment payment)))
|
|
||||||
"has-text-success")]}
|
|
||||||
[:i.fa.fa-money]] (str " " (:check-number (:payment payment)) " (" (gstring/format "$%.2f" (:amount payment) ) ") "
|
|
||||||
(when (= :cleared (:status (:payment payment)))
|
|
||||||
(str " - " (:post-date (:transaction (:payment payment))))))]))]])]]]))]]]))))
|
|
||||||
|
|||||||
@@ -7,11 +7,75 @@
|
|||||||
[goog.string :as gstring]
|
[goog.string :as gstring]
|
||||||
[bidi.bidi :as bidi]
|
[bidi.bidi :as bidi]
|
||||||
[auto-ap.routes :as routes]
|
[auto-ap.routes :as routes]
|
||||||
|
[auto-ap.views.components.date-range-filter :refer [date-range-filter]]
|
||||||
|
[auto-ap.views.components.typeahead :refer [typeahead-entity]]
|
||||||
[auto-ap.views.utils :refer [active-when dispatch-event bind-field horizontal-field date->str str->date pretty standard]]
|
[auto-ap.views.utils :refer [active-when dispatch-event bind-field horizontal-field date->str str->date pretty standard]]
|
||||||
[auto-ap.subs :as subs]
|
[auto-ap.subs :as subs]
|
||||||
[auto-ap.events :as events]))
|
[auto-ap.events :as events]))
|
||||||
|
|
||||||
(defn invoices-side-bar [params & rest]
|
|
||||||
|
(re-frame/reg-sub
|
||||||
|
::filters
|
||||||
|
(fn [db ]
|
||||||
|
(::filters db {})))
|
||||||
|
|
||||||
|
(re-frame/reg-sub
|
||||||
|
::filter
|
||||||
|
:<- [::filters]
|
||||||
|
(fn [filters [_ which]]
|
||||||
|
(filters which)))
|
||||||
|
|
||||||
|
(re-frame/reg-sub
|
||||||
|
::filter-params
|
||||||
|
:<- [::filters]
|
||||||
|
:<- [::subs/active-page]
|
||||||
|
(fn [[filters ap]]
|
||||||
|
(println (:invoice-number-like filters))
|
||||||
|
{:vendor-id (:id (:vendor filters))
|
||||||
|
:date-range (:date-range filters)
|
||||||
|
:invoice-number-like (:settled (:invoice-number-like filters))
|
||||||
|
:status (condp = ap
|
||||||
|
:invoices nil
|
||||||
|
:unpaid-invoices :unpaid
|
||||||
|
:paid-invoices :paid
|
||||||
|
:voided-invoices :voided)}))
|
||||||
|
|
||||||
|
|
||||||
|
(re-frame/reg-event-fx
|
||||||
|
::filter-changed
|
||||||
|
(fn [{:keys [db]} [_ & params]]
|
||||||
|
(let [[a b c] params
|
||||||
|
[which val] (if (= 3 (count params))
|
||||||
|
[(into [a] b) c]
|
||||||
|
[[a] b])]
|
||||||
|
{:dispatch [:auto-ap.views.pages.unpaid-invoices/params-change]
|
||||||
|
:db (assoc-in db (into [::filters] which) val)})))
|
||||||
|
|
||||||
|
(re-frame/reg-event-fx
|
||||||
|
::invoice-number-like-settled
|
||||||
|
[(re-frame/path [::filters :invoice-number-like])]
|
||||||
|
(fn [{:keys [db]} [_ invoice-number-like]]
|
||||||
|
{:db (assoc db :settled invoice-number-like)
|
||||||
|
:dispatch [::filter-changed :invoice-number-like [:settled] invoice-number-like]}))
|
||||||
|
|
||||||
|
|
||||||
|
(re-frame/reg-event-fx
|
||||||
|
::invoice-number-like-changed
|
||||||
|
[(re-frame/path [::filters :invoice-number-like])]
|
||||||
|
(fn [{:keys [db]} [_ invoice-number-like]]
|
||||||
|
{:dispatch-debounce {:event [::invoice-number-like-settled invoice-number-like]
|
||||||
|
:time 500
|
||||||
|
:key ::invoice-number-like}
|
||||||
|
:db (assoc db :raw invoice-number-like)}))
|
||||||
|
|
||||||
|
(defn invoice-number-filter []
|
||||||
|
[:div.field
|
||||||
|
[:div.control [:input.input {:placeholder "AP-123"
|
||||||
|
:value (:raw @(re-frame/subscribe [::filter :invoice-number-like]))
|
||||||
|
:on-change (fn [x]
|
||||||
|
(re-frame/dispatch [::invoice-number-like-changed (.. x -target -value) ]))} ]]])
|
||||||
|
|
||||||
|
(defn invoices-side-bar [params]
|
||||||
(let [ap @(re-frame/subscribe [::subs/active-page])
|
(let [ap @(re-frame/subscribe [::subs/active-page])
|
||||||
user @(re-frame/subscribe [::subs/user])]
|
user @(re-frame/subscribe [::subs/user])]
|
||||||
[:div
|
[:div
|
||||||
@@ -49,5 +113,20 @@
|
|||||||
[:span {:class "icon icon-accounting-document" :style {:font-size "25px"}}]
|
[:span {:class "icon icon-accounting-document" :style {:font-size "25px"}}]
|
||||||
|
|
||||||
[:span {:class "name"} "Import Invoices"]]])]]
|
[:span {:class "name"} "Import Invoices"]]])]]
|
||||||
[:div
|
(when (not= ap :import-invoices)
|
||||||
rest]]))
|
[:div
|
||||||
|
[:p.menu-label "Vendor"]
|
||||||
|
[:div
|
||||||
|
[typeahead-entity {:matches @(re-frame/subscribe [::subs/vendors])
|
||||||
|
:on-change #(re-frame/dispatch [::filter-changed :vendor %])
|
||||||
|
:match->text :name
|
||||||
|
:type "typeahead-entity"
|
||||||
|
:value @(re-frame/subscribe [::filter :vendor])}]]
|
||||||
|
[:p.menu-label "Date Range"]
|
||||||
|
[:div
|
||||||
|
[date-range-filter
|
||||||
|
{:on-change-event [::filter-changed :date-range]
|
||||||
|
:value @(re-frame/subscribe [::filter :date-range])}]]
|
||||||
|
[:p.menu-label "Invoice #"]
|
||||||
|
[:div
|
||||||
|
[invoice-number-filter]]])]))
|
||||||
|
|||||||
@@ -2,7 +2,6 @@
|
|||||||
(:require [re-frame.core :as re-frame]
|
(:require [re-frame.core :as re-frame]
|
||||||
[auto-ap.entities.clients :as client]
|
[auto-ap.entities.clients :as client]
|
||||||
[auto-ap.entities.vendors :as vendor]
|
[auto-ap.entities.vendors :as vendor]
|
||||||
[auto-ap.entities.invoice :as invoice]
|
|
||||||
[reagent.core :as reagent]
|
[reagent.core :as reagent]
|
||||||
[goog.string :as gstring]
|
[goog.string :as gstring]
|
||||||
[clojure.spec.alpha :as s]
|
[clojure.spec.alpha :as s]
|
||||||
@@ -18,7 +17,6 @@
|
|||||||
[auto-ap.views.pages.payments.side-bar :as side-bar]
|
[auto-ap.views.pages.payments.side-bar :as side-bar]
|
||||||
[auto-ap.views.pages.payments.table :as table]
|
[auto-ap.views.pages.payments.table :as table]
|
||||||
[auto-ap.views.pages.check :as check]
|
[auto-ap.views.pages.check :as check]
|
||||||
[auto-ap.views.components.invoice-table :refer [invoice-table] :as invoice-table]
|
|
||||||
[auto-ap.subs :as subs]))
|
[auto-ap.subs :as subs]))
|
||||||
|
|
||||||
|
|
||||||
@@ -91,21 +89,27 @@
|
|||||||
(update ::payment-page merge (first (:payment-page data)))
|
(update ::payment-page merge (first (:payment-page data)))
|
||||||
(assoc-in [:status :loading] false))))
|
(assoc-in [:status :loading] false))))
|
||||||
|
|
||||||
(def checks-content
|
(re-frame/reg-event-fx
|
||||||
(with-meta
|
::unmounted
|
||||||
(fn []
|
(fn [{:keys [db]} _]
|
||||||
(let [current-client @(re-frame/subscribe [::subs/client])]
|
{:db (dissoc db ::last-params ::table/table-params ::side-bar/filters ::payment-page)}))
|
||||||
[:div
|
|
||||||
[:h1.title "Checks"]
|
|
||||||
[table/table {:id :payments
|
|
||||||
:payment-page (re-frame/subscribe [::payment-page])
|
|
||||||
:status (re-frame/subscribe [::subs/status])
|
|
||||||
:void-event [::void-check]
|
|
||||||
}]]))
|
|
||||||
{:component-will-mount #(re-frame/dispatch-sync [::params-change {}]) }))
|
|
||||||
|
|
||||||
|
(defn content []
|
||||||
|
(let [current-client @(re-frame/subscribe [::subs/client])]
|
||||||
|
[:div
|
||||||
|
[:h1.title "Payments"]
|
||||||
|
[table/table {:id :payments
|
||||||
|
:payment-page (re-frame/subscribe [::payment-page])
|
||||||
|
:status (re-frame/subscribe [::subs/status])
|
||||||
|
:void-event [::void-check]}]]))
|
||||||
|
|
||||||
|
|
||||||
(defn payments-page []
|
(defn payments-page []
|
||||||
[side-bar-layout {:side-bar [side-bar/side-bar]
|
(reagent/create-class
|
||||||
:main [checks-content]}])
|
{:display-name "payments-page"
|
||||||
|
:component-did-mount #(re-frame/dispatch [::params-change {}])
|
||||||
|
:component-will-unmount #(re-frame/dispatch [::unmounted])
|
||||||
|
:reagent-render
|
||||||
|
(fn []
|
||||||
|
[side-bar-layout {:side-bar [side-bar/side-bar]
|
||||||
|
:main [content]}])}))
|
||||||
|
|||||||
@@ -7,22 +7,14 @@
|
|||||||
[auto-ap.views.pages.invoices.form :as form]
|
[auto-ap.views.pages.invoices.form :as form]
|
||||||
[auto-ap.views.components.dropdown :refer [drop-down]]
|
[auto-ap.views.components.dropdown :refer [drop-down]]
|
||||||
[auto-ap.views.components.expense-accounts-dialog :as expense-accounts-dialog :refer [change-expense-accounts-modal]]
|
[auto-ap.views.components.expense-accounts-dialog :as expense-accounts-dialog :refer [change-expense-accounts-modal]]
|
||||||
[auto-ap.views.components.invoice-table :as invoice-table :refer [invoice-table]]
|
[auto-ap.views.components.invoice-table :as table :refer [invoice-table]]
|
||||||
[auto-ap.views.components.invoices.side-bar :refer [invoices-side-bar]]
|
[auto-ap.views.components.invoices.side-bar :refer [invoices-side-bar] :as side-bar]
|
||||||
[auto-ap.views.components.layouts :refer [appearing-side-bar side-bar-layout]]
|
[auto-ap.views.components.layouts :refer [appearing-side-bar side-bar-layout]]
|
||||||
[auto-ap.views.components.modal :refer [action-modal modal]]
|
[auto-ap.views.components.modal :refer [action-modal modal]]
|
||||||
[auto-ap.views.components.typeahead :refer [typeahead]]
|
[auto-ap.views.components.typeahead :refer [typeahead]]
|
||||||
[auto-ap.views.components.vendor-filter :refer [vendor-filter]]
|
[auto-ap.views.components.vendor-filter :refer [vendor-filter]]
|
||||||
[auto-ap.views.components.date-range-filter :refer [date-range-filter]]
|
|
||||||
[auto-ap.views.pages.invoices.common :refer [invoice-read]]
|
[auto-ap.views.pages.invoices.common :refer [invoice-read]]
|
||||||
[auto-ap.views.utils
|
[auto-ap.views.utils :refer [bind-field date->str date-picker dispatch-event horizontal-field standard with-user]]
|
||||||
:refer
|
|
||||||
[bind-field
|
|
||||||
date->str
|
|
||||||
date-picker
|
|
||||||
dispatch-event
|
|
||||||
horizontal-field
|
|
||||||
standard]]
|
|
||||||
[cljs-time.core :as c]
|
[cljs-time.core :as c]
|
||||||
[clojure.spec.alpha :as s]
|
[clojure.spec.alpha :as s]
|
||||||
[clojure.string :as str :refer [blank?]]
|
[clojure.string :as str :refer [blank?]]
|
||||||
@@ -74,8 +66,14 @@
|
|||||||
|
|
||||||
(re-frame/reg-sub
|
(re-frame/reg-sub
|
||||||
::params
|
::params
|
||||||
(fn [db]
|
:<- [::subs/client]
|
||||||
(-> db (::params {}))))
|
:<- [::side-bar/filter-params]
|
||||||
|
:<- [::table/table-params]
|
||||||
|
(fn [[client filter-params table-params]]
|
||||||
|
(cond-> {:import-status "imported"}
|
||||||
|
client (assoc :client-id (:id client))
|
||||||
|
(seq filter-params) (merge filter-params)
|
||||||
|
(seq table-params) (merge @(re-frame/subscribe [::table/table-params])))))
|
||||||
|
|
||||||
(re-frame/reg-event-db
|
(re-frame/reg-event-db
|
||||||
::invoice-updated
|
::invoice-updated
|
||||||
@@ -86,22 +84,24 @@
|
|||||||
|
|
||||||
(re-frame/reg-event-fx
|
(re-frame/reg-event-fx
|
||||||
::params-change
|
::params-change
|
||||||
(fn [cofx [_ params]]
|
[with-user]
|
||||||
{:db (-> (:db cofx)
|
(fn [cofx _]
|
||||||
(assoc-in [:status :loading] true)
|
(let [new-params @(re-frame/subscribe [::params])]
|
||||||
(assoc-in [::params] params))
|
(when (not= new-params (::last-params (:db cofx)))
|
||||||
:graphql {:token (-> cofx :db :user)
|
{:db (-> (:db cofx)
|
||||||
:query-obj (invoice-table/query (-> params (assoc :import-status "imported") (dissoc :invoice-number-like-current)) )
|
(assoc-in [:status :loading] true)
|
||||||
:on-success [::received]
|
(assoc-in [::last-params] new-params))
|
||||||
:on-error [::events/page-failed]}}))
|
:graphql {:token (-> cofx :db :user)
|
||||||
|
:query-obj (table/query new-params )
|
||||||
|
:on-success [::received]
|
||||||
|
:on-error [::events/page-failed]}}))))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
(re-frame/reg-event-db
|
(re-frame/reg-event-fx
|
||||||
::unmount-invoices
|
::unmounted
|
||||||
(fn [db [_ data]]
|
(fn [{:keys [db]} _]
|
||||||
(-> db
|
{:db (dissoc db ::invoice-page ::table/table-params ::side-bar/filters ::last-params)}))
|
||||||
(dissoc ::invoice-page ))))
|
|
||||||
|
|
||||||
(re-frame/reg-event-db
|
(re-frame/reg-event-db
|
||||||
::received
|
::received
|
||||||
@@ -272,11 +272,6 @@
|
|||||||
(assoc-in [::check-results :shown?] true)
|
(assoc-in [::check-results :shown?] true)
|
||||||
(assoc-in [::check-results :pdf-url] pdf-url))))
|
(assoc-in [::check-results :pdf-url] pdf-url))))
|
||||||
|
|
||||||
(re-frame/reg-event-fx
|
|
||||||
::invalidated
|
|
||||||
(fn [cofx [_ params]]
|
|
||||||
{:dispatch [::params-change @(re-frame/subscribe [::params])]}))
|
|
||||||
|
|
||||||
(re-frame/reg-event-fx
|
(re-frame/reg-event-fx
|
||||||
::new-invoice-clicked
|
::new-invoice-clicked
|
||||||
(fn [{:keys [db]} _]
|
(fn [{:keys [db]} _]
|
||||||
@@ -356,16 +351,6 @@
|
|||||||
(dissoc ::handwrite-checks))})))
|
(dissoc ::handwrite-checks))})))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
(re-frame/reg-event-fx
|
(re-frame/reg-event-fx
|
||||||
::invoice-unvoided
|
::invoice-unvoided
|
||||||
(fn [{:keys [db]} [_ {:keys [unvoid-invoice]}]]
|
(fn [{:keys [db]} [_ {:keys [unvoid-invoice]}]]
|
||||||
@@ -551,48 +536,6 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
(re-frame/reg-event-db
|
|
||||||
::change-selected-vendor
|
|
||||||
(fn [db [_ key value]]
|
|
||||||
(let [[key] key
|
|
||||||
updated (assoc-in db [::invoice-page :vendor-filter key] value)]
|
|
||||||
(if (and (= key :vendor-id)
|
|
||||||
(not= value (get-in db [::params :vendor-id])))
|
|
||||||
(do
|
|
||||||
(re-frame/dispatch [::params-change (assoc (::params updated) :vendor-id value :start 0)])
|
|
||||||
(assoc-in updated [::params :vendor-id] value))
|
|
||||||
updated))))
|
|
||||||
|
|
||||||
(re-frame/reg-event-fx
|
|
||||||
::change-selected-date-range
|
|
||||||
(fn [{:keys [db]} [_ key value]]
|
|
||||||
(let [[key] key
|
|
||||||
updated (-> db
|
|
||||||
(assoc-in [::invoice-page :date-range-filter key] value)
|
|
||||||
(assoc-in [::params :date-range key] value))]
|
|
||||||
{:dispatch [::params-change (::params updated)]
|
|
||||||
:db updated})))
|
|
||||||
|
|
||||||
(re-frame/reg-event-fx
|
|
||||||
::invoice-number-like-current-changed
|
|
||||||
(fn [{:keys [db]} [_ params invoice-like]]
|
|
||||||
{:db (assoc-in db [::params :invoice-number-like-current] invoice-like )
|
|
||||||
:dispatch-debounce {:event [::invoice-number-like-settled invoice-like]
|
|
||||||
:time 500
|
|
||||||
:key ::invoice-number-like}}))
|
|
||||||
|
|
||||||
(re-frame/reg-event-fx
|
|
||||||
::invoice-number-like-settled
|
|
||||||
(fn [{:keys [db]} [_ invoice-like]]
|
|
||||||
{:dispatch [::params-change (assoc (::params db) :invoice-number-like invoice-like :start 0) ]}))
|
|
||||||
|
|
||||||
(defn invoice-number-filter []
|
|
||||||
(let [{:keys [invoice-number-like-current] :as params} @(re-frame/subscribe [::params])]
|
|
||||||
[:div.field
|
|
||||||
[:div.control [:input.input {:placeholder "AP-123"
|
|
||||||
:value invoice-number-like-current
|
|
||||||
:on-change (fn [x]
|
|
||||||
(re-frame/dispatch [::invoice-number-like-current-changed params (.. x -target -value) ]))} ]]]))
|
|
||||||
|
|
||||||
(defn pay-button [{:keys [print-checks-shown? checked-invoices print-checks-loading?]}]
|
(defn pay-button [{:keys [print-checks-shown? checked-invoices print-checks-loading?]}]
|
||||||
(let [current-client @(re-frame/subscribe [::subs/client])]
|
(let [current-client @(re-frame/subscribe [::subs/client])]
|
||||||
@@ -603,14 +546,7 @@
|
|||||||
(when current-client
|
(when current-client
|
||||||
[drop-down {:header [:button.button.is-success {:aria-haspopup true
|
[drop-down {:header [:button.button.is-success {:aria-haspopup true
|
||||||
:on-click (dispatch-event [::events/toggle-menu ::print-checks ])
|
:on-click (dispatch-event [::events/toggle-menu ::print-checks ])
|
||||||
:disabled (if (and (seq checked-invoices)
|
:disabled (if (and (seq checked-invoices))
|
||||||
#_(->> checked-invoices
|
|
||||||
vals
|
|
||||||
(group-by #(get-in % [:vendor :id]))
|
|
||||||
(reduce-kv (fn [negative? _ invoices]
|
|
||||||
(or negative? (< (reduce + 0 (map (fn [x] (-> x :outstanding-balance js/parseFloat)) invoices) ) 0)))
|
|
||||||
false)
|
|
||||||
not))
|
|
||||||
""
|
""
|
||||||
"disabled")
|
"disabled")
|
||||||
|
|
||||||
@@ -666,63 +602,42 @@
|
|||||||
]))))
|
]))))
|
||||||
|
|
||||||
(defn unpaid-invoices-content [{:keys [status] :as params}]
|
(defn unpaid-invoices-content [{:keys [status] :as params}]
|
||||||
(r/create-class {:display-name "unpaid-invoices-content"
|
(let [{:keys [checked print-checks-shown? print-checks-loading? advanced-print-shown? vendor-filter]} @(re-frame/subscribe [::invoice-page])
|
||||||
:component-will-unmount (fn [this]
|
current-client @(re-frame/subscribe [::subs/client])]
|
||||||
(re-frame/dispatch [::unmount-invoices]))
|
[:div
|
||||||
:reagent-render (fn [{:keys [status]}]
|
[:h1.title (str (str/capitalize (or status "all")) " invoices")]
|
||||||
(let [{:keys [checked print-checks-shown? print-checks-loading? advanced-print-shown? vendor-filter]} @(re-frame/subscribe [::invoice-page])
|
(when (= status "unpaid")
|
||||||
current-client @(re-frame/subscribe [::subs/client])]
|
[pay-button {:print-checks-shown? print-checks-shown? :checked-invoices checked :print-checks-loading? print-checks-loading?}])
|
||||||
[:div
|
[table/invoice-table {:id :unpaid
|
||||||
[:h1.title (str (str/capitalize (or status "all")) " invoices")]
|
:invoice-page (re-frame/subscribe [::invoice-page])
|
||||||
|
:status (re-frame/subscribe [::subs/status])
|
||||||
(when (= status "unpaid")
|
:on-edit-invoice (fn [which]
|
||||||
[pay-button {:print-checks-shown? print-checks-shown? :checked-invoices checked :print-checks-loading? print-checks-loading?}])
|
(re-frame/dispatch [::form/editing which]))
|
||||||
|
:on-unvoid-invoice (fn [which]
|
||||||
|
(re-frame/dispatch [::unvoid-invoice which]))
|
||||||
|
:on-void-invoice (fn [which]
|
||||||
[invoice-table {:id :unpaid
|
(re-frame/dispatch [::void-invoice which]))
|
||||||
:params (re-frame/subscribe [::params])
|
:check-boxes (= status "unpaid")
|
||||||
:invoice-page (re-frame/subscribe [::invoice-page])
|
:checked checked
|
||||||
:status (re-frame/subscribe [::subs/status])
|
:on-check-changed (fn [which invoice]
|
||||||
:on-edit-invoice (fn [which]
|
(re-frame/dispatch [::toggle-check which invoice]))
|
||||||
(re-frame/dispatch [::form/editing which]))
|
:expense-event [::expense-accounts-dialog/change-expense-accounts]}]
|
||||||
:on-unvoid-invoice (fn [which]
|
]))
|
||||||
(re-frame/dispatch [::unvoid-invoice which]))
|
|
||||||
|
|
||||||
: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 invoice]
|
|
||||||
(re-frame/dispatch [::toggle-check which invoice]))
|
|
||||||
:expense-event [::expense-accounts-dialog/change-expense-accounts]}]
|
|
||||||
]))
|
|
||||||
:component-will-mount #(re-frame/dispatch-sync [::params-change params]) }))
|
|
||||||
|
|
||||||
(defn unpaid-invoices-page [params]
|
(defn unpaid-invoices-page [params]
|
||||||
(let [{invoice-bar-active? :active?} @(re-frame/subscribe [::forms/form ::form/form])]
|
(r/create-class
|
||||||
[side-bar-layout {:side-bar [invoices-side-bar {}
|
{:display-name "invoices-page"
|
||||||
^{:key "extra-filter"}
|
:component-did-mount #(re-frame/dispatch [::params-change])
|
||||||
[:div
|
:component-will-unmount #(re-frame/dispatch [::unmounted])
|
||||||
[:p.menu-label "Vendor"]
|
:reagent-render
|
||||||
[:div [vendor-filter {:on-change-event [::change-selected-vendor]
|
(fn []
|
||||||
:value (:vendor-filter @(re-frame/subscribe [::invoice-page]))
|
(let [{invoice-bar-active? :active?} @(re-frame/subscribe [::forms/form ::form/form])]
|
||||||
:vendors @(re-frame/subscribe [::subs/vendors])}]]
|
[side-bar-layout {:side-bar [invoices-side-bar {}]
|
||||||
[:p.menu-label "Date Range"]
|
:main [unpaid-invoices-content params]
|
||||||
[:div
|
:bottom [:div
|
||||||
[date-range-filter
|
[check-results-dialog]
|
||||||
{:on-change-event [::change-selected-date-range]
|
[print-checks-modal]
|
||||||
:value (:date-range-filter @(re-frame/subscribe [::invoice-page]))}]]
|
[handwrite-checks-modal]
|
||||||
[:p.menu-label "Invoice #"]
|
[change-expense-accounts-modal {:updated-event [::expense-accounts-updated]}]]
|
||||||
[:div
|
:right-side-bar [appearing-side-bar {:visible? invoice-bar-active?} [form/form {:invoice-created [::invoice-updated]
|
||||||
[invoice-number-filter]]]]
|
:invoice-printed [::checks-printed]}]]}]))}))
|
||||||
:main [unpaid-invoices-content params]
|
|
||||||
:bottom [:div
|
|
||||||
[check-results-dialog]
|
|
||||||
[print-checks-modal]
|
|
||||||
[handwrite-checks-modal]
|
|
||||||
[change-expense-accounts-modal {:updated-event [::expense-accounts-updated]}]]
|
|
||||||
:right-side-bar [appearing-side-bar {:visible? invoice-bar-active?} [form/form {:invoice-created [::invoice-updated]
|
|
||||||
:invoice-printed [::checks-printed]}]]}]))
|
|
||||||
|
|||||||
Reference in New Issue
Block a user