you can find transactions now
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
(:require [datomic.api :as d]
|
||||
[auto-ap.datomic :refer [uri]]))
|
||||
|
||||
(defn get-all []
|
||||
(defn get-graphql []
|
||||
|
||||
(->> (d/q '[:find (pull ?e [*])
|
||||
:where [?e :vendor/name]]
|
||||
|
||||
@@ -22,12 +22,12 @@
|
||||
(defn get-all []
|
||||
(query base-query))
|
||||
(defn base-graphql [{:keys [company-id id]}]
|
||||
(println "ID" id)
|
||||
|
||||
(cond-> base-query
|
||||
(limited-companies id) (helpers/merge-where [:in :company-id (limited-companies id)])
|
||||
(not (nil? company-id)) (helpers/merge-where [:= :company-id company-id])))
|
||||
|
||||
(defn get-graphql [{:keys [start sort-by asc limit] :as args :or {limit 20}}]
|
||||
(defn get-graphql [{:keys [start sort-by asc limit] :as args :or {limit 10}}]
|
||||
(query
|
||||
(cond-> (base-graphql args)
|
||||
#_#_(not (nil? sort-by) ) (add-sort-by sort-by asc)
|
||||
|
||||
@@ -35,6 +35,13 @@
|
||||
:objects
|
||||
{
|
||||
:company
|
||||
{:fields {:id {:type 'String}
|
||||
:name {:type 'String}
|
||||
:email {:type 'String}
|
||||
:address {:type :address}
|
||||
:locations {:type '(list String)}
|
||||
:bank_accounts {:type '(list :bank_account)}}}
|
||||
:client
|
||||
{:fields {:id {:type 'String}
|
||||
:name {:type 'String}
|
||||
:email {:type 'String}
|
||||
@@ -105,15 +112,31 @@
|
||||
:resolve :get-checks-invoices}
|
||||
}}
|
||||
|
||||
:payment {:fields {:id {:type 'Int}
|
||||
:type {:type 'String}
|
||||
:amount {:type 'String}
|
||||
:vendor {:type :vendor
|
||||
:resolve :get-vendor-for-check}
|
||||
:company {:type :company
|
||||
:resolve :get-company-for-check}
|
||||
:date {:type 'String}
|
||||
:bank_account {:type :bank_account
|
||||
:resolve :bank-account-for-check}
|
||||
:memo {:type 'String}
|
||||
:s3_url {:type 'String}
|
||||
:check_number {:type 'Int}
|
||||
:status {:type 'String}
|
||||
:invoices {:type '(list :invoice_check)
|
||||
:resolve :get-checks-invoices}
|
||||
}}
|
||||
|
||||
:transaction {:fields {:id {:type 'String}
|
||||
:amount {:type 'String}
|
||||
:description_original {:type 'String}
|
||||
:description_simple {:type 'String}
|
||||
:status {:type 'String}
|
||||
:company {:type :company
|
||||
:resolve :get-company-for-transaction}
|
||||
:check {:type :check
|
||||
:resolve :get-check-for-transaction}
|
||||
:client {:type :client}
|
||||
:payment {:type :payment}
|
||||
:date {:type 'String}
|
||||
:post_date {:type 'String}}}
|
||||
:invoice_check
|
||||
@@ -212,7 +235,7 @@
|
||||
:resolve :get-all-checks}
|
||||
|
||||
:transaction_page {:type '(list :transaction_page)
|
||||
:args {:company_id {:type 'Int}
|
||||
:args {:company_id {:type 'String}
|
||||
:start {:type 'Int}
|
||||
:sort_by {:type 'String}
|
||||
:asc {:type 'Boolean}}
|
||||
@@ -234,6 +257,8 @@
|
||||
:resolve :get-reminder-page}
|
||||
:company {:type '(list :company)
|
||||
:resolve :get-company}
|
||||
:client {:type '(list :company)
|
||||
:resolve :get-company}
|
||||
:vendor {:type '(list :vendor)
|
||||
:resolve :get-vendor}
|
||||
:user {:type '(list :user)
|
||||
@@ -504,7 +529,6 @@
|
||||
:get-vendor-for-invoice get-vendor-for-invoice
|
||||
:get-vendor-for-check gq-checks/get-vendor-for-check
|
||||
:get-company-for-check gq-checks/get-company-for-check
|
||||
:get-company-for-transaction gq-transactions/get-company-for-transaction
|
||||
:get-check-for-transaction gq-transactions/get-check-for-transaction
|
||||
:get-company-for-invoice get-company-for-invoice
|
||||
:get-invoices-checks get-invoices-checks
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
(ns auto-ap.graphql.transactions
|
||||
(:require [auto-ap.graphql.utils :refer [->graphql <-graphql]]
|
||||
[auto-ap.datomic.transactions :as d-transactions]
|
||||
|
||||
[com.walmartlabs.lacinia :refer [execute]]
|
||||
[com.walmartlabs.lacinia.executor :as executor]
|
||||
@@ -23,21 +24,15 @@
|
||||
|
||||
(defn get-transaction-page [context args value]
|
||||
(let [args (assoc args :id (:id context))
|
||||
extra-context
|
||||
(cond-> {}
|
||||
(executor/selects-field? context :invoice/vendor) (assoc :vendor-cache (by :id (vendors/get-all)))
|
||||
(executor/selects-field? context :invoice/company) (assoc :company-cache (by :id (companies/get-all))))
|
||||
|
||||
transactions (map
|
||||
->graphql
|
||||
(transactions/get-graphql (<-graphql args)))
|
||||
transactions-count (transactions/count-graphql (<-graphql args))]
|
||||
(resolve/with-context
|
||||
[{:transactions transactions
|
||||
:total transactions-count
|
||||
:count (count transactions)
|
||||
:start (:start args 0)
|
||||
:end (+ (:start args 0) (count transactions))}] extra-context)))
|
||||
(d-transactions/get-graphql (<-graphql args)))
|
||||
transactions-count (d-transactions/count-graphql (<-graphql args))]
|
||||
[{:transactions transactions
|
||||
:total transactions-count
|
||||
:count (count transactions)
|
||||
:start (:start args 0)
|
||||
:end (+ (:start args 0) (count transactions))}]))
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user