Yodlee exists as datomic entities!

This commit is contained in:
Bryce Covert
2020-12-22 13:12:22 -08:00
parent c28bd9635d
commit 6930a8c7c2
17 changed files with 883 additions and 478 deletions

View File

@@ -1,7 +1,7 @@
(ns auto-ap.graphql.clients
(:require [auto-ap.datomic :refer [audit-transact conn remove-nils]]
[auto-ap.datomic.clients :as d-clients]
[auto-ap.graphql.utils :refer [->graphql assert-admin can-see-client?]]
[auto-ap.graphql.utils :refer [->graphql assert-admin can-see-client? is-admin?]]
[clj-time.coerce :as coerce]
[config.core :refer [env]]
[clojure.string :as str]
@@ -47,10 +47,16 @@
(mapv (fn [lm] [:db/retractEntity (:db/id lm)]) (:client/location-matches client))
(mapv (fn [m] [:db/retract (:db/id client) :client/matches m]) (:client/matches client)))
(:id context)))
reverts (->> (:bank_accounts edit_client)
(filter #(nil? (:yodlee_account_id %)))
(filter #(:bank-account/yodlee-account-id (d/entity (d/db conn) (:id %))))
(map (fn [ba] [:db/retract (:id ba) :bank-account/yodlee-account-id (:bank-account/yodlee-account-id (d/entity (d/db conn) (:id ba)))])))
reverts (into (->> (:bank_accounts edit_client)
(filter #(nil? (:yodlee_account_id %)))
(filter #(:bank-account/yodlee-account-id (d/entity (d/db conn) (:id %))))
(map (fn [ba] [:db/retract (:id ba) :bank-account/yodlee-account-id (:bank-account/yodlee-account-id (d/entity (d/db conn) (:id ba)))])))
(->> (:bank_accounts edit_client)
(filter #(nil? (:yodlee_account %)))
(filter #(:bank-account/yodlee-account (d/entity (d/db conn) (:id %))))
(map (fn [ba] [:db/retract (:id ba) :bank-account/yodlee-account (:db/id (:bank-account/yodlee-account (d/entity (d/db conn) (:id ba))))]))))
transactions (into [(remove-nils {:db/id id
:client/code (if (str/blank? (:client/code client))
(:code edit_client)
@@ -77,24 +83,26 @@
:client/bank-accounts (map #(remove-nils
{:db/id (:id %)
:bank-account/code (:code %)
:bank-account/bank-name (:bank_name %)
:bank-account/bank-code (:bank_code %)
:bank-account/start-date (-> (:start_date %) (coerce/to-date))
:bank-account/routing (:routing %)
:bank-account/include-in-reports (:include_in_reports %)
(cond-> {:db/id (:id %)
:bank-account/code (:code %)
:bank-account/bank-name (:bank_name %)
:bank-account/bank-code (:bank_code %)
:bank-account/start-date (-> (:start_date %) (coerce/to-date))
:bank-account/routing (:routing %)
:bank-account/include-in-reports (:include_in_reports %)
:bank-account/name (:name %)
:bank-account/visible (:visible %)
:bank-account/number (:number %)
:bank-account/check-number (:check_number %)
:bank-account/sort-order (:sort_order %)
:bank-account/locations (:locations %)
:bank-account/name (:name %)
:bank-account/visible (:visible %)
:bank-account/number (:number %)
:bank-account/check-number (:check_number %)
:bank-account/sort-order (:sort_order %)
:bank-account/locations (:locations %)
:bank-account/yodlee-account-id (:yodlee_account_id %)
:bank-account/type (keyword "bank-account-type" (name (:type %)))
}
:bank-account/yodlee-account-id (:yodlee_account_id %)
:bank-account/type (keyword "bank-account-type" (name (:type %)))
}
(:yodlee_account %) (assoc :bank-account/yodlee-account [:yodlee-account/id (:yodlee_account %)]))
) (:bank_accounts edit_client))
})
@@ -122,5 +130,9 @@
(defn get-client [context args value]
(->graphql
(filter #(can-see-client? (:id context) %)
(d-clients/get-all))))
(->> (d-clients/get-all)
(filter #(can-see-client? (:id context) %))
(map (fn [c]
(if (is-admin? (:id context))
c
(dissoc c :client/yodlee-provider-accounts)))))))