exports work

This commit is contained in:
BC
2018-06-21 22:43:22 -07:00
parent be139abb5d
commit fc411909aa
5 changed files with 49 additions and 10 deletions

View File

@@ -68,7 +68,7 @@
:plugins [[lein-figwheel "0.5.13"]
[lein-pdo "0.1.1"]
[cider/cider-nrepl "0.16.0"]]
:jvm-opts ["-Dconfig=config/dev.edn" #_#_"--add-modules" "java.xml.bind"]}
:jvm-opts ["-Dconfig=config/dev.edn" "--add-modules" "java.xml.bind"]}
:uberjar {:prep-tasks [["cljsbuild" "once" "min"] "compile"]}
:provided {:dependencies [[org.clojure/clojurescript "1.10.238"]
[reagent "0.7.0"]

View File

@@ -114,11 +114,11 @@
(not (nil? status)) (helpers/merge-where [:= :status status])
(not (nil? company-id)) (helpers/merge-where [:= :company-id company-id])))
(defn get-graphql [{:keys [start sort-by asc] :as args}]
(defn get-graphql [{:keys [start sort-by asc limit] :as args :or {limit 20}}]
(query
(cond-> (base-graphql args)
(not (nil? sort-by) ) (add-sort-by sort-by asc)
true (assoc :limit 20)
true (assoc :limit limit)
start (assoc :offset start))))
(defn count-graphql [args]

View File

@@ -8,6 +8,7 @@
[auto-ap.routes.vendors :as vendors]
[auto-ap.routes.events :as events]
[auto-ap.routes.checks :as checks]
[auto-ap.routes.exports :as exports]
[auto-ap.db.utils :as u]
[buddy.auth.backends.token :refer [jws-backend]]
[buddy.auth.middleware :refer [wrap-authentication
@@ -31,6 +32,7 @@
(defroutes api-routes
(context "/api" []
exports/routes
invoices/routes
companies/routes
vendors/routes

View File

@@ -0,0 +1,41 @@
(ns auto-ap.routes.exports
(:require
[auto-ap.db.invoices :as invoices]
[auto-ap.db.checks :as checks]
[auto-ap.db.transactions :as transactions]
[auto-ap.db.utils :refer [query]]
[auto-ap.utils :refer [by]]
[auto-ap.parse :as parse]
[auto-ap.routes.utils :refer [wrap-secure]]
[clj-time.coerce :refer [to-date]]
[auto-ap.db.invoices-expense-accounts :as expense-accounts]
[ring.middleware.json :refer [wrap-json-response]]
[compojure.core :refer [GET POST context defroutes wrap-routes]]
[clojure.string :as str]))
(defroutes routes
(wrap-routes
(wrap-routes
(context "/" []
(GET "/invoices/export" {:keys [query-params]}
(let [invoices (invoices/get-graphql {:company (query-params "company")})]
(map (fn [i]
(update i :date to-date))
invoices)))
(GET "/checks/export" {:keys [query-params]}
(let [checks (checks/get-graphql {:company (query-params "company")})]
(map (fn [i]
(update i :date to-date))
checks)))
(GET "/transactions/export" {:keys [query-params]}
(let [transactions (transactions/get-graphql {:company (query-params "company")})]
(println transactions)
(map (fn [i]
(-> i
(update :date to-date)
(update :post-date to-date)))
transactions))))
wrap-secure)
wrap-json-response))

View File

@@ -6,7 +6,9 @@
[auto-ap.utils :refer [by]]
[auto-ap.parse :as parse]
[auto-ap.routes.utils :refer [wrap-secure]]
[clj-time.coerce :refer [to-date]]
[auto-ap.db.invoices-expense-accounts :as expense-accounts]
[ring.middleware.json :refer [wrap-json-response]]
[compojure.core :refer [GET POST context defroutes
wrap-routes]]
[clojure.string :as str]))
@@ -150,11 +152,5 @@
:already-imported already-imported-count
:vendors-not-found vendors-not-found
:errors (map #(dissoc % :date) error-rows)})
:headers {"Content-Type" "application/edn"}}))
;; Removing the export view for now...
#_(wrap-json-response (GET "/export" {:keys [query-params]}
(println query-params)
(doto (invoices/get-unpaid (query-params "company"))
println))))
:headers {"Content-Type" "application/edn"}})))
wrap-secure))