Fixes issues with square loading

This commit is contained in:
2022-05-10 08:50:02 -07:00
parent 8f47b4bb2b
commit e8f1a0d734
2 changed files with 64 additions and 32 deletions

View File

@@ -485,8 +485,8 @@
(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)
(doseq [d (clj-time.periodic/periodic-seq (t/plus (t/today) (t/days (- days)))
(t/today)
(t/days 1))]
(println d)
(square/upsert client square-location d)))
@@ -497,8 +497,8 @@
(println "settlements")
(with-redefs [square/lookup-dates (fn lookup-dates []
(->> (clj-time.periodic/periodic-seq (t/plus (t/now) (t/days (- days)))
(t/now)
(->> (clj-time.periodic/periodic-seq (t/plus (t/today) (t/days (- days)))
(t/today)
(t/days 2))
(map (fn [d]
[(atime/unparse (t/plus d (t/days 1)) atime/iso-date)
@@ -507,10 +507,22 @@
(square/upsert-settlements client square-location)))))
(defn load-sales-for-day [date]
(doseq [client (d/q [:find [(list 'pull '?e square/square-read ) '...]
:where ['?e :client/square-locations ]]
(d/db auto-ap.datomic/conn))
square-location (:client/square-locations client)
:when (:square-location/client-location square-location)]
(println client)
(println "orders")
(lc/with-context {:source "Historical loading data"}
(square/upsert client square-location (c/to-date-time date)))))
(defn upsert-invoice-amounts [tsv]
(let [data (with-open [reader (io/reader (char-array tsv))]
(let [data (with-open [reader (io/reader (char-array tsv))]
(doall (csv/read-csv reader :separator \tab)))
db (d/db auto-ap.datomic/conn)
db (d/db auto-ap.datomic/conn)
invoice-totals (->> data
(drop 1)
(group-by first)