invoice tweaks.
This commit is contained in:
@@ -684,7 +684,7 @@
|
||||
(:db-after tx)
|
||||
(map :e (:tx-data tx))))
|
||||
(throw (ex-info "No new invoices found."
|
||||
{})))
|
||||
{:template (:template (first imports))})))
|
||||
tx)))
|
||||
|
||||
(defn import-internal [tempfile filename force-client force-location force-vendor identity]
|
||||
@@ -707,7 +707,18 @@
|
||||
:source-url (str "https://" (:data-bucket env)
|
||||
"/"
|
||||
s3-location))))]
|
||||
(import-uploaded-invoice identity imports))
|
||||
(try
|
||||
|
||||
(import-uploaded-invoice identity imports)
|
||||
(catch Exception e
|
||||
(alog/warn ::couldnt-import-upload
|
||||
:error e
|
||||
:template (:template ( first imports)))
|
||||
(throw (ex-info (ex-message e)
|
||||
{:template (:template ( first imports))
|
||||
:sample (first imports)}
|
||||
e))))
|
||||
imports)
|
||||
(catch Exception e
|
||||
(alog/warn ::couldnt-import-upload
|
||||
:error e)
|
||||
@@ -722,14 +733,17 @@
|
||||
results (reduce
|
||||
(fn [result {:keys [filename tempfile]}]
|
||||
(try
|
||||
(import-internal tempfile filename force-client force-location force-vendor (:identity request) )
|
||||
(update result :results conj {:filename filename
|
||||
:response "success!"})
|
||||
(let [i (import-internal tempfile filename force-client force-location force-vendor (:identity request) )]
|
||||
(update result :results conj {:filename filename
|
||||
:response "success!"
|
||||
:template (:template (first i))}))
|
||||
(catch Exception e
|
||||
(-> result
|
||||
(assoc :error? true)
|
||||
(update :results conj {:filename filename
|
||||
:response (.getMessage e)})))))
|
||||
:response (.getMessage e)
|
||||
:sample (:sample (ex-data e))
|
||||
:template (:template (ex-data e))})))))
|
||||
{:error? false :results []}
|
||||
file)]
|
||||
(html-response [:div#page-notification.p-4.rounded-lg
|
||||
@@ -737,6 +751,15 @@
|
||||
"bg-red-50 text-red-700"
|
||||
"bg-primary-50 text-primary-700")}
|
||||
[:table
|
||||
[:thead
|
||||
[:tr [:td "File"] [:td "Result"]
|
||||
(if (:error? results)
|
||||
[:td "Template"])
|
||||
(if (:error? results)
|
||||
[:td "Sample match"])]
|
||||
#_[:tr "Result"]
|
||||
#_[:tr "Template"]
|
||||
]
|
||||
(for [r (:results results)]
|
||||
[:tr
|
||||
[:td.p-2.border
|
||||
@@ -748,7 +771,19 @@
|
||||
{:class (if (:error? results)
|
||||
"bg-red-50 text-red-700 border-red-300"
|
||||
"bg-primary-50 text-primary-700 border-green-500")}
|
||||
(:response r)]])]]
|
||||
(:response r)]
|
||||
(if (:error? results )
|
||||
[:td.p-2.border
|
||||
{:class "bg-red-50 text-red-700 border-red-300"}
|
||||
"Template: " (:template r)])
|
||||
(if (:error? results )
|
||||
[:td.p-2.border
|
||||
{:class "bg-red-50 text-red-700 border-red-300"}
|
||||
|
||||
[:ul
|
||||
(for [[k v] (dissoc (:sample r) :template :source-url)]
|
||||
[:li (name k) ": " (str v)])]
|
||||
#_(:template r)])])]]
|
||||
:headers
|
||||
{"hx-trigger" "invalidated"})
|
||||
))
|
||||
|
||||
Reference in New Issue
Block a user