Less error prone
This commit is contained in:
@@ -126,20 +126,20 @@
|
||||
|
||||
|
||||
(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]} clients]
|
||||
(let [matching-client (cond
|
||||
account-number (parse/best-match clients account-number 0.0)
|
||||
customer-identifier (parse/best-match clients customer-identifier)
|
||||
client-override (first (filter (fn [c]
|
||||
(= (:db/id c) (Long/parseLong client-override)))
|
||||
clients)))
|
||||
matching-vendor (match-vendor vendor-code vendor-override)
|
||||
matching-location (or (when-not (str/blank? location-override)
|
||||
location-override)
|
||||
|
||||
(parse/best-location-match matching-client text full-text))]
|
||||
(let [[matching-client similarity] (cond
|
||||
account-number (parse/best-match clients account-number 0.0)
|
||||
customer-identifier (parse/best-match clients customer-identifier)
|
||||
client-override (first (filter (fn [c]
|
||||
(= (:db/id c) (Long/parseLong client-override)))
|
||||
clients)))
|
||||
matching-vendor (match-vendor vendor-code vendor-override)
|
||||
matching-location (or (when-not (str/blank? location-override)
|
||||
location-override)
|
||||
(parse/best-location-match matching-client text full-text))]
|
||||
(remove-nils #:invoice {:invoice/client (:db/id matching-client)
|
||||
:invoice/client-identifier (or account-number customer-identifier)
|
||||
:invoice/vendor (:db/id matching-vendor)
|
||||
:invoice/similarity (some-> similarity double (#(- 1.0 %)))
|
||||
:invoice/source-url source-url
|
||||
:invoice/invoice-number invoice-number
|
||||
:invoice/total (Double/parseDouble total)
|
||||
|
||||
Reference in New Issue
Block a user