fixed errors.

This commit is contained in:
2022-04-06 09:16:02 -07:00
parent 54de896c6c
commit 2dbafd157a
5 changed files with 48 additions and 68 deletions

View File

@@ -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 "}