(ns auto-ap.graphql.expected-deposit
  (:require [auto-ap.datomic.expected-deposit :as d-expected-deposit]
            [auto-ap.graphql.utils
             :refer
             [->graphql <-graphql assert-admin result->page]]))

(defn get-expected-deposit [context args value]
  (let [args (assoc args :id (:id context))
        [sales-orders sales-orders-count] (d-expected-deposit/get-graphql  (<-graphql args))]
    (result->page sales-orders sales-orders-count :data args )))

(defn get-all-expected-deposits [context args value]
  (assert-admin (:id context))
  (map
   ->graphql
   (first (d-expected-deposit/get-graphql (assoc (<-graphql args) :count Integer/MAX_VALUE)))))

(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))]
    (result->page expected-deposits expected-deposit-count :expected_deposits args )))
