you can add overrides.

This commit is contained in:
Bryce Covert
2020-04-19 14:38:55 -07:00
parent 5579fc95b2
commit a48ee8dd52
6 changed files with 179 additions and 103 deletions

View File

@@ -8,7 +8,7 @@
[clojure.set :as set]))
(defn upsert-vendor [context {{:keys [id name hidden terms code print_as primary_contact secondary_contact address default_account_id invoice_reminder_schedule] :as in} :vendor} value]
(defn upsert-vendor [context {{:keys [id name hidden terms code print_as primary_contact secondary_contact address default_account_id invoice_reminder_schedule terms_overrides account_overrides] :as in} :vendor} value]
(let [_ (println default_account_id)
transaction [(remove-nils #:vendor {:db/id (if id
id
@@ -20,6 +20,20 @@
:print-as print_as
:default-account default_account_id
:invoice-reminder-schedule (keyword invoice_reminder_schedule)
:terms-overrides (mapv
(fn [to]
(cond->
#:vendor-terms-override {:client (:client_id to)
:terms (:terms to)}
(:id to) (assoc :db/id (:id to))))
terms_overrides)
:account-overrides (mapv
(fn [ao]
(cond->
#:vendor-account-override {:client (:client_id ao)
:account (:account_id ao)}
(:id ao) (assoc :db/id (:id ao))))
account_overrides)
:address (when address
(remove-nils #:address {:db/id (if (:id address)
(:id address)