fixing minor bugs in general produce import
This commit is contained in:
@@ -65,19 +65,22 @@
|
|||||||
(defmethod extract-invoice-details :general-produce
|
(defmethod extract-invoice-details :general-produce
|
||||||
[k input-stream clients]
|
[k input-stream clients]
|
||||||
(log/info ::parsing-general-produce :key k)
|
(log/info ::parsing-general-produce :key k)
|
||||||
|
(let [missing-client-hints (atom #{})]
|
||||||
(try
|
(try
|
||||||
(->> (read-csv input-stream)
|
(->> (read-csv input-stream)
|
||||||
(drop 1)
|
(drop 1)
|
||||||
(filter (fn [[_ _ _ _ _ _ _ _ _ _ _ break-flag]]
|
#_(filter (fn [[_ _ _ _ _ _ _ _ _ _ _ break-flag]]
|
||||||
(= "Y" break-flag)))
|
(= "Y" break-flag)))
|
||||||
(map (fn [[_ location-hint invoice-number ship-date invoice-total ]]
|
(map (fn [[_ location-hint invoice-number ship-date invoice-total ]]
|
||||||
(let [matching-client (and location-hint
|
(let [matching-client (and location-hint
|
||||||
(parse/exact-match clients location-hint))
|
(parse/exact-match clients location-hint))
|
||||||
location (parse/best-location-match matching-client location-hint location-hint )
|
location (parse/best-location-match matching-client location-hint location-hint )
|
||||||
vendor (d/pull (d/db conn) '[:vendor/default-account] :vendor/general-produce)]
|
vendor (d/pull (d/db conn) '[:vendor/default-account] :vendor/general-produce)]
|
||||||
(when-not matching-client
|
(when-not (and matching-client
|
||||||
|
(not (@missing-client-hints location-hint)))
|
||||||
(log/warn ::missing-client
|
(log/warn ::missing-client
|
||||||
:client-hint location-hint))
|
:client-hint location-hint)
|
||||||
|
(swap! missing-client-hints conj location-hint))
|
||||||
{:invoice/location location
|
{:invoice/location location
|
||||||
:invoice/date (coerce/to-date (atime/parse ship-date atime/normal-date))
|
:invoice/date (coerce/to-date (atime/parse ship-date atime/normal-date))
|
||||||
:invoice/invoice-number invoice-number
|
:invoice/invoice-number invoice-number
|
||||||
@@ -98,7 +101,7 @@
|
|||||||
(catch Exception e
|
(catch Exception e
|
||||||
(log/error ::cant-import-general-produce
|
(log/error ::cant-import-general-produce
|
||||||
:error e)
|
:error e)
|
||||||
[])))
|
[]))))
|
||||||
|
|
||||||
(defmethod extract-invoice-details :unknown
|
(defmethod extract-invoice-details :unknown
|
||||||
[k input-stream clients]
|
[k input-stream clients]
|
||||||
@@ -245,6 +248,7 @@
|
|||||||
(->> (extract-invoice-details k
|
(->> (extract-invoice-details k
|
||||||
is
|
is
|
||||||
clients)
|
clients)
|
||||||
|
(set)
|
||||||
(map (fn [i]
|
(map (fn [i]
|
||||||
(log/info ::importing-invoice
|
(log/info ::importing-invoice
|
||||||
:invoice i)
|
:invoice i)
|
||||||
|
|||||||
@@ -631,7 +631,7 @@
|
|||||||
|
|
||||||
(defn cash-drawer-shifts
|
(defn cash-drawer-shifts
|
||||||
([client l]
|
([client l]
|
||||||
(cash-drawer-shifts client l (time/plus (time/now) (time/days -14)) (time/now)))
|
(cash-drawer-shifts client l (time/plus (time/now) (time/days -75)) (time/now)))
|
||||||
([client l start end]
|
([client l start end]
|
||||||
(de/chain (manifold-api-call {:url (str "https://connect.squareup.com/v2/cash-drawers/shifts"
|
(de/chain (manifold-api-call {:url (str "https://connect.squareup.com/v2/cash-drawers/shifts"
|
||||||
"?"
|
"?"
|
||||||
@@ -639,7 +639,8 @@
|
|||||||
(url/map->query
|
(url/map->query
|
||||||
{:location_id (:square-location/square-id l)
|
{:location_id (:square-location/square-id l)
|
||||||
:begin_time (->square-date start)
|
:begin_time (->square-date start)
|
||||||
:end_time (->square-date end)}))
|
:end_time (->square-date end)
|
||||||
|
:limit 1000}))
|
||||||
:method :get
|
:method :get
|
||||||
|
|
||||||
:headers (client-base-headers client "2023-04-19")
|
:headers (client-base-headers client "2023-04-19")
|
||||||
|
|||||||
Reference in New Issue
Block a user