Adds support for more than one email address.

This commit is contained in:
2022-03-24 15:45:49 -07:00
parent 5d17091847
commit 1e7f8f9b0a
9 changed files with 58 additions and 16 deletions

View File

@@ -29,7 +29,8 @@
:bank-account/intuit-bank-account [:intuit-bank-account/name :intuit-bank-account/external-id :db/id]} :bank-account/intuit-bank-account [:intuit-bank-account/name :intuit-bank-account/external-id :db/id]}
]} ]}
{:yodlee-provider-account/_client [*]} {:yodlee-provider-account/_client [*]}
{:plaid-item/_client [*]}]) {:plaid-item/_client [*]}
{:client/emails [:db/id :email-contact/email :email-contact/description]}])
:where [?e :client/name]] :where [?e :client/name]]
(d/db (d/connect uri))) (d/db (d/connect uri)))
(map first) (map first)
@@ -42,7 +43,8 @@
'[* {:client/bank-accounts [* {:bank-account/type [*] '[* {:client/bank-accounts [* {:bank-account/type [*]
:bank-account/yodlee-account [:yodlee-account/name :yodlee-account/id :yodlee-account/number] :bank-account/yodlee-account [:yodlee-account/name :yodlee-account/id :yodlee-account/number]
:bank-account/intuit-bank-account [:intuit-bank-account/name :intuit-bank-account/external-id :db/id] :bank-account/intuit-bank-account [:intuit-bank-account/name :intuit-bank-account/external-id :db/id]
:bank-account/plaid-account [:plaid-account/name :db/id :plaid-account/number :plaid-account/balance]}]} :bank-account/plaid-account [:plaid-account/name :db/id :plaid-account/number :plaid-account/balance]}]
:client/emails [:db/id :email-contact/email :email-contact/description]}
{:yodlee-provider-account/_client [*]} {:yodlee-provider-account/_client [*]}
{:plaid-item/_client [*]}] {:plaid-item/_client [*]}]
id) id)

View File

@@ -58,4 +58,18 @@
{:txes [[{:db/ident :client/locked-until {:txes [[{:db/ident :client/locked-until
:db/doc "No new data before this date can be added/changed" :db/doc "No new data before this date can be added/changed"
:db/valueType :db.type/instant :db/valueType :db.type/instant
:db/cardinality :db.cardinality/one}]]}}) :db/cardinality :db.cardinality/one}]]}
::add-email-contacts
{:txes [[{:db/ident :email-contact/email
:db/doc "Email contact's email"
:db/valueType :db.type/string
:db/cardinality :db.cardinality/one}
{:db/ident :email-contact/description
:db/doc "Manager, Owner, etc"
:db/valueType :db.type/string
:db/cardinality :db.cardinality/one}
{:db/ident :client/emails
:db/doc "collection of email contacts"
:db/valueType :db.type/ref
:db/cardinality :db.cardinality/many}]]}
})

View File

@@ -258,7 +258,7 @@
:check (str (+ index (:bank-account/check-number bank-account))) :check (str (+ index (:bank-account/check-number bank-account)))
:memo memo :memo memo
:date (date->str (local-now)) :date (date->str (local-now))
:client (dissoc client :client/bank-accounts :client/locked-until) :client (dissoc client :client/bank-accounts :client/locked-until :client/emails)
:bank-account (dissoc bank-account :bank-account/start-date) :bank-account (dissoc bank-account :bank-account/start-date)
#_#_:client {:name (:name client) #_#_:client {:name (:name client)
:address (:address client) :address (:address client)

View File

