can edit accounts.
This commit is contained in:
@@ -420,13 +420,26 @@
|
||||
:edit_transaction
|
||||
{:fields {:id {:type :id}
|
||||
:vendor_id {:type :id}
|
||||
:account_id {:type :id}}}}
|
||||
:account_id {:type :id}}}
|
||||
|
||||
:edit_account
|
||||
{:fields {:id {:type :id}
|
||||
:type {:type :account_type}
|
||||
:numeric_code {:type 'Int}
|
||||
:account_set {:type 'String}
|
||||
:name {:type 'String}}}}
|
||||
|
||||
:enums {:payment_type {:values [{:enum-value :check}
|
||||
{:enum-value :cash}
|
||||
{:enum-value :debit}]}
|
||||
:bank_account_type {:values [{:enum-value :check}
|
||||
{:enum-value :cash}]}}
|
||||
{:enum-value :cash}]}
|
||||
:account_type {:values [{:enum-value :dividend}
|
||||
{:enum-value :expense}
|
||||
{:enum-value :asset}
|
||||
{:enum-value :liability}
|
||||
{:enum-value :equities}
|
||||
{:enum-value :revenue}]}}
|
||||
:mutations
|
||||
{:reject_invoices {:type '(list :id)
|
||||
:args {:invoices {:type '(list :id)}}
|
||||
@@ -472,6 +485,9 @@
|
||||
:edit_invoice {:type :invoice
|
||||
:args {:invoice {:type :edit_invoice}}
|
||||
:resolve :mutation/edit-invoice}
|
||||
:upsert_account {:type :account
|
||||
:args {:account {:type :edit_account}}
|
||||
:resolve :mutation/upsert-account}
|
||||
:edit_transaction {:type :transaction
|
||||
:args {:transaction {:type :edit_transaction}}
|
||||
:resolve :mutation/edit-transaction}
|
||||
@@ -647,6 +663,7 @@
|
||||
:mutation/edit-transaction gq-transactions/edit-transaction
|
||||
:mutation/edit-client gq-clients/edit-client
|
||||
:mutation/upsert-vendor gq-vendors/upsert-vendor
|
||||
:mutation/upsert-account gq-accounts/upsert-account
|
||||
:mutation/void-invoice gq-invoices/void-invoice
|
||||
:mutation/unvoid-invoice gq-invoices/unvoid-invoice
|
||||
:mutation/void-payment gq-checks/void-check
|
||||
|
||||
@@ -2,8 +2,20 @@
|
||||
(:require [datomic.api :as d]
|
||||
[auto-ap.datomic.accounts :as d-accounts]
|
||||
[auto-ap.graphql.utils :refer [->graphql <-graphql] ]
|
||||
[auto-ap.datomic :refer [uri merge-query]]))
|
||||
[auto-ap.datomic :refer [uri merge-query remove-nils]]))
|
||||
|
||||
(defn get-accounts [context args value]
|
||||
(->graphql (d-accounts/get-accounts (<-graphql args))))
|
||||
|
||||
(defn upsert-account [context args value]
|
||||
@(d/transact (d/connect uri)
|
||||
[(remove-nils
|
||||
{:db/id (:id (:account args))
|
||||
:account/name (:name (:account args))
|
||||
:account/type (keyword "account-type" (name (:type (:account args))))
|
||||
:account/account-set (:account_set (:account args))
|
||||
:account/numeric-code (if-not (:id (:account args))
|
||||
(:numeric_code (:account args)))
|
||||
})])
|
||||
(:account args))
|
||||
|
||||
|
||||
Reference in New Issue
Block a user