invoice fixes.

This commit is contained in:
2022-01-18 16:15:14 -08:00
parent d4bd4e45fb
commit cd5b1cbb8a
4 changed files with 10 additions and 18 deletions

View File

@@ -126,21 +126,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]} clients]
(let [matching-client (or (and account-number
(parse/best-match clients account-number 0.0))
(and customer-identifier
(parse/best-match clients customer-identifier))
(when client-override
(first (filter (fn [c]
(= (:db/id c) (Long/parseLong client-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))]
(remove-nils #:invoice {:invoice/client (:db/id matching-client)
:invoice/client-identifier customer-identifier
:invoice/client-identifier (or account-number customer-identifier)
:invoice/vendor (:db/id matching-vendor)
:invoice/source-url source-url
:invoice/invoice-number invoice-number