duplicates.
This commit is contained in:
@@ -49,11 +49,18 @@
|
|||||||
:headers {"Content-Type" "application/edn"}})
|
:headers {"Content-Type" "application/edn"}})
|
||||||
(POST "/pdf-upload"
|
(POST "/pdf-upload"
|
||||||
{{ files "file"} :params :as params}
|
{{ files "file"} :params :as params}
|
||||||
(let [{:keys [filename tempfile]} files]
|
(let [{:keys [filename tempfile]} files
|
||||||
|
existing-invoices (invoices/get-all)]
|
||||||
|
(println existing-invoices)
|
||||||
(invoices/insert-multi!
|
(invoices/insert-multi!
|
||||||
(for [{:keys [total date invoice-number customer-identifier] :as row}
|
(for [{:keys [total date invoice-number customer-identifier vendor] :as row}
|
||||||
(parse/parse-file (.getPath tempfile))]
|
(parse/parse-file (.getPath tempfile))]
|
||||||
(assoc row :imported false)))
|
(assoc row
|
||||||
|
:imported false
|
||||||
|
:potential-duplicate (boolean (seq (filter #(and (= vendor (:vendor %))
|
||||||
|
(= invoice-number (:invoice-number %)))
|
||||||
|
existing-invoices)))
|
||||||
|
)))
|
||||||
{:status 200
|
{:status 200
|
||||||
:body (pr-str (invoices/get-pending))
|
:body (pr-str (invoices/get-pending))
|
||||||
:headers {"Content-Type" "application/edn"}}))
|
:headers {"Content-Type" "application/edn"}}))
|
||||||
|
|||||||
@@ -112,15 +112,18 @@
|
|||||||
[:th "Customer"]
|
[:th "Customer"]
|
||||||
[:th "Invoice #"]
|
[:th "Invoice #"]
|
||||||
[:th "Date"]
|
[:th "Date"]
|
||||||
[:th "Amount"]]]
|
[:th "Amount"]
|
||||||
[:tbody (for [{:keys [vendor customer-identifier invoice-number date total id] :as i} @invoices]
|
[:th]]]
|
||||||
|
[:tbody (for [{:keys [vendor potential-duplicate customer-identifier invoice-number date total id] :as i} @invoices]
|
||||||
^{:key (str customer-identifier "-" invoice-number "-" date "-" total "-" id)}
|
^{:key (str customer-identifier "-" invoice-number "-" date "-" total "-" id)}
|
||||||
[:tr
|
[:tr
|
||||||
[:td vendor]
|
[:td vendor]
|
||||||
[:td customer-identifier]
|
[:td customer-identifier]
|
||||||
[:td invoice-number]
|
[:td invoice-number]
|
||||||
[:td date]
|
[:td date]
|
||||||
[:td total]])]]
|
[:td total]
|
||||||
|
[:td (when potential-duplicate
|
||||||
|
[:i.icon.fa.fa-warning {:title "potential duplicate"}])]])]]
|
||||||
[:span "No pending invoices"]))]
|
[:span "No pending invoices"]))]
|
||||||
(if (and (seq @invoices) (not (:loading @status)))
|
(if (and (seq @invoices) (not (:loading @status)))
|
||||||
[:div.card-footer
|
[:div.card-footer
|
||||||
@@ -279,4 +282,3 @@
|
|||||||
[:a {:class "icon", :href "https://github.com/dansup/bulma-templates"}
|
[:a {:class "icon", :href "https://github.com/dansup/bulma-templates"}
|
||||||
[:i {:class "fa fa-github"}]]]]]]
|
[:i {:class "fa fa-github"}]]]]]]
|
||||||
[:div#dz-hidden]]))
|
[:div#dz-hidden]]))
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user