diff --git a/src/clj/auto_ap/graphql.clj b/src/clj/auto_ap/graphql.clj index 37cd9eb8..c142c840 100644 --- a/src/clj/auto_ap/graphql.clj +++ b/src/clj/auto_ap/graphql.clj @@ -46,6 +46,8 @@ :serialize #(or (:ident %) (:db/ident %) %)} :iso_date {:parse #(time/parse % time/iso-date) :serialize #(time/unparse % time/iso-date)} + :iso_date_time {:parse #(clj-time.coerce/to-date-time %) + :serialize #(str (clj-time.coerce/to-date-time %))} :money {:parse #(cond (and (string? %) (not (str/blank? %))) (Double/parseDouble %) @@ -459,22 +461,7 @@ :start {:type 'Int} :end {:type 'Int}}} - :import_batch {:fields {:user_name {:type 'String} - :id {:type :id} - :date {:type :iso_date} - :imported {:type 'Int} - :extant {:type 'Int} - :suppressed {:type 'Int} - :status {:type :import_batch_status} - :source {:type :import_batch_source}}} - - :import_batch_page {:fields {:data {:type '(list :import_batch)} - :count {:type 'Int} - :total {:type 'Int} - :start {:type 'Int} - :end {:type 'Int}}} - - :transaction_rule_page {:fields {:transaction_rules {:type '(list :transaction_rule)} + :transaction_rule_page {:fields {:transaction_rules {:type '(list :transaction_rule)} :count {:type 'Int} :total {:type 'Int} :start {:type 'Int} @@ -655,10 +642,7 @@ :resolve :get-transaction-page} - :import_batch_page {:type :import_batch_page - :args {:filters {:type :import_batch_filters}} - - :resolve :get-import-batch-page} + :transaction_rule_page {:type :transaction_rule_page :args {:client_id {:type :id} @@ -748,9 +732,7 @@ :sort {:type '(list :sort_item)} :approval_status {:type :transaction_approval_status} :unresolved {:type 'Boolean}}} - :import_batch_filters {:fields {:start {:type 'Int} - :per_page {:type 'Int} - :sort {:type '(list :sort_item)}}} + :ledger_filters {:fields {:client_id {:type :id} :vendor_id {:type :id} @@ -967,13 +949,8 @@ {:enum-value :cash} {:enum-value :debit}]} - :import_batch_source {:values [{:enum-value :intuit} - {:enum-value :yodlee} - {:enum-value :yodlee2} - {:enum-value :plaid} - {:enum-value :manual}]} - :import_batch_status {:values [{:enum-value :started} - {:enum-value :completed}]} + + :processor {:values [{:enum-value :na} {:enum-value :doordash} @@ -1373,7 +1350,6 @@ :get-potential-unpaid-invoices-matches gq-transactions/get-potential-unpaid-invoices-matches :get-accounts gq-accounts/get-accounts :get-transaction-page gq-transactions/get-transaction-page - :get-import-batch-page gq-import-batches/get-import-batch-page :get-ledger-page gq-ledger/get-ledger-page :get-sales-order-page gq-sales-orders/get-sales-orders-page :get-balance-sheet gq-ledger/get-balance-sheet @@ -1421,6 +1397,7 @@ :mutation/request-import gq-requests/request-import :get-vendor gq-vendors/get-graphql}) gq-plaid/attach + gq-import-batches/attach schema/compile)) diff --git a/src/clj/auto_ap/graphql/import_batch.clj b/src/clj/auto_ap/graphql/import_batch.clj index 15f9a0a9..bf1b785c 100644 --- a/src/clj/auto_ap/graphql/import_batch.clj +++ b/src/clj/auto_ap/graphql/import_batch.clj @@ -1,11 +1,12 @@ (ns auto-ap.graphql.import-batch - (:require - [clojure.tools.logging :as log] - - [datomic.api :as d] - [auto-ap.datomic - :refer [add-sorter-fields apply-pagination apply-sort-3 merge-query conn]] - [auto-ap.graphql.utils :refer [<-graphql assert-admin ident->enum-f result->page]])) + (:require [auto-ap.datomic + :refer + [add-sorter-fields apply-pagination apply-sort-3 conn merge-query]] + [auto-ap.graphql.utils + :refer + [<-graphql assert-admin ident->enum-f result->page]] + [com.walmartlabs.lacinia.util :refer [attach-resolvers]] + [datomic.api :as d])) (def default-read '[:db/id :import-batch/external-id @@ -60,4 +61,38 @@ matching-count :data args))) +(defn attach [schema] + (-> + (merge-with merge schema + {:objects {:import_batch {:fields {:user_name {:type 'String} + :id {:type :id} + :date {:type :iso_date_time} + :imported {:type 'Int} + :extant {:type 'Int} + :suppressed {:type 'Int} + :status {:type :import_batch_status} + :source {:type :import_batch_source}}} + :import_batch_page {:fields {:data {:type '(list :import_batch)} + :count {:type 'Int} + :total {:type 'Int} + :start {:type 'Int} + :end {:type 'Int}}} + +} + :queries {:import_batch_page {:type :import_batch_page + :args {:filters {:type :import_batch_filters}} + + :resolve :get-import-batch-page}} + :mutations {} + :input-objects {:import_batch_filters {:fields {:start {:type 'Int} + :per_page {:type 'Int} + :sort {:type '(list :sort_item)}}}} + :enums {:import_batch_status {:values [{:enum-value :started} + {:enum-value :completed}]} + :import_batch_source {:values [{:enum-value :intuit} + {:enum-value :yodlee} + {:enum-value :yodlee2} + {:enum-value :plaid} + {:enum-value :manual}]}}}) + (attach-resolvers {:get-import-batch-page get-import-batch-page}))) diff --git a/src/clj/auto_ap/time.clj b/src/clj/auto_ap/time.clj index 4abc101a..15088774 100644 --- a/src/clj/auto_ap/time.clj +++ b/src/clj/auto_ap/time.clj @@ -1,6 +1,7 @@ (ns auto-ap.time (:require [clj-time.core :as time] - [clj-time.format :as f])) + [clj-time.format :as f] + [clojure.tools.logging :as log])) (defn localize [d] (time/to-time-zone d (time/time-zone-for-id "America/Los_Angeles"))) @@ -10,6 +11,7 @@ (def normal-date "MM/dd/yyyy") (def iso-date "yyyy-MM-dd") +(def iso-date-time (:date-hour-minute-second-ms f/formatters)) (defn parse [v format] (try @@ -22,6 +24,7 @@ (try (f/unparse (f/formatter format) v) (catch Exception e + (log/warn e) nil))) (defn unparse-local [v format] diff --git a/src/cljs/auto_ap/effects.cljs b/src/cljs/auto_ap/effects.cljs index 09d3a2cf..68480bac 100644 --- a/src/cljs/auto_ap/effects.cljs +++ b/src/cljs/auto_ap/effects.cljs @@ -57,7 +57,6 @@ (def is-year-month-day #"^\d{4}-\d{2}-\d{2}$") - (defn dates->date-times [x] (walk/postwalk (fn [node] @@ -65,7 +64,7 @@ (and (string? node) (re-matches is-8601 node)) - (format/parse (format/formatters :date-time) node) + (time/to-default-time-zone (format/parse (format/formatters :date-time) node)) (and (string? node) (re-matches is-year-month-day node)) diff --git a/src/cljs/auto_ap/views/components/admin/side_bar.cljs b/src/cljs/auto_ap/views/components/admin/side_bar.cljs index 2e70be0e..01ba386f 100644 --- a/src/cljs/auto_ap/views/components/admin/side_bar.cljs +++ b/src/cljs/auto_ap/views/components/admin/side_bar.cljs @@ -60,7 +60,12 @@ [:a {:href (bidi/path-for routes/routes :admin-yodlee2), :class (str "item" (active-when ap = :admin-yodlee2))} [:span {:class "icon icon-saving-bank-1" :style {:font-size "25px"}}] [:span {:class "name"} "Yodlee 2 Link"]]] - + + [:li.menu-item + [:a {:href (bidi/path-for routes/routes :admin-plaid), :class (str "item" (active-when ap = :admin-plaid))} + [:span {:class "icon icon-saving-bank-1" :style {:font-size "25px"}}] + [:span {:class "name"} "Plaid Link"]]] + [:ul ]] [:p.menu-label "History"] [:ul.menu-list diff --git a/src/cljs/auto_ap/views/pages/admin/import_batches/table.cljs b/src/cljs/auto_ap/views/pages/admin/import_batches/table.cljs index 6d725c82..212e715a 100644 --- a/src/cljs/auto_ap/views/pages/admin/import_batches/table.cljs +++ b/src/cljs/auto_ap/views/pages/admin/import_batches/table.cljs @@ -1,16 +1,17 @@ (ns auto-ap.views.pages.admin.import-batches.table - (:require - [auto-ap.status :as status] - [auto-ap.subs :as subs] - [auto-ap.views.components.buttons :as buttons] - [auto-ap.views.components.grid :as grid] - [auto-ap.views.pages.data-page :as data-page] - [auto-ap.views.utils :refer [date->str dispatch-event action-cell-width]] - [re-frame.core :as re-frame] - [reagent.core :as r] - [bidi.bidi :as bidi] - [auto-ap.routes :as routes] - [cemerick.url :as url])) + (:require [auto-ap.routes :as routes] + [auto-ap.status :as status] + [auto-ap.subs :as subs] + [auto-ap.views.components.buttons :as buttons] + [auto-ap.views.components.grid :as grid] + [auto-ap.views.pages.data-page :as data-page] + [auto-ap.views.utils + :refer + [action-cell-width date->str dispatch-event pretty-long]] + [bidi.bidi :as bidi] + [cemerick.url :as url] + [re-frame.core :as re-frame] + [reagent.core :as r])) (re-frame/reg-sub ::specific-table-params @@ -67,7 +68,7 @@ (for [{:keys [date source status user-name id imported extant suppressed] :as r} (:data data)] ^{:key id} [grid/row {:class (:class r) :id id} - [grid/cell {} (date->str date)] + [grid/cell {} (date->str date pretty-long)] [grid/cell {} source] [grid/cell {} status] [grid/cell {} user-name]