From 141e5b06f1eb39f4b7011ec7085f5cf1a5ee43d2 Mon Sep 17 00:00:00 2001 From: Bryce Covert Date: Sun, 17 Nov 2019 12:07:06 -0800 Subject: [PATCH] shows the matching information. --- src/clj/auto_ap/datomic/migrate.clj | 7 +++++++ src/clj/auto_ap/graphql.clj | 1 + src/clj/auto_ap/routes/invoices.clj | 1 + src/cljs/auto_ap/views/components/invoice_table.cljs | 8 +++++--- src/cljs/auto_ap/views/pages/import_invoices.cljs | 5 +++++ 5 files changed, 19 insertions(+), 3 deletions(-) diff --git a/src/clj/auto_ap/datomic/migrate.clj b/src/clj/auto_ap/datomic/migrate.clj index 769c1505..3c3b4101 100644 --- a/src/clj/auto_ap/datomic/migrate.clj +++ b/src/clj/auto_ap/datomic/migrate.clj @@ -46,6 +46,12 @@ :invoice-status/paid :invoice-status/unpaid)]])})}]] ) +(def add-client-identifier + [[{:db/ident :invoice/client-identifier + :db/doc "An identifier found in an uploaded invoice" + :db/valueType :db.type/string + :db/cardinality :db.cardinality/one}]]) + (defn -main [& args] (println "Creating database...") (d/create-database uri) @@ -78,6 +84,7 @@ :auto-ap/add-new-vendors {:txes-fn 'auto-ap.datomic.migrate.add-new-vendors/add-new-vendors :requires [:auto-ap/fix-check-numbers]} :auto-ap/add-account-visibility-fields {:txes-fn 'auto-ap.datomic.migrate.account-sorting/add-account-visibility-fields :requires [:auto-ap/add-new-vendors]} :auto-ap/make-every-account-visible {:txes-fn 'auto-ap.datomic.migrate.account-sorting/make-every-account-visible :requires [:auto-ap/add-account-visibility-fields]} + :auto-ap/add-client-identifier2 {:txes add-client-identifier :requires [:auto-ap/make-every-account-visible]} }] (println "Conforming database...") diff --git a/src/clj/auto_ap/graphql.clj b/src/clj/auto_ap/graphql.clj index 88e62287..2bc56c98 100644 --- a/src/clj/auto_ap/graphql.clj +++ b/src/clj/auto_ap/graphql.clj @@ -174,6 +174,7 @@ :invoice {:fields {:id {:type :id} :original_id {:type 'Int} + :client_identifier {:type 'String} :total {:type 'String} :outstanding_balance {:type 'String} :invoice_number {:type 'String} diff --git a/src/clj/auto_ap/routes/invoices.clj b/src/clj/auto_ap/routes/invoices.clj index 7ec2e141..d5aff19b 100644 --- a/src/clj/auto_ap/routes/invoices.clj +++ b/src/clj/auto_ap/routes/invoices.clj @@ -199,6 +199,7 @@ :else (conj result (remove-nils #:invoice {:invoice/client (:db/id matching-client) + :invoice/client-identifier customer-identifier :invoice/vendor matching-vendor :invoice/invoice-number invoice-number :invoice/total (Double/parseDouble total) diff --git a/src/cljs/auto_ap/views/components/invoice_table.cljs b/src/cljs/auto_ap/views/components/invoice_table.cljs index e7e9515a..99e997f9 100644 --- a/src/cljs/auto_ap/views/components/invoice_table.cljs +++ b/src/cljs/auto_ap/views/components/invoice_table.cljs @@ -47,7 +47,7 @@ {:venia/queries [[:invoice_page (assoc params :client-id (:id @(re-frame/subscribe [::subs/client]))) - [[:invoices [:id :total :outstanding-balance :invoice-number :date :status + [[:invoices [:id :total :outstanding-balance :invoice-number :date :status :client-identifier [:vendor [:name :id]] [:expense_accounts [:amount :id :expense_account_id :location [:expense_account [:id :name :location [:parent [:id :name]]]]]] @@ -58,7 +58,7 @@ :start :end]]]}) -(defn invoice-table [{:keys [id invoice-page status on-params-change vendors params check-boxes checked on-check-changed on-edit-invoice on-void-invoice on-unvoid-invoice expense-event]}] +(defn invoice-table [{:keys [id invoice-page status on-params-change vendors params check-boxes checked on-check-changed on-edit-invoice on-void-invoice on-unvoid-invoice expense-event overrides]}] (let [visible-checks @(re-frame/subscribe [::visible-checks]) visible-expense-accounts @(re-frame/subscribe [::visible-expense-accounts]) selected-client @(re-frame/subscribe [::subs/client]) @@ -158,7 +158,9 @@ (on-check-changed id i)))} ]]) (when-not selected-client - [:td (:name client)]) + [:td (if-let [client-override (:client overrides)] + (client-override i) + (:name client))]) [:td (:name vendor)] [:td invoice-number] [:td (date->str date) ] diff --git a/src/cljs/auto_ap/views/pages/import_invoices.cljs b/src/cljs/auto_ap/views/pages/import_invoices.cljs index 0c889f3c..31db5e41 100644 --- a/src/cljs/auto_ap/views/pages/import_invoices.cljs +++ b/src/cljs/auto_ap/views/pages/import_invoices.cljs @@ -171,6 +171,11 @@ (if (seq (:invoices @invoice-page)) [invoice-table {:id :approved :invoice-page invoice-page + :overrides {:client (fn [row] + [:p (:name (:client row)) + [:p [:i.is-size-7 (:client-identifier row)]]] + + )} :check-boxes true :checked (:checked @invoice-page) :on-check-changed (fn [which invoice]