can edit accounts.

This commit is contained in:
Bryce Covert
2019-04-12 10:42:18 -07:00
parent c2229c11eb
commit bdb06d802b
6 changed files with 92 additions and 13 deletions

View File

@@ -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

View File

@@ -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))