This commit is contained in:
BC
2018-07-05 20:36:09 -07:00
parent e5caab4285
commit 6d685ffd3b
7 changed files with 45 additions and 17 deletions

View File

@@ -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

View File

@@ -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

View File

@@ -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))}))

View File

@@ -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))))

View File

@@ -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]}}))))

View File

@@ -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))
{}

View File

@@ -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