From 8c746e2100fbaffac54bd93048c82653443aa3f8 Mon Sep 17 00:00:00 2001 From: Bryce Covert Date: Fri, 16 Oct 2020 14:20:51 -0700 Subject: [PATCH] various fixes. --- src/clj/auto_ap/datomic/invoices.clj | 10 ++++- src/clj/auto_ap/graphql.clj | 1 + src/clj/auto_ap/graphql/ledger.clj | 7 ++-- src/clj/auto_ap/ledger.clj | 1 + src/clj/auto_ap/yodlee/core.clj | 11 +++--- .../views/components/invoice_table.cljs | 1 + .../views/components/invoices/side_bar.cljs | 39 ++++++++++++------- 7 files changed, 47 insertions(+), 23 deletions(-) diff --git a/src/clj/auto_ap/datomic/invoices.clj b/src/clj/auto_ap/datomic/invoices.clj index 90c69904..f4514efe 100644 --- a/src/clj/auto_ap/datomic/invoices.clj +++ b/src/clj/auto_ap/datomic/invoices.clj @@ -28,7 +28,7 @@ (defn raw-graphql-ids [db args] (->> (doto (cond-> {:query {:find [] :in ['$] - :where []} + :where ['[?e :invoice/client]]} :args [(d/db (d/connect uri))]} (limited-clients (:id args)) @@ -105,6 +105,14 @@ '[(.contains ^String ?invoice-number ?invoice-number-like)]]} :args [(:invoice-number-like args)]}) + (:unresolved args) + (merge-query {:query {:in [] + :where ['(or-join [?e] + (not [?e :invoice/expense-accounts ]) + (and [?e :invoice/expense-accounts ?ea] + (not [?ea :invoice-expense-account/account])))]} + :args []}) + (seq (:location args)) (merge-query {:query {:in ['?location] :where ['[?e :invoice/expense-accounts ?eas] diff --git a/src/clj/auto_ap/graphql.clj b/src/clj/auto_ap/graphql.clj index 7daf6ba1..fab231bd 100644 --- a/src/clj/auto_ap/graphql.clj +++ b/src/clj/auto_ap/graphql.clj @@ -481,6 +481,7 @@ :date_range {:type :date_range} :due_range {:type :date_range} :status {:type :invoice_status} + :unresolved {:type 'Boolean} :client_id {:type :id} :vendor_id {:type :id} :amount_lte {:type :money} diff --git a/src/clj/auto_ap/graphql/ledger.clj b/src/clj/auto_ap/graphql/ledger.clj index ecccbbc9..3421f84a 100644 --- a/src/clj/auto_ap/graphql/ledger.clj +++ b/src/clj/auto_ap/graphql/ledger.clj @@ -308,9 +308,10 @@ :journal-entry/line-items (mapv (fn [ea] - (when-not (get - (get all-client-locations (:client_code entry)) - (:location ea)) + (when (and (not (get + (get all-client-locations (:client_code entry)) + (:location ea))) + (not= "A" (:location ea))) (throw (ex-info (str "Location '" (:location ea) "' not found.") {:status :error}))) (when (and (<= (:debit ea 0.0) 0.0) diff --git a/src/clj/auto_ap/ledger.clj b/src/clj/auto_ap/ledger.clj index dcd5dce7..0cb3793f 100644 --- a/src/clj/auto_ap/ledger.clj +++ b/src/clj/auto_ap/ledger.clj @@ -196,6 +196,7 @@ (when (seq repairs) + (log/info (take 3 repairs)) (log/warn "repairing " (count txes-missing-ledger-entries) " missing transactions, " (count invoices-missing-ledger-entries) " missing invoices that were missing ledger entries") diff --git a/src/clj/auto_ap/yodlee/core.clj b/src/clj/auto_ap/yodlee/core.clj index fbf58b57..c1e0faa8 100644 --- a/src/clj/auto_ap/yodlee/core.clj +++ b/src/clj/auto_ap/yodlee/core.clj @@ -361,12 +361,13 @@ user-session (login-user cob-session) batch-size 100] - (-> (str (:yodlee-base-url env) "/providerAccounts?providerAccountIds=" pa) + (doto (-> (str (:yodlee-base-url env) "/providerAccounts?providerAccountIds=" pa) - (client/put (merge {:headers (merge base-headers {"Authorization" (auth-header cob-session user-session)}) - :body (json/write-str data) - :as :json} - other-config))) + (client/put (merge {:headers (merge base-headers {"Authorization" (auth-header cob-session user-session)}) + :body (json/write-str data) + :as :json} + other-config))) + log/info) (refresh-provider-account pa))) #_(defn get-users [] diff --git a/src/cljs/auto_ap/views/components/invoice_table.cljs b/src/cljs/auto_ap/views/components/invoice_table.cljs index 1c2f9591..1ab7d47b 100644 --- a/src/cljs/auto_ap/views/components/invoice_table.cljs +++ b/src/cljs/auto_ap/views/components/invoice_table.cljs @@ -32,6 +32,7 @@ :amount-gte (:amount-gte (:amount-range params)) :amount-lte (:amount-lte (:amount-range params)) :location (:location params) + :unresolved (:unresolved 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 bfa38045..0b6352dd 100644 --- a/src/cljs/auto_ap/views/components/invoices/side_bar.cljs +++ b/src/cljs/auto_ap/views/components/invoices/side_bar.cljs @@ -1,20 +1,14 @@ (ns auto-ap.views.components.invoices.side-bar - (:require [re-frame.core :as re-frame] - [reagent.core :as r] - [clojure.string :as str] - [clojure.spec.alpha :as s] - [cljs-time.core :as c] - [goog.string :as gstring] - [bidi.bidi :as bidi] - [auto-ap.utils :refer [deep-merge ]] - [auto-ap.routes :as routes] + (:require [auto-ap.routes :as routes] + [auto-ap.subs :as subs] [auto-ap.views.components.date-range-filter :refer [date-range-filter]] [auto-ap.views.components.number-filter :refer [number-filter]] + [auto-ap.views.components.switch-field :refer [switch-field]] [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 query-params dispatch-value-change]] - [auto-ap.subs :as subs] - [auto-ap.events :as events] - [auto-ap.views.pages.data-page :as data-page])) + [auto-ap.views.pages.data-page :as data-page] + [auto-ap.views.utils :refer [active-when dispatch-value-change]] + [bidi.bidi :as bidi] + [re-frame.core :as re-frame])) (defn invoice-number-filter [{:keys [data-page]}] [:div.field @@ -97,4 +91,21 @@ [:p.menu-label "Invoice #"] [:div - [invoice-number-filter params]]])])) + [invoice-number-filter params]] + + (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"}]]] + ) + ])]))