fixes, adding renames.
This commit is contained in:
@@ -23,7 +23,8 @@
|
||||
(def default-read '(pull ?e [*
|
||||
{:invoice-payment/_payment [* {:invoice-payment/invoice [*]}]}
|
||||
{:payment/client [:client/name :db/id]}
|
||||
{:payment/vendor [:vendor/name :db/id]}
|
||||
{:payment/bank-account [*]}
|
||||
{:payment/vendor [:vendor/name :vendor/default-expense-account :db/id {:vendor/primary-contact [*]} {:vendor/address [*]}]}
|
||||
{:payment/status [:db/ident]}
|
||||
{:payment/type [:db/ident]}]))
|
||||
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
|
||||
(def default-read '(pull ?e [*
|
||||
{:invoice/client [:client/name :db/id :client/locations]}
|
||||
{:invoice/vendor [:vendor/name :db/id]}
|
||||
{:invoice/vendor [* {:vendor/address [*]}]}
|
||||
{:invoice/status [:db/ident]}
|
||||
{:invoice-payment/_invoice [* {:invoice-payment/payment [* {:payment/status [*]}
|
||||
{:payment/bank-account [*]}
|
||||
|
||||
@@ -53,6 +53,8 @@
|
||||
:auto-ap/add-client-codes {:txes-fn 'auto-ap.datomic.migrate.add-client-codes/add-client-codes :requires [:auto-ap/migrate-transactions]}
|
||||
:auto-ap/add-bank-account-codes-schema {:txes-fn 'auto-ap.datomic.migrate.add-bank-account-codes/add-bank-account-codes-schema :requires [:auto-ap/add-client-codes]}
|
||||
:auto-ap/add-bank-account-codes {:txes-fn 'auto-ap.datomic.migrate.add-bank-account-codes/add-bank-account-codes :requires [:auto-ap/add-bank-account-codes-schema]}
|
||||
:auto-ap/add-nick-the-greek {:txes [[{:client/name "Nick the Greek" :client/code "NGAK" :client/locations ["MH"] :client/bank-accounts [{:bank-account/code "NGAK-0" :bank-account/type :bank-account-type/cash :bank-account/name "Cash"}]}]] :requires [:auto-ap/add-bank-account-codes]}
|
||||
:auto-ap/rename-codes-3 {:txes-fn 'auto-ap.datomic.migrate.rename-codes/rename-1 :requires [:auto-ap/add-nick-the-greek]}
|
||||
}]
|
||||
(println "Conforming database...")
|
||||
(println (c/ensure-conforms conn norms-map))
|
||||
|
||||
37
src/clj/auto_ap/datomic/migrate/rename_codes.clj
Normal file
37
src/clj/auto_ap/datomic/migrate/rename_codes.clj
Normal file
@@ -0,0 +1,37 @@
|
||||
(ns auto-ap.datomic.migrate.rename-codes
|
||||
(:require [datomic.api :as d]
|
||||
[auto-ap.datomic :refer [uri]]
|
||||
[clojure.string :as str]))
|
||||
|
||||
(defn rename [old-code new-code conn ]
|
||||
(let [results (->> (d/query {:query {:find ['?e '?b '?bc]
|
||||
:in ['$ '?old-code]
|
||||
:where ['[?e :client/code ?old-code]
|
||||
'[?e :client/bank-accounts ?b]
|
||||
'[?b :bank-account/code ?bc]]}
|
||||
:args [(d/db conn) old-code]})
|
||||
(group-by first))
|
||||
|
||||
#_#_[[id]] results]
|
||||
(for [[id change] results
|
||||
[_ ba-id ba-code] change]
|
||||
[{:db/id id
|
||||
:client/code new-code}
|
||||
{:db/id ba-id
|
||||
:bank-account/code (str/replace ba-code #"^.*-" (str new-code "-"))}])
|
||||
|
||||
#_[{:db/id id
|
||||
:client/code new-code
|
||||
#_#_:client/bank-accounts (map)}]
|
||||
)
|
||||
)
|
||||
|
||||
(defn rename-1 [conn]
|
||||
(apply concat [(rename "WE" "WME" (d/connect uri))
|
||||
(rename "HM" "HIM" (d/connect uri))
|
||||
(rename "BES" "SBE" (d/connect uri))
|
||||
(rename "BES" "SBE" (d/connect uri))
|
||||
(rename "ORA" "OMG" (d/connect uri))
|
||||
(rename "INT" "IGC" (d/connect uri))
|
||||
(rename "MV" "MVSC" (d/connect uri))]))
|
||||
|
||||
@@ -113,7 +113,7 @@
|
||||
|
||||
(defn graphql-results [ids db args]
|
||||
(->> (d/pull-many db '[* {:transaction/client [:client/name :db/id]
|
||||
:transaction/bank-account [:bank-account/name :bank-account/yodlee-account-id]}]
|
||||
:transaction/bank-account [:bank-account/name :bank-account/yodlee-account-id :db/id]}]
|
||||
ids)
|
||||
(map #(update % :transaction/date c/from-date))
|
||||
(map #(update % :transaction/post-date c/from-date))
|
||||
|
||||
@@ -57,6 +57,7 @@
|
||||
:check_number {:type 'Int}
|
||||
:name {:type 'String}
|
||||
:bank_code {:type 'String}
|
||||
:routing {:type 'String}
|
||||
:bank_name {:type 'String}
|
||||
:yodlee_account_id {:type 'Int}}}
|
||||
:address
|
||||
|
||||
@@ -9,6 +9,14 @@
|
||||
(def google-client-id "264081895820-0nndcfo3pbtqf30sro82vgq5r27h8736.apps.googleusercontent.com")
|
||||
(def google-client-secret "OC-WemHurPXYpuIw5cT-B90g")
|
||||
|
||||
(defn make-api-token []
|
||||
(jwt/sign {:user "API"
|
||||
:exp (time/plus (time/now) (time/days 700))
|
||||
:user/role "admin"
|
||||
:user/name "API"}
|
||||
(:jwt-secret env)
|
||||
{:alg :hs512}))
|
||||
|
||||
(defroutes routes
|
||||
(GET "/oauth" {{:strs [code]} :query-params :keys [scheme] :as r {:strs [host]} :headers}
|
||||
(try
|
||||
@@ -37,14 +45,14 @@
|
||||
;; TODO - these namespaces are not being transmitted/deserialized properly
|
||||
(if (and token user)
|
||||
{:status 301
|
||||
:headers {"Location" (str "/?jwt=" (jwt/sign {:user (:name profile)
|
||||
:exp (time/plus (time/now) (time/days 7))
|
||||
:user/clients (map (fn [c]
|
||||
(dissoc c :client/bank-accounts )
|
||||
)
|
||||
(:user/clients user))
|
||||
:user/role (name (:user/role user))
|
||||
:user/name (:name profile)}
|
||||
:headers {"Location" (str "/?jwt=" (jwt/sign (doto {:user (:name profile)
|
||||
:exp (time/plus (time/now) (time/days 7))
|
||||
:user/clients (map (fn [c]
|
||||
(dissoc c :client/bank-accounts ))
|
||||
(:user/clients user))
|
||||
:user/role (name (:user/role user))
|
||||
:user/name (:name profile)}
|
||||
println)
|
||||
(:jwt-secret env)
|
||||
{:alg :hs512}))}}
|
||||
{:status 401
|
||||
|
||||
@@ -57,7 +57,7 @@
|
||||
(assert-admin identity)
|
||||
(let [[transactions] (d-transactions/get-graphql {:client-code (query-params "client-code")
|
||||
#_#_:original-id (Integer/parseInt (query-params "original"))
|
||||
:limit Integer/MAX_VALUE})
|
||||
:count Integer/MAX_VALUE})
|
||||
]
|
||||
(map (comp ->graphql (fn [i]
|
||||
(-> i
|
||||
|
||||
Reference in New Issue
Block a user