From 1534175608aee3dba676dd16095bc174aaab622a Mon Sep 17 00:00:00 2001 From: Bryce Covert Date: Wed, 16 Dec 2020 08:09:54 -0800 Subject: [PATCH] Adds the ability to find unresolved transactions --- src/clj/auto_ap/datomic/transactions.clj | 6 ++++++ src/clj/auto_ap/graphql.clj | 3 ++- src/cljs/auto_ap/views/pages/transactions.cljs | 1 + .../auto_ap/views/pages/transactions/side_bar.cljs | 14 +++++++++++++- 4 files changed, 22 insertions(+), 2 deletions(-) diff --git a/src/clj/auto_ap/datomic/transactions.clj b/src/clj/auto_ap/datomic/transactions.clj index 56257205..078535a1 100644 --- a/src/clj/auto_ap/datomic/transactions.clj +++ b/src/clj/auto_ap/datomic/transactions.clj @@ -101,6 +101,12 @@ '[?tas :transaction-account/location ?location]]} :args [(:location args)]}) + (:unresolved args) + (merge-query {:query {:where ['(or-join [?e] + (not [?e :transaction/accounts]) + (and [?e :transaction/accounts ?tas] + (not [?tas :transaction-account/account])))]}}) + (:description args) (merge-query {:query {:in ['?description] :where ['[?e :transaction/description-original ?do] diff --git a/src/clj/auto_ap/graphql.clj b/src/clj/auto_ap/graphql.clj index 04183915..a4df9fee 100644 --- a/src/clj/auto_ap/graphql.clj +++ b/src/clj/auto_ap/graphql.clj @@ -600,7 +600,8 @@ :start {:type 'Int} :per_page {:type 'Int} :sort {:type '(list :sort_item)} - :approval_status {:type :transaction_approval_status} }} + :approval_status {:type :transaction_approval_status} + :unresolved {:type 'Boolean}}} :ledger_filters {:fields {:client_id {:type :id} :vendor_id {:type :id} diff --git a/src/cljs/auto_ap/views/pages/transactions.cljs b/src/cljs/auto_ap/views/pages/transactions.cljs index 3610a506..08011a28 100644 --- a/src/cljs/auto_ap/views/pages/transactions.cljs +++ b/src/cljs/auto_ap/views/pages/transactions.cljs @@ -31,6 +31,7 @@ :account-id (:id (:account params)) :bank-account-id (:id (:bank-account params)) :amount-gte (:amount-gte (:amount-range params)) + :unresolved (:unresolved params) :location (:location params) :amount-lte (:amount-lte (:amount-range params)) :description (:description params) diff --git a/src/cljs/auto_ap/views/pages/transactions/side_bar.cljs b/src/cljs/auto_ap/views/pages/transactions/side_bar.cljs index 5ca71ca2..33fb453a 100644 --- a/src/cljs/auto_ap/views/pages/transactions/side_bar.cljs +++ b/src/cljs/auto_ap/views/pages/transactions/side_bar.cljs @@ -5,6 +5,7 @@ [auto-ap.views.components.date-range-filter :refer [date-range-filter]] [auto-ap.views.components.number-filter :refer [number-filter]] [auto-ap.views.components.bank-account-filter :refer [bank-account-filter]] + [auto-ap.views.components.switch-field :refer [switch-field]] [auto-ap.views.components.typeahead :refer [typeahead-entity]] [bidi.bidi :as bidi] [re-frame.core :as re-frame] @@ -101,5 +102,16 @@ [:div.field [:div.control [:input.input {:placeholder "CHECK 123 ABC" :value @(re-frame/subscribe [::data-page/filter data-page :description]) - :on-change (dispatch-value-change [::data-page/filter-changed data-page :description])} ]]]]])) + :on-change (dispatch-value-change [::data-page/filter-changed data-page :description])} ]]]] + + (when (= "admin" (:user/role user)) + [:<> + [:p.menu-label "Admin only"] + [:div + [switch-field {:id "unresolved-only" + :checked (boolean @(re-frame/subscribe [::data-page/filter data-page :unresolved])) + :on-change (fn [e] + (re-frame/dispatch [::data-page/filter-changed data-page :unresolved (.-checked (.-target e))])) + :label "Unresolved only" + :type "checkbox"}]]])]))