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] [clj-time.core :as time]
[clojure.set :as set] [clojure.set :as set]
[auto-ap.time :as atime] [auto-ap.time :as atime]
[auto-ap.logging :as alog]
[cemerick.url :as url])) [cemerick.url :as url]))
(defn query [{:ezcater-integration/keys [api-key]} q] (defn query [{:ezcater-integration/keys [api-key]} q]
@@ -203,72 +204,72 @@
integration (:ezcater-integration/_caterers caterer) integration (:ezcater-integration/_caterers caterer)
client (-> caterer :ezcater-location/_caterer first :client/_ezcater-locations :client/code) client (-> caterer :ezcater-location/_caterer first :client/_ezcater-locations :client/code)
location (-> caterer :ezcater-location/_caterer first :ezcater-location/location)] location (-> caterer :ezcater-location/_caterer first :ezcater-location/location)]
(doto (if (and client location)
(-> (query (doto
integration (-> (query
{:venia/queries [[:order {:id (get json "entity_id")} integration
[:uuid {:venia/queries [[:order {:id (get json "entity_id")}
:orderSourceType [:uuid
[:caterer :orderSourceType
[:name [:caterer
:uuid [:name
[:address [:street]]]] :uuid
[:event [:address [:street]]]]
[:timestamp [:event
:catererHandoffFoodTime [:timestamp
:orderType]] :catererHandoffFoodTime
[:catererCart [[:orderItems :orderType]]
[:name [:catererCart [[:orderItems
:quantity [:name
:posItemId :quantity
[:totalInSubunits :posItemId
[:currency [:totalInSubunits
:subunits]]]] [:currency
[:totals :subunits]]]]
[:catererTotalDue]] [:totals
[:feesAndDiscounts [:catererTotalDue]]
{:type 'DELIVERY_FEE} [:feesAndDiscounts
[[:cost {:type 'DELIVERY_FEE}
[:currency [[:cost
:subunits]]]]]] [:currency
[:totals [[:customerTotalDue :subunits]]]]]]
[ [:totals [[:customerTotalDue
:currency [
:subunits :currency
]] :subunits
[:pointOfSaleIntegrationFee ]]
[ [:pointOfSaleIntegrationFee
:currency [
:subunits :currency
]] :subunits
[:tip ]]
[:currency [:tip
:subunits]] [:currency
[:salesTax :subunits]]
[ [:salesTax
:currency [
:subunits :currency
]] :subunits
[:salesTaxRemittance ]]
[:currency [:salesTaxRemittance
:subunits [:currency
]] :subunits
[:subTotal ]]
[:currency [:subTotal
:subunits]]]]]]]}) [:currency
(:order) :subunits]]]]]]]})
(assoc :client-code client (:order)
:client-location location)) (assoc :client-code client
log/info))) :client-location location))
(#(alog/info ::order-details :detail %)))
(alog/warn ::caterer-no-longer-has-location :json json))))
(defn import-order [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"} ;; {"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 (alog/info
(lookup-order) ::try-import-order
(order->sales-order) :json json)
(update :sales-order/date coerce/to-date) @(d/transact conn [(some-> json
(update-in [:sales-order/charges 0 :charge/date] coerce/to-date))])
@(d/transact conn [(-> json
(lookup-order) (lookup-order)
(order->sales-order) (order->sales-order)
(update :sales-order/date coerce/to-date) (update :sales-order/date coerce/to-date)
@@ -339,7 +340,6 @@
:when (not= updated-order extant-order)] :when (not= updated-order extant-order)]
updated-order))] updated-order))]
(log/info "Found these orders to update:" orders-to-update) (log/info "Found these orders to update:" orders-to-update)
@(d/transact conn orders-to-update))) @(d/transact conn orders-to-update)))

View File

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

View File

@@ -304,7 +304,7 @@
(cond-> (cond->
{:yodlee-provider-account/id (:id pa) {:yodlee-provider-account/id (:id pa)
:yodlee-provider-account/status (:status 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/client [:client/code client-code]
:yodlee-provider-account/accounts (mapv :yodlee-provider-account/accounts (mapv

View File

@@ -177,7 +177,8 @@
(fn [] (fn []
(let [page @(re-frame/subscribe [::data-page/page :import-invoices]) (let [page @(re-frame/subscribe [::data-page/page :import-invoices])
batch @(re-frame/subscribe [::batch]) 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)} ^{:key (str client "-" batch)}
[:div [:div
[:h1.title "Upload invoices"] [:h1.title "Upload invoices"]
@@ -191,7 +192,9 @@
[:div {:class "card-header"} [:div {:class "card-header"}
[:span {:class "card-header-title"} "Found Invoices"]] [:span {:class "card-header-title"} "Found Invoices"]]
[:div {:class "card-content"} [: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))) (if (seq (:data (:data page)))
[invoice-table {:id :approved [invoice-table {:id :approved
:data-page :import-invoices :data-page :import-invoices