filtering on ledger page.

This commit is contained in:
Bryce Covert
2020-04-28 07:49:53 -07:00
parent 1f649794eb
commit edc7d50661
10 changed files with 137 additions and 111 deletions

View File

@@ -155,8 +155,8 @@
{:token (-> cofx :db :user)
:query-obj {:venia/queries [[:profit-and-loss
{:client-id (:id c)
:from-date (:from-date params)
:to-date (:to-date params)}
:date-range {:start (:from-date params)
:end (:to-date params)}}
[[:balance-sheet-accounts [:name :amount :account-type :id :numeric-code :location]]
[:comparable-balance-sheet-accounts [:name :amount :account-type :id :numeric-code :location]]]]]}
:on-success [::received]
@@ -219,14 +219,14 @@
:from-numeric-code from-numeric-code
:to-numeric-code to-numeric-code
:location location
:from-date (if (= :current which)
(:from-date (::params db))
(date->str (t/minus (str->date (:from-date (::params db)) standard) (t/years 1))
standard))
:to-date (if (= :current which)
(:to-date (::params db))
(date->str (t/minus (str->date (:to-date (::params db)) standard) (t/years 1))
standard)))]}))
:date-range {:start (if (= :current which)
(:from-date (::params db))
(date->str (t/minus (str->date (:from-date (::params db)) standard) (t/years 1))
standard))
:end (if (= :current which)
(:to-date (::params db))
(date->str (t/minus (str->date (:to-date (::params db)) standard) (t/years 1))
standard))})]}))
(def groupings
{:sales [["4000-4099 HQ Income" 4000 4099]

View File

@@ -2,6 +2,8 @@
(:require [auto-ap.routes :as routes]
[auto-ap.subs :as subs]
[auto-ap.views.utils :refer [active-when]]
[auto-ap.views.components.date-range-filter :refer [date-range-filter]]
[auto-ap.views.components.bank-account-filter :refer [bank-account-filter]]
[auto-ap.views.components.typeahead :refer [typeahead-entity]]
[bidi.bidi :as bidi]
[re-frame.core :as re-frame]))
@@ -21,13 +23,20 @@
::filter-params
:<- [::filters]
(fn [filters]
{:vendor-id (:id (:vendor filters))}))
{:vendor-id (:id (:vendor filters))
:date-range (:date-range filters)
:bank-account-id (:id (:bank-account 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)}))
(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.ledger/params-change]
:db (assoc-in db (into [::filters] which) val)})))
(defn ledger-side-bar []
(let [ap @(re-frame/subscribe [::subs/active-page])
@@ -60,10 +69,23 @@
:class [(active-when ap = :external-import-ledger)]}
[:span.icon [:i {:class "fa fa-download"}]]
[:span {:class "name"} "External Import"]]])
[:p.menu-label "Bank Account"]
[:div
[bank-account-filter
{:on-change-event [::filter-changed :bank-account]
:value @(re-frame/subscribe [::filter :bank-account])
:bank-accounts @(re-frame/subscribe [::subs/bank-accounts])}]]
[: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])}]]]]))
: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])}]]]]))

View File

@@ -17,9 +17,7 @@
[(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]}
))
: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?]
@@ -116,7 +114,8 @@
(when status?
[:td status])]]
(for [{:keys [debit credit location account]} line-items]
(for [{:keys [debit credit location account id]} line-items]
^{:key id}
[:tr {:class (:class i)}
(when-not selected-client
[:td ])