From 477654a8aed6b1cf3021aaed18ae608b40aed212 Mon Sep 17 00:00:00 2001 From: Bryce Covert Date: Wed, 9 Sep 2020 22:51:17 -0700 Subject: [PATCH] sales fixes. --- src/clj/auto_ap/routes/exports.clj | 2 ++ src/clj/auto_ap/square/core.clj | 11 +++++++---- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/clj/auto_ap/routes/exports.clj b/src/clj/auto_ap/routes/exports.clj index 8d41d215..dd30b7b6 100644 --- a/src/clj/auto_ap/routes/exports.clj +++ b/src/clj/auto_ap/routes/exports.clj @@ -78,12 +78,14 @@ (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 :discount parsedouble) (update :tip parsedouble) (update :line-items (fn [lis] (map (fn [li] (-> li (update :tax parsedouble) + (update :discount parsedouble) (update :total parsedouble))) lis))) (update :charges (fn [charges] diff --git a/src/clj/auto_ap/square/core.clj b/src/clj/auto_ap/square/core.clj index 106c0545..5f414eda 100644 --- a/src/clj/auto_ap/square/core.clj +++ b/src/clj/auto_ap/square/core.clj @@ -140,10 +140,13 @@ :client [:client/code client] :location loc :external-id (str "square/order/" client "-" loc "-" (:id order)) - :total (-> order :net_amounts :total_money amount->money) - :tax (-> order :net_amounts :tax_money amount->money) - :tip (-> order :net_amounts :tip_money amount->money) - :discount (-> order :net_amounts :discount_money amount->money) + :total (- (-> order :total_money amount->money) + (or (some-> order :return_amounts :total_money amount->money) 0.0)) + :tax (- (-> order :total_tax_money amount->money) + (or (some-> order :return_amounts :tax_money amount->money) 0.0)) + :tip (- (-> order :net_amounts :tip_money amount->money) + (or (some-> order :return_amounts :tip_money amount->money) 0.0)) + :discount (-> order :total_discount_money amount->money) :charges (->> (:tenders order) (map (fn [t] (remove-nils