lots of fixes.

This commit is contained in:
Bryce Covert
2020-09-08 18:00:07 -07:00
parent 74e34e3592
commit 179c2d13c6
6 changed files with 182 additions and 41 deletions

View File

@@ -14,7 +14,9 @@
[compojure.core :refer [GET POST context defroutes wrap-routes]]
[clojure.string :as str]
[venia.core :as venia]
[clojure.tools.logging :as log]))
[clojure.tools.logging :as log]
[clj-time.core :as time]
[clj-time.coerce :as coerce]))
(defroutes routes
(wrap-routes
@@ -61,12 +63,37 @@
:total
:tip
:tax
:discount
:date
[:charges [:type_name :total :tip]]
[:line_items [:item_name :total :tax]]
[:line_items [:item_name :total :tax :discount :category]]
[:client [:id :name :code]]]]]
payments (graphql/query identity (venia/graphql-query {:venia/queries (->graphql query)}))]
(seq (:all-sales-orders (:data payments)))))
payments (graphql/query identity (venia/graphql-query {:venia/queries (->graphql query)}))
parsedouble #(some-> % Double/parseDouble) ]
(seq (map
(fn [s]
(-> s
(assoc :utc_date (:date s))
(update :date (fn [d]
(coerce/to-string (coerce/to-local-date-time (time/to-time-zone (coerce/to-date-time d) (time/time-zone-for-id "America/Los_Angeles"))))))
(update :total parsedouble)
(update :tax parsedouble)
(update :tip parsedouble)
(update :line-items (fn [lis]
(map
(fn [li]
(-> li
(update :tax parsedouble)
(update :total parsedouble)))
lis)))
(update :charges (fn [charges]
(map
(fn [charge]
(-> charge
(update :tip parsedouble)
(update :total parsedouble)))
charges)))))
(:all-sales-orders (:data payments))))))
(GET "/expected-deposit/export" {:keys [query-params identity]}
(assert-admin identity)
@@ -82,7 +109,12 @@
:fee
:date]]]
payments (graphql/query identity (venia/graphql-query {:venia/queries (->graphql query)}))]
(seq (:all-expected-deposits (:data payments)))))
(seq (map
(fn [d]
(-> d
(update :fee #(some-> % Double/parseDouble))
(update :total #(some-> % Double/parseDouble))))
(:all-expected-deposits (:data payments))))))
(GET "/clients/export" {:keys [query-params identity]}
(assert-admin identity)