Less error prone

This commit is contained in:
2022-01-19 08:05:43 -08:00
parent cd5b1cbb8a
commit 6e0720c3b3
8 changed files with 284 additions and 308 deletions

View File

@@ -67,8 +67,8 @@
(header-row "City2")])
account-number (some-> account-number Long/parseLong str)
matching-client (and account-number
(parse/best-match clients account-number 0.0))
[matching-client similarity] (and account-number
(parse/best-match clients account-number 0.0))
_ (when-not matching-client
(throw (ex-info "cannot find matching client"
{:account-number account-number
@@ -80,16 +80,18 @@
"yyMMdd")]
(log/infof "Importing %s for %s" (header-row "InvoiceNumber") (header-row "CustomerName"))
(code-invoice #:invoice {:invoice-number (header-row "InvoiceNumber")
:total (+ total tax)
:outstanding-balance (+ total tax)
:location (parse/best-location-match matching-client location-hint location-hint )
:date (coerce/to-date date)
:vendor (:db/id sysco-vendor )
:client (:db/id matching-client)
:import-status :import-status/completed
:status :invoice-status/unpaid
:client-identifier customer-identifier})))
(cond-> #:invoice {:invoice-number (header-row "InvoiceNumber")
:total (+ total tax)
:outstanding-balance (+ total tax)
:location (parse/best-location-match matching-client location-hint location-hint )
:date (coerce/to-date date)
:vendor (:db/id sysco-vendor )
:client (:db/id matching-client)
:import-status :import-status/completed
:status :invoice-status/unpaid
:client-identifier customer-identifier}
similarity (assoc :invoice/similarity (- 1.0 (double similarity)))
true (code-invoice))))
(defn mark-key [k]
(s3/copy-object {:source-bucket-name bucket-name