From 53905c317b764a3098cd562b5b8a2676dd6763a1 Mon Sep 17 00:00:00 2001 From: Bryce Covert Date: Tue, 10 Apr 2018 10:51:21 -0700 Subject: [PATCH] not using namespaced keys, due to graphql --- config/dev.edn | 8 ++- src/clj/auto_ap/db/companies.clj | 16 +---- src/clj/auto_ap/db/invoices.clj | 12 ++-- src/clj/auto_ap/db/reminders.clj | 1 + src/clj/auto_ap/db/utils.clj | 36 +++++------ src/clj/auto_ap/db/vendors.clj | 5 +- src/clj/auto_ap/handler.clj | 1 + src/clj/auto_ap/parse.clj | 3 +- src/cljc/auto_ap/entities/companies.cljc | 8 +-- src/cljc/auto_ap/entities/vendors.cljc | 6 +- src/cljs/auto_ap/events.cljs | 13 ++-- src/cljs/auto_ap/events/admin/companies.cljs | 4 +- src/cljs/auto_ap/events/admin/vendors.cljs | 8 +-- .../auto_ap/views/pages/admin/companies.cljs | 11 ++-- .../auto_ap/views/pages/admin/vendors.cljs | 61 ++++++++++++------- .../auto_ap/views/pages/import_invoices.cljs | 6 +- .../auto_ap/views/pages/paid_invoices.cljs | 8 +-- .../auto_ap/views/pages/unpaid_invoices.cljs | 4 +- src/cljs/auto_ap/views/utils.cljs | 12 ++-- 19 files changed, 114 insertions(+), 109 deletions(-) diff --git a/config/dev.edn b/config/dev.edn index 5c5eb7f1..b0d91d64 100644 --- a/config/dev.edn +++ b/config/dev.edn @@ -1,3 +1,9 @@ {:db {:server "localhost"} :scheme "http" - :jwt-secret "auto ap invoices are awesome"} + :jwt-secret "auto ap invoices are awesome" + :aws-access-key-id "AKIAJIS67OSJARD2E6VQ" + :aws-secret-access-key "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" + :aws-region "us-east-1" + :invoice-import-queue-url "https://sqs.us-east-1.amazonaws.com/679918342773/integreat-mail-staging" + :invoice-email "invoices-staging@mail.app.integreatconsult.com" + } diff --git a/src/clj/auto_ap/db/companies.clj b/src/clj/auto_ap/db/companies.clj index 012b59de..bb55995a 100644 --- a/src/clj/auto_ap/db/companies.clj +++ b/src/clj/auto_ap/db/companies.clj @@ -1,26 +1,16 @@ (ns auto-ap.db.companies - (:require [auto-ap.db.utils :refer [assign-namespace clj->db db->clj - get-conn]] + (:require [auto-ap.db.utils :refer [clj->db db->clj get-conn]] [auto-ap.entities.companies :as entity] [clojure.edn :as edn] [clojure.java.jdbc :as j])) -(defn merge-data [{:keys [::entity/data] :as x}] - (merge x (edn/read-string data))) - (defn parse [x] - (-> x - (db->clj) - - (assign-namespace "auto-ap.entities.companies") - merge-data - )) + (db->clj x)) (defn get-all [] (->> (j/query (get-conn) "SELECT * FROM companies") - (map parse) - )) + (map parse))) (defn upsert [id data] (j/update! (get-conn) :companies (clj->db data) ["id = ?" (Integer/parseInt id)] ) diff --git a/src/clj/auto_ap/db/invoices.clj b/src/clj/auto_ap/db/invoices.clj index 1ea42107..18cc3d0f 100644 --- a/src/clj/auto_ap/db/invoices.clj +++ b/src/clj/auto_ap/db/invoices.clj @@ -5,8 +5,7 @@ [auto-ap.db.vendors :as vendors] [auto-ap.entities.companies :as company] [auto-ap.entities.vendors :as vendor] - [clojure.java.jdbc :as j] - [aggregate.core :as agg])) + [clojure.java.jdbc :as j])) (defn insert-multi! [rows] (j/insert-multi! (get-conn) @@ -15,13 +14,14 @@ (defn with-relations [results] (let [companies (reduce - #(assoc %1 (::company/id %2) %2) + #(assoc %1 (:id %2) %2) {} (companies/get-all)) vendors (reduce - #(assoc %1 (::vendor/id %2) %2) + #(assoc %1 (:id %2) %2) {} (vendors/get-all))] + (println companies vendors) (->> results (map #(assoc % :vendor (vendors (:vendor-id %)))) (map #(assoc % :company (companies (:company-id %))))))) @@ -56,8 +56,8 @@ (for [{:keys [total date invoice-number customer-identifier vendor-code] :as row} parsed-invoices] (do (dissoc (assoc row - :company-id (::company/id (parse/best-match companies customer-identifier)) - :vendor-id (::vendor/id (first (filter #(= (::vendor/code %) vendor-code) vendors))) + :company-id (:id (parse/best-match companies customer-identifier)) + :vendor-id (:id (first (filter #(= (:code %) vendor-code) vendors))) :imported false :potential-duplicate false) :vendor-code))))) diff --git a/src/clj/auto_ap/db/reminders.clj b/src/clj/auto_ap/db/reminders.clj index fa4262a4..1b0236c6 100644 --- a/src/clj/auto_ap/db/reminders.clj +++ b/src/clj/auto_ap/db/reminders.clj @@ -2,6 +2,7 @@ (:require [auto-ap.db.utils :refer [clj->db db->clj get-conn]] [clj-time.core :as time] [clojure.java.jdbc :as j] + [clj-time.jdbc :as jdbc] [clojure.string :as str])) (defn insert [row] diff --git a/src/clj/auto_ap/db/utils.clj b/src/clj/auto_ap/db/utils.clj index 547b3b52..7e20587c 100644 --- a/src/clj/auto_ap/db/utils.clj +++ b/src/clj/auto_ap/db/utils.clj @@ -16,18 +16,23 @@ (fn [[k v]] [(keyword (snake->kebab (name k))) v]) x)) - merged (merge kebabed (edn/read-string (:data kebabed)))] - merged)) - ([x namespace] - (let [x (db->clj x)] - (assign-namespace x namespace)))) + merged (if (:data kebabed) + (update kebabed :data edn/read-string) + kebabed)] + merged))) (defn clj->db [x] - (into {} - (map - (fn [[k v]] - [(keyword (kebab->snake (name k))) v]) - x))) + (let [snaked (into {} + (map + (fn [[k v]] + [(keyword (kebab->snake (name k))) v]) + x)) + unmerged (if (:data snaked) + (update snaked :data pr-str) + snaked)] + unmerged)) + + (defn merge-data [{:keys [data] :as x}] (merge x (edn/read-string data))) @@ -44,14 +49,3 @@ :user "ap" :password "fifteen-invoices-imported!"})) - -(defn assign-namespace [x n] - (reduce-kv - (fn [x k v] - (assoc x (if (and (keyword? k) - (not (qualified-keyword? k))) - (keyword n (name k)) - k) - v)) - {} - x)) diff --git a/src/clj/auto_ap/db/vendors.clj b/src/clj/auto_ap/db/vendors.clj index 8d618be2..242e8e76 100644 --- a/src/clj/auto_ap/db/vendors.clj +++ b/src/clj/auto_ap/db/vendors.clj @@ -1,13 +1,12 @@ (ns auto-ap.db.vendors - (:require [auto-ap.db.utils :refer [assign-namespace clj->db db->clj - get-conn]] + (:require [auto-ap.db.utils :refer [clj->db db->clj get-conn]] [auto-ap.entities.vendors :as entities] [clojure.edn :as edn] [clojure.java.jdbc :as j])) (defn parse [x] - (db->clj x "auto-ap.entities.vendors")) + (db->clj x)) (defn unparse [x] (-> x diff --git a/src/clj/auto_ap/handler.clj b/src/clj/auto_ap/handler.clj index 455f1c00..05471175 100644 --- a/src/clj/auto_ap/handler.clj +++ b/src/clj/auto_ap/handler.clj @@ -16,6 +16,7 @@ [ring.middleware.params :refer [wrap-params]] [ring.middleware.reload :refer [wrap-reload]] [ring.util.response :as response])) +(println env) (defcredential (:aws-access-key-id env) (:aws-secret-access-key env) (:aws-region env)) diff --git a/src/clj/auto_ap/parse.clj b/src/clj/auto_ap/parse.clj index 59e0e679..a2f12562 100644 --- a/src/clj/auto_ap/parse.clj +++ b/src/clj/auto_ap/parse.clj @@ -52,10 +52,9 @@ (excel/parse-file file filename)) (defn best-match [companies company-identifier] - (println companies) (->> companies (map (fn [company] - [company (apply min (map #(m/jaccard (.toLowerCase company-identifier) %) (:matches company)))])) + [company (apply min (map #(m/jaccard (.toLowerCase company-identifier) %) (:matches (:data company))))])) (filter #(< (second %) 0.25)) (sort-by second) diff --git a/src/cljc/auto_ap/entities/companies.cljc b/src/cljc/auto_ap/entities/companies.cljc index f616ff01..32db6041 100644 --- a/src/cljc/auto_ap/entities/companies.cljc +++ b/src/cljc/auto_ap/entities/companies.cljc @@ -13,10 +13,10 @@ (s/def ::email (s/nilable (s/and string? (s/or :is-email #(re-matches email-regex %) :is-empty #(= % ""))))) -(s/def ::company (s/keys :req [::name] - :opt [::email - ::id])) +(s/def ::company (s/keys :req-un [::name] + :opt-un [::email + ::id])) (def company-spec (apply hash-map (drop 1 (s/form ::company)))) -(def all-keys (concat (:req company-spec) (:opt company-spec))) +(def all-keys (map #(keyword (name %)) (concat (:req-un company-spec) (:opt-un company-spec)))) diff --git a/src/cljc/auto_ap/entities/vendors.cljc b/src/cljc/auto_ap/entities/vendors.cljc index d7e92654..6da2caa2 100644 --- a/src/cljc/auto_ap/entities/vendors.cljc +++ b/src/cljc/auto_ap/entities/vendors.cljc @@ -31,8 +31,8 @@ (s/def ::state (s/nilable string?)) (s/def ::zip (s/nilable string?)) -(s/def ::vendor (s/keys :req [::name] - :opt [::code +(s/def ::vendor (s/keys :req-un [::name] + :opt-un [::code ::id ::invoice-reminder-schedule ::primary-contact @@ -49,4 +49,4 @@ (def vendor-spec (apply hash-map (drop 1 (s/form ::vendor)))) -(def all-keys (concat (:req vendor-spec) (:opt vendor-spec))) +(def all-keys (map #(keyword (name %)) (concat (:req-un vendor-spec) (:opt-un vendor-spec)))) diff --git a/src/cljs/auto_ap/events.cljs b/src/cljs/auto_ap/events.cljs index 4d4c5ac4..24d5e587 100644 --- a/src/cljs/auto_ap/events.cljs +++ b/src/cljs/auto_ap/events.cljs @@ -4,7 +4,6 @@ [auto-ap.subs :as subs] [auto-ap.routes :as routes] [auto-ap.effects :as effects] - [auto-ap.entities.companies :as companies] [bidi.bidi :as bidi])) (re-frame/reg-event-fx @@ -43,14 +42,14 @@ (fn [db [_ companies]] (assoc db :companies (reduce (fn [companies company] - (assoc companies (::companies/id company) company)) + (assoc companies (:id company) company)) {} companies)))) (re-frame/reg-event-db ::swap-company (fn [db [_ company]] - (assoc db :company (::companies/id company)))) + (assoc db :company (:id company)))) (re-frame/reg-event-fx ::set-active-page @@ -71,7 +70,7 @@ {:http {:method :post :token (-> cofx :db :user) :uri (str "/api/invoices/approve" - (when-let [company-id (::companies/id @(re-frame/subscribe [::subs/company]))] + (when-let [company-id (:id @(re-frame/subscribe [::subs/company]))] (str "?company=" company-id))) :on-success [::received-invoices :pending] }})) @@ -83,7 +82,7 @@ :http {:method :get :token (-> cofx :db :user) :uri (str "/api/invoices/pending" - (when-let [company-id (::companies/id @(re-frame/subscribe [::subs/company]))] + (when-let [company-id (:id @(re-frame/subscribe [::subs/company]))] (str "?company=" company-id))) :on-success [::received-invoices :pending]}})) @@ -94,7 +93,7 @@ :http {:method :get :token (-> cofx :db :user) :uri (str "/api/invoices/unpaid" - (when-let [company-id (::companies/id @(re-frame/subscribe [::subs/company]))] + (when-let [company-id (:id @(re-frame/subscribe [::subs/company]))] (str "?company=" company-id))) :on-success [::received-invoices :unpaid]}})) @@ -104,7 +103,7 @@ {:http {:method :post :token (-> cofx :db :user) :uri (str "/api/invoices/reject" - (when-let [company-id (::companies/id @(re-frame/subscribe [::subs/company]))] + (when-let [company-id (:id @(re-frame/subscribe [::subs/company]))] (str "?company=" company-id))) :on-success [::received-invoices :pending] }})) diff --git a/src/cljs/auto_ap/events/admin/companies.cljs b/src/cljs/auto_ap/events/admin/companies.cljs index 07751454..a094b2da 100644 --- a/src/cljs/auto_ap/events/admin/companies.cljs +++ b/src/cljs/auto_ap/events/admin/companies.cljs @@ -21,7 +21,7 @@ :token (:user db) :body (pr-str edited-company) :headers {"Content-Type" "application/edn"} - :uri (str "/api/companies/" (::entity/id edited-company)) + :uri (str "/api/companies/" (:id edited-company)) :on-success [::save-complete] :on-error [::save-error]}}))) @@ -31,7 +31,7 @@ (-> db (assoc-in [:admin :company] nil) - (assoc-in [:companies (::entity/id company)] company)))) + (assoc-in [:companies (:id company)] company)))) (re-frame/reg-event-db ::save-error diff --git a/src/cljs/auto_ap/events/admin/vendors.cljs b/src/cljs/auto_ap/events/admin/vendors.cljs index 29b01a81..8d7e4f8d 100644 --- a/src/cljs/auto_ap/events/admin/vendors.cljs +++ b/src/cljs/auto_ap/events/admin/vendors.cljs @@ -26,12 +26,12 @@ (let [edited-vendor (get-in db [:admin :vendor]) fx {:db (assoc-in db [:admin :vendor :saving?] true)}] (when (s/valid? ::entity/vendor edited-vendor) - (if (::entity/id edited-vendor) + (if (:id edited-vendor) (assoc fx :http {:method :put :token (:user db) :body (pr-str edited-vendor) :headers {"Content-Type" "application/edn"} - :uri (str "/api/vendors/" (::entity/id edited-vendor)) + :uri (str "/api/vendors/" (:id edited-vendor)) :on-success [::save-complete] :on-error [::save-error]}) (assoc fx :http {:method :post @@ -48,7 +48,7 @@ (-> db (assoc-in [:admin :vendor] nil) - (assoc-in [:vendors (::entity/id vendor)] vendor)))) + (assoc-in [:vendors (:id vendor)] vendor)))) (re-frame/reg-event-db ::save-error @@ -76,6 +76,6 @@ (fn [db [_ vendors]] (assoc db :vendors (reduce (fn [vendors vendor] - (assoc vendors (::entity/id vendor) vendor)) + (assoc vendors (:id vendor) vendor)) {} vendors)))) diff --git a/src/cljs/auto_ap/views/pages/admin/companies.cljs b/src/cljs/auto_ap/views/pages/admin/companies.cljs index f66219d6..87369a10 100644 --- a/src/cljs/auto_ap/views/pages/admin/companies.cljs +++ b/src/cljs/auto_ap/views/pages/admin/companies.cljs @@ -17,13 +17,12 @@ [:tr [:th "Name"] [:th "Email"]]] - [:tbody (for [{:keys [::entity/id ::entity/name ::entity/email] :as c} @companies] + [:tbody (for [{:keys [id name email] :as c} @companies] ^{:key (str name "-" id )} [:tr {:on-click (fn [] (re-frame/dispatch [::events/edit id])) :style {"cursor" "pointer"}} [:td name] - [:td email] - ])]])) + [:td email]])]])) (defn admin-companies-page [] [:div {:class "inbox-messages"} @@ -55,7 +54,8 @@ [:div.control [bind-field [:input.input {:type "text" - :field ::entity/name + :field :name + :spec ::entity/name :event ::events/change :subscription editing-company}]]]] @@ -64,7 +64,8 @@ [:div.control [bind-field [:input.input {:type "email" - :field ::entity/email + :field :email + :spec ::entity/name :event ::events/change :subscription editing-company}]]]] diff --git a/src/cljs/auto_ap/views/pages/admin/vendors.cljs b/src/cljs/auto_ap/views/pages/admin/vendors.cljs index f9d153ed..33ee4bf3 100644 --- a/src/cljs/auto_ap/views/pages/admin/vendors.cljs +++ b/src/cljs/auto_ap/views/pages/admin/vendors.cljs @@ -26,12 +26,12 @@ [:th "Email"] [:th "Invoice Reminders"]]] [:tbody (for [v @vendors] - ^{:key (str (::entity/id v))} - [:tr {:on-click (fn [] (re-frame/dispatch [::events/edit (::entity/id v)])) + ^{:key (str (:id v))} + [:tr {:on-click (fn [] (re-frame/dispatch [::events/edit (:id v)])) :style {"cursor" "pointer"}} - [:td (::entity/name v)] - [:td (::entity/primary-email v)] - [:td (::entity/invoice-reminder-schedule v)]])]])) + [:td (:name v)] + [:td (:primary-email v)] + [:td (:invoice-reminder-schedule v)]])]])) (defn danger-for [[dom {:keys [field subscription class] :as keys} & rest]] (let [keys (assoc keys :class (str class @@ -50,9 +50,9 @@ [:div.modal-card [:header.modal-card-head [:p.modal-card-title - (if (::entity/id editing-vendor) - (str "Edit " (or (::entity/name editing-vendor) "")) - (str "Add " (or (::entity/name editing-vendor) "")))] + (if (:id editing-vendor) + (str "Edit " (or (:name editing-vendor) "")) + (str "Add " (or (:name editing-vendor) "")))] (when (:error editing-vendor) [:span.icon.has-text-danger [:i.fa.fa-exclamation-triangle]]) @@ -63,7 +63,8 @@ [:div.control [bind-field [:input.input {:type "text" - :field ::entity/name + :field :name + :spec ::entity/name :event ::events/change :subscription editing-vendor}]]]] @@ -73,7 +74,8 @@ [bind-field [:input.input.is-expanded {:type "text" - :field ::entity/code + :field :code + :spec ::entity/code :event ::events/change :subscription editing-vendor}]] [:p.help "The vendor code is used for invoice parsing. Only one vendor at a time can use a code"]]] @@ -86,7 +88,8 @@ [bind-field [:input.input.is-expanded {:type "text" :placeholder "1700 Pennsylvania Ave" - :field ::entity/address1 + :field :address1 + :spec ::entity/address1 :event ::events/change :subscription editing-vendor}]]]] @@ -96,7 +99,8 @@ [bind-field [:input.input.is-expanded {:type "text" :placeholder "Suite 400" - :field ::entity/address2 + :field :address2 + :spec ::entity/address2 :event ::events/change :subscription editing-vendor}]]]] @@ -107,7 +111,8 @@ [bind-field [:input.input.is-expanded {:type "text" :placeholder "Cupertino" - :field ::entity/city + :field :city + :spec ::entity/city :event ::events/change :subscription editing-vendor}]]] [:div.control @@ -115,14 +120,16 @@ [bind-field [:input.input {:type "text" :placeholder "CA" - :field ::entity/state + :field :state + :spec ::entity/state :event ::events/change :subscription editing-vendor}]]] [:div.control [:p.help "Zip"] [bind-field [:input.input {:type "text" - :field ::entity/zip + :field :zip + :spec ::entity/zip :event ::events/change :subscription editing-vendor :placeholder "95014"}]]]] @@ -133,7 +140,8 @@ [:div.control.has-icons-left [bind-field [:input.input.is-expanded {:type "text" - :field ::entity/primary-contact + :field :primary-contact + :spec ::entity/primary-contact :event ::events/change :subscription editing-vendor}]] [:span.icon.is-small.is-left @@ -144,14 +152,16 @@ [:i.fa.fa-envelope]] [bind-field [:input.input {:type "email" - :field ::entity/primary-email + :field :primary-email + :spec ::entity/primary-email :event ::events/change :subscription editing-vendor}]]] [:div.control.has-icons-left [bind-field [:input.input {:type "phone" - :field ::entity/primary-phone + :field :primary-phone + :spec ::entity/primary-phone :event ::events/change :subscription editing-vendor}]] [:span.icon.is-small.is-left @@ -162,7 +172,8 @@ [:div.control.has-icons-left [bind-field [:input.input.is-expanded {:type "text" - :field ::entity/secondary-contact + :field :secondary-contact + :spec ::entity/secondary-contact :event ::events/change :subscription editing-vendor}]] [:span.icon.is-small.is-left @@ -172,13 +183,15 @@ [:i.fa.fa-envelope]] [bind-field [:input.input {:type "email" - :field ::entity/secondary-email + :field :secondary-email + :spec ::entity/secondary-email :event ::events/change :subscription editing-vendor}]]] [:div.control.has-icons-left [bind-field [:input.input {:type "phone" - :field ::entity/secondary-phone + :field :secondary-phone + :spec ::entity/secondary-phone :event ::events/change :subscription editing-vendor}]] [:span.icon.is-small.is-left @@ -192,7 +205,8 @@ [:input {:type "radio" :name "schedule" :value "Weekly" - :field ::entity/invoice-reminder-schedule + :field :invoice-reminder-schedule + :spec ::entity/invoice-reminder-schedule :event ::events/change :subscription editing-vendor}]] " Send weekly"] @@ -202,7 +216,8 @@ [:input {:type "radio" :name "schedule" :value "Never" - :field ::entity/invoice-reminder-schedule + :field :invoice-reminder-schedule + :spec ::entity/invoice-reminder-schedule :event ::events/change :subscription editing-vendor}]] " Never"]]] diff --git a/src/cljs/auto_ap/views/pages/import_invoices.cljs b/src/cljs/auto_ap/views/pages/import_invoices.cljs index c9e6ceaf..830d75ac 100644 --- a/src/cljs/auto_ap/views/pages/import_invoices.cljs +++ b/src/cljs/auto_ap/views/pages/import_invoices.cljs @@ -27,7 +27,7 @@ :paramName "file" :headers {"Authorization" (str "Token " @token)} :url (str "/api/invoices/upload" - (when-let [company-name (-> @company ::company/id)] + (when-let [company-name (-> @company :id)] (str "?company=" company-name))) :previewsContainer "#dz-hidden" :previewTemplate "
"})))}))) @@ -61,9 +61,9 @@ [:tbody (for [{:keys [vendor vendor-id potential-duplicate company-id customer-identifier invoice-number date total id] :as i} @invoices] ^{:key (str company-id "-" invoice-number "-" date "-" total "-" id)} [:tr - [:td (::vendor/name (:vendor i))] + [:td (:name (:vendor i))] (if company-id - [:td (::company/name (:company i))] + [:td (:name (:company i))] [:td [:i.icon.fa.fa-warning {:title "potential duplicate"}] (str "'" customer-identifier "' doesn't match any known company")]) [:td invoice-number] diff --git a/src/cljs/auto_ap/views/pages/paid_invoices.cljs b/src/cljs/auto_ap/views/pages/paid_invoices.cljs index c07711bd..78808b1b 100644 --- a/src/cljs/auto_ap/views/pages/paid_invoices.cljs +++ b/src/cljs/auto_ap/views/pages/paid_invoices.cljs @@ -23,11 +23,11 @@ [:th "Invoice #"] [:th "Date"] [:th "Amount"]]] - [:tbody (for [{:keys [company invoice-number date total id vendor-id] :as i} @invoices] - ^{:key (str company "-" invoice-number "-" date "-" total "-" id)} + [:tbody (for [{:keys [company vendor invoice-number date total id] :as i} @invoices] + ^{:key (str (:id company) "-" invoice-number "-" date "-" total "-" id)} [:tr - [:td vendor-id] - [:td company] + [:td (:name vendor)] + [:td (:name company)] [:td invoice-number] [:td date] [:td total]])]])])) diff --git a/src/cljs/auto_ap/views/pages/unpaid_invoices.cljs b/src/cljs/auto_ap/views/pages/unpaid_invoices.cljs index b364e105..195b58cd 100644 --- a/src/cljs/auto_ap/views/pages/unpaid_invoices.cljs +++ b/src/cljs/auto_ap/views/pages/unpaid_invoices.cljs @@ -29,8 +29,8 @@ [:tbody (for [{:keys [company invoice-number date total id vendor] :as i} @invoices] ^{:key (str company "-" invoice-number "-" date "-" total "-" id)} [:tr - [:td (::vendor/name vendor)] - [:td (::company/name company)] + [:td (:name vendor)] + [:td (:name company)] [:td invoice-number] [:td date] [:td total]])]])])) diff --git a/src/cljs/auto_ap/views/utils.cljs b/src/cljs/auto_ap/views/utils.cljs index 1937aa9f..0e4df3cb 100644 --- a/src/cljs/auto_ap/views/utils.cljs +++ b/src/cljs/auto_ap/views/utils.cljs @@ -36,25 +36,25 @@ type)) -(defmethod do-bind "radio" [dom {:keys [field subscription event class value] :as keys} & rest] +(defmethod do-bind "radio" [dom {:keys [field subscription event class value spec] :as keys} & rest] (let [keys (assoc keys :on-change (dispatch-value-change [event [field]]) :checked (= (field subscription) value) :class (str class - (when (not (s/valid? field (field subscription))) + (when (and spec (not (s/valid? spec (field subscription)))) " is-danger"))) - keys (dissoc keys :field :subscription :event)] + keys (dissoc keys :field :subscription :event :spec)] (vec (concat [dom keys] rest)))) -(defmethod do-bind :default [dom {:keys [field event subscription class] :as keys} & rest] +(defmethod do-bind :default [dom {:keys [field event subscription class spec] :as keys} & rest] (let [keys (assoc keys :on-change (dispatch-value-change [event [field]]) :value (field subscription) :class (str class - (when (not (s/valid? field (field subscription))) + (when (and spec (not (s/valid? spec (field subscription)))) " is-danger"))) - keys (dissoc keys :field :subscription :event)] + keys (dissoc keys :field :subscription :event :spec)] (vec (concat [dom keys] rest)))) (defn bind-field [all]