Add vendor pre-population for bulk code and individual edit forms
- Add vendor-changed HTMX handlers for both bulk code and individual edit - Pre-populate default account at 100% when vendor is selected and no accounts exist - Fix render-accounts-section to render from step-params correctly - Change bulk code vendor-changed from hx-get to hx-post to include form data - Add routes for vendor-changed endpoints - Update e2e tests to cover vendor pre-population - Run lein cljfmt fix across codebase
This commit is contained in:
@@ -16,7 +16,6 @@
|
||||
|
||||
(defonce last-text (atom nil))
|
||||
|
||||
|
||||
(defn template-applies? [text {:keys [keywords]}]
|
||||
(every? #(re-find % text) keywords))
|
||||
|
||||
@@ -24,7 +23,7 @@
|
||||
([text template]
|
||||
(alog/info ::template-determined
|
||||
:template (str template))
|
||||
|
||||
|
||||
(if (:multi template)
|
||||
(mapcat
|
||||
#(extract-template % text (dissoc template :multi))
|
||||
@@ -60,8 +59,6 @@
|
||||
first
|
||||
(extract-template text)))
|
||||
|
||||
|
||||
|
||||
(defmulti parse-file
|
||||
"Parses a file based on its extension. Accepts options as additional arguments.
|
||||
Options:
|
||||
@@ -74,17 +71,16 @@
|
||||
:socket-timeout 120000}} {:function-name "glimpse2" :payload
|
||||
(json/write-str
|
||||
(alog/peek ::x {"url" (str "https://" "data.prod.app.integreatconsult.com" "/" f)}))})))]
|
||||
|
||||
|
||||
(alog/info ::glimpse2-payload :payload result)
|
||||
(-> result
|
||||
json/read-str)))
|
||||
json/read-str)))
|
||||
|
||||
(defn glimpse2 [file]
|
||||
(try
|
||||
(try
|
||||
(let [tmp-key (str "glimpse2/import/" (java.util.UUID/randomUUID) ".pdf")
|
||||
_ (with-open [f (io/input-stream file)]
|
||||
(s3/put-object {:bucket-name "data.prod.app.integreatconsult.com"
|
||||
(s3/put-object {:bucket-name "data.prod.app.integreatconsult.com"
|
||||
:key tmp-key
|
||||
:input-stream f}))
|
||||
is (invoke-glimpse2 tmp-key)]
|
||||
@@ -99,7 +95,7 @@
|
||||
:total (get i "total")
|
||||
:invoice-number (get i "invoice_number")
|
||||
:template "None found - defaulting to ChatGPT"}))
|
||||
|
||||
|
||||
(catch Exception e
|
||||
(alog/warn ::glimpse2-not-work :error e)
|
||||
nil)))
|
||||
@@ -107,7 +103,7 @@
|
||||
(defmethod parse-file
|
||||
"pdf"
|
||||
[file _ & {:keys [allow-glimpse?] :or {allow-glimpse? false}}]
|
||||
(or
|
||||
(or
|
||||
(-> (sh/sh "pdftotext" "-layout" file "-")
|
||||
:out
|
||||
parse)
|
||||
@@ -123,7 +119,6 @@
|
||||
[file filename & _]
|
||||
(excel/parse-file file filename))
|
||||
|
||||
|
||||
(defmethod parse-file
|
||||
"xlsx"
|
||||
[file filename & _]
|
||||
@@ -157,8 +152,8 @@
|
||||
client-word-match (->> clients
|
||||
(map
|
||||
(fn [{:keys [:client/matches :client/name] :as client :or {matches []}}]
|
||||
(let [client-words (-> #{}
|
||||
(into
|
||||
(let [client-words (-> #{}
|
||||
(into
|
||||
(mapcat
|
||||
(fn [match] (str/split (.toLowerCase match) #"\s"))
|
||||
matches))
|
||||
@@ -175,13 +170,13 @@
|
||||
([clients invoice-client-name]
|
||||
(->> clients
|
||||
(filter (fn [{:keys [:client/matches :client/location-matches :client/locations :client/name] :as client :or {matches []}}]
|
||||
(seq
|
||||
(filter (fn [m]
|
||||
(and
|
||||
m
|
||||
invoice-client-name
|
||||
(= (.toLowerCase invoice-client-name) (.toLowerCase m))))
|
||||
(conj matches name)))))
|
||||
(seq
|
||||
(filter (fn [m]
|
||||
(and
|
||||
m
|
||||
invoice-client-name
|
||||
(= (.toLowerCase invoice-client-name) (.toLowerCase m))))
|
||||
(conj matches name)))))
|
||||
first)))
|
||||
|
||||
(defn best-location-match [client text full-text]
|
||||
@@ -207,9 +202,9 @@
|
||||
(defn dbg-parse [v]
|
||||
(println v)
|
||||
(map
|
||||
(fn [x] (dissoc x :full-text :text))
|
||||
(parse v)))
|
||||
|
||||
(fn [x] (dissoc x :full-text :text))
|
||||
(parse v)))
|
||||
|
||||
#_(nth (re-find #"ELECTRONICALLY.*\n\s*(.*?)\s{2,}" @last-text)
|
||||
|
||||
1)
|
||||
1)
|
||||
|
||||
Reference in New Issue
Block a user