makes plaid really usable, allowing choosing on bank screen, and searchable on vendors page.
This commit is contained in:
@@ -200,7 +200,8 @@
|
||||
:account/location
|
||||
{:account/client-overrides [:account-client-override/name
|
||||
{:account-client-override/client [:db/id]}]}]}]
|
||||
:transaction/yodlee-merchant [:db/id :yodlee-merchant/yodlee-id :yodlee-merchant/name]}]
|
||||
:transaction/yodlee-merchant [:db/id :yodlee-merchant/yodlee-id :yodlee-merchant/name]
|
||||
:transaction/plaid-merchant [:db/id :plaid-merchant/name]}]
|
||||
ids)
|
||||
(map #(update % :transaction/date coerce/from-date))
|
||||
(map #(update % :transaction/post-date coerce/from-date))
|
||||
|
||||
@@ -47,6 +47,7 @@
|
||||
:vendor/legal-entity-tin-type [:db/ident :db/id]
|
||||
:vendor/legal-entity-1099-type [:db/ident :db/id]
|
||||
:vendor/default-account [:db/id :account/numeric-code :account/name]
|
||||
:vendor/plaid-merchant [:db/id :plaid-merchant/name]
|
||||
:vendor-usage/_vendor [:vendor-usage/client :vendor-usage/count]}])
|
||||
|
||||
|
||||
@@ -124,6 +125,7 @@
|
||||
{:vendor/default-account [:account/name :db/id :account/location]
|
||||
:vendor/legal-entity-tin-type [:db/ident :db/id]
|
||||
:vendor/legal-entity-1099-type [:db/ident :db/id]
|
||||
:vendor/plaid-merchant [:db/id :plaid-merchant/name]
|
||||
:vendor/account-overrides [* {:vendor-account-override/client [:client/name :db/id]
|
||||
:vendor-account-override/account [:account/name :account/numeric-code :db/id]}]
|
||||
:vendor/terms-overrides [* {:vendor-terms-override/client [:client/name :db/id]}]
|
||||
|
||||
@@ -176,6 +176,7 @@
|
||||
|
||||
:print_as {:type 'String}
|
||||
:primary_contact {:type :contact}
|
||||
:plaid_merchant {:type :plaid_merchant}
|
||||
:secondary_contact {:type :contact}
|
||||
:address {:type :address}
|
||||
|
||||
@@ -210,6 +211,9 @@
|
||||
:yodlee_id {:type 'String}
|
||||
:name {:type 'String}}}
|
||||
|
||||
:plaid_merchant {:fields {:id {:type :id}
|
||||
:name {:type 'String}}}
|
||||
|
||||
:intuit_bank_account {:fields {:id {:type :id}
|
||||
:external_id {:type 'String}
|
||||
:name {:type 'String}}}
|
||||
@@ -470,6 +474,7 @@
|
||||
:secondary_contact {:type :add_contact}
|
||||
:address {:type :add_address}
|
||||
:default_account_id {:type :id}
|
||||
:plaid_merchant {:type :id}
|
||||
:account_overrides {:type '(list :add_account_override)}
|
||||
:schedule_payment_dom {:type '(list :add_schedule_payment_dom)}
|
||||
:invoice_reminder_schedule {:type 'String}
|
||||
@@ -882,3 +887,4 @@
|
||||
:exception e)
|
||||
|
||||
(throw e))))))))))
|
||||
|
||||
|
||||
@@ -16,12 +16,16 @@
|
||||
assert-can-see-client
|
||||
assert-present
|
||||
attach-tracing-resolvers
|
||||
cleanse-query
|
||||
limited-clients]]
|
||||
[auto-ap.plaid.core :as p]
|
||||
[clj-time.coerce :as coerce]
|
||||
[clj-time.core :as time]
|
||||
[clojure.tools.logging :as log]
|
||||
[datomic.api :as dc]))
|
||||
[datomic.api :as dc]
|
||||
[auto-ap.solr :as solr]
|
||||
[manifold.deferred :as de]
|
||||
[manifold.executor :as ex]))
|
||||
|
||||
(defn plaid-link-token [context value _]
|
||||
(when-not (:client_id value)
|
||||
@@ -128,6 +132,30 @@
|
||||
@(dc/transact conn [[:db/retractEntity (:id args)]])
|
||||
{:message "Item deleted."})
|
||||
|
||||
(defn search-merchants [context args _]
|
||||
(if-let [query (not-empty (cleanse-query (:query args)))]
|
||||
(let [search-query (str "name:(" query ")")]
|
||||
(for [{:keys [id name]} (solr/query solr/impl "plaid_merchants" {"query" search-query
|
||||
"fields" "id, name"})]
|
||||
{:id (Long/parseLong id)
|
||||
:name (first name)}))
|
||||
[]))
|
||||
|
||||
(def single-thread (ex/fixed-thread-executor 1))
|
||||
|
||||
(defn rebuild-search-index []
|
||||
(de/future-with
|
||||
single-thread
|
||||
(auto-ap.solr/index-documents-raw
|
||||
auto-ap.solr/impl
|
||||
"plaid_merchants"
|
||||
(for [[result] (dc/qseq {:query '[:find (pull ?v [:plaid-merchant/name :db/id])
|
||||
:in $
|
||||
:where [?v :plaid-merchant/name]]
|
||||
:args [(dc/db conn)]})]
|
||||
{"id" (:db/id result)
|
||||
"name" (:plaid-merchant/name result)}))))
|
||||
|
||||
(defn attach [schema]
|
||||
(->
|
||||
(merge-with merge schema
|
||||
@@ -162,7 +190,10 @@
|
||||
:sort {:type '(list :sort_item)}
|
||||
:start {:type 'Int}
|
||||
:per_page {:type 'Int}}
|
||||
:resolve :get-plaid-item-page}}
|
||||
:resolve :get-plaid-item-page}
|
||||
:search_plaid_merchants {:type '(list :plaid_merchant)
|
||||
:args {:query {:type 'String}}
|
||||
:resolve :search-plaid-merchants}}
|
||||
:mutations {:link_plaid {:type :message
|
||||
:args {:client_code {:type 'String}
|
||||
:public_token {:type 'String}}
|
||||
@@ -171,6 +202,7 @@
|
||||
:args {:id {:type :id}}
|
||||
:resolve :mutation/delete-plaid-item}}})
|
||||
(attach-tracing-resolvers {:plaid-link-token plaid-link-token
|
||||
:search-plaid-merchants search-merchants
|
||||
:get-plaid-item-page get-plaid-item-page
|
||||
:mutation/link-plaid link-plaid
|
||||
:mutation/delete-plaid-item delete-plaid-item})))
|
||||
|
||||
@@ -550,6 +550,7 @@
|
||||
:accounts {:type '(list :invoices_expense_accounts)}
|
||||
:payment {:type :payment}
|
||||
:expected_deposit {:type :expected_deposit}
|
||||
:plaid_merchant {:type :plaid_merchant}
|
||||
:vendor {:type :vendor}
|
||||
:bank_account {:type :bank_account}
|
||||
:date {:type 'String}
|
||||
|
||||
@@ -34,7 +34,7 @@
|
||||
(map first)))
|
||||
(set (map :db/id (:user/clients id)))))))
|
||||
|
||||
(defn upsert-vendor [context {{:keys [id name hidden terms code print_as primary_contact secondary_contact address default_account_id invoice_reminder_schedule schedule_payment_dom terms_overrides account_overrides] :as in} :vendor} _]
|
||||
(defn upsert-vendor [context {{:keys [id name hidden terms code print_as primary_contact plaid_merchant secondary_contact address default_account_id invoice_reminder_schedule schedule_payment_dom terms_overrides account_overrides] :as in} :vendor} _]
|
||||
(when (and id (not (can-user-edit-vendor? id (:id context))))
|
||||
(assert-failure "This vendor is managed by Integreat. Please reach out to ben@integreatconsult.com for your changes."))
|
||||
|
||||
@@ -125,6 +125,7 @@
|
||||
:vendor/legal-entity-tin (:legal_entity_tin in)
|
||||
:vendor/legal-entity-tin-type (enum->keyword (:legal_entity_tin_type in) "legal-entity-tin-type")
|
||||
:vendor/legal-entity-1099-type (enum->keyword (:legal_entity_1099_type in) "legal-entity-1099-type")
|
||||
:vendor/plaid-merchant plaid_merchant
|
||||
:vendor/account-overrides account-overrides
|
||||
:vendor/terms-overrides terms-overrides
|
||||
:vendor/schedule-payment-dom schedule-payment-dom
|
||||
|
||||
@@ -25,16 +25,18 @@
|
||||
|
||||
|
||||
(defn plaid->transaction [t]
|
||||
#:transaction {:description-original (:name t)
|
||||
:raw-id (:transaction_id t)
|
||||
:db/id (random-tempid)
|
||||
:id #_{:clj-kondo/ignore [:unresolved-var]}
|
||||
(di/sha-256 (:transaction_id t))
|
||||
:amount (if (= "credit" (:type (:account t)))
|
||||
(- (double (:amount t)))
|
||||
(double (:amount t)))
|
||||
:date (coerce/to-date (atime/parse (:authorized_date t) atime/iso-date))
|
||||
:status "POSTED"})
|
||||
(cond-> #:transaction {:description-original (:name t)
|
||||
:raw-id (:transaction_id t)
|
||||
:db/id (random-tempid)
|
||||
:id #_{:clj-kondo/ignore [:unresolved-var]}
|
||||
(di/sha-256 (:transaction_id t))
|
||||
:amount (if (= "credit" (:type (:account t)))
|
||||
(- (double (:amount t)))
|
||||
(double (:amount t)))
|
||||
:date (coerce/to-date (atime/parse (:authorized_date t) atime/iso-date))
|
||||
:status "POSTED"}
|
||||
(:merchant_name t) (assoc :transaction/plaid-merchant {:plaid-merchant/name (:merchant_name t)
|
||||
:db/id (random-tempid)})))
|
||||
|
||||
|
||||
(defn import-plaid-int []
|
||||
@@ -53,6 +55,7 @@
|
||||
:account
|
||||
(accounts-by-id (:account_id transaction))))
|
||||
:transaction/bank-account bank-account-id
|
||||
|
||||
:transaction/client client-id))))
|
||||
(t/finish! import-batch)
|
||||
(catch Exception e
|
||||
|
||||
Reference in New Issue
Block a user