Makes sales orders link to their deposits
This commit is contained in:
@@ -22,7 +22,6 @@
|
||||
(defn get-expected-deposit-page [context args value]
|
||||
(let [args (assoc args :id (:id context))
|
||||
[expected-deposits expected-deposit-count] (d-expected-deposit/get-graphql (<-graphql args))
|
||||
_ (log/info expected-deposits)
|
||||
expected-deposits (map status->graphql expected-deposits)]
|
||||
|
||||
(result->page expected-deposits expected-deposit-count :expected_deposits args)))
|
||||
|
||||
@@ -1,10 +1,100 @@
|
||||
(ns auto-ap.graphql.sales-orders
|
||||
(:require [auto-ap.datomic.sales-orders :as d-sales-orders2]
|
||||
[auto-ap.graphql.utils :refer [->graphql <-graphql result->page]]))
|
||||
[auto-ap.graphql.utils :refer [->graphql <-graphql result->page assert-admin] ]
|
||||
[com.walmartlabs.lacinia.util :refer [attach-resolvers]]))
|
||||
|
||||
(defn get-sales-orders-page [context args value]
|
||||
(defn get-sales-orders-page [context args _]
|
||||
(let [args (assoc args :id (:id context))
|
||||
[sales-orders sales-orders-count {:keys [total tax]}] (d-sales-orders2/get-graphql (<-graphql args))]
|
||||
(assoc (result->page sales-orders sales-orders-count :sales_orders args)
|
||||
:sales_order_total total
|
||||
:sales_order_tax tax)))
|
||||
|
||||
(defn get-all-sales-orders [context args _]
|
||||
(assert-admin (:id context))
|
||||
(map
|
||||
->graphql
|
||||
(first (d-sales-orders2/get-graphql (assoc (<-graphql args) :count Integer/MAX_VALUE)))))
|
||||
|
||||
|
||||
(def objects
|
||||
{:sales_order_page
|
||||
{:fields {:sales_orders {:type '(list :sales_order)}
|
||||
:count {:type 'Int}
|
||||
:total {:type 'Int}
|
||||
:start {:type 'Int}
|
||||
:end {:type 'Int}
|
||||
:sales_order_total {:type :money}
|
||||
:sales_order_tax {:type :money}}}
|
||||
|
||||
:sales_order
|
||||
{:fields {:id {:type :id}
|
||||
:location {:type 'String}
|
||||
:external_id {:type 'String}
|
||||
:total {:type :money}
|
||||
:tip {:type :money}
|
||||
:tax {:type :money}
|
||||
:discount {:type :money}
|
||||
:service_charge {:type :money}
|
||||
:returns {:type :money}
|
||||
:client {:type :client}
|
||||
:date {:type 'String}
|
||||
:charges {:type '(list :charge)}
|
||||
:line_items {:type '(list :order_line_item)}}}
|
||||
|
||||
:order_line_item
|
||||
{:fields {:id {:type :id}
|
||||
:item_name {:type 'String}
|
||||
:total {:type :money}
|
||||
:tax {:type :money}
|
||||
:category {:type 'String}
|
||||
:discount {:type :money}}}
|
||||
:charge
|
||||
{:fields {:id {:type :id}
|
||||
:processor {:type :processor}
|
||||
:type_name {:type 'String}
|
||||
:total {:type :money}
|
||||
:tip {:type :money}
|
||||
:expected_deposit {:type :expected_deposit}}}})
|
||||
|
||||
(def queries
|
||||
{:all_sales_orders {:type '(list :sales_order)
|
||||
:args {:client_id {:type :id}
|
||||
:date_range {:type :date_range}
|
||||
:client_code {:type 'String}}
|
||||
:resolve :get-all-sales-orders}
|
||||
|
||||
:sales_order_page {:type :sales_order_page
|
||||
:args {:client_id {:type :id}
|
||||
:date_range {:type :date_range}
|
||||
:total_lte {:type :money}
|
||||
:total_gte {:type :money}
|
||||
:processor {:type :processor}
|
||||
:start {:type 'Int}
|
||||
:per_page {:type 'Int}
|
||||
:sort {:type '(list :sort_item)}}
|
||||
:resolve :get-sales-order-page}})
|
||||
|
||||
(def mutations
|
||||
{})
|
||||
|
||||
(def input-objects
|
||||
{})
|
||||
|
||||
(def enums
|
||||
{})
|
||||
|
||||
(def resolvers
|
||||
{:get-all-sales-orders get-all-sales-orders
|
||||
:get-sales-order-page get-sales-orders-page
|
||||
})
|
||||
|
||||
(defn attach [schema]
|
||||
(->
|
||||
(merge-with merge schema
|
||||
{:objects objects
|
||||
:queries queries
|
||||
:mutations mutations
|
||||
:input-objects input-objects
|
||||
:enums enums})
|
||||
(attach-resolvers resolvers)))
|
||||
|
||||
Reference in New Issue
Block a user