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]
|
[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,6 +204,7 @@
|
|||||||
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)]
|
||||||
|
(if (and client location)
|
||||||
(doto
|
(doto
|
||||||
(-> (query
|
(-> (query
|
||||||
integration
|
integration
|
||||||
@@ -259,16 +261,15 @@
|
|||||||
(:order)
|
(:order)
|
||||||
(assoc :client-code client
|
(assoc :client-code client
|
||||||
:client-location location))
|
:client-location location))
|
||||||
log/info)))
|
(#(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)))
|
||||||
|
|
||||||
|
|||||||
@@ -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,7 +116,8 @@
|
|||||||
[?p :payment/amount ?a]
|
[?p :payment/amount ?a]
|
||||||
[?p :payment/vendor ?v]]
|
[?p :payment/vendor ?v]]
|
||||||
(d/db conn)
|
(d/db conn)
|
||||||
clients)
|
clients))]
|
||||||
|
(->> results
|
||||||
(filter (fn [[_ _ a]]
|
(filter (fn [[_ _ a]]
|
||||||
(>= (or a 0.0) 600.0)))
|
(>= (or a 0.0) 600.0)))
|
||||||
(take 200)
|
(take 200)
|
||||||
|
|||||||
@@ -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
|
||||||
|
|||||||
@@ -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
|
||||||
|
|||||||
Reference in New Issue
Block a user