Yodlee exists as datomic entities!
This commit is contained in:
@@ -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)))))))
|
||||
|
||||
29
src/clj/auto_ap/graphql/yodlee2.clj
Normal file
29
src/clj/auto_ap/graphql/yodlee2.clj
Normal file
@@ -0,0 +1,29 @@
|
||||
(ns auto-ap.graphql.yodlee2
|
||||
(:require [auto-ap.graphql.utils :refer [->graphql <-graphql assert-can-see-client assert-admin enum->keyword]]
|
||||
[auto-ap.datomic.yodlee2 :as d-yodlee2]
|
||||
[auto-ap.time :refer [parse iso-date]]
|
||||
[auto-ap.utils :refer [dollars=]]
|
||||
[datomic.api :as d]
|
||||
[auto-ap.datomic :refer [uri remove-nils audit-transact conn]]
|
||||
[clj-time.coerce :as coerce]
|
||||
[clj-time.core :as time]
|
||||
[clojure.set :as set]
|
||||
[clojure.tools.logging :as log]))
|
||||
|
||||
(defn get-yodlee-provider-account-page [context args value]
|
||||
(assert-admin (:id context))
|
||||
(let [args (assoc args :id (:id context))
|
||||
[yodlee-provider-accounts cnt] (d-yodlee2/get-graphql (<-graphql (assoc args :id (:id context))))]
|
||||
{:yodlee_provider_accounts (map ->graphql yodlee-provider-accounts)
|
||||
:total cnt
|
||||
:count (count yodlee-provider-accounts)
|
||||
:start (:start args 0)
|
||||
:end (+ (:start args 0) (count yodlee-provider-accounts))}))
|
||||
|
||||
(defn get-all-yodlee-provider-accounts [context args value]
|
||||
(assert-admin (:id context))
|
||||
(map
|
||||
->graphql
|
||||
(first (d-yodlee2/get-graphql (assoc (<-graphql args)
|
||||
:count Integer/MAX_VALUE)))))
|
||||
|
||||
Reference in New Issue
Block a user