Fixes a series of issues on the invoice import page, company 1099 dropdown, and ezcater warnings.

This commit is contained in:
2023-01-23 13:59:16 -08:00
parent 475a21530d
commit be44000b6a
4 changed files with 80 additions and 75 deletions

View File

@@ -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)))

View File

@@ -23,11 +23,12 @@
[(auto-ap.graphql.utils/can-see-client? ?user ?c)]]
(d/db conn) user)
(map first)
set)]
(cond
set)
results (cond
(and (some-> session :client :db/id)
(can-see-client? user
(some-> session :client :db/id)))
:else
(d/q '[:find
(pull ?c [:client/code :db/id])
(pull ?v [:db/id
@@ -115,12 +116,13 @@
[?p :payment/amount ?a]
[?p :payment/vendor ?v]]
(d/db conn)
clients)
(filter (fn [[_ _ a]]
(>= (or a 0.0) 600.0)))
(take 200)
(sort-by (fn [[client _ amount]]
[(:client/code client ) amount]) ))))
clients))]
(->> results
(filter (fn [[_ _ a]]
(>= (or a 0.0) 600.0)))
(take 200)
(sort-by (fn [[client _ amount]]
[(:client/code client ) amount])))))
(defn dialog [header content footer]
[:div.modal.is-active

View File

@@ -304,7 +304,7 @@
(cond->
{:yodlee-provider-account/id (:id pa)
:yodlee-provider-account/status (:status pa)
:yodlee-provider-account/detailed-status (-> pa :dataset first :additionalStatus)
:yodlee-provider-account/detailed-status (or (-> pa :dataset first :additionalStatus) "unknown")
:yodlee-provider-account/client [:client/code client-code]
:yodlee-provider-account/accounts (mapv

View File

@@ -177,7 +177,8 @@
(fn []
(let [page @(re-frame/subscribe [::data-page/page :import-invoices])
batch @(re-frame/subscribe [::batch])
client (:id @(re-frame/subscribe [::subs/client]))]
client (:id @(re-frame/subscribe [::subs/client]))
checked-set (into #{} (:checked-set page))]
^{:key (str client "-" batch)}
[:div
[:h1.title "Upload invoices"]
@@ -191,7 +192,9 @@
[:div {:class "card-header"}
[:span {:class "card-header-title"} "Found Invoices"]]
[:div {:class "card-content"}
[approve-reject-button (:checked-set page)]
[approve-reject-button (if (get checked-set "header")
(into #{} (map :id (:data (:data page))))
checked-set)]
(if (seq (:data (:data page)))
[invoice-table {:id :approved
:data-page :import-invoices