checks are now stored

This commit is contained in:
Bryce Covert
2018-05-12 15:57:42 -07:00
parent 501a3f0ff1
commit fd2164e8ba
5 changed files with 134 additions and 49 deletions

View File

@@ -8,7 +8,9 @@
[auto-ap.db.invoices :as invoices]
[auto-ap.db.vendors :as vendors]
[auto-ap.db.companies :as companies]
[auto-ap.db.checks :as checks]
[auto-ap.db.reminders :as reminders]
[auto-ap.db.invoices-checks :as invoices-checks]
[auto-ap.db.utils :as utils]
[clojure.walk :as walk]
[clojure.string :as str])
@@ -37,18 +39,34 @@
:vendor {:type :vendor
:resolve :get-vendor-for-invoice}}
}
:check {:fields {:id {:type 'Int}
:amount {:type 'String}
:s3_url {:type 'String}
:check_number {:type 'Int}}}
:invoice_check
{:fields {:id {:type 'Int}
:amount {:type 'String}
:check_id {:type 'Int}
:check {:type :check
:resolve :get-check-by-id}}}
:invoice
{:fields {:id {:type 'Int}
:total {:type 'String}
:invoice_number {:type 'String}
: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}}}
:invoice_page {:fields {:invoices {:type '(list :invoice)}
:count {:type 'Int}
:total {:type 'Int}
@@ -162,6 +180,14 @@
(vendor-cache (:vendor_id value))
(vendors/get-by-id (:vendor_id value)))))
(defn get-check-by-id [context args value]
(->graphql
(checks/get-by-id (:check_id value))))
(defn get-invoices-checks [context args value]
(->graphql
(invoices-checks/get-for-invoice-id (:id value))))
(defn get-company-for-invoice [context args value]
(->graphql
(if-let [company-cache (:company-cache context)]
@@ -182,6 +208,8 @@
:get-reminder-page get-reminder-page
:get-vendor-for-invoice get-vendor-for-invoice
:get-company-for-invoice get-company-for-invoice
:get-invoices-checks get-invoices-checks
:get-check-by-id get-check-by-id
:get-company get-company
:get-vendor get-vendor})
schema/compile))