fixes.
This commit is contained in:
@@ -2,9 +2,33 @@
|
||||
(:require [auto-ap.routes :as routes]
|
||||
[auto-ap.subs :as subs]
|
||||
[auto-ap.views.utils :refer [active-when]]
|
||||
[auto-ap.views.components.typeahead :refer [typeahead-entity]]
|
||||
[bidi.bidi :as bidi]
|
||||
[re-frame.core :as re-frame]))
|
||||
|
||||
(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]
|
||||
(fn [filters]
|
||||
{:vendor-id (:id (:vendor filters))}))
|
||||
|
||||
(re-frame/reg-event-fx
|
||||
::filter-changed
|
||||
(fn [{:keys [db]} [_ which val]]
|
||||
{:dispatch [:auto-ap.views.pages.ledger/params-change]
|
||||
:db (assoc-in db [::filters which] val)}))
|
||||
|
||||
(defn ledger-side-bar []
|
||||
(let [ap @(re-frame/subscribe [::subs/active-page])
|
||||
user @(re-frame/subscribe [::subs/user])]
|
||||
@@ -35,4 +59,11 @@
|
||||
[:a.item {:href (bidi/path-for routes/routes :external-import-ledger)
|
||||
:class [(active-when ap = :external-import-ledger)]}
|
||||
[:span.icon [:i {:class "fa fa-download"}]]
|
||||
[:span {:class "name"} "External Import"]]])]]))
|
||||
[:span {:class "name"} "External Import"]]])
|
||||
[: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])}]]]]))
|
||||
|
||||
@@ -7,117 +7,130 @@
|
||||
[goog.string :as gstring]
|
||||
[re-frame.core :as re-frame]))
|
||||
|
||||
(defn table [{:keys [id ledger-page status on-params-change vendors params check-boxes checked on-check-changed expense-event]}]
|
||||
(let [opc (fn [p]
|
||||
(on-params-change (merge @params p )))]
|
||||
(fn [{:keys [id ledger-page status on-params-change vendors checked status?]
|
||||
:or {status? true}}]
|
||||
(let [{:keys [sort]} @params
|
||||
{:keys [journal-entries start end count total]} @ledger-page
|
||||
selected-client @(re-frame/subscribe [::subs/client])
|
||||
percentage-size (if selected-client "25%" "33%")]
|
||||
[:div
|
||||
[:div.level
|
||||
[:div.level-left
|
||||
[:div.level-item
|
||||
[paginator {:start start :end end :count count :total total
|
||||
:on-change (fn [p ]
|
||||
(on-params-change (merge @params p)))}]]
|
||||
[:div.level-item
|
||||
[sort-by-list {:sort sort
|
||||
:on-change opc}]]]]
|
||||
|
||||
|
||||
[:table.table.is-fullwidth.compact
|
||||
[:thead
|
||||
[:tr
|
||||
(when-not selected-client
|
||||
[sorted-column {:on-sort opc
|
||||
:style {:width percentage-size :cursor "pointer"}
|
||||
:sort-key "client"
|
||||
:sort-name "Client"
|
||||
:sort sort}
|
||||
"Client"])
|
||||
(re-frame/reg-sub
|
||||
::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.ledger/params-change]}
|
||||
|
||||
))
|
||||
|
||||
(defn table [{:keys [id ledger-page status vendors params check-boxes checked on-check-changed expense-event]}]
|
||||
(fn [{:keys [id ledger-page status vendors checked status?]
|
||||
:or {status? true}}]
|
||||
(let [{:keys [sort]} @params
|
||||
{:keys [journal-entries start end count total]} @ledger-page
|
||||
selected-client @(re-frame/subscribe [::subs/client])
|
||||
percentage-size (if selected-client "25%" "33%")
|
||||
opc (fn [e]
|
||||
(re-frame/dispatch [::params-changed e]))]
|
||||
[:div
|
||||
[:div.level
|
||||
[:div.level-left
|
||||
[:div.level-item
|
||||
[paginator {:start start :end end :count count :total total
|
||||
:on-change opc}]]
|
||||
[:div.level-item
|
||||
[sort-by-list {:sort sort
|
||||
:on-change opc}]]]]
|
||||
|
||||
|
||||
[:table.table.is-fullwidth.compact
|
||||
[:thead
|
||||
[:tr
|
||||
(when-not selected-client
|
||||
[sorted-column {:on-sort opc
|
||||
:style {:width percentage-size :cursor "pointer"}
|
||||
:sort-key "vendor"
|
||||
:sort-name "Vendor"
|
||||
:sort-key "client"
|
||||
:sort-name "Client"
|
||||
:sort sort}
|
||||
"Vendor"]
|
||||
|
||||
[sorted-column {:on-sort opc
|
||||
:style {:width "8em" :cursor "pointer"}
|
||||
:sort-key "date"
|
||||
:sort-name "Date"
|
||||
:sort sort}
|
||||
"Date"]
|
||||
[:th
|
||||
{:style {:width percentage-size }}
|
||||
"Account"]
|
||||
[sorted-column {:on-sort opc
|
||||
:style {:width "8em" :cursor "pointer"}
|
||||
:sort-key "amount"
|
||||
:sort-name "Amount"
|
||||
:class "has-text-right"
|
||||
:sort sort}
|
||||
"Debit"]
|
||||
"Client"])
|
||||
|
||||
[sorted-column {:on-sort opc
|
||||
:style {:width percentage-size :cursor "pointer"}
|
||||
:sort-key "vendor"
|
||||
:sort-name "Vendor"
|
||||
:sort sort}
|
||||
"Vendor"]
|
||||
|
||||
[sorted-column {:on-sort opc
|
||||
:style {:width "8em" :cursor "pointer"}
|
||||
:sort-key "date"
|
||||
:sort-name "Date"
|
||||
:sort sort}
|
||||
"Date"]
|
||||
[:th
|
||||
{:style {:width percentage-size }}
|
||||
"Account"]
|
||||
[sorted-column {:on-sort opc
|
||||
:style {:width "8em" :cursor "pointer"}
|
||||
:sort-key "amount"
|
||||
:sort-name "Amount"
|
||||
:class "has-text-right"
|
||||
:sort sort}
|
||||
"Debit"]
|
||||
|
||||
[sorted-column {:on-sort opc
|
||||
:style {:width "8em" :cursor "pointer"}
|
||||
:sort-key "amount"
|
||||
:sort-name "Amount"
|
||||
:class "has-text-right"
|
||||
:sort sort}
|
||||
"Credit"]
|
||||
|
||||
|
||||
(when status?
|
||||
|
||||
[sorted-column {:on-sort opc
|
||||
:style {:width "8em" :cursor "pointer"}
|
||||
:sort-key "amount"
|
||||
:sort-name "Amount"
|
||||
:class "has-text-right"
|
||||
:sort-key "status"
|
||||
:sort-name "Status"
|
||||
:sort sort}
|
||||
"Credit"]
|
||||
|
||||
|
||||
(when status?
|
||||
|
||||
[sorted-column {:on-sort opc
|
||||
:style {:width "8em" :cursor "pointer"}
|
||||
:sort-key "status"
|
||||
:sort-name "Status"
|
||||
:sort sort}
|
||||
"Status"])]]
|
||||
[:tbody
|
||||
(if (:loading @status)
|
||||
[:tr
|
||||
[:td {:col-span 5}
|
||||
[:i.fa.fa-spin.fa-spinner]]]
|
||||
(->>
|
||||
(for [{:keys [client vendor status date amount id line-items] :as i} (:journal-entries @ledger-page)]
|
||||
(into
|
||||
[^{:key id}
|
||||
[:tr {:class (:class i)}
|
||||
(when-not selected-client
|
||||
[:td (:name client)])
|
||||
[:td (if vendor
|
||||
(:name vendor)
|
||||
[:i.has-text-grey (str "Unknown Merchant")])]
|
||||
#_[:td description-original]
|
||||
[:td (date->str date) ]
|
||||
[:td ]
|
||||
[:td.has-text-right (nf amount )]
|
||||
[:td.has-text-right (nf amount )]
|
||||
|
||||
(when status?
|
||||
[:td status])]]
|
||||
(for [{:keys [debit credit location account]} line-items]
|
||||
[:tr {:class (:class i)}
|
||||
(when-not selected-client
|
||||
[:td ])
|
||||
[:td ]
|
||||
#_[:td description-original]
|
||||
[:td ]
|
||||
[:td (if (:name account)
|
||||
(str location ": " (:name account))
|
||||
[:i "unknown"])]
|
||||
[:td.has-text-right (when debit (nf debit ))]
|
||||
[:td.has-text-right (when credit (nf credit ))]
|
||||
|
||||
(when status?
|
||||
[:td status])]
|
||||
)))
|
||||
(mapcat identity)))]]]))))
|
||||
"Status"])]]
|
||||
[:tbody
|
||||
(if (:loading @status)
|
||||
[:tr
|
||||
[:td {:col-span 5}
|
||||
[:i.fa.fa-spin.fa-spinner]]]
|
||||
(->>
|
||||
(for [{:keys [client vendor status date amount id line-items] :as i} (:journal-entries @ledger-page)]
|
||||
(into
|
||||
[^{:key id}
|
||||
[:tr {:class (:class i)}
|
||||
(when-not selected-client
|
||||
[:td (:name client)])
|
||||
[:td (if vendor
|
||||
(:name vendor)
|
||||
[:i.has-text-grey (str "Unknown Merchant")])]
|
||||
#_[:td description-original]
|
||||
[:td (date->str date) ]
|
||||
[:td ]
|
||||
[:td.has-text-right (nf amount )]
|
||||
[:td.has-text-right (nf amount )]
|
||||
|
||||
(when status?
|
||||
[:td status])]]
|
||||
(for [{:keys [debit credit location account]} line-items]
|
||||
[:tr {:class (:class i)}
|
||||
(when-not selected-client
|
||||
[:td ])
|
||||
[:td ]
|
||||
#_[:td description-original]
|
||||
[:td ]
|
||||
[:td (if (:name account)
|
||||
(str location ": " (:name account))
|
||||
[:i "unknown"])]
|
||||
[:td.has-text-right (when debit (nf debit ))]
|
||||
[:td.has-text-right (when credit (nf credit ))]
|
||||
|
||||
(when status?
|
||||
[:td status])]
|
||||
)))
|
||||
(mapcat identity)))]]])))
|
||||
|
||||
|
||||
Reference in New Issue
Block a user