added new fields.

This commit is contained in:
2021-02-15 20:46:56 -08:00
parent 6bacf90fbb
commit e2d3acd5c6
7 changed files with 241 additions and 77 deletions

View File

@@ -25,6 +25,9 @@
[:primary-contact [:name :phone :email :id]]
[:secondary-contact [:id :name :phone :email]]
:print-as :invoice-reminder-schedule :code
:legal-entity-first-name :legal-entity-middle-name :legal-entity-last-name
:legal-entity-tin :legal-entity-tin-type
:legal-entity-1099-type
[:address [:street1 :street2 :city :state :zip]]])
(defn client-query [token]

View File

@@ -89,7 +89,7 @@
(re-frame/reg-event-fx
::save
[with-user with-is-admin? (forms/triggers-loading ::vendor-form) (forms/in-form ::vendor-form)]
(fn [{:keys [user is-admin?] {{:keys [name hidden print-as terms invoice-reminder-schedule primary-contact automatically-paid-when-due schedule-payment-dom secondary-contact address default-account terms-overrides account-overrides id] :as data} :data} :db} _]
(fn [{:keys [user is-admin?] {{:keys [name hidden print-as terms invoice-reminder-schedule primary-contact automatically-paid-when-due schedule-payment-dom secondary-contact address default-account terms-overrides account-overrides id legal-entity-tin legal-entity-tin-type legal-entity-first-name legal-entity-last-name legal-entity-middle-name legal-entity-1099-type] :as data} :data} :db} _]
(println data)
(when (s/valid? ::entity/vendor data)
{ :graphql
@@ -97,37 +97,45 @@
:owns-state {:single ::vendor-form}
:query-obj {:venia/operation {:operation/type :mutation
:operation/name "UpsertVendor"} :venia/queries [{:query/data [:upsert-vendor
{:vendor (cond-> {:id id
:name name
:print-as print-as
:terms terms
:default-account-id (:id default-account)
:address address
:primary-contact primary-contact
:secondary-contact secondary-contact
:invoice-reminder-schedule invoice-reminder-schedule}
is-admin? (assoc :hidden hidden
:terms-overrides (mapv
(fn [{:keys [client override id]}]
{:id id
:client-id (:id client)
:terms override})
terms-overrides)
:account-overrides (mapv
(fn [{:keys [client override id]}]
{:id id
:client-id (:id client)
:account-id (:id override)})
account-overrides)
:schedule-payment-dom (mapv
(fn [{:keys [client override id]}]
{:id id
:client-id (:id client)
:dom override})
schedule-payment-dom)
:automatically-paid-when-due (mapv
:id
automatically-paid-when-due)))}
{:vendor (doto (cond-> {:id id
:name name
:print-as print-as
:terms terms
:default-account-id (:id default-account)
:address address
:primary-contact primary-contact
:secondary-contact secondary-contact
:invoice-reminder-schedule invoice-reminder-schedule}
is-admin? (assoc :hidden hidden
:terms-overrides (mapv
(fn [{:keys [client override id]}]
{:id id
:client-id (:id client)
:terms override})
terms-overrides)
:account-overrides (mapv
(fn [{:keys [client override id]}]
{:id id
:client-id (:id client)
:account-id (:id override)})
account-overrides)
:schedule-payment-dom (mapv
(fn [{:keys [client override id]}]
{:id id
:client-id (:id client)
:dom override})
schedule-payment-dom)
:automatically-paid-when-due (mapv
:id
automatically-paid-when-due)
:legal-entity-first-name legal-entity-first-name
:legal-entity-middle-name legal-entity-middle-name
:legal-entity-last-name legal-entity-last-name
:legal-entity-tin legal-entity-tin
:legal-entity-tin-type (some-> legal-entity-tin-type clojure.core/name not-empty keyword)
:legal-entity-1099-type (some-> legal-entity-1099-type clojure.core/name not-empty keyword)
))
println)}
events/vendor-query]}]}
:on-success [::save-complete]}})))
@@ -392,7 +400,74 @@
:spec ::entity/invoice-reminder-schedule
:event change-event
:subscription data}]]
" Never"]]]]))
" Never"]]]
[:h2.subtitle "Legal Entity"]
[horizontal-field
[:label.label "Name"]
[:div.control
[bind-field
[:input.input {:type "text"
:placeholder "First Name"
:field [:legal-entity-first-name]
:spec ::contact/name
:event change-event
:subscription data}]]]
[:div.control
[bind-field
[:input.input {:type "text"
:placeholder "Middle Name"
:field [:legal-entity-middle-name]
:spec ::contact/name
:event change-event
:subscription data}]]]
[:div.control
[bind-field
[:input.input {:type "text"
:placeholder "Last Name"
:field [:legal-entity-last-name]
:spec ::contact/name
:event change-event
:subscription data}]]]]
[horizontal-field
[:label.label "TIN"]
[:div.control
[bind-field
[:input.input {:type "text"
:placeholder "SSN or EIN"
:field [:legal-entity-tin]
:size "12"
:spec ::contact/name
:event change-event
:subscription data}]]]
[:div.control
[:div.select
[bind-field
[:select {:type "select"
:field [:legal-entity-tin-type]
:event change-event
:subscription data}
[:option {:value nil} ""]
[:option {:value "ein"} "EIN"]
[:option {:value "ssn"} "SSN"]]]]]]
[horizontal-field
[:label.label "1099 Type"]
[:div.control
[:div.select
[bind-field
[:select {:type "select"
:field [:legal-entity-1099-type]
:event change-event
:subscription data}
[:option {:value nil} ""]
[:option {:value "none"} "Don't 1099"]
[:option {:value "misc"} "Misc"]
[:option {:value "landlord"} "Landlord"]]]]]]
]))
(defn vendor-dialog [{:keys [save-event] }]
(let [clients @(re-frame/subscribe [::subs/clients])