Fixes a series of issues on the invoice import page, company 1099 dropdown, and ezcater warnings.
This commit is contained in:
@@ -11,6 +11,7 @@
|
||||
[clj-time.core :as time]
|
||||
[clojure.set :as set]
|
||||
[auto-ap.time :as atime]
|
||||
[auto-ap.logging :as alog]
|
||||
[cemerick.url :as url]))
|
||||
|
||||
(defn query [{:ezcater-integration/keys [api-key]} q]
|
||||
@@ -203,72 +204,72 @@
|
||||
integration (:ezcater-integration/_caterers caterer)
|
||||
client (-> caterer :ezcater-location/_caterer first :client/_ezcater-locations :client/code)
|
||||
location (-> caterer :ezcater-location/_caterer first :ezcater-location/location)]
|
||||
(doto
|
||||
(-> (query
|
||||
integration
|
||||
{:venia/queries [[:order {:id (get json "entity_id")}
|
||||
[:uuid
|
||||
:orderSourceType
|
||||
[:caterer
|
||||
[:name
|
||||
:uuid
|
||||
[:address [:street]]]]
|
||||
[:event
|
||||
[:timestamp
|
||||
:catererHandoffFoodTime
|
||||
:orderType]]
|
||||
[:catererCart [[:orderItems
|
||||
[:name
|
||||
:quantity
|
||||
:posItemId
|
||||
[:totalInSubunits
|
||||
[:currency
|
||||
:subunits]]]]
|
||||
[:totals
|
||||
[:catererTotalDue]]
|
||||
[:feesAndDiscounts
|
||||
{:type 'DELIVERY_FEE}
|
||||
[[:cost
|
||||
[:currency
|
||||
:subunits]]]]]]
|
||||
[:totals [[:customerTotalDue
|
||||
[
|
||||
:currency
|
||||
:subunits
|
||||
]]
|
||||
[:pointOfSaleIntegrationFee
|
||||
[
|
||||
:currency
|
||||
:subunits
|
||||
]]
|
||||
[:tip
|
||||
[:currency
|
||||
:subunits]]
|
||||
[:salesTax
|
||||
[
|
||||
:currency
|
||||
:subunits
|
||||
]]
|
||||
[:salesTaxRemittance
|
||||
[:currency
|
||||
:subunits
|
||||
]]
|
||||
[:subTotal
|
||||
[:currency
|
||||
:subunits]]]]]]]})
|
||||
(:order)
|
||||
(assoc :client-code client
|
||||
:client-location location))
|
||||
log/info)))
|
||||
(if (and client location)
|
||||
(doto
|
||||
(-> (query
|
||||
integration
|
||||
{:venia/queries [[:order {:id (get json "entity_id")}
|
||||
[:uuid
|
||||
:orderSourceType
|
||||
[:caterer
|
||||
[:name
|
||||
:uuid
|
||||
[:address [:street]]]]
|
||||
[:event
|
||||
[:timestamp
|
||||
:catererHandoffFoodTime
|
||||
:orderType]]
|
||||
[:catererCart [[:orderItems
|
||||
[:name
|
||||
:quantity
|
||||
:posItemId
|
||||
[:totalInSubunits
|
||||
[:currency
|
||||
:subunits]]]]
|
||||
[:totals
|
||||
[:catererTotalDue]]
|
||||
[:feesAndDiscounts
|
||||
{:type 'DELIVERY_FEE}
|
||||
[[:cost
|
||||
[:currency
|
||||
:subunits]]]]]]
|
||||
[:totals [[:customerTotalDue
|
||||
[
|
||||
:currency
|
||||
:subunits
|
||||
]]
|
||||
[:pointOfSaleIntegrationFee
|
||||
[
|
||||
:currency
|
||||
:subunits
|
||||
]]
|
||||
[:tip
|
||||
[:currency
|
||||
:subunits]]
|
||||
[:salesTax
|
||||
[
|
||||
:currency
|
||||
:subunits
|
||||
]]
|
||||
[:salesTaxRemittance
|
||||
[:currency
|
||||
:subunits
|
||||
]]
|
||||
[:subTotal
|
||||
[:currency
|
||||
:subunits]]]]]]]})
|
||||
(:order)
|
||||
(assoc :client-code client
|
||||
:client-location location))
|
||||
(#(alog/info ::order-details :detail %)))
|
||||
(alog/warn ::caterer-no-longer-has-location :json json))))
|
||||
|
||||
(defn import-order [json]
|
||||
;; {"id" "bf3dcf5c-a68f-42d9-9084-049133e03d3d", "parent_type" "Caterer", "parent_id" "91541331-d7ae-4634-9e8b-ccbbcfb2ce70", "entity_type" "Order", "entity_id" "9ab05fee-a9c5-483b-a7f2-14debde4b7a8", "key" "accepted", "occurred_at" "2022-07-21T19:21:07.549Z"}
|
||||
(clojure.pprint/pprint [(-> json
|
||||
(lookup-order)
|
||||
(order->sales-order)
|
||||
(update :sales-order/date coerce/to-date)
|
||||
(update-in [:sales-order/charges 0 :charge/date] coerce/to-date))])
|
||||
@(d/transact conn [(-> json
|
||||
(alog/info
|
||||
::try-import-order
|
||||
:json json)
|
||||
@(d/transact conn [(some-> json
|
||||
(lookup-order)
|
||||
(order->sales-order)
|
||||
(update :sales-order/date coerce/to-date)
|
||||
@@ -339,7 +340,6 @@
|
||||
:when (not= updated-order extant-order)]
|
||||
|
||||
updated-order))]
|
||||
|
||||
(log/info "Found these orders to update:" orders-to-update)
|
||||
@(d/transact conn orders-to-update)))
|
||||
|
||||
|
||||
Reference in New Issue
Block a user