@@ -136,6 +136,12 @@
(:bank_accounts edit_client)) (:bank_accounts edit_client))
}) })
[:reset id :client/emails (map #(remove-nils
{:db/id (or (:id %)
(str (UUID/randomUUID)))
:email-contact/email (:email %)
:email-contact/description (:description %)})
(:emails edit_client))]
[:reset id :client/forecasted-transactions (map #(remove-nils [:reset id :client/forecasted-transactions (map #(remove-nils
{:db/id (:id %) {:db/id (:id %)
:forecasted-transaction/day-of-month (:day_of_month %) :forecasted-transaction/day-of-month (:day_of_month %)
@@ -267,6 +273,10 @@
:match {:type 'String} :match {:type 'String}
:id {:type :id}}} :id {:type :id}}}
:email_contact {:fields {:id {:type :id}
:email {:type 'String}
:description {:type 'String}}}
:client :client
{:fields {:id {:type :id} {:fields {:id {:type :id}
:name {:type 'String} :name {:type 'String}
@@ -278,6 +288,7 @@
:week_b_debits {:type :money} :week_b_debits {:type :money}
:week_b_credits {:type :money} :week_b_credits {:type :money}
:email {:type 'String} :email {:type 'String}
:emails {:type '(list :email_contact)}
:address {:type :address} :address {:type :address}
:location_matches {:type '(list :location_match)} :location_matches {:type '(list :location_match)}
:locations {:type '(list String)} :locations {:type '(list String)}
@@ -335,12 +346,16 @@
:id {:type :id} :id {:type :id}
:day_of_month {:type 'Int} :day_of_month {:type 'Int}
:amount {:type :money}}} :amount {:type :money}}}
:edit_email_contact {:fields {:id {:type :id}
:email {:type 'String}
:description {:type 'String}}}
:edit_client {:fields {:id {:type :id} :edit_client {:fields {:id {:type :id}
:name {:type 'String} :name {:type 'String}
:locked_until {:type :iso_date} :locked_until {:type :iso_date}
:code {:type 'String} :code {:type 'String}
:signature_data {:type 'String} :signature_data {:type 'String}
:email {:type 'String} :email {:type 'String}
:emails {:type '(list :edit_email_contact)}
:week_a_credits {:type :money} :week_a_credits {:type :money}
:week_a_debits {:type :money} :week_a_debits {:type :money}
:week_b_credits {:type :money} :week_b_credits {:type :money}

View File

@@ -506,4 +506,4 @@
:input-stream (io/make-input-stream pdf-data {}) :input-stream (io/make-input-stream pdf-data {})
:metadata {:content-length (count pdf-data) :metadata {:content-length (count pdf-data)
:content-type "application/pdf"}) :content-type "application/pdf"})
(str "http://" (:data-bucket env) ".s3-website-us-east-1.amazonaws.com/reports/pnl/" uuid ".pdf"))) (str "https://" (:data-bucket env) ".s3-website-us-east-1.amazonaws.com/reports/pnl/" uuid ".pdf")))

View File

@@ -46,7 +46,7 @@
(let [jwt (jwt/sign {:user (:name profile) (let [jwt (jwt/sign {:user (:name profile)
:exp (time/plus (time/now) (time/days 30)) :exp (time/plus (time/now) (time/days 30))
:user/clients (map (fn [c] :user/clients (map (fn [c]
(dissoc c :client/bank-accounts :client/location-matches :client/forecasted-transactions :client/matches :client/week-a-debits :client/week-a-credits :client/week-b-debits :client/week-b-credits :client/signature-file :client/address)) (dissoc c :client/bank-accounts :client/location-matches :client/forecasted-transactions :client/matches :client/week-a-debits :client/week-a-credits :client/week-b-debits :client/week-b-credits :client/signature-file :client/address :client/emails))
(:user/clients user)) (:user/clients user))
:user/role (name (:user/role user)) :user/role (name (:user/role user))
:user/name (:name profile)} :user/name (:name profile)}

View File

@@ -32,6 +32,7 @@
(defn client-query [token] (defn client-query [token]
(cond-> [:id :name :signature-file :code :email :matches :week-a-debits :week-a-credits :week-b-debits :week-b-credits :locations :locked-until (cond-> [:id :name :signature-file :code :email :matches :week-a-debits :week-a-credits :week-b-debits :week-b-credits :locations :locked-until
[:emails [:id :email :description]]
[:location-matches [:id :location :match]] [:location-matches [:id :location :match]]
[:bank-accounts [:id :start-date :numeric-code :code :number :bank-name :bank-code :check-number :name :routing :type :sort-order :visible :yodlee-account-id [:bank-accounts [:id :start-date :numeric-code :code :number :bank-name :bank-code :check-number :name :routing :type :sort-order :visible :yodlee-account-id
[:yodlee-account [:name :id :number]] [:yodlee-account [:name :id :number]]

View File

@@ -107,7 +107,7 @@
{:id (:id new-client-data), {:id (:id new-client-data),
:name (:name new-client-data) :name (:name new-client-data)
:code (:code new-client-data) ;; TODO add validation can't change :code (:code new-client-data) ;; TODO add validation can't change
:email (:email new-client-data) :emails (:emails new-client-data)
:locked-until (cond (not (:locked-until new-client-data)) :locked-until (cond (not (:locked-until new-client-data))
nil nil
@@ -537,10 +537,18 @@
:field [:locked-until]}]) :field [:locked-until]}])
(field "Email" [:h2.subtitle.is-5 "Emails (address/description)"]
[:input.input {:type "email" [:div.control
:field :email (raw-field
:spec ::entity/email}]) [multi-field {:type "multi-field"
:field :emails
:template [[:input.input {:type "email"
:field [:email]
:placeholder "tom@myspace.com"
:spec ::entity/email}]
[:input.input {:type "text"
:placeholder "Manager"
:field [:description]}]]}])]
[:div.field [:div.field
[:p.help "Signature"] [:p.help "Signature"]

View File

@@ -223,20 +223,22 @@ Please download it by clicking this link: " report-url)))
(let [selected-clients (-> db ::forms/forms ::form :data :clients) (let [selected-clients (-> db ::forms/forms ::form :data :clients)
single-client? (= (count selected-clients) single-client? (= (count selected-clients)
1) 1)
client-email (when single-client? client-emails (when single-client?
(-> clients-by-id (-> clients-by-id
(get (:id (first selected-clients))) (get (:id (first selected-clients)))
:email))] :emails))]
{:dispatch [::modal/modal-requested {:title "Your report is ready" {:dispatch [::modal/modal-requested {:title "Your report is ready"
:body [:div :body [:div
[:div "Click " [:div "Click "
[:a {:href (-> result :profit-and-loss-pdf :report-url) :target "_new"} "here"] " to view it."] [:a {:href (-> result :profit-and-loss-pdf :report-url) :target "_new"} "here"] " to view it."]
(when single-client? (when (and single-client? (seq client-emails))
[:div "Once you've confirmed you're happy with it, click " [:div "Once you've confirmed you're happy with it, click "
[:a {:href (str "mailto:" (or client-email "client@xyz.com") "?body=" (email-body (-> result :profit-and-loss-pdf :report-url)))} [:a {:href (str "mailto:" (str/join ";" (map :email client-emails)) "?body=" (email-body (-> result :profit-and-loss-pdf :report-url)))}
"here"] " to open your email client and to send it to " (str (or client-email "client@xyz.com")) "."])]}]}))) "here"] " to open your email client and to send it to " (str/join "," (map (fn [e]
(str (:email e) " (" (:description e) ")"))
client-emails)) "."])]}]})))
(re-frame/reg-event-fx (re-frame/reg-event-fx
::export-pdf ::export-pdf
[with-user (forms/in-form ::form)] [with-user (forms/in-form ::form)]