made invoice import back to working, mostly
This commit is contained in:
@@ -11,6 +11,12 @@
|
||||
(defmulti parse-value (fn [method _ _]
|
||||
method))
|
||||
|
||||
|
||||
(defmethod parse-value :trim-commas
|
||||
[_ _ value]
|
||||
(str/replace value #"," "")
|
||||
)
|
||||
|
||||
(defmethod parse-value :clj-time
|
||||
[_ format value]
|
||||
(time/from-time-zone (f/parse (f/formatter format) value)
|
||||
@@ -30,16 +36,17 @@
|
||||
#(extract-template % (dissoc template :multi))
|
||||
(str/split text (:multi template)))
|
||||
|
||||
[(->> template
|
||||
:extract
|
||||
(reduce-kv
|
||||
(fn [result k v]
|
||||
(let [value (some-> (first (map second (re-seq v text)))
|
||||
str/trim )
|
||||
[value-parser parser-params] (-> template :parser k)]
|
||||
(assoc result k (parse-value value-parser parser-params value))))
|
||||
{:vendor-code (:vendor template)
|
||||
:text text}))]))
|
||||
(when template
|
||||
[(->> template
|
||||
:extract
|
||||
(reduce-kv
|
||||
(fn [result k v]
|
||||
(let [value (some-> (first (map second (re-seq v text)))
|
||||
str/trim )
|
||||
[value-parser parser-params] (-> template :parser k)]
|
||||
(assoc result k (parse-value value-parser parser-params value))))
|
||||
{:vendor-code (:vendor template)
|
||||
:text text}))])))
|
||||
|
||||
(defn parse [text]
|
||||
(println text)
|
||||
@@ -72,11 +79,10 @@
|
||||
(defn best-match [clients invoice-client-name]
|
||||
(->> clients
|
||||
|
||||
(mapcat (fn [{:keys [:db/id :client/matches] :as client :or {matches []}}]
|
||||
(println matches)
|
||||
(mapcat (fn [{:keys [:db/id :client/matches :client/name] :as client :or {matches []}}]
|
||||
(map (fn [m]
|
||||
[client (m/jaccard (.toLowerCase invoice-client-name) (.toLowerCase m))])
|
||||
matches)))
|
||||
(conj matches name))))
|
||||
(filter #(< (second %) 0.25))
|
||||
(sort-by second)
|
||||
ffirst))
|
||||
|
||||
Reference in New Issue
Block a user