everything is now looked up through datomic
This commit is contained in:
@@ -512,6 +512,7 @@
|
||||
|
||||
(d/transact (d/connect uri))))
|
||||
|
||||
|
||||
(defn load-entities []
|
||||
(d/transact (d/connect uri)
|
||||
[{:db/ident :test
|
||||
@@ -555,7 +556,7 @@
|
||||
(map
|
||||
(fn [{:keys [name address id code locations email bank-accounts signature-file] client-id :id}]
|
||||
(remove-nils #:client {:original-id id
|
||||
:name (str name "-test")
|
||||
:name (str name)
|
||||
:code nil
|
||||
:email email
|
||||
:signature-file signature-file
|
||||
@@ -706,7 +707,7 @@
|
||||
(d/db (d/connect uri))))
|
||||
|
||||
(defn query-check-payments []
|
||||
(d/q '[:find (pull ?e [*])
|
||||
(d/q '[:find (pull ?e [* {:invoice-payment/payment [*]}])
|
||||
:where [?e :invoice-payment/original-id]]
|
||||
(d/db (d/connect uri))))
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
(:require [datomic.api :as d]
|
||||
[auto-ap.datomic :refer [uri]]))
|
||||
|
||||
(defn get-graphql []
|
||||
(defn get-graphql [args]
|
||||
|
||||
(->> (d/q '[:find (pull ?e [*])
|
||||
:where [?e :vendor/name]]
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
[auto-ap.db.vendors :as vendors]
|
||||
[auto-ap.db.companies :as companies]
|
||||
[auto-ap.datomic.clients :as d-clients]
|
||||
[auto-ap.datomic.invoices :as d-invoices]
|
||||
[auto-ap.datomic.vendors :as d-vendors]
|
||||
[auto-ap.db.users :as users]
|
||||
[auto-ap.db.checks :as checks]
|
||||
@@ -97,10 +98,8 @@
|
||||
:check {: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}
|
||||
:vendor {:type :vendor}
|
||||
:company {:type :company}
|
||||
:date {:type 'String}
|
||||
:bank_account {:type :bank_account
|
||||
:resolve :bank-account-for-check}
|
||||
@@ -108,8 +107,7 @@
|
||||
:s3_url {:type 'String}
|
||||
:check_number {:type 'Int}
|
||||
:status {:type 'String}
|
||||
:invoices {:type '(list :invoice_check)
|
||||
:resolve :get-checks-invoices}
|
||||
:invoices {:type '(list :invoice_payment)}
|
||||
}}
|
||||
|
||||
:payment {:fields {:id {:type 'String}
|
||||
@@ -124,8 +122,7 @@
|
||||
:s3_url {:type 'String}
|
||||
:check_number {:type 'Int}
|
||||
:status {:type 'String}
|
||||
:invoices {:type '(list :invoice_check)
|
||||
:resolve :get-checks-invoices}
|
||||
:invoices {:type '(list :invoice_payment)}
|
||||
}}
|
||||
|
||||
:transaction {:fields {:id {:type 'String}
|
||||
@@ -137,13 +134,12 @@
|
||||
:payment {:type :payment}
|
||||
:date {:type 'String}
|
||||
:post_date {:type 'String}}}
|
||||
:invoice_check
|
||||
:invoice_payment
|
||||
{:fields {:id {:type 'Int}
|
||||
:amount {:type 'String}
|
||||
:invoice_id {:type 'Int}
|
||||
:check_id {:type 'Int}
|
||||
:check {:type :check
|
||||
:resolve :get-check-by-id}}}
|
||||
:invoice_id {:type 'String}
|
||||
:payment_id {:type 'String}
|
||||
:payment {:type :payment}}}
|
||||
|
||||
:user
|
||||
{:fields {:id {:type 'Int}
|
||||
@@ -159,30 +155,27 @@
|
||||
:resolve :get-expense-account-parent}}}
|
||||
|
||||
:invoices_expense_accounts
|
||||
{:fields {:id {:type 'Int}
|
||||
:invoice_id {:type 'Int}
|
||||
{:fields {:id {:type 'String}
|
||||
:invoice_id {:type 'String}
|
||||
:expense_account_id {:type 'Int}
|
||||
:location {:type 'String}
|
||||
:expense_account {:type :expense_account
|
||||
:resolve :get-expense-account}
|
||||
:resolve :get-expense-account
|
||||
|
||||
}
|
||||
:amount {:type 'String}}}
|
||||
|
||||
:invoice
|
||||
{:fields {:id {:type 'Int}
|
||||
{:fields {:id {:type 'String}
|
||||
:total {:type 'String}
|
||||
:outstanding_balance {:type 'String}
|
||||
:invoice_number {:type 'String}
|
||||
:expense_accounts {:type '(list :invoices_expense_accounts)
|
||||
:resolve :get-invoices-expense-accounts}
|
||||
:expense_accounts {:type '(list :invoices_expense_accounts)}
|
||||
:date {:type 'String}
|
||||
:company_id {:type 'Int}
|
||||
:checks {:type '(list :invoice_check)
|
||||
:resolve :get-invoices-checks}
|
||||
:vendor {:type :vendor
|
||||
|
||||
:resolve :get-vendor-for-invoice}
|
||||
:company {:type :company
|
||||
:resolve :get-company-for-invoice}}}
|
||||
:payments {:type '(list :invoice_payment)}
|
||||
:vendor {:type :vendor}
|
||||
:client {:type :client}}}
|
||||
|
||||
|
||||
:invoice_page {:fields {:invoices {:type '(list :invoice)}
|
||||
@@ -191,7 +184,7 @@
|
||||
:start {:type 'Int}
|
||||
:end {:type 'Int}}}
|
||||
|
||||
:check_page {:fields {:checks {:type '(list :payment)}
|
||||
:payment_page {:fields {:checks {:type '(list :payment)}
|
||||
:count {:type 'Int}
|
||||
:total {:type 'Int}
|
||||
:start {:type 'Int}
|
||||
@@ -217,7 +210,7 @@
|
||||
{:invoice_page {:type '(list :invoice_page)
|
||||
:args {:imported {:type 'Boolean}
|
||||
:status {:type 'String}
|
||||
:company_id {:type 'Int}
|
||||
:client_id {:type 'String}
|
||||
:start {:type 'Int}
|
||||
:sort_by {:type 'String}
|
||||
:asc {:type 'Boolean}}
|
||||
@@ -228,7 +221,7 @@
|
||||
:args {:company_id {:type 'Int}}
|
||||
:resolve :get-all-invoices}
|
||||
|
||||
:all_checks {:type '(list :check)
|
||||
:all_checks {:type '(list :payment)
|
||||
:args {:company_id {:type 'Int}}
|
||||
:resolve :get-all-checks}
|
||||
|
||||
@@ -240,7 +233,7 @@
|
||||
|
||||
:resolve :get-transaction-page}
|
||||
|
||||
:check_page {:type '(list :check_page)
|
||||
:payment_page {:type '(list :payment_page)
|
||||
:args {:company_id {:type 'Int}
|
||||
:start {:type 'Int}
|
||||
:sort_by {:type 'String}
|
||||
@@ -264,7 +257,7 @@
|
||||
|
||||
:input-objects
|
||||
{
|
||||
:invoice_payment {:fields {:invoice_id {:type 'Int}
|
||||
:invoice_payment_amount {:fields {:invoice_id {:type 'String}
|
||||
:amount {:type 'Float}}}
|
||||
|
||||
:edit_user
|
||||
@@ -297,7 +290,7 @@
|
||||
|
||||
:mutations
|
||||
{:print_checks {:type :check_result
|
||||
:args {:invoice_payments {:type '(list :invoice_payment)}
|
||||
:args {:invoice_payments {:type '(list :invoice_payment_amount)}
|
||||
:bank_account_id {:type 'Int}
|
||||
:type {:type 'String}
|
||||
:company_id {:type 'Int}}
|
||||
@@ -370,21 +363,16 @@
|
||||
|
||||
(defn get-invoice-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))))
|
||||
|
||||
|
||||
invoices (map
|
||||
->graphql
|
||||
(invoices/get-graphql (<-graphql (assoc args :id (:id context)))))
|
||||
invoice-count (invoices/count-graphql (<-graphql args))]
|
||||
(resolve/with-context
|
||||
[{:invoices invoices
|
||||
:total invoice-count
|
||||
:count (count invoices)
|
||||
:start (:start args 0)
|
||||
:end (+ (:start args 0) (count invoices))}] extra-context)))
|
||||
(d-invoices/get-graphql (<-graphql (assoc args :id (:id context)))))
|
||||
invoice-count (d-invoices/count-graphql (<-graphql args))]
|
||||
[{:invoices invoices
|
||||
:total invoice-count
|
||||
:count (count invoices)
|
||||
:start (:start args 0)
|
||||
:end (+ (:start args 0) (count invoices))}]))
|
||||
|
||||
|
||||
(defn get-all-invoices [context args value]
|
||||
@@ -475,7 +463,6 @@
|
||||
|
||||
|
||||
(defn get-company [context args value]
|
||||
(println "GETTING COMPANY" (:id context))
|
||||
(->graphql
|
||||
(filter #(can-see-company? (:id context) %)
|
||||
(d-clients/get-all))))
|
||||
@@ -500,7 +487,7 @@
|
||||
|
||||
(defn get-vendor [context args value]
|
||||
(->graphql
|
||||
(d-vendors/get-all)))
|
||||
(d-vendors/get-graphql args)))
|
||||
|
||||
(defn print-checks [context args value]
|
||||
|
||||
@@ -525,8 +512,6 @@
|
||||
:get-transaction-page gq-transactions/get-transaction-page
|
||||
:get-reminder-page get-reminder-page
|
||||
: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-check-for-transaction gq-transactions/get-check-for-transaction
|
||||
:get-company-for-invoice get-company-for-invoice
|
||||
:get-invoices-checks get-invoices-checks
|
||||
|
||||
Reference in New Issue
Block a user