added new fields.
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
(ns auto-ap.graphql.vendors
|
||||
(:require [auto-ap.graphql.utils :refer [->graphql assert-can-see-client assert-admin is-admin?]]
|
||||
(:require [auto-ap.graphql.utils :refer [->graphql assert-can-see-client assert-admin is-admin? enum->keyword]]
|
||||
[auto-ap.datomic.vendors :as d-vendors]
|
||||
[auto-ap.time :refer [parse iso-date]]
|
||||
[datomic.api :as d]
|
||||
@@ -40,45 +40,49 @@
|
||||
(:id ao) (assoc :db/id (:id ao))))
|
||||
schedule_payment_dom)
|
||||
transaction (cond->
|
||||
[(remove-nils #:vendor {:db/id (if id
|
||||
id
|
||||
"vendor")
|
||||
:name name
|
||||
:code code
|
||||
:hidden hidden
|
||||
:terms terms
|
||||
:print-as print_as
|
||||
:default-account default_account_id
|
||||
:invoice-reminder-schedule (keyword invoice_reminder_schedule)
|
||||
|
||||
|
||||
:address (when address
|
||||
(remove-nils #:address {:db/id (if (:id address)
|
||||
(:id address)
|
||||
"address")
|
||||
:street1 (:street1 address)
|
||||
:street2 (:street2 address)
|
||||
:city (:city address)
|
||||
:state (:state address)
|
||||
:zip (:zip address)}))
|
||||
:primary-contact (when primary_contact
|
||||
[(remove-nils (cond-> #:vendor {:db/id (if id
|
||||
id
|
||||
"vendor")
|
||||
:name name
|
||||
:code code
|
||||
:hidden hidden
|
||||
:terms terms
|
||||
:print-as print_as
|
||||
:default-account default_account_id
|
||||
:invoice-reminder-schedule (keyword invoice_reminder_schedule)
|
||||
:address (when address
|
||||
(remove-nils #:address {:db/id (if (:id address)
|
||||
(:id address)
|
||||
"address")
|
||||
:street1 (:street1 address)
|
||||
:street2 (:street2 address)
|
||||
:city (:city address)
|
||||
:state (:state address)
|
||||
:zip (:zip address)}))
|
||||
:primary-contact (when primary_contact
|
||||
|
||||
(remove-nils #:contact {:db/id (if (:id primary_contact)
|
||||
(:id primary_contact)
|
||||
"primary")
|
||||
:name (:name primary_contact)
|
||||
:phone (:phone primary_contact)
|
||||
:email (:email primary_contact)}))
|
||||
|
||||
:secondary-contact (when secondary_contact
|
||||
(remove-nils #:contact {:db/id (if (:id primary_contact)
|
||||
(:id primary_contact)
|
||||
"primary")
|
||||
:name (:name primary_contact)
|
||||
:phone (:phone primary_contact)
|
||||
:email (:email primary_contact)}))
|
||||
:secondary-contact (when secondary_contact
|
||||
|
||||
(remove-nils #:contact {:db/id (if (:id secondary_contact)
|
||||
(:id secondary_contact)
|
||||
"secondary")
|
||||
:name (:name secondary_contact)
|
||||
:phone (:phone secondary_contact)
|
||||
:email (:email secondary_contact)})
|
||||
)})]
|
||||
(remove-nils #:contact {:db/id (if (:id secondary_contact)
|
||||
(:id secondary_contact)
|
||||
"secondary")
|
||||
:name (:name secondary_contact)
|
||||
:phone (:phone secondary_contact)
|
||||
:email (:email secondary_contact)})
|
||||
)}
|
||||
(is-admin? (:id context)) (assoc
|
||||
:vendor/legal-entity-first-name (:legal_entity_first_name in)
|
||||
:vendor/legal-entity-middle-name (:legal_entity_middle_name in)
|
||||
:vendor/legal-entity-last-name (:legal_entity_last_name in)
|
||||
:vendor/legal-entity-tin (:legal_entity_tin in)
|
||||
:vendor/legal-entity-tin-type (enum->keyword (:legal_entity_tin_type in) "legal-entity-tin-type")
|
||||
:vendor/legal-entity-1099-type (enum->keyword (:legal_entity_1099_type in) "legal-entity-1099-type"))))]
|
||||
(is-admin? (:id context)) (conj [:reset (if id id "vendor") :vendor/account-overrides account-overrides])
|
||||
(is-admin? (:id context)) (conj [:reset (if id id "vendor") :vendor/terms-overrides terms-overrides])
|
||||
(is-admin? (:id context)) (conj [:reset (if id id "vendor") :vendor/schedule-payment-dom schedule-payment-dom])
|
||||
@@ -91,9 +95,10 @@
|
||||
_ (log/info "Upserting vendor" transaction)
|
||||
transaction-result (audit-transact transaction (:id context))]
|
||||
|
||||
(-> (d-vendors/get-by-id (or (-> transaction-result :tempids (get "vendor"))
|
||||
id))
|
||||
(->graphql))))
|
||||
(doto (-> (d-vendors/get-by-id (or (-> transaction-result :tempids (get "vendor"))
|
||||
id))
|
||||
(->graphql))
|
||||
log/info)))
|
||||
|
||||
(defn merge-vendors [context {:keys [from to]} value]
|
||||
(let [transaction (->> (d/query {:query {:find '[?x ?a2]
|
||||
|
||||
Reference in New Issue
Block a user