From 6dd801d710d9fbe98f67009c326ecbc91137a499 Mon Sep 17 00:00:00 2001 From: Bryce Covert Date: Tue, 5 Oct 2021 16:23:15 -0700 Subject: [PATCH] NGWH --- config/prod-background-worker.edn | 4 ++++ src/clj/user.clj | 25 +++++++++++++++++++++++++ 2 files changed, 29 insertions(+) diff --git a/config/prod-background-worker.edn b/config/prod-background-worker.edn index f5a15ad3..ea5d3490 100644 --- a/config/prod-background-worker.edn +++ b/config/prod-background-worker.edn @@ -83,6 +83,10 @@ {:square-location "LSWNP14T0YKD9", :location "WL", :token "EAAAEO2xSqesDutZz71hz3eulKmrlKTiEqG3uZ4j25x5GYlOluQ2cj2JxNUXqXD7"}, + "NGWH" + {:square-location "L8XFVAYYK6QGM", + :location "WH", + :token "EAAAEO2xSqesDutZz71hz3eulKmrlKTiEqG3uZ4j25x5GYlOluQ2cj2JxNUXqXD7"}, "NGMJ" {:square-location "FNH5VRT890WK8", :location "SC", diff --git a/src/clj/user.clj b/src/clj/user.clj index 1b667bc5..f1dd064b 100644 --- a/src/clj/user.clj +++ b/src/clj/user.clj @@ -4,6 +4,7 @@ [auto-ap.utils :refer [by]] [clojure.core.async :as async] #_[auto-ap.ledger :as l] + [unilog.context :as lc] [mount.core :as mount] [auto-ap.server ] [datomic.api :as d] @@ -593,3 +594,27 @@ )]))) +(defn historical-load-sales [client-code days] + (println "orders") + (lc/with-context {:source "Historical loading data"} + (doseq [d (clj-time.periodic/periodic-seq (t/plus (t/now) (t/days (- days))) + (t/now) + (t/days 1))] + (println d) + (auto-ap.square.core/upsert client-code d))) + + (println "refunds") + (auto-ap.square.core/upsert-refunds client-code) + + (with-redefs [auto-ap.square.core/lookup-dates (fn lookup-dates [] + (->> (clj-time.periodic/periodic-seq (t/plus (t/now) (t/days (- days))) + (t/now) + (t/days 2)) + (map (fn [d] + [(auto-ap.time/unparse (t/plus d (t/days 1)) auto-ap.time/iso-date) + + (auto-ap.time/unparse (t/plus d (t/days 2)) auto-ap.time/iso-date)]))))] + + (auto-ap.square.core/upsert-settlements client-code))) + +