diff --git a/src/clj/auto_ap/ledger.clj b/src/clj/auto_ap/ledger.clj index bc4f602c..82b0b634 100644 --- a/src/clj/auto_ap/ledger.clj +++ b/src/clj/auto_ap/ledger.clj @@ -10,6 +10,7 @@ [datomic.api :as d] [mount.core :as mount] [unilog.context :as lc] + #_{:clj-kondo/ignore [:unused-namespace]} [yang.scheduler :as scheduler])) (defn datums->impacted-entity [db [e changes]] @@ -291,21 +292,20 @@ '[?lia :account/name] '[?e :transaction/amount ?amt] '[(not= ?amt 0.0)]]} - :args [(d/db auto-ap.datomic/conn)]})) - ] - (filter - (fn [[e accounts]] (not= accounts (get jel-accounts e))) - transaction-accounts) - (filter (fn [[e]] - (let [[tx-date] (d/q '[:find [(max ?d) ...] - :in $ ?t - :where - [?t _ _ ?tx] - [?tx :db/txInstant ?d]] - (d/history (d/db auto-ap.datomic/conn)) - e)] - (t/before? (c/to-date-time tx-date) - (t/minus (t/now) (t/hours 1)))))))) + :args [(d/db auto-ap.datomic/conn)]}))] + (->> transaction-accounts + (filter + (fn [[e accounts]] (not= accounts (get jel-accounts e)))) + (filter (fn [[e]] + (let [[tx-date] (d/q '[:find [(max ?d) ...] + :in $ ?t + :where + [?t _ _ ?tx] + [?tx :db/txInstant ?d]] + (d/history (d/db auto-ap.datomic/conn)) + e)] + (t/before? (c/to-date-time tx-date) + (t/minus (t/now) (t/hours 1))))))))) (defn unbalanced-transactions [] (->> (d/query {:query {:find ['?je '?a '(sum ?debit) '(sum ?credit)] @@ -398,7 +398,7 @@ (doseq [[m] mismatched-ts] (touch-transaction m)) (statsd/gauge "data.mismatched_transactions" (count (mismatched-transactions)))) - (statsd/gauge "data.mismatched_transactions" 0))) + (statsd/gauge "data.mismatched_transactions" 0.0))) (log/info "Attempting to fix transactions that are in the ledger but debits/credits don't add up") (let [unbalanced-ts (unbalanced-transactions)] (if (seq unbalanced-ts) @@ -407,7 +407,7 @@ (doseq [m unbalanced-ts] (touch-transaction m)) (statsd/gauge "data.unbalanced_transactions" (count (unbalanced-transactions)))) - (statsd/gauge "data.unbalanced_transactions" 0))) + (statsd/gauge "data.unbalanced_transactions" 0.0))) (log/info "Finished fixing transactions that are in the ledger but are wrong") (let [mismatched-is (mismatched-invoices)] (if (seq mismatched-is) @@ -416,7 +416,7 @@ (doseq [[m] mismatched-is] (touch-invoice m)) (statsd/gauge "data.mismatched_invoices" (count (mismatched-invoices)))) - (statsd/gauge "data.mismatched_invoices" 0))) + (statsd/gauge "data.mismatched_invoices" 0.0))) (log/info "Attempting to fix transactions that are in the ledger but debits/credits don't add up") (let [unbalanced-invoices (unbalanced-invoices)] (if (seq unbalanced-invoices) @@ -425,7 +425,7 @@ (doseq [m unbalanced-invoices] (touch-invoice m)) (statsd/gauge "data.unbalanced_invoices" (count (unbalanced-invoices)))) - (statsd/gauge "data.unbalanced_invoices" 0))) + (statsd/gauge "data.unbalanced_invoices" 0.0))) (log/info "Finish fixing invoices that are in the ledger but are wrong") (statsd/event {:title "Finished Reconciling Ledger" diff --git a/src/clj/auto_ap/square/core.clj b/src/clj/auto_ap/square/core.clj index 5d8093fe..17a24111 100644 --- a/src/clj/auto_ap/square/core.clj +++ b/src/clj/auto_ap/square/core.clj @@ -12,6 +12,7 @@ [datomic.api :as d] [mount.core :as mount] [unilog.context :as lc] + #_{:clj-kondo/ignore [:unused-namespace]} [yang.scheduler :as scheduler] [clojure.core.async :as async])) @@ -98,28 +99,16 @@ ([client location d] (log/info "Searching for" (:square-location/client-location location)) (let [result (->> (client/post "https://connect.squareup.com/v2/orders/search" - (doto {:headers (client-base-headers client) - :body (json/write-str (cond-> {"location_ids" [(:square-location/square-id location)] "limit" 10000} - d (merge (pc d)))) - :as :json} - clojure.pprint/pprint)) + {:headers (client-base-headers client) + :body (json/write-str (cond-> {"location_ids" [(:square-location/square-id location)] "limit" 10000} + d (merge (pc d)))) + :as :json}) :body :orders)] (log/info "found " (count result)) result))) -(defn order - - ([client o] - (log/info "Searching for" o) - (let [result (->> (client/get (str "https://connect.squareup.com/v2/orders/" o) - {:headers (base-headers client) - :as :json}) - :body)] - - (log/info "found " (count result)) - result))) (defn amount->money [amt] (* 0.01 (or (:amount amt) 0.0))) @@ -137,7 +126,8 @@ (:sales-order/discount i) ))) - 0.0)) + 0.0 + [])) (defn order->sales-order [client location order] (remove-nils @@ -240,7 +230,7 @@ :created_at coerce/to-date) (coerce/to-date (time/now)))))) - (async/to-chan (->> settlement + (async/to-chan! (->> settlement :entries (filter #(= "CHARGE" (:type %))) (map :payment_id) @@ -274,7 +264,7 @@ (log/info "sales date for " s " is " sales-date) (assoc settlement :sales-date sales-date))))) - (async/to-chan settlements) + (async/to-chan! settlements) true (fn [e] (lc/with-context {:source "Square settlements loading "} diff --git a/src/clj/auto_ap/yodlee/core2.clj b/src/clj/auto_ap/yodlee/core2.clj index 2341ca98..56dcb907 100644 --- a/src/clj/auto_ap/yodlee/core2.clj +++ b/src/clj/auto_ap/yodlee/core2.clj @@ -1,16 +1,16 @@ (ns auto-ap.yodlee.core2 (:require [clj-http.client :as client] [auto-ap.utils :refer [by]] - [cemerick.url :as u] [unilog.context :as lc] [clojure.tools.logging :as log] [clojure.data.json :as json] [clojure.core.async :as async] [config.core :refer [env]] + #_{:clj-kondo/ignore [:unused-namespace]} [mount.core :as mount] + #_{:clj-kondo/ignore [:unused-namespace]} [yang.scheduler :as scheduler] [clj-time.coerce :as coerce] - [auto-ap.time :as time2] [datomic.api :as d] [auto-ap.datomic :refer [conn]] [auto-ap.datomic.clients :as d-clients])) @@ -220,23 +220,19 @@ :body))) -(defn assert-user [client-code] - (let [cob-session (login-cobrand client-code)] - cob-session)) - (defn get-provider-accounts-with-details [client-code ] - (let [provider-accounts (get-provider-accounts client-code)] - (let [concurrent 20 - output-chan (async/chan)] - (async/pipeline-blocking concurrent - output-chan - (map (fn [provider-account] - (lc/with-context {:provider-account-id (:id provider-account)} - (get-provider-account-detail client-code (:id provider-account))))) - (async/to-chan provider-accounts)) - (async/ (str (:yodlee2-base-url env) "/providerAccounts?providerAccountIds=" pa) + (-> (str (:yodlee2-base-url env) "/providerAccounts?providerAccountIds=" pa) - (client/put (doto (merge {:headers (merge base-headers {"Authorization" (auth-header (login-user (client-code->login client-code)))}) - :body (json/write-str data) - :as :json} - other-config) - clojure.pprint/pprint))) - log/info) + (client/put (merge {:headers (merge base-headers {"Authorization" (auth-header (login-user (client-code->login client-code)))}) + :body (json/write-str data) + :as :json} + other-config))) (catch Exception e (log/error e))) ) diff --git a/src/cljs/auto_ap/views/components/dropdown.cljs b/src/cljs/auto_ap/views/components/dropdown.cljs index 1dfd80d1..cffe8e5e 100644 --- a/src/cljs/auto_ap/views/components/dropdown.cljs +++ b/src/cljs/auto_ap/views/components/dropdown.cljs @@ -16,7 +16,7 @@ (defn drop-down [{:keys [ header id is-right? class]} child] (let [menu-active? (re-frame/subscribe [::subs/menu-active? id])] (r/create-class - {:reagent-render (fn [{:keys [header id is-right? class] :or {:is-right? true}} child] + {:reagent-render (fn [{:keys [header id is-right? class] :or {is-right? true}} child] (let [menu-active? @(re-frame/subscribe [::subs/menu-active? id])] [:div.dropdown {:class (str (if menu-active? "is-active" diff --git a/src/cljs/auto_ap/views/pages/admin/yodlee.cljs b/src/cljs/auto_ap/views/pages/admin/yodlee.cljs index 39c5f252..8ab3fad7 100644 --- a/src/cljs/auto_ap/views/pages/admin/yodlee.cljs +++ b/src/cljs/auto_ap/views/pages/admin/yodlee.cljs @@ -133,7 +133,7 @@ (re-frame/reg-event-fx ::save-error (fn [{:keys [db]} [_ authentication]] - {:db (assoc :db ::load-error "error")})) + {:db (assoc db ::load-error "error")})) (defn yodlee-link-button [] [:div