Added the ability to load historcial sales yourself.

This commit is contained in:
2022-12-04 20:04:35 -08:00
parent 586159f8e0
commit de8eb31493
6 changed files with 230 additions and 127 deletions

View File

@@ -435,70 +435,6 @@
(async/<!! (async/into [] output-chan))))
#_{:clj-kondo/ignore [:clojure-lsp/unused-public-var]}
(defn historical-load-sales [client-code days]
(let [client (d/pull (d/db auto-ap.datomic/conn)
square/square-read
[:client/code client-code])]
(doseq [square-location (:client/square-locations client)
:when (:square-location/client-location square-location)]
(println "orders")
(lc/with-context {:source "Historical loading data"}
(doseq [d (per/periodic-seq (t/plus (t/today) (t/days (- days)))
(t/today)
(t/days 1))]
(println d)
(square/upsert client square-location (c/to-date-time d) (c/to-date-time (t/plus d (t/days 1))))))
(println "refunds")
(square/upsert-refunds client square-location)
(println "settlements")
(with-redefs [square/lookup-dates (fn lookup-dates []
(->> (per/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)
(atime/unparse (t/plus d (t/days 2)) atime/iso-date)]))))]
(square/upsert-settlements client square-location)))))
(defn historical-load-sales2 [client-code days]
(let [client (d/pull (d/db auto-ap.datomic/conn)
square/square-read
[:client/code client-code])]
(doseq [square-location (:client/square-locations client)
:when (:square-location/client-location square-location)]
(println "orders")
(lc/with-context {:source "Historical loading data"}
(doseq [d (per/periodic-seq (t/plus (t/today) (t/days (- days)))
(t/today)
(t/days 1))]
(println d)
(square2/upsert client square-location (c/to-date-time d) (c/to-date-time (t/plus d (t/days 1))))))
(println "refunds")
(square2/upsert-refunds client square-location)
(println "settlements")
(with-redefs [square2/lookup-dates (fn lookup-dates []
(->> (per/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)
(atime/unparse (t/plus d (t/days 2)) atime/iso-date)]))))]
(square2/upsert-settlements client square-location)))))
#_{:clj-kondo/ignore [:clojure-lsp/unused-public-var]}
(defn load-sales-for-day [date]
(doseq [client (d/q [:find [(list 'pull '?e square/square-read ) '...]