Supports assigning vendors to transactions
This commit is contained in:
@@ -113,10 +113,12 @@
|
||||
|
||||
(defn graphql-results [ids db args]
|
||||
(->> (d/pull-many db '[* {:transaction/client [:client/name :db/id :client/code]
|
||||
:transaction/bank-account [:bank-account/name :bank-account/code :bank-account/yodlee-account-id :db/id]}]
|
||||
:transaction/bank-account [:bank-account/name :bank-account/code :bank-account/yodlee-account-id :db/id]
|
||||
:transaction/vendor [:db/id :vendor/name]}]
|
||||
ids)
|
||||
(map #(update % :transaction/date c/from-date))
|
||||
(map #(update % :transaction/post-date c/from-date))
|
||||
(map #(dissoc % :transaction/id))
|
||||
(apply-sort args (some-> (:sort-by args) sort-fn))))
|
||||
|
||||
(defn get-graphql [args]
|
||||
@@ -125,3 +127,14 @@
|
||||
|
||||
[(->> (graphql-results ids-to-retrieve db args))
|
||||
matching-count]))
|
||||
|
||||
(defn get-by-id [id]
|
||||
(->
|
||||
(d/pull (d/db (d/connect uri))
|
||||
'[* {:transaction/client [:client/name :db/id :client/code]
|
||||
:transaction/bank-account [:bank-account/name :bank-account/code :bank-account/yodlee-account-id :db/id]
|
||||
:transaction/vendor [:db/id :vendor/name]}]
|
||||
id)
|
||||
(update :transaction/date c/from-date)
|
||||
(update :transaction/post-date c/from-date)
|
||||
(dissoc :transaction/id)))
|
||||
|
||||
@@ -359,7 +359,10 @@
|
||||
:invoice_number {:type 'String}
|
||||
:expense_accounts {:type '(list :edit_expense_account)}
|
||||
:date {:type 'String}
|
||||
:total {:type 'Float}}}}
|
||||
:total {:type 'Float}}}
|
||||
:edit_transaction
|
||||
{:fields {:id {:type :id}
|
||||
:vendor_id {:type :id}}}}
|
||||
|
||||
:enums {:payment_type {:values [{:enum-value :check}
|
||||
{:enum-value :cash}
|
||||
@@ -411,6 +414,9 @@
|
||||
:edit_invoice {:type :invoice
|
||||
:args {:invoice {:type :edit_invoice}}
|
||||
:resolve :mutation/edit-invoice}
|
||||
:edit_transaction {:type :transaction
|
||||
:args {:transaction {:type :edit_transaction}}
|
||||
:resolve :mutation/edit-transaction}
|
||||
:void_invoice {:type :invoice
|
||||
:args {:invoice_id {:type :id}}
|
||||
:resolve :mutation/void-invoice}
|
||||
@@ -577,6 +583,7 @@
|
||||
:mutation/add-invoice gq-invoices/add-invoice
|
||||
:mutation/add-and-print-invoice gq-invoices/add-and-print-invoice
|
||||
:mutation/edit-invoice gq-invoices/edit-invoice
|
||||
:mutation/edit-transaction gq-transactions/edit-transaction
|
||||
:mutation/edit-client gq-clients/edit-client
|
||||
:mutation/upsert-vendor gq-vendors/upsert-vendor
|
||||
:mutation/void-invoice gq-invoices/void-invoice
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
(ns auto-ap.graphql.transactions
|
||||
(:require [auto-ap.graphql.utils :refer [->graphql <-graphql]]
|
||||
(:require [auto-ap.graphql.utils :refer [->graphql <-graphql assert-can-see-client]]
|
||||
[auto-ap.datomic.transactions :as d-transactions]
|
||||
[auto-ap.datomic.vendors :as d-vendors]
|
||||
[datomic.api :as d]
|
||||
[auto-ap.datomic :refer [uri]]
|
||||
[com.walmartlabs.lacinia :refer [execute]]
|
||||
[com.walmartlabs.lacinia.executor :as executor]
|
||||
[com.walmartlabs.lacinia.resolve :as resolve]
|
||||
@@ -20,3 +23,12 @@
|
||||
|
||||
|
||||
|
||||
|
||||
(defn edit-transaction [context {{:keys [id vendor_id] :as transaction} :transaction} value]
|
||||
(assert-can-see-client (:id context) (:db/id (d-transactions/get-by-id id)))
|
||||
@(d/transact (d/connect uri)
|
||||
[{:db/id id
|
||||
:transaction/vendor vendor_id}])
|
||||
(->graphql (d-transactions/get-by-id id))
|
||||
#_(->graphql {:id id
|
||||
:vendor (d-vendors/get-by-id vendor_id) }))
|
||||
|
||||
Reference in New Issue
Block a user