Allows users to self set up square
This commit is contained in:
@@ -2,9 +2,11 @@
|
||||
(:require [auto-ap.datomic :refer [uri]]
|
||||
[config.core :refer [env]]
|
||||
[auto-ap.utils :refer [by]]
|
||||
[auto-ap.time :as atime]
|
||||
[clojure.core.async :as async]
|
||||
#_[auto-ap.ledger :as l]
|
||||
[unilog.context :as lc]
|
||||
[auto-ap.square.core :as square]
|
||||
[mount.core :as mount]
|
||||
[auto-ap.server ]
|
||||
[datomic.api :as d]
|
||||
@@ -610,29 +612,35 @@
|
||||
|
||||
|
||||
(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)))
|
||||
(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 (clj-time.periodic/periodic-seq (t/plus (t/now) (t/days (- days)))
|
||||
(t/now)
|
||||
(t/days 1))]
|
||||
(println d)
|
||||
(square/upsert client square-location d)))
|
||||
|
||||
(println "refunds")
|
||||
(auto-ap.square.core/upsert-refunds client-code)
|
||||
(println "refunds")
|
||||
(square/upsert-refunds client square-location)
|
||||
|
||||
|
||||
(println "settlements")
|
||||
(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)
|
||||
(println "settlements")
|
||||
(with-redefs [square/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]
|
||||
[(atime/unparse (t/plus d (t/days 1)) atime/iso-date)
|
||||
|
||||
(auto-ap.time/unparse (t/plus d (t/days 2)) auto-ap.time/iso-date)]))))]
|
||||
(atime/unparse (t/plus d (t/days 2)) atime/iso-date)]))))]
|
||||
|
||||
(auto-ap.square.core/upsert-settlements client-code)))
|
||||
(square/upsert-settlements client square-location)))))
|
||||
|
||||
(defn upsert-invoice-amounts [tsv]
|
||||
(let [data (with-open [reader (io/reader (char-array tsv))]
|
||||
@@ -668,7 +676,7 @@
|
||||
current-account-id (:db/id (:invoice-expense-account/account invoice-expense-account))
|
||||
target-account-id (Long/parseLong (str/trim target-account))
|
||||
|
||||
target-date (clj-time.coerce/to-date (auto-ap.time/parse target-date auto-ap.time/normal-date))
|
||||
target-date (clj-time.coerce/to-date (atime/parse target-date atime/normal-date))
|
||||
current-date (:invoice/date invoice)
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user