adds register invoice import

This commit is contained in:
2022-12-04 11:09:51 -08:00
parent 58fad1b4f1
commit 3e512a52ac
7 changed files with 394 additions and 19 deletions

View File

@@ -5,6 +5,7 @@
[auto-ap.ledger :as l :refer [transact-with-ledger]]
[auto-ap.server]
[auto-ap.square.core :as square]
[auto-ap.square.core2 :as square2]
[auto-ap.time :as atime]
[auto-ap.utils :refer [by]]
[clj-time.coerce :as c]
@@ -466,11 +467,43 @@
(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 ) '...]
:where ['?e :client/square-locations ]]
(d/db auto-ap.datomic/conn))
: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)