From 6d685ffd3b8de55e6cfd75debfa73e143dc3e40b Mon Sep 17 00:00:00 2001 From: BC Date: Thu, 5 Jul 2018 20:36:09 -0700 Subject: [PATCH] print as --- src/clj/auto_ap/db/vendors.clj | 5 ++++- src/clj/auto_ap/graphql.clj | 12 ++++++++++ src/clj/auto_ap/routes/checks.clj | 8 ++++--- src/cljc/auto_ap/entities/vendors.cljc | 22 ++++++++++--------- src/cljs/auto_ap/events.cljs | 2 +- src/cljs/auto_ap/events/admin/vendors.cljs | 1 - .../views/components/vendor_dialog.cljs | 12 +++++++++- 7 files changed, 45 insertions(+), 17 deletions(-) diff --git a/src/clj/auto_ap/db/vendors.clj b/src/clj/auto_ap/db/vendors.clj index 8f627c3e..f90208b6 100644 --- a/src/clj/auto_ap/db/vendors.clj +++ b/src/clj/auto_ap/db/vendors.clj @@ -10,9 +10,12 @@ (defn fields->data [x] (-> x (assoc-in [:data :address] (:address x)) - (dissoc :address))) + (assoc-in [:data :print-as] (:print-as x)) + (dissoc :address) + (dissoc :print-as))) (def all-fields [:name + :print-as :code :id :invoice-reminder-schedule diff --git a/src/clj/auto_ap/graphql.clj b/src/clj/auto_ap/graphql.clj index 9e04b030..e8580607 100644 --- a/src/clj/auto_ap/graphql.clj +++ b/src/clj/auto_ap/graphql.clj @@ -47,6 +47,18 @@ :vendor {:fields {:id {:type 'Int} :name {:type 'String} + :code {:type 'String} + + :print_as {:type 'String} + :primary_contact {:type 'String} + :primary_email {:type 'String} + :primary_phone {:type 'String} + + :secondary_contact {:type 'String} + :secondary_email {:type 'String} + :secondary_phone {:type 'String} + + :default_expense_account {:type 'Int} :invoice_reminder_schedule {:type 'String}}} :reminder diff --git a/src/clj/auto_ap/routes/checks.clj b/src/clj/auto_ap/routes/checks.clj index e09a0041..ae762be2 100644 --- a/src/clj/auto_ap/routes/checks.clj +++ b/src/clj/auto_ap/routes/checks.clj @@ -32,7 +32,7 @@ (let [output-stream (ByteArrayOutputStream.)] (pdf/pdf [{:left-margin 10 :right-margin 0 :top-margin 0 :bottom-margin 0 :size :letter} - (let [{:keys [paid-to company check date amount memo] {vendor-name :name :as vendor} :vendor} check + (let [{:keys [paid-to company check date amount memo] {print-as :print-as vendor-name :name :as vendor} :vendor} check df (DecimalFormat. "#,###.00") word-amount (num->words amount) @@ -51,7 +51,9 @@ [[:cell {:size 16 :leading 16} "PAY"] [:cell {:size 6 :leading 6 } "TO THE ORDER OF"] - [:cell {:colspan 7} vendor-name] + [:cell {:colspan 7} (if (seq print-as) + print-as + vendor-name)] [:cell {:colspan 3} amount]] [[:cell {}] @@ -226,7 +228,7 @@ (companies/upsert company-id updated-company) (doseq [{:keys [invoice-id amount]} invoice-payments] (invoices/apply-payment invoice-id amount)) - {:invoices (invoices/get-multi (map :id (doto (mapcat first checks) println))) + {:invoices (invoices/get-multi (map :id (mapcat first checks))) :pdf-url (merge-pdfs (map (comp :s3-key second) checks))})) diff --git a/src/cljc/auto_ap/entities/vendors.cljc b/src/cljc/auto_ap/entities/vendors.cljc index b71851c1..c44a0c66 100644 --- a/src/cljc/auto_ap/entities/vendors.cljc +++ b/src/cljc/auto_ap/entities/vendors.cljc @@ -10,6 +10,7 @@ #(not (str/blank? %)))) (s/def ::name ::required-identifier) +(s/def ::print-as (s/nilable string?)) (s/def ::email (s/nilable (s/and string? (s/or :is-email #(re-matches email-regex %) :is-empty #(= % ""))))) @@ -30,17 +31,18 @@ (s/def ::vendor (s/keys :req-un [::name] :opt-un [::code - ::id - ::invoice-reminder-schedule - ::primary-contact - ::primary-email - ::primary-phone - ::secondary-contact - ::secondary-email - ::secondary-phone - ::address + ::id + ::print-as + ::invoice-reminder-schedule + ::primary-contact + ::primary-email + ::primary-phone + ::secondary-contact + ::secondary-email + ::secondary-phone + ::address ::default-expense-account - ])) + ])) (def vendor-spec (apply hash-map (drop 1 (s/form ::vendor)))) diff --git a/src/cljs/auto_ap/events.cljs b/src/cljs/auto_ap/events.cljs index 55a6c480..111948ee 100644 --- a/src/cljs/auto_ap/events.cljs +++ b/src/cljs/auto_ap/events.cljs @@ -39,7 +39,7 @@ [:id :name :locations [:bank-accounts [:id :number :check-number :name] ]]] [:vendor - [:id :name :default-expense-account]]]} + [:id :name :default-expense-account :primary-contact :primary-email :primary-phone :secondary-contact :secondary-email :secondary-phone :print-as :invoice-reminder-schedule :code]]]} :on-success [::received-initial]}})))) diff --git a/src/cljs/auto_ap/events/admin/vendors.cljs b/src/cljs/auto_ap/events/admin/vendors.cljs index 84341a71..d463741b 100644 --- a/src/cljs/auto_ap/events/admin/vendors.cljs +++ b/src/cljs/auto_ap/events/admin/vendors.cljs @@ -115,7 +115,6 @@ (re-frame/reg-event-db ::received-vendors (fn [db [_ vendors]] - (assoc db :vendors (reduce (fn [vendors vendor] (assoc vendors (:id vendor) vendor)) {} diff --git a/src/cljs/auto_ap/views/components/vendor_dialog.cljs b/src/cljs/auto_ap/views/components/vendor_dialog.cljs index 91f9cc29..e4a5081e 100644 --- a/src/cljs/auto_ap/views/components/vendor_dialog.cljs +++ b/src/cljs/auto_ap/views/components/vendor_dialog.cljs @@ -33,8 +33,18 @@ :spec ::entity/name :event change-event :subscription vendor}]]]] - + [horizontal-field + [:label.label "Print Checks As"] + [:div.control + [bind-field + [:input.input {:type "text" + :field :print-as + :spec ::entity/print-as + :event change-event + :subscription vendor}]]]] + + #_[horizontal-field [:label.label "Code"] [:div.control