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