Should prevent accidentally deleting signature

This commit is contained in:
Bryce
2023-06-12 15:03:49 -07:00
parent 7af840a1de
commit e16361bc70

View File

@@ -78,78 +78,77 @@
client-code (if (str/blank? (:client/code client)) client-code (if (str/blank? (:client/code client))
(:code edit_client) (:code edit_client)
(:client/code client)) (:client/code client))
updated-entity {:db/id id updated-entity (cond-> {:db/id id
:client/code client-code :client/code client-code
:client/name (:name edit_client) :client/name (:name edit_client)
:client/matches (:matches edit_client) :client/matches (:matches edit_client)
:client/signature-file signature-file :client/email (:email edit_client)
:client/email (:email edit_client) :client/locked-until (some-> (:locked_until edit_client) (coerce/to-date))
:client/locked-until (some-> (:locked_until edit_client) (coerce/to-date)) :client/locations (filter identity (:locations edit_client))
:client/locations (filter identity (:locations edit_client)) :client/week-a-debits (:week_a_debits edit_client)
:client/week-a-debits (:week_a_debits edit_client) :client/week-a-credits (:week_a_credits edit_client)
:client/week-a-credits (:week_a_credits edit_client) :client/week-b-debits (:week_b_debits edit_client)
:client/week-b-debits (:week_b_debits edit_client) :client/square-auth-token (:square_auth_token edit_client)
:client/square-auth-token (:square_auth_token edit_client) :client/square-locations (map
:client/square-locations (map (fn [sl]
(fn [sl] {:db/id (or (:id sl) (random-tempid))
{:db/id (or (:id sl) (random-tempid)) :square-location/client-location (:client_location sl)})
:square-location/client-location (:client_location sl)}) (:square_locations edit_client))
(:square_locations edit_client))
:client/emails (map (fn [e] :client/emails (map (fn [e]
{:db/id (or (:id e) {:db/id (or (:id e)
(random-tempid)) (random-tempid))
:email-contact/email (:email e) :email-contact/email (:email e)
:email-contact/description (:description e)}) :email-contact/description (:description e)})
(:emails edit_client)) (:emails edit_client))
:client/feature-flags (:feature_flags edit_client) :client/feature-flags (:feature_flags edit_client)
:client/ezcater-locations (map :client/ezcater-locations (map
(fn [el] (fn [el]
{:db/id (or (:id el) (random-tempid)) {:db/id (or (:id el) (random-tempid))
:ezcater-location/location (:location el) :ezcater-location/location (:location el)
:ezcater-location/caterer (:caterer el)}) :ezcater-location/caterer (:caterer el)})
(:ezcater_locations edit_client)) (:ezcater_locations edit_client))
:client/week-b-credits (:week_b_credits edit_client) :client/week-b-credits (:week_b_credits edit_client)
:client/location-matches (->> (:location_matches edit_client) :client/location-matches (->> (:location_matches edit_client)
(filter (fn [lm] (and (:location lm) (:match lm)))) (filter (fn [lm] (and (:location lm) (:match lm))))
(map (fn [lm] {:db/id (or (:id lm ) (random-tempid)) (map (fn [lm] {:db/id (or (:id lm) (random-tempid))
:location-match/location (:location lm) :location-match/location (:location lm)
:location-match/matches [(:match lm)]}))) :location-match/matches [(:match lm)]})))
:client/address (when (seq (filter identity (vals (:address edit_client)))) :client/address (when (seq (filter identity (vals (:address edit_client))))
{:db/id (or (:id (:address edit_client)) (random-tempid)) {:db/id (or (:id (:address edit_client)) (random-tempid))
:address/street1 (:street1 (:address edit_client)) :address/street1 (:street1 (:address edit_client))
:address/street2 (:street2 (:address edit_client)) :address/street2 (:street2 (:address edit_client))
:address/city (:city (:address edit_client)) :address/city (:city (:address edit_client))
:address/state (:state (:address edit_client)) :address/state (:state (:address edit_client))
:address/zip (:zip (:address edit_client))}) :address/zip (:zip (:address edit_client))})
:client/bank-accounts (map (fn [ba] :client/bank-accounts (map (fn [ba]
{:db/id (or (:id ba) (random-tempid)) {:db/id (or (:id ba) (random-tempid))
:bank-account/code (:code ba) :bank-account/code (:code ba)
:bank-account/bank-name (:bank_name ba) :bank-account/bank-name (:bank_name ba)
:bank-account/bank-code (:bank_code ba) :bank-account/bank-code (:bank_code ba)
:bank-account/start-date (-> (:start_date ba) (coerce/to-date)) :bank-account/start-date (-> (:start_date ba) (coerce/to-date))
:bank-account/routing (:routing ba) :bank-account/routing (:routing ba)
:bank-account/include-in-reports (:include_in_reports ba) :bank-account/include-in-reports (:include_in_reports ba)
:bank-account/name (:name ba) :bank-account/name (:name ba)
:bank-account/visible (:visible ba) :bank-account/visible (:visible ba)
:bank-account/number (:number ba) :bank-account/number (:number ba)
:bank-account/check-number (:check_number ba) :bank-account/check-number (:check_number ba)
:bank-account/numeric-code (:numeric_code ba) :bank-account/numeric-code (:numeric_code ba)
:bank-account/sort-order (:sort_order ba) :bank-account/sort-order (:sort_order ba)
:bank-account/locations (:locations ba) :bank-account/locations (:locations ba)
:bank-account/use-date-instead-of-post-date? (boolean (:use_date_instead_of_post_date ba)) :bank-account/use-date-instead-of-post-date? (boolean (:use_date_instead_of_post_date ba))
:bank-account/yodlee-account-id (:yodlee_account_id ba) :bank-account/yodlee-account-id (:yodlee_account_id ba)
:bank-account/type (keyword "bank-account-type" (name (:type ba))) :bank-account/type (keyword "bank-account-type" (name (:type ba)))
:bank-account/yodlee-account (when (:yodlee_account ba) :bank-account/yodlee-account (when (:yodlee_account ba)
[:yodlee-account/id (:yodlee_account ba)]) [:yodlee-account/id (:yodlee_account ba)])
:bank-account/plaid-account (:plaid_account ba) :bank-account/plaid-account (:plaid_account ba)
:bank-account/intuit-bank-account (:intuit_bank_account ba)}) :bank-account/intuit-bank-account (:intuit_bank_account ba)})
(:bank_accounts edit_client)) (:bank_accounts edit_client))}
signature-file (assoc :client/signature-file signature-file))
}
_ (mu/log ::upserting :up updated-entity) _ (mu/log ::upserting :up updated-entity)
_ (assert-no-shared-transaction-sources client-code [[:upsert-entity updated-entity]]) _ (assert-no-shared-transaction-sources client-code [[:upsert-entity updated-entity]])
_ (log/info "upserting client" updated-entity) _ (log/info "upserting client" updated-entity)
@@ -167,18 +166,18 @@
(:client/name updated-client)))}]) (:client/name updated-client)))}])
(-> updated-client (-> updated-client
(update :client/bank-accounts (update :client/bank-accounts
(fn [bas] (fn [bas]
(map #(set/rename-keys % {:bank-account/use-date-instead-of-post-date? :use-date-instead-of-post-date}) bas))) (map #(set/rename-keys % {:bank-account/use-date-instead-of-post-date? :use-date-instead-of-post-date}) bas)))
(update :client/location-matches (update :client/location-matches
(fn [lms] (fn [lms]
(mapcat (fn [lm] (mapcat (fn [lm]
(map (fn [m] (map (fn [m]
{:location-match/match m {:location-match/match m
:location-match/location (:location-match/location lm)}) :location-match/location (:location-match/location lm)})
(:location-match/matches lm))) (:location-match/matches lm)))
lms))) lms)))
->graphql)))) ->graphql))))
(defn refresh-all-current-balance [] (defn refresh-all-current-balance []