diff --git a/src/clj/auto_ap/routes/invoices.clj b/src/clj/auto_ap/routes/invoices.clj index b4f2b840..40502151 100644 --- a/src/clj/auto_ap/routes/invoices.clj +++ b/src/clj/auto_ap/routes/invoices.clj @@ -54,6 +54,12 @@ account-number (:db/id (d-clients/exact-match account-number)) customer-identifier (:db/id (d-clients/best-match customer-identifier)) client-override (Long/parseLong client-override)) + _ (alog/info ::client-matched + :account-number account-number + :customer-identifier customer-identifier + :client-override client-override + :matching (when matching-client + (dc/pull (dc/db conn) [:client/name :client/code] matching-client))) matching-vendor (match-vendor vendor-code vendor-override) matching-location (or (when-not (str/blank? location-override) diff --git a/src/clj/auto_ap/square/core3.clj b/src/clj/auto_ap/square/core3.clj index 458522ae..c3e6cc08 100644 --- a/src/clj/auto_ap/square/core3.clj +++ b/src/clj/auto_ap/square/core3.clj @@ -969,9 +969,17 @@ :headers (client-base-headers client) :as :json}) :body))) +(->> + @(let [[c [l]] (get-square-client-and-location "NGGG")] + + + (search c l (time/plus (time/now)))) + (filter (fn [r] + (str/starts-with? (:created_at r) "2024-03-14")))) + (def refs (->> - @(let [[c [l]] (get-square-client-and-location "NGCL")] + @(let [[c [l]] (get-square-client-and-location "NGGG")] (refunds-raw-cont c l nil [])) @@ -984,6 +992,8 @@ (map (fn [r] @(get-payment c (:payment_id r))) refs)) +(get-square-client-and-location "NGGB") + (def my-results (let [[c [l]] (get-square-client-and-location "NGFA")])) diff --git a/src/clj/auto_ap/ssr/invoice/import.clj b/src/clj/auto_ap/ssr/invoice/import.clj index 31fa074d..f9a8b15e 100644 --- a/src/clj/auto_ap/ssr/invoice/import.clj +++ b/src/clj/auto_ap/ssr/invoice/import.clj @@ -579,13 +579,19 @@ (defn import->invoice [{:keys [invoice-number source-url customer-identifier account-number total date vendor-code text full-text client-override vendor-override location-override import-status]}] (let [matching-client (cond - client-override client-override - account-number (:db/id (d-clients/exact-match account-number)) - customer-identifier (:db/id (d-clients/best-match customer-identifier))) - + client-override client-override + account-number (:db/id (d-clients/exact-match account-number)) + customer-identifier (:db/id (d-clients/best-match customer-identifier))) + _ (alog/info ::client-matched + :account-number account-number + :customer-identifier customer-identifier + :client-override client-override + :matching (when matching-client + (dc/pull (dc/db conn) [:client/name :client/code] matching-client))) + matching-vendor (match-vendor vendor-code vendor-override) matching-location (or (when-not (str/blank? location-override) - location-override) + location-override) (parse/best-location-match (dc/pull (dc/db conn) [{:client/location-matches [:location-match/location :location-match/matches]} :client/default-location diff --git a/src/cljc/auto_ap/permissions.cljc b/src/cljc/auto_ap/permissions.cljc index 660a4f0d..a7868e05 100644 --- a/src/cljc/auto_ap/permissions.cljc +++ b/src/cljc/auto_ap/permissions.cljc @@ -19,7 +19,8 @@ (cond (#{:user-role/admin "admin"} role) true - (and client-id (not (get (into #{} (map :db/id (:clients user))) client-id))) + (and client-id (not (get (into #{} (map :db/id (or (:clients user) + (:user/clients user)))) client-id))) false (#{:user-role/power-user "power-user"} role)