merged.
This commit is contained in:
@@ -607,6 +607,11 @@
|
||||
:args {:invoices {:type '(list :id)}}
|
||||
:resolve :mutation/approve-invoices}
|
||||
|
||||
:merge_vendors {:type :id
|
||||
:args {:from {:type :id}
|
||||
:to {:type :id}}
|
||||
:resolve :mutation/merge-vendors}
|
||||
|
||||
:add_and_print_invoice {:type :check_result
|
||||
:args {:invoice {:type :add_invoice}
|
||||
:bank_account_id {:type :id}
|
||||
@@ -842,6 +847,7 @@
|
||||
:mutation/edit-client gq-clients/edit-client
|
||||
:mutation/upsert-vendor gq-vendors/upsert-vendor
|
||||
:mutation/upsert-account gq-accounts/upsert-account
|
||||
:mutation/merge-vendors gq-vendors/merge-vendors
|
||||
:mutation/void-invoice gq-invoices/void-invoice
|
||||
:mutation/unvoid-invoice gq-invoices/unvoid-invoice
|
||||
:mutation/void-payment gq-checks/void-check
|
||||
|
||||
@@ -52,4 +52,18 @@
|
||||
id))
|
||||
(->graphql))))
|
||||
|
||||
(defn merge-vendors [context {:keys [from to]} value]
|
||||
(let [conn (d/connect uri)
|
||||
transaction (->> (d/query {:query {:find '[?x ?a2]
|
||||
:in '[$ ?vendor-from ]
|
||||
:where ['[?x ?a ?vendor-from]
|
||||
'[?a :db/ident ?a2]]}
|
||||
:args [(d/db conn)
|
||||
from]})
|
||||
(mapcat (fn [[src attr]]
|
||||
|
||||
[[:db/retract src attr from]
|
||||
[:db/add src attr to]])))
|
||||
transaction (conj transaction [:db/retractEntity from])]
|
||||
@(d/transact conn transaction)
|
||||
to))
|
||||
|
||||
Reference in New Issue
Block a user