Added the ability to import invoices again

This commit is contained in:
Bryce Covert
2019-02-11 20:48:43 -08:00
parent 085440bedd
commit 7c01a04ee8
13 changed files with 196 additions and 22 deletions

View File

@@ -38,9 +38,11 @@
str/trim )
[value-parser parser-params] (-> template :parser k)]
(assoc result k (parse-value value-parser parser-params value))))
{:vendor-code (:vendor template)}))]))
{:vendor-code (:vendor template)
:text text}))]))
(defn parse [text]
(println text)
(->> t/pdf-templates
(filter (partial template-applies? text))
first
@@ -67,13 +69,25 @@
[file filename]
(excel/parse-file file filename))
(defn best-match [clients client-identifier]
(defn best-match [clients invoice-client-name]
(->> clients
(map (fn [client]
(if-let [matches (:client/matches client)]
[client (apply min (map #(m/jaccard (.toLowerCase client-identifier) %) matches))]
[client 1])))
(mapcat (fn [{:keys [:db/id :client/matches] :as client :or {matches []}}]
(println matches)
(map (fn [m]
[client (m/jaccard (.toLowerCase invoice-client-name) (.toLowerCase m))])
matches)))
(filter #(< (second %) 0.25))
(sort-by second)
ffirst))
(defn best-location-match [client text]
(or (->> client
:client/location-matches
(mapcat (fn [{:keys [:location-match/location :location-match/matches]}]
(map (fn [match] [location match]) matches)))
(filter (fn [[location match]] (re-find (re-pattern (str "(?i)" match)) text)) )
first
first)
(:client/default-location client)
(first (:client/locations client))))