From 2263a5f24a8d998f70c27a4367067c4ff1c3582a Mon Sep 17 00:00:00 2001 From: Bryce Covert Date: Sun, 11 Nov 2018 11:18:05 -0800 Subject: [PATCH] minor reorg. --- src/clj/auto_ap/graphql.clj | 24 ++++-------------------- src/clj/auto_ap/graphql/invoices.clj | 21 ++++++++++++++++++++- 2 files changed, 24 insertions(+), 21 deletions(-) diff --git a/src/clj/auto_ap/graphql.clj b/src/clj/auto_ap/graphql.clj index b682489b..c4fcfe72 100644 --- a/src/clj/auto_ap/graphql.clj +++ b/src/clj/auto_ap/graphql.clj @@ -386,26 +386,10 @@ node)) m)) -(defn get-invoice-page [context args value] - (let [args (assoc args :id (:id context)) - - invoices (map - ->graphql - (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] - (assert-admin (:id context)) - (map - ->graphql - (d-invoices/get-graphql (assoc (<-graphql args) - :limit Integer/MAX_VALUE)))) + + (defn get-all-payments [context args value] (assert-admin (:id context)) @@ -459,8 +443,8 @@ (def schema (-> integreat-schema - (attach-resolvers {:get-invoice-page get-invoice-page - :get-all-invoices get-all-invoices + (attach-resolvers {:get-invoice-page gq-invoices/get-invoice-page + :get-all-invoices gq-invoices/get-all-invoices :get-all-payments get-all-payments :get-payment-page gq-checks/get-payment-page :get-transaction-page gq-transactions/get-transaction-page diff --git a/src/clj/auto_ap/graphql/invoices.clj b/src/clj/auto_ap/graphql/invoices.clj index 7aedc320..99f178f2 100644 --- a/src/clj/auto_ap/graphql/invoices.clj +++ b/src/clj/auto_ap/graphql/invoices.clj @@ -1,5 +1,5 @@ (ns auto-ap.graphql.invoices - (:require [auto-ap.graphql.utils :refer [->graphql assert-can-see-company]] + (:require [auto-ap.graphql.utils :refer [->graphql <-graphql assert-can-see-company assert-admin]] [auto-ap.datomic.vendors :as d-vendors] [auto-ap.datomic.invoices :as d-invoices] @@ -10,6 +10,25 @@ [clj-time.coerce :as coerce] [clojure.set :as set])) +(defn get-invoice-page [context args value] + (let [args (assoc args :id (:id context)) + invoices (map + ->graphql + (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] + (assert-admin (:id context)) + (map + ->graphql + (d-invoices/get-graphql (assoc (<-graphql args) + :limit Integer/MAX_VALUE)))) + (defn add-invoice [context {{:keys [total invoice_number location client_id vendor_id vendor_name date] :as in} :invoice} value] (when (seq (d-invoices/find-conflicting {:invoice/invoice-number invoice_number :invoice/vendor (Long/parseLong vendor_id)