diff --git a/src/clj/auto_ap/datomic/invoices.clj b/src/clj/auto_ap/datomic/invoices.clj index db2f38c8..90c69904 100644 --- a/src/clj/auto_ap/datomic/invoices.clj +++ b/src/clj/auto_ap/datomic/invoices.clj @@ -105,6 +105,12 @@ '[(.contains ^String ?invoice-number ?invoice-number-like)]]} :args [(:invoice-number-like args)]}) + (seq (:location args)) + (merge-query {:query {:in ['?location] + :where ['[?e :invoice/expense-accounts ?eas] + '[?eas :invoice-expense-account/location ?location]]} + :args [(:location args)]}) + (:sort args) (add-sorter-fields {"client" ['[?e :invoice/client ?c] '[?c :client/name ?sort-client]] "vendor" ['[?e :invoice/vendor ?v] diff --git a/src/clj/auto_ap/datomic/transactions.clj b/src/clj/auto_ap/datomic/transactions.clj index 97ce69ac..56257205 100644 --- a/src/clj/auto_ap/datomic/transactions.clj +++ b/src/clj/auto_ap/datomic/transactions.clj @@ -95,6 +95,12 @@ '[?c :client/original-id ?original-id]]} :args [(:original-id args)]}) + (seq (:location args)) + (merge-query {:query {:in ['?location] + :where ['[?e :transaction/accounts ?tas] + '[?tas :transaction-account/location ?location]]} + :args [(:location args)]}) + (: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 7bd0bd00..6034a9da 100644 --- a/src/clj/auto_ap/graphql.clj +++ b/src/clj/auto_ap/graphql.clj @@ -485,6 +485,7 @@ :amount_lte {:type :money} :amount_gte {:type :money} :invoice_number_like {:type 'String} + :location {:type 'String} :start {:type 'Int} :per_page {:type 'Int} :sort {:type '(list :sort_item)}} @@ -588,6 +589,7 @@ :bank_account_id {:type :id} :account_id {:type :id} :date_range {:type :date_range} + :location {:type 'String} :amount_lte {:type :money} :amount_gte {:type :money} :description {:type 'String} diff --git a/src/cljs/auto_ap/views/components/invoice_table.cljs b/src/cljs/auto_ap/views/components/invoice_table.cljs index 7d9ecef6..1c2f9591 100644 --- a/src/cljs/auto_ap/views/components/invoice_table.cljs +++ b/src/cljs/auto_ap/views/components/invoice_table.cljs @@ -31,6 +31,7 @@ :due-range (:due-range params) :amount-gte (:amount-gte (:amount-range params)) :amount-lte (:amount-lte (:amount-range params)) + :location (:location params) :invoice-number-like (:invoice-number-like params) :client-id (:id @(re-frame/subscribe [::subs/client])) :import-status (:import-status params) diff --git a/src/cljs/auto_ap/views/components/invoices/side_bar.cljs b/src/cljs/auto_ap/views/components/invoices/side_bar.cljs index f27dfc39..bfa38045 100644 --- a/src/cljs/auto_ap/views/components/invoices/side_bar.cljs +++ b/src/cljs/auto_ap/views/components/invoices/side_bar.cljs @@ -88,6 +88,13 @@ {:on-change-event [::data-page/filter-changed data-page :amount-range] :value @(re-frame/subscribe [::data-page/filter data-page :amount-range])}]] + [:p.menu-label "Location"] + [:div.field + [:div.control [:input.input {:placeholder "SC" + :style {:width "3em"} + :value @(re-frame/subscribe [::data-page/filter data-page :location]) + :on-change (dispatch-value-change [::data-page/filter-changed data-page :location ])} ]]] + [:p.menu-label "Invoice #"] [:div [invoice-number-filter params]]])])) diff --git a/src/cljs/auto_ap/views/pages/ledger.cljs b/src/cljs/auto_ap/views/pages/ledger.cljs index 01cf9a5f..97de9612 100644 --- a/src/cljs/auto_ap/views/pages/ledger.cljs +++ b/src/cljs/auto_ap/views/pages/ledger.cljs @@ -30,6 +30,7 @@ :vendor-id (:id (:vendor params)) :date-range (:date-range params) :account-id (:id (:account params)) + :location (:location params) :bank-account-id (:id (:bank-account params)) :amount-gte (:amount-gte (:amount-range params)) :amount-lte (:amount-lte (:amount-range params))}) diff --git a/src/cljs/auto_ap/views/pages/ledger/side_bar.cljs b/src/cljs/auto_ap/views/pages/ledger/side_bar.cljs index c93b7a41..1ac76972 100644 --- a/src/cljs/auto_ap/views/pages/ledger/side_bar.cljs +++ b/src/cljs/auto_ap/views/pages/ledger/side_bar.cljs @@ -88,6 +88,13 @@ {:on-change-event [::data-page/filter-changed data-page :amount-range] :value @(re-frame/subscribe [::data-page/filter data-page :amount-range])}]] + [:p.menu-label "Location"] + [:div.field + [:div.control [:input.input {:placeholder "SC" + :style {:width "3em"} + :value @(re-frame/subscribe [::data-page/filter data-page :location]) + :on-change (dispatch-value-change [::data-page/filter-changed data-page :location ])} ]]] + (when (= :external-ledger ap) [:<> [:p.menu-label "External ID"] diff --git a/src/cljs/auto_ap/views/pages/transactions.cljs b/src/cljs/auto_ap/views/pages/transactions.cljs index 1e617d06..b5716d33 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)) + :location (:location params) :amount-lte (:amount-lte (:amount-range params)) :description (:description params) :approval-status (condp = @(re-frame/subscribe [::subs/active-page]) 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 ed91c22b..5ca71ca2 100644 --- a/src/cljs/auto_ap/views/pages/transactions/side_bar.cljs +++ b/src/cljs/auto_ap/views/pages/transactions/side_bar.cljs @@ -89,6 +89,12 @@ :value @(re-frame/subscribe [::data-page/filter data-page :date-range])}]] + [:p.menu-label "Location"] + [:div.field + [:div.control [:input.input {:placeholder "SC" + :style {:width "3em"} + :value @(re-frame/subscribe [::data-page/filter data-page :location]) + :on-change (dispatch-value-change [::data-page/filter-changed data-page :location ])} ]]] [:p.menu-label "Description"] [:div