Should make reloading AND aot work again
This commit is contained in:
@@ -119,7 +119,7 @@
|
|||||||
|
|
||||||
:profiles {
|
:profiles {
|
||||||
:dev
|
:dev
|
||||||
{
|
{:main user
|
||||||
:resource-paths ["resources" "target"]
|
:resource-paths ["resources" "target"]
|
||||||
:dependencies [#_[binaryage/devteols "1.0.2"]
|
:dependencies [#_[binaryage/devteols "1.0.2"]
|
||||||
[postgresql/postgresql "9.3-1102.jdbc41"]
|
[postgresql/postgresql "9.3-1102.jdbc41"]
|
||||||
@@ -144,7 +144,7 @@
|
|||||||
[com.bhauman/rebel-readline-cljs "0.1.4" :exclusions [org.clojure/clojurescript]]
|
[com.bhauman/rebel-readline-cljs "0.1.4" :exclusions [org.clojure/clojurescript]]
|
||||||
[javax.servlet/servlet-api "2.5"]]
|
[javax.servlet/servlet-api "2.5"]]
|
||||||
:plugins [[lein-pdo "0.1.1"]]
|
:plugins [[lein-pdo "0.1.1"]]
|
||||||
:jvm-opts ["-Dconfig=config/dev.edn" "-Xms4G" "-Xmx20G" "-XX:-OmitStackTraceInFastThrow" ]}
|
:jvm-opts ["-Dconfig=config/dev.edn" "-Xms4G" "-Xmx20G" "-XX:-OmitStackTraceInFastThrow"]}
|
||||||
|
|
||||||
:uberjar
|
:uberjar
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -18,38 +18,38 @@
|
|||||||
|
|
||||||
(defn kebab [x]
|
(defn kebab [x]
|
||||||
(if (qualified-keyword? x)
|
(if (qualified-keyword? x)
|
||||||
(keyword (snake->kebab (namespace x)) (snake->kebab (name x)) )
|
(keyword (snake->kebab (namespace x)) (snake->kebab (name x)))
|
||||||
(keyword (snake->kebab (name x)))))
|
(keyword (snake->kebab (name x)))))
|
||||||
|
|
||||||
(defn kebab->snake [s]
|
(defn kebab->snake [s]
|
||||||
(str/replace (str/replace s #"-" "_") #"\?$" "" ))
|
(str/replace (str/replace s #"-" "_") #"\?$" ""))
|
||||||
|
|
||||||
(defn snake [x]
|
(defn snake [x]
|
||||||
(keyword (kebab->snake (name x))))
|
(keyword (kebab->snake (name x))))
|
||||||
|
|
||||||
(defn ->graphql [m]
|
(defn ->graphql [m]
|
||||||
(walk/postwalk
|
(walk/postwalk
|
||||||
(fn [node]
|
(fn [node]
|
||||||
(cond
|
(cond
|
||||||
|
|
||||||
(keyword? node)
|
(keyword? node)
|
||||||
(snake node)
|
(snake node)
|
||||||
|
|
||||||
:else
|
:else
|
||||||
node))
|
node))
|
||||||
m))
|
m))
|
||||||
|
|
||||||
(defn <-graphql [m]
|
(defn <-graphql [m]
|
||||||
(walk/postwalk
|
(walk/postwalk
|
||||||
(fn [node]
|
(fn [node]
|
||||||
(cond
|
(cond
|
||||||
|
|
||||||
(keyword? node)
|
(keyword? node)
|
||||||
(kebab node)
|
(kebab node)
|
||||||
|
|
||||||
:else
|
:else
|
||||||
node))
|
node))
|
||||||
m))
|
m))
|
||||||
|
|
||||||
(defn is-admin? [id]
|
(defn is-admin? [id]
|
||||||
(= "admin" (:user/role id)))
|
(= "admin" (:user/role id)))
|
||||||
@@ -141,7 +141,7 @@
|
|||||||
not-empty
|
not-empty
|
||||||
(str "*"))
|
(str "*"))
|
||||||
query (as-> exacts e
|
query (as-> exacts e
|
||||||
(filter #(not (str/blank? %)) e)
|
(filter #(not (str/blank? %)) e)
|
||||||
(mapv #(str "+" %) e)
|
(mapv #(str "+" %) e)
|
||||||
(conj e partial)
|
(conj e partial)
|
||||||
(str/join " " e))]
|
(str/join " " e))]
|
||||||
@@ -150,44 +150,43 @@
|
|||||||
(defn trace-query [key f]
|
(defn trace-query [key f]
|
||||||
(fn trace [a b c]
|
(fn trace [a b c]
|
||||||
(mu/with-context (merge
|
(mu/with-context (merge
|
||||||
(:log-context a {})
|
(:log-context a {})
|
||||||
{:query key
|
{:query key
|
||||||
:mutation (boolean (= "mutation"
|
:mutation (boolean (= "mutation"
|
||||||
(namespace key)))
|
(namespace key)))
|
||||||
:user (:id a)})
|
:user (:id a)})
|
||||||
(mu/trace (keyword "graphql" (name key))
|
(mu/trace (keyword "graphql" (name key))
|
||||||
[]
|
[]
|
||||||
(f a b c)))))
|
(f a b c)))))
|
||||||
|
|
||||||
(defn attach-tracing-resolvers [schema m]
|
(defn attach-tracing-resolvers [schema m]
|
||||||
(attach-resolvers schema
|
(attach-resolvers schema
|
||||||
(reduce
|
(reduce
|
||||||
(fn [resolvers [resolver-key resolver-fn]]
|
(fn [resolvers [resolver-key resolver-fn]]
|
||||||
(assoc resolvers
|
(assoc resolvers
|
||||||
resolver-key (trace-query resolver-key resolver-fn))
|
resolver-key (trace-query resolver-key resolver-fn)))
|
||||||
)
|
{}
|
||||||
{}
|
m)))
|
||||||
m)))
|
|
||||||
|
|
||||||
(defn extract-client-ids [user-clients & possible-clients]
|
(defn extract-client-ids [user-clients & possible-clients]
|
||||||
(let [coerce-client-ids (fn coerce-client-ids [x]
|
(let [coerce-client-ids (fn coerce-client-ids [x]
|
||||||
(cond (and (map? x)
|
(cond (and (map? x)
|
||||||
(:db/id x))
|
(:db/id x))
|
||||||
[(:db/id x)]
|
[(:db/id x)]
|
||||||
|
|
||||||
(nat-int? x)
|
(nat-int? x)
|
||||||
[x]
|
[x]
|
||||||
|
|
||||||
(and (vector? x)
|
(and (vector? x)
|
||||||
(= :client/code (first x)))
|
(= :client/code (first x)))
|
||||||
[(entid (dc/db conn) x)]
|
[(entid (dc/db conn) x)]
|
||||||
|
|
||||||
|
|
||||||
(sequential? x)
|
(sequential? x)
|
||||||
(mapcat coerce-client-ids x)
|
(mapcat coerce-client-ids x)
|
||||||
|
|
||||||
:else
|
:else
|
||||||
[]))
|
[]))
|
||||||
user-client-ids (set (mapcat coerce-client-ids user-clients))
|
user-client-ids (set (mapcat coerce-client-ids user-clients))
|
||||||
extra-client-ids (set (mapcat coerce-client-ids possible-clients))]
|
extra-client-ids (set (mapcat coerce-client-ids possible-clients))]
|
||||||
(if (seq extra-client-ids)
|
(if (seq extra-client-ids)
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
(ns auto-ap.jobs.bulk-journal-import
|
(ns auto-ap.jobs.bulk-journal-import
|
||||||
(:gen-class)
|
|
||||||
(:require
|
(:require
|
||||||
[amazonica.aws.s3 :as s3]
|
[amazonica.aws.s3 :as s3]
|
||||||
[auto-ap.graphql.ledger :refer [import-ledger]]
|
[auto-ap.graphql.ledger :refer [import-ledger]]
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
(ns auto-ap.jobs.close-auto-invoices
|
(ns auto-ap.jobs.close-auto-invoices
|
||||||
(:gen-class)
|
|
||||||
(:require
|
(:require
|
||||||
[auto-ap.datomic :refer [conn]]
|
[auto-ap.datomic :refer [conn]]
|
||||||
[auto-ap.jobs.core :refer [execute]]
|
[auto-ap.jobs.core :refer [execute]]
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
(ns auto-ap.jobs.current-balance-cache
|
(ns auto-ap.jobs.current-balance-cache
|
||||||
(:gen-class)
|
|
||||||
(:require
|
(:require
|
||||||
[auto-ap.graphql.clients :as clients]
|
[auto-ap.graphql.clients :as clients]
|
||||||
[auto-ap.jobs.core :refer [execute]]))
|
[auto-ap.jobs.core :refer [execute]]))
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
(ns auto-ap.jobs.ezcater-upsert
|
(ns auto-ap.jobs.ezcater-upsert
|
||||||
(:gen-class)
|
|
||||||
(:require
|
(:require
|
||||||
[auto-ap.jobs.core :refer [execute]]
|
[auto-ap.jobs.core :refer [execute]]
|
||||||
[auto-ap.ezcater.core :as ezcater]))
|
[auto-ap.ezcater.core :as ezcater]))
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
(ns auto-ap.jobs.intuit
|
(ns auto-ap.jobs.intuit
|
||||||
(:gen-class)
|
|
||||||
(:require
|
(:require
|
||||||
[auto-ap.import.intuit :as intuit]
|
[auto-ap.import.intuit :as intuit]
|
||||||
[auto-ap.jobs.core :refer [execute]]))
|
[auto-ap.jobs.core :refer [execute]]))
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
(ns auto-ap.jobs.ledger-reconcile
|
(ns auto-ap.jobs.ledger-reconcile
|
||||||
(:gen-class)
|
|
||||||
(:require
|
(:require
|
||||||
[auto-ap.jobs.core :refer [execute]]
|
[auto-ap.jobs.core :refer [execute]]
|
||||||
[auto-ap.ledger :as ledger]))
|
[auto-ap.ledger :as ledger]))
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
(ns auto-ap.jobs.load-historical-sales
|
(ns auto-ap.jobs.load-historical-sales
|
||||||
(:gen-class)
|
|
||||||
(:require
|
(:require
|
||||||
[auto-ap.datomic :refer [conn]]
|
[auto-ap.datomic :refer [conn]]
|
||||||
[auto-ap.jobs.core :refer [execute]]
|
[auto-ap.jobs.core :refer [execute]]
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
(ns auto-ap.jobs.plaid
|
(ns auto-ap.jobs.plaid
|
||||||
(:gen-class)
|
|
||||||
(:require
|
(:require
|
||||||
[auto-ap.import.plaid :as plaid]
|
[auto-ap.import.plaid :as plaid]
|
||||||
[auto-ap.jobs.core :refer [execute]]))
|
[auto-ap.jobs.core :refer [execute]]))
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
(ns auto-ap.jobs.register-invoice-import
|
(ns auto-ap.jobs.register-invoice-import
|
||||||
(:gen-class)
|
|
||||||
(:require
|
(:require
|
||||||
[amazonica.aws.s3 :as s3]
|
[amazonica.aws.s3 :as s3]
|
||||||
[auto-ap.datomic :refer [audit-transact conn pull-attr]]
|
[auto-ap.datomic :refer [audit-transact conn pull-attr]]
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
(ns auto-ap.jobs.square
|
(ns auto-ap.jobs.square
|
||||||
(:gen-class)
|
|
||||||
(:require
|
(:require
|
||||||
[auto-ap.jobs.core :refer [execute]]
|
[auto-ap.jobs.core :refer [execute]]
|
||||||
[auto-ap.square.core3 :as square3]))
|
[auto-ap.square.core3 :as square3]))
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
(ns auto-ap.jobs.vendor-usages
|
(ns auto-ap.jobs.vendor-usages
|
||||||
(:gen-class)
|
|
||||||
(:require
|
(:require
|
||||||
[auto-ap.datomic :refer [conn]]
|
[auto-ap.datomic :refer [conn]]
|
||||||
[auto-ap.jobs.core :refer [execute]]
|
[auto-ap.jobs.core :refer [execute]]
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
(ns auto-ap.jobs.yodlee2
|
(ns auto-ap.jobs.yodlee2
|
||||||
(:gen-class)
|
|
||||||
(:require
|
(:require
|
||||||
[auto-ap.import.yodlee2 :as yodlee2]
|
[auto-ap.import.yodlee2 :as yodlee2]
|
||||||
[auto-ap.jobs.core :refer [execute]]
|
[auto-ap.jobs.core :refer [execute]]
|
||||||
|
|||||||
@@ -1,107 +0,0 @@
|
|||||||
(ns auto-ap.main
|
|
||||||
(:gen-class)
|
|
||||||
(:require
|
|
||||||
[auto-ap.handler :refer [app]]
|
|
||||||
[auto-ap.server :as server]
|
|
||||||
[auto-ap.jobs.restore-from-backup :as job-restore-from-backup]
|
|
||||||
[auto-ap.jobs.bulk-journal-import :as job-bulk-journal-import]
|
|
||||||
[auto-ap.jobs.close-auto-invoices :as job-close-auto-invoices]
|
|
||||||
[auto-ap.jobs.current-balance-cache :as job-current-balance-cache]
|
|
||||||
[auto-ap.jobs.ezcater-upsert :as job-ezcater-upsert]
|
|
||||||
[auto-ap.jobs.import-uploaded-invoices :as job-import-uploaded-invoices]
|
|
||||||
[auto-ap.jobs.intuit :as job-intuit]
|
|
||||||
[auto-ap.jobs.ntg :as job-ntg]
|
|
||||||
#_[auto-ap.backup :as backup]
|
|
||||||
[auto-ap.jobs.ledger-reconcile :as job-reconcile-ledger]
|
|
||||||
[auto-ap.jobs.load-historical-sales :as job-load-historical-sales]
|
|
||||||
[auto-ap.jobs.plaid :as job-plaid]
|
|
||||||
[auto-ap.jobs.register-invoice-import :as job-register-invoice-import]
|
|
||||||
[auto-ap.jobs.square :as job-square]
|
|
||||||
[auto-ap.jobs.sysco :as job-sysco]
|
|
||||||
[auto-ap.jobs.vendor-usages :as job-vendor-usages]
|
|
||||||
[auto-ap.jobs.yodlee2 :as job-yodlee2]
|
|
||||||
[auto-ap.logging :as alog]
|
|
||||||
[com.unbounce.dogstatsd.core :as statsd]
|
|
||||||
[config.core :refer [env]]
|
|
||||||
[mount.core :as mount]
|
|
||||||
[nrepl.server :refer [start-server]]
|
|
||||||
[ring.adapter.jetty :refer [run-jetty]]
|
|
||||||
[yang.scheduler :as scheduler]
|
|
||||||
[auto-ap.jobs.insight-outcome-recommendation :as insight-outcome-recommendation])
|
|
||||||
(:import
|
|
||||||
(org.eclipse.jetty.server.handler StatisticsHandler)
|
|
||||||
(org.eclipse.jetty.server.handler.gzip GzipHandler)))
|
|
||||||
|
|
||||||
(defn add-shutdown-hook! [^Runnable f]
|
|
||||||
(.addShutdownHook (Runtime/getRuntime)
|
|
||||||
(Thread. f)))
|
|
||||||
|
|
||||||
(defn shutdown-mount []
|
|
||||||
(mount/stop))
|
|
||||||
|
|
||||||
(defn -main [& _]
|
|
||||||
(let [job (System/getenv "INTEGREAT_JOB")]
|
|
||||||
(println "JOB is" job)
|
|
||||||
(cond (= job "square-import-job")
|
|
||||||
(job-square/-main)
|
|
||||||
|
|
||||||
(= job "reconcile-ledger")
|
|
||||||
(job-reconcile-ledger/-main)
|
|
||||||
|
|
||||||
(= job "current-balance-cache")
|
|
||||||
(job-current-balance-cache/-main)
|
|
||||||
|
|
||||||
(= job "yodlee2")
|
|
||||||
(job-yodlee2/-main)
|
|
||||||
|
|
||||||
(= job "yodlee2-accounts")
|
|
||||||
(job-yodlee2/accounts-only)
|
|
||||||
|
|
||||||
(= job "plaid")
|
|
||||||
(job-plaid/-main)
|
|
||||||
|
|
||||||
(= job "intuit")
|
|
||||||
(job-intuit/-main)
|
|
||||||
|
|
||||||
(= job "vendor-usages")
|
|
||||||
(job-vendor-usages/-main)
|
|
||||||
|
|
||||||
(= job "import-uploaded-invoices")
|
|
||||||
(job-import-uploaded-invoices/-main)
|
|
||||||
|
|
||||||
(= job "sysco")
|
|
||||||
(job-sysco/-main)
|
|
||||||
|
|
||||||
(= job "close-auto-invoices")
|
|
||||||
(job-close-auto-invoices/-main)
|
|
||||||
|
|
||||||
(= job "ezcater-upsert")
|
|
||||||
(job-ezcater-upsert/-main)
|
|
||||||
|
|
||||||
(= job "register-invoice-import")
|
|
||||||
(job-register-invoice-import/-main)
|
|
||||||
|
|
||||||
(= job "load-historical-sales")
|
|
||||||
(job-load-historical-sales/-main)
|
|
||||||
|
|
||||||
(= job "bulk-journal-import")
|
|
||||||
(job-bulk-journal-import/-main)
|
|
||||||
|
|
||||||
(= job "restore-from-backup")
|
|
||||||
(job-restore-from-backup/-main)
|
|
||||||
|
|
||||||
(= job "insight-outcome-recommendation")
|
|
||||||
(insight-outcome-recommendation/-main)
|
|
||||||
|
|
||||||
;; (= job "export-backup")
|
|
||||||
;; (backup/-main)
|
|
||||||
|
|
||||||
(= job "ntg")
|
|
||||||
(job-ntg/-main)
|
|
||||||
|
|
||||||
:else
|
|
||||||
(do
|
|
||||||
(add-shutdown-hook! shutdown-mount)
|
|
||||||
(start-server :port 9000 :bind "0.0.0.0" #_#_:handler (cider-nrepl-handler))
|
|
||||||
(mount/start)
|
|
||||||
#_(alter-var-root #'nrepl.middleware.print/*print-fn* (constantly clojure.pprint/pprint))))))
|
|
||||||
@@ -31,6 +31,9 @@
|
|||||||
(org.eclipse.jetty.server.handler StatisticsHandler)
|
(org.eclipse.jetty.server.handler StatisticsHandler)
|
||||||
(org.eclipse.jetty.server.handler.gzip GzipHandler)))
|
(org.eclipse.jetty.server.handler.gzip GzipHandler)))
|
||||||
|
|
||||||
|
(println "LOADING SERVER")
|
||||||
|
|
||||||
|
|
||||||
(defn add-shutdown-hook! [^Runnable f]
|
(defn add-shutdown-hook! [^Runnable f]
|
||||||
(.addShutdownHook (Runtime/getRuntime)
|
(.addShutdownHook (Runtime/getRuntime)
|
||||||
(Thread. f)))
|
(Thread. f)))
|
||||||
|
|||||||
@@ -27,22 +27,22 @@
|
|||||||
query (format "_text_:(%s) AND %s" (cleanse-query query) client-part)]
|
query (format "_text_:(%s) AND %s" (cleanse-query query) client-part)]
|
||||||
(mu/log ::searching :search-query query)
|
(mu/log ::searching :search-query query)
|
||||||
(for [{:keys [account_id name] :as g} (solr/query solr/impl "accounts"
|
(for [{:keys [account_id name] :as g} (solr/query solr/impl "accounts"
|
||||||
{"query" query
|
{"query" query
|
||||||
"fields" "id, name, client_id, numeric_code, applicability, account_id"})]
|
"fields" "id, name, client_id, numeric_code, applicability, account_id"})]
|
||||||
|
|
||||||
{:account_id (first account_id)
|
{:account_id (first account_id)
|
||||||
:name (first name)})))
|
:name (first name)})))
|
||||||
|
|
||||||
|
|
||||||
(defn account-search [{{:keys [q client-id allowance vendor-id] :as qp} :query-params id :identity}]
|
(defn account-search [{{:keys [q client-id allowance vendor-id] :as qp} :query-params id :identity}]
|
||||||
|
|
||||||
(when client-id
|
(when client-id
|
||||||
(assert-can-see-client id client-id))
|
(assert-can-see-client id client-id))
|
||||||
(let [num (some-> (re-find #"([0-9]+)" q)
|
(let [num (some-> (re-find #"([0-9]+)" q)
|
||||||
second
|
second
|
||||||
(not-empty )
|
(not-empty)
|
||||||
Integer/parseInt)
|
Integer/parseInt)
|
||||||
|
|
||||||
valid-allowances (cond-> #{:allowance/allowed
|
valid-allowances (cond-> #{:allowance/allowed
|
||||||
:allowance/warn}
|
:allowance/warn}
|
||||||
(is-admin? id) (conj :allowance/admin-only))
|
(is-admin? id) (conj :allowance/admin-only))
|
||||||
@@ -55,23 +55,23 @@
|
|||||||
|
|
||||||
vendor-account (when vendor-id
|
vendor-account (when vendor-id
|
||||||
(-> (dc/q '[:find ?da
|
(-> (dc/q '[:find ?da
|
||||||
:in $ ?v
|
:in $ ?v
|
||||||
:where [?v :vendor/default-account ?da]]
|
:where [?v :vendor/default-account ?da]]
|
||||||
(dc/db conn)
|
(dc/db conn)
|
||||||
vendor-id)
|
vendor-id)
|
||||||
ffirst))
|
ffirst))
|
||||||
xform (comp
|
xform (comp
|
||||||
(filter (fn [[_ a]]
|
(filter (fn [[_ a]]
|
||||||
(or
|
(or
|
||||||
(valid-allowances (-> a allowance :db/ident))
|
(valid-allowances (-> a allowance :db/ident))
|
||||||
(= (:db/id a) vendor-account))))
|
(= (:db/id a) vendor-account))))
|
||||||
(map (fn [[n a]]
|
(map (fn [[n a]]
|
||||||
{:label (str (:account/numeric-code a) " - " n)
|
{:label (str (:account/numeric-code a) " - " n)
|
||||||
:value (:db/id a)
|
:value (:db/id a)
|
||||||
:location (:account/location a)
|
:location (:account/location a)
|
||||||
:warning (when (= :allowance/warn (-> a allowance :db/ident))
|
:warning (when (= :allowance/warn (-> a allowance :db/ident))
|
||||||
"This account is not typically used for this purpose.")})))]
|
"This account is not typically used for this purpose.")})))]
|
||||||
{:body (take 10 (if q
|
{:body (take 10 (if q
|
||||||
(if num
|
(if num
|
||||||
(->> (dc/q '[:find ?n (pull ?i pattern)
|
(->> (dc/q '[:find ?n (pull ?i pattern)
|
||||||
:in $ ?numeric-code ?allowance pattern
|
:in $ ?numeric-code ?allowance pattern
|
||||||
@@ -87,18 +87,18 @@
|
|||||||
(sequence xform))
|
(sequence xform))
|
||||||
(->> (search- id q client-id)
|
(->> (search- id q client-id)
|
||||||
(sequence
|
(sequence
|
||||||
(comp (map (fn [i] [(:name i) (dc/pull (dc/db conn) search-pattern (:account_id i))]))
|
(comp (map (fn [i] [(:name i) (dc/pull (dc/db conn) search-pattern (:account_id i))]))
|
||||||
xform))))
|
xform))))
|
||||||
[]))}))
|
[]))}))
|
||||||
|
|
||||||
(def account-search (wrap-json-response (wrap-schema-enforce account-search
|
(def account-search (wrap-json-response (wrap-schema-enforce account-search
|
||||||
:query-schema [:map
|
:query-schema [:map
|
||||||
[:q :string]
|
[:q :string]
|
||||||
[:client-id {:optional true
|
[:client-id {:optional true
|
||||||
:default nil}
|
:default nil}
|
||||||
[:maybe entity-id]]
|
[:maybe entity-id]]
|
||||||
[:vendor-id {:optional true}
|
[:vendor-id {:optional true}
|
||||||
[:maybe entity-id]]
|
[:maybe entity-id]]
|
||||||
[:allowance {:optional true}
|
[:allowance {:optional true}
|
||||||
[:maybe (ref->enum-schema "allowance")]]])))
|
[:maybe (ref->enum-schema "allowance")]]])))
|
||||||
|
|
||||||
|
|||||||
@@ -40,6 +40,7 @@
|
|||||||
[manifold.deferred :as de])
|
[manifold.deferred :as de])
|
||||||
(:import [java.util UUID]))
|
(:import [java.util UUID]))
|
||||||
|
|
||||||
|
|
||||||
;; TODO make more reusable malli schemas, use unions if it would be helpful
|
;; TODO make more reusable malli schemas, use unions if it would be helpful
|
||||||
;; TODO copy save logic from graphql version
|
;; TODO copy save logic from graphql version
|
||||||
;; TODO cash drawer shift
|
;; TODO cash drawer shift
|
||||||
@@ -1416,8 +1417,7 @@
|
|||||||
(first step-key)))))
|
(first step-key)))))
|
||||||
(form-schema [_] form-schema-2)
|
(form-schema [_] form-schema-2)
|
||||||
(submit [_ {:keys [multi-form-state request-method identity] :as request}]
|
(submit [_ {:keys [multi-form-state request-method identity] :as request}]
|
||||||
(let [
|
(let [snapshot (mc/decode
|
||||||
snapshot (mc/decode
|
|
||||||
form-schema-2
|
form-schema-2
|
||||||
(:snapshot multi-form-state)
|
(:snapshot multi-form-state)
|
||||||
mt/strip-extra-keys-transformer)
|
mt/strip-extra-keys-transformer)
|
||||||
|
|||||||
103
src/clj/user.clj
103
src/clj/user.clj
@@ -1,36 +1,30 @@
|
|||||||
(ns user
|
(ns user
|
||||||
(:require
|
(:require [amazonica.aws.s3 :as s3]
|
||||||
[amazonica.aws.s3 :as s3]
|
[auto-ap.datomic :refer [conn pull-attr random-tempid]]
|
||||||
[clojure.tools.namespace.repl :refer [set-refresh-dirs refresh]]
|
[auto-ap.solr :as solr]
|
||||||
[auto-ap.datomic :refer [conn pull-attr random-tempid]]
|
[auto-ap.time :as atime]
|
||||||
[auto-ap.ledger :as l]
|
[auto-ap.utils :refer [by]]
|
||||||
[clj-http.core :as http]
|
[clj-time.coerce :as c]
|
||||||
[clj-http.client :as client]
|
[clj-time.core :as t]
|
||||||
[figwheel.main.api]
|
[clojure.core.async :as async]
|
||||||
[hawk.core]
|
[auto-ap.handler :refer [app]]
|
||||||
[auto-ap.server]
|
[ring.adapter.jetty :refer [run-jetty]]
|
||||||
[auto-ap.time :as atime]
|
[clojure.data.csv :as csv]
|
||||||
[auto-ap.utils :refer [by]]
|
[clojure.java.io :as io]
|
||||||
[clj-time.coerce :as c]
|
[clojure.pprint]
|
||||||
[clj-time.core :as t]
|
[clojure.string :as str]
|
||||||
[clj-time.periodic :as per]
|
[clojure.tools.namespace.repl :refer [refresh set-refresh-dirs]]
|
||||||
[clojure.core.async :as async]
|
[com.brunobonacci.mulog :as mu]
|
||||||
[clojure.data.csv :as csv]
|
[com.brunobonacci.mulog.buffer :as rb]
|
||||||
[clojure.java.io :as io]
|
[config.core :refer [env]]
|
||||||
[clojure.pprint]
|
[datomic.api :as dc]
|
||||||
[clojure.string :as str]
|
[datomic.api :as d]
|
||||||
[config.core :refer [env]]
|
[figwheel.main.api]
|
||||||
[datomic.api :as dc]
|
[hawk.core]
|
||||||
[mount.core :as mount]
|
[mount.core :as mount]
|
||||||
[nrepl.middleware.print]
|
[nrepl.middleware.print])
|
||||||
[com.brunobonacci.mulog :as mu]
|
(:import (org.apache.commons.io.input BOMInputStream)
|
||||||
[com.brunobonacci.mulog.buffer :as rb]
|
[org.eclipse.jetty.server.handler.gzip GzipHandler]))
|
||||||
[datomic.api :as d]
|
|
||||||
[puget.printer :as puget]
|
|
||||||
[clojure.data.json :as json]
|
|
||||||
[auto-ap.solr :as solr])
|
|
||||||
(:import
|
|
||||||
(org.apache.commons.io.input BOMInputStream)))
|
|
||||||
|
|
||||||
|
|
||||||
(defn println-event [item]
|
(defn println-event [item]
|
||||||
@@ -307,11 +301,6 @@
|
|||||||
accounts)))
|
accounts)))
|
||||||
vec))
|
vec))
|
||||||
|
|
||||||
#_{:clj-kondo/ignore [:clojure-lsp/unused-public-var]}
|
|
||||||
(defn go []
|
|
||||||
(require '[mount.core :as mount])
|
|
||||||
(require '[auto-ap.server])
|
|
||||||
(mount/start-without #'auto-ap.server/jetty))
|
|
||||||
|
|
||||||
#_{:clj-kondo/ignore [:clojure-lsp/unused-public-var]}
|
#_{:clj-kondo/ignore [:clojure-lsp/unused-public-var]}
|
||||||
(defn entity-history [i]
|
(defn entity-history [i]
|
||||||
@@ -367,12 +356,48 @@
|
|||||||
(hawk.core/watch! [{:paths ["src/"]
|
(hawk.core/watch! [{:paths ["src/"]
|
||||||
:handler auto-reset-handler}]))
|
:handler auto-reset-handler}]))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
(defn gzip-handler []
|
||||||
|
(doto (GzipHandler.)
|
||||||
|
(.setIncludedMimeTypes (into-array ["text/css"
|
||||||
|
"text/plain"
|
||||||
|
"text/javascript"
|
||||||
|
"text/csv"
|
||||||
|
"text/html"
|
||||||
|
"text/html;charset=utf-8"
|
||||||
|
"application/javascript"
|
||||||
|
"application/csv"
|
||||||
|
"application/edn"
|
||||||
|
"application/json"
|
||||||
|
"image/svg+xml"]))
|
||||||
|
(.setMinGzipSize 1024)))
|
||||||
|
|
||||||
|
(defn configure-jetty [server]
|
||||||
|
(let [ gzip-handler (gzip-handler)
|
||||||
|
default-handler (.getHandler server)]
|
||||||
|
|
||||||
|
(.setHandler gzip-handler default-handler)
|
||||||
|
(.setHandler server gzip-handler))
|
||||||
|
(.setStopAtShutdown server true))
|
||||||
|
|
||||||
|
(mount/defstate port :start (Integer/parseInt (or (env :port) "3000")))
|
||||||
|
|
||||||
|
(mount/defstate jetty
|
||||||
|
:start (run-jetty app {:port port
|
||||||
|
:join? false
|
||||||
|
:configurator configure-jetty
|
||||||
|
:response-header-size 16384
|
||||||
|
:request-header-size 16384})
|
||||||
|
:stop (.stop jetty))
|
||||||
(defn start-http []
|
(defn start-http []
|
||||||
(mount.core/start (mount.core/only #{#'auto-ap.server/port #'auto-ap.server/jetty})))
|
(mount.core/start (mount.core/only #{#'user/port #'user/jetty})))
|
||||||
|
|
||||||
|
|
||||||
(defn start-dev []
|
(defn start-dev []
|
||||||
(set-refresh-dirs "src")
|
(set-refresh-dirs "src")
|
||||||
|
#_(clojure.tools.namespace.repl/disable-reload! (find-ns 'auto-ap.server))
|
||||||
|
(clojure.tools.namespace.repl/disable-reload! (find-ns 'auto-ap.time))
|
||||||
(start-db)
|
(start-db)
|
||||||
(start-http)
|
(start-http)
|
||||||
(auto-reset))
|
(auto-reset))
|
||||||
@@ -386,8 +411,6 @@
|
|||||||
(mount.core/stop (mount.core/only #{#'auto-ap.datomic/conn}))
|
(mount.core/stop (mount.core/only #{#'auto-ap.datomic/conn}))
|
||||||
(start-db))
|
(start-db))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#_{:clj-kondo/ignore [:clojure-lsp/unused-public-var]}
|
#_{:clj-kondo/ignore [:clojure-lsp/unused-public-var]}
|
||||||
(defn spit-csv [columns data]
|
(defn spit-csv [columns data]
|
||||||
(csv/write-csv *out*
|
(csv/write-csv *out*
|
||||||
|
|||||||
@@ -1,129 +1,152 @@
|
|||||||
(defn setup-randy-queries []
|
|
||||||
(import '[java.util UUID])
|
|
||||||
(def my-id "a4345849-00a7-424e-b393-06257d3c1820")
|
|
||||||
|
|
||||||
(auto-ap.routes.queries/put-query
|
|
||||||
my-id
|
|
||||||
(str '[:find ?an ?cn ?a ?fmt-date ?action ?payee
|
|
||||||
:where [(ground ["SCSJ-USB9606" "SCCB-USB9598" "SCMH-USB4250" "SCM8-UB3082" "PWL-PWL2370"]) [?bac ...]]
|
|
||||||
[(iol-ion.query/recent-date 5) ?sd]
|
|
||||||
[(ground (clj-time.format/with-zone (clj-time.format/formatter "MMddyyyy") (clj-time.core/time-zone-for-id "America/Los_Angeles"))) ?fmt]
|
|
||||||
[?ba :bank-account/code ?bac]
|
|
||||||
[?ba :bank-account/number ?an]
|
|
||||||
[?p :payment/bank-account ?ba]
|
|
||||||
[?p :payment/date ?pd]
|
|
||||||
[(>= ?pd ?sd)]
|
|
||||||
[?p :payment/type :payment-type/check]
|
|
||||||
[?p :payment/amount ?a]
|
|
||||||
[?p :payment/check-number ?cn]
|
|
||||||
[(clj-time.coerce/from-date ?pd) ?pd2]
|
|
||||||
[(clj-time.format/unparse ?fmt ?pd2) ?fmt-date]
|
|
||||||
[(ground "IS") ?action]
|
|
||||||
[?p :payment/vendor ?v]
|
|
||||||
[(get-some $ ?v :vendor/print-as :vendor/name) [_ ?payee]]])
|
|
||||||
"One-off for randy"))
|
|
||||||
|
|
||||||
|
|
||||||
(dc/q
|
|
||||||
'[:find ?cd ?bal (count ?l)
|
|
||||||
:where [?b :bank-account/locations ?bal]
|
|
||||||
[?c :client/bank-accounts ?b]
|
|
||||||
[?c :client/code ?cd]
|
|
||||||
[?c :client/locations ?l]]
|
|
||||||
(dc/db conn))
|
|
||||||
|
|
||||||
|
|
||||||
(init-repl)
|
(init-repl)
|
||||||
|
(comment
|
||||||
|
(defn setup-randy-queries []
|
||||||
|
(import '[java.util UUID])
|
||||||
|
(def my-id "a4345849-00a7-424e-b393-06257d3c1820")
|
||||||
|
|
||||||
(seq (dc/q
|
(auto-ap.routes.queries/put-query
|
||||||
'[:find ?a ?n ?n2
|
my-id
|
||||||
:where [?a :account/name ?n]
|
(str '[:find ?an ?cn ?a ?fmt-date ?action ?payee
|
||||||
[?a :account/numeric-code ?n2]
|
:where [(ground ["SCSJ-USB9606" "SCCB-USB9598" "SCMH-USB4250" "SCM8-UB3082" "PWL-PWL2370"]) [?bac ...]]
|
||||||
(not [?a :account/code])]
|
[(iol-ion.query/recent-date 5) ?sd]
|
||||||
(dc/db conn)))
|
[(ground (clj-time.format/with-zone (clj-time.format/formatter "MMddyyyy") (clj-time.core/time-zone-for-id "America/Los_Angeles"))) ?fmt]
|
||||||
|
[?ba :bank-account/code ?bac]
|
||||||
(dc/q
|
[?ba :bank-account/number ?an]
|
||||||
'[:find (pull ?a [* {:account/applicability [:db/ident] :account/default-allowance [*]}])
|
[?p :payment/bank-account ?ba]
|
||||||
:where [?a :account/numeric-code 34090]]
|
[?p :payment/date ?pd]
|
||||||
(dc/db conn))
|
[(>= ?pd ?sd)]
|
||||||
|
[?p :payment/type :payment-type/check]
|
||||||
|
[?p :payment/amount ?a]
|
||||||
|
[?p :payment/check-number ?cn]
|
||||||
|
[(clj-time.coerce/from-date ?pd) ?pd2]
|
||||||
|
[(clj-time.format/unparse ?fmt ?pd2) ?fmt-date]
|
||||||
|
[(ground "IS") ?action]
|
||||||
|
[?p :payment/vendor ?v]
|
||||||
|
[(get-some $ ?v :vendor/print-as :vendor/name) [_ ?payee]]])
|
||||||
|
"One-off for randy"))
|
||||||
|
|
||||||
|
|
||||||
(dc/q
|
(dc/q
|
||||||
'[:find ?a
|
'[:find ?cd ?bal (count ?l)
|
||||||
:where [?a :account/numeric-code ?nc]
|
:where [?b :bank-account/locations ?bal]
|
||||||
(not [?a :account/default-allowance])]
|
[?c :client/bank-accounts ?b]
|
||||||
(dc/since (dc/db conn) #inst "2023-02-01"))
|
[?c :client/code ?cd]
|
||||||
|
[?c :client/locations ?l]]
|
||||||
@(dc/transact conn
|
(dc/db conn))
|
||||||
(->>
|
|
||||||
(dc/q
|
|
||||||
'[:find ?a
|
|
||||||
:where [?a :account/numeric-code ?nc]
|
|
||||||
(not [?a :account/default-allowance])]
|
|
||||||
(dc/since (dc/db conn) #inst "2023-02-01"))
|
|
||||||
(map (fn [[a]]
|
|
||||||
{:db/id a
|
|
||||||
:account/default-allowance :allowance/allowed}))))
|
|
||||||
|
|
||||||
|
|
||||||
(dc/q '[:find (pull ?l [*])
|
(init-repl)
|
||||||
:in $ ?a
|
|
||||||
:where [?a :invoice/client]
|
|
||||||
[?l :journal-entry/original-entity ?a]]
|
|
||||||
(dc/db conn)
|
|
||||||
17592316421929)
|
|
||||||
|
|
||||||
(dc/pull (dc/db conn) '[*] 17592316421929)
|
(seq (dc/q
|
||||||
|
'[:find ?a ?n ?n2
|
||||||
|
:where [?a :account/name ?n]
|
||||||
|
[?a :account/numeric-code ?n2]
|
||||||
|
(not [?a :account/code])]
|
||||||
|
(dc/db conn)))
|
||||||
|
|
||||||
(entity-history 17592316421929)
|
(dc/q
|
||||||
|
'[:find (pull ?a [* {:account/applicability [:db/ident] :account/default-allowance [*]}])
|
||||||
|
:where [?a :account/numeric-code 34090]]
|
||||||
|
(dc/db conn))
|
||||||
|
|
||||||
|
|
||||||
(dc/q '[:find (pull ?l [*])
|
(dc/q
|
||||||
:in $ ?a
|
'[:find ?a
|
||||||
:where [?a :invoice/client]
|
:where [?a :account/numeric-code ?nc]
|
||||||
[?l :journal-entry/original-entity ?a]]
|
(not [?a :account/default-allowance])]
|
||||||
(dc/db conn)
|
(dc/since (dc/db conn) #inst "2023-02-01"))
|
||||||
17592316421929)
|
|
||||||
|
@(dc/transact conn
|
||||||
|
(->>
|
||||||
|
(dc/q
|
||||||
|
'[:find ?a
|
||||||
|
:where [?a :account/numeric-code ?nc]
|
||||||
|
(not [?a :account/default-allowance])]
|
||||||
|
(dc/since (dc/db conn) #inst "2023-02-01"))
|
||||||
|
(map (fn [[a]]
|
||||||
|
{:db/id a
|
||||||
|
:account/default-allowance :allowance/allowed}))))
|
||||||
|
|
||||||
|
|
||||||
|
(dc/q '[:find (pull ?l [*])
|
||||||
|
:in $ ?a
|
||||||
|
:where [?a :invoice/client]
|
||||||
|
[?l :journal-entry/original-entity ?a]]
|
||||||
|
(dc/db conn)
|
||||||
|
17592316421929)
|
||||||
|
|
||||||
|
(dc/pull (dc/db conn) '[*] 17592316421929)
|
||||||
|
|
||||||
|
(entity-history 17592316421929)
|
||||||
|
|
||||||
|
|
||||||
|
(dc/q '[:find (pull ?l [*])
|
||||||
|
:in $ ?a
|
||||||
|
:where [?a :invoice/client]
|
||||||
|
[?l :journal-entry/original-entity ?a]]
|
||||||
|
(dc/db conn)
|
||||||
|
17592316421929)
|
||||||
|
|
||||||
|
|
||||||
;; Find journal entries that have been divorced from the original entity
|
;; Find journal entries that have been divorced from the original entity
|
||||||
@(dc/transact auto-ap.datomic/conn
|
@(dc/transact auto-ap.datomic/conn
|
||||||
(->>
|
(->>
|
||||||
(dc/q '[:find ?l
|
(dc/q '[:find ?l
|
||||||
:in $ $$ $$$
|
:in $ $$ $$$
|
||||||
:where [$$ ?l :journal-entry/amount]
|
:where [$$ ?l :journal-entry/amount]
|
||||||
(not [$ ?l :journal-entry/external-id])
|
(not [$ ?l :journal-entry/external-id])
|
||||||
[$ ?l :journal-entry/source "invoice"]
|
[$ ?l :journal-entry/source "invoice"]
|
||||||
(not [$ ?l :journal-entry/original-entity])
|
(not [$ ?l :journal-entry/original-entity])
|
||||||
[$ ?l :journal-entry/client ?c]
|
[$ ?l :journal-entry/client ?c]
|
||||||
[$ ?c :client/code ?cd]
|
[$ ?c :client/code ?cd]
|
||||||
[$$$ ?l :journal-entry/original-entity _ ?tx false]]
|
[$$$ ?l :journal-entry/original-entity _ ?tx false]]
|
||||||
(dc/db conn)
|
(dc/db conn)
|
||||||
(dc/since (dc/db conn) #inst "2024-02-04")
|
(dc/since (dc/db conn) #inst "2024-02-04")
|
||||||
(dc/history (dc/db conn)))
|
(dc/history (dc/db conn)))
|
||||||
(map (fn [[jl]]
|
(map (fn [[jl]]
|
||||||
[:db/retractEntity jl]))
|
[:db/retractEntity jl]))
|
||||||
seq)
|
seq))
|
||||||
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
(entity-history 13194269907490)
|
(entity-history 13194269907490)
|
||||||
|
|
||||||
(user/tx-detail 13194269907766)
|
(user/tx-detail 13194269907766)
|
||||||
|
|
||||||
(dc/tx-range (dc/log conn)
|
(dc/tx-range (dc/log conn)
|
||||||
13194269907490
|
13194269907490
|
||||||
13194269907490)
|
13194269907490)
|
||||||
(dc/q '[:find ?l
|
(dc/q '[:find ?l
|
||||||
:in $ $$ $$$
|
:in $ $$ $$$
|
||||||
:where [$$ ?l :journal-entry/amount]
|
:where [$$ ?l :journal-entry/amount]
|
||||||
(not [$ ?l :journal-entry/external-id])
|
(not [$ ?l :journal-entry/external-id])
|
||||||
[$ ?l :journal-entry/source "invoice"]
|
[$ ?l :journal-entry/source "invoice"]
|
||||||
(not [$ ?l :journal-entry/original-entity])
|
(not [$ ?l :journal-entry/original-entity])
|
||||||
[$ ?l :journal-entry/client ?c]
|
[$ ?l :journal-entry/client ?c]
|
||||||
[$ ?c :client/code ?cd]
|
[$ ?c :client/code ?cd]
|
||||||
[$$$ ?l :journal-entry/original-entity _ ?tx false]]
|
[$$$ ?l :journal-entry/original-entity _ ?tx false]]
|
||||||
(dc/db conn)
|
(dc/db conn)
|
||||||
(dc/since (dc/db conn) #inst "2024-02-04")
|
(dc/since (dc/db conn) #inst "2024-02-04")
|
||||||
(dc/history (dc/db conn)))
|
(dc/history (dc/db conn)))
|
||||||
|
|
||||||
|
(dc/transact conn (->> (dc/q '[:find ?v
|
||||||
|
:in $
|
||||||
|
:where [?v :vendor/plaid-merchant]
|
||||||
|
(not [?v :vendor/name])
|
||||||
|
[?t :transaction/vendor ?v]
|
||||||
|
[?t :transaction/date ?d]]
|
||||||
|
(dc/db conn))
|
||||||
|
(mapv (fn [[i]]
|
||||||
|
[:db/retractEntity i]))))
|
||||||
|
|
||||||
|
|
||||||
|
@(dc/transact conn (->> (dc/q '[:find ?c
|
||||||
|
:where [?c :client/name ?n]
|
||||||
|
[(clojure.string/upper-case ?n) ?n2]
|
||||||
|
[(clojure.string/includes? ?n2 "NICK")]]
|
||||||
|
(dc/db conn))
|
||||||
|
(map (fn [[c]]
|
||||||
|
{:db/id c :client/groups ["NTG"]}))))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user