major switch to support import from excel.
This commit is contained in:
@@ -8,7 +8,8 @@
|
||||
[auto-ap.views.utils :refer [login-url dispatch-value-change bind-field horizontal-field dispatch-event]]
|
||||
[cljs.reader :as edn]
|
||||
[auto-ap.routes :as routes]
|
||||
[bidi.bidi :as bidi]))
|
||||
[bidi.bidi :as bidi]
|
||||
[clojure.string :as str]))
|
||||
|
||||
(re-frame/reg-sub
|
||||
::excel-import
|
||||
@@ -36,7 +37,8 @@
|
||||
:headers {"Content-Type" "application/edn"}
|
||||
:uri (str "/api/invoices/upload-integreat")
|
||||
:on-success [::save-complete]
|
||||
:on-error [::save-error]}})))
|
||||
:on-error [::save-error]}
|
||||
:db (assoc-in db [::excel-import :rows] nil)})))
|
||||
|
||||
(re-frame/reg-event-fx
|
||||
::save-complete
|
||||
@@ -62,18 +64,28 @@
|
||||
:subscription excel-import-data}]]
|
||||
|
||||
[:button.button.is-large.is-pulled-right.is-primary {:on-click (dispatch-event [::save])} "Import"]
|
||||
[:div
|
||||
[:table.table.is-fullwidth
|
||||
[:thead
|
||||
[:td "Date"]
|
||||
[:td "Invoice #"]
|
||||
[:td "Vendor"]
|
||||
[:td "Company"]]
|
||||
[:tbody
|
||||
(for [{:keys [invoice-number date vendor-name company]} (:rows excel-import-data)]
|
||||
[:tr
|
||||
|
||||
[:td date]
|
||||
[:td invoice-number]
|
||||
[:td vendor-name]
|
||||
[:td company]])]]]])])
|
||||
|
||||
[:div.is-clearfix
|
||||
(when-let [imported (:imported (:rows excel-import-data))]
|
||||
(str imported " rows imported."))
|
||||
]
|
||||
(when-let [errors (:errors (:rows excel-import-data))]
|
||||
|
||||
[:div
|
||||
[:h3 (str "Import errors (" (min 100 (count errors)) ")")]
|
||||
[:table.table.is-fullwidth
|
||||
[:thead
|
||||
[:th "Date"]
|
||||
[:th "Invoice #"]
|
||||
[:th "Company"]
|
||||
[:th "Vendor"]
|
||||
[:th "Amount"]
|
||||
[:th "Errors"]]
|
||||
(for [{:keys [raw-date invoice-number company vendor-name amount] row-errors :errors} (take 100 errors)]
|
||||
[:tr
|
||||
[:td raw-date]
|
||||
[:td invoice-number]
|
||||
[:td company]
|
||||
[:td vendor-name]
|
||||
[:td amount]
|
||||
[:td (map #(vector :p (:info %)) row-errors)]])]])])])
|
||||
|
||||
Reference in New Issue
Block a user