Fixed UI bug with transactions unable to autochoose accounts, added new locations
This commit is contained in:
@@ -152,7 +152,8 @@
|
|||||||
"LQTHXQY69MYB6" ["NGDG" "DB"]
|
"LQTHXQY69MYB6" ["NGDG" "DB"]
|
||||||
"L7S9MXZBJ00HY" ["NGGG" "LM"]
|
"L7S9MXZBJ00HY" ["NGGG" "LM"]
|
||||||
"LRC7WVD77ZM81" ["NGLK" "SM"]
|
"LRC7WVD77ZM81" ["NGLK" "SM"]
|
||||||
"FZ3ZYC77T3W1T" ["NGA1" "KA"]} location))
|
"FZ3ZYC77T3W1T" ["NGA1" "KA"]
|
||||||
|
"LG5X0MHA4NZDM" ["NGSM" "SM"]} location))
|
||||||
|
|
||||||
;; to get totals:
|
;; to get totals:
|
||||||
(comment
|
(comment
|
||||||
@@ -262,10 +263,12 @@
|
|||||||
(recur xs (conj result n))
|
(recur xs (conj result n))
|
||||||
(conj result n))))))
|
(conj result n))))))
|
||||||
|
|
||||||
(defn daily-settlements []
|
(defn daily-settlements
|
||||||
(->> (locations)
|
([] (daily-settlements (->> (locations)
|
||||||
(map :id)
|
(map :id)
|
||||||
(filter location_id->client-location)
|
(filter location_id->client-location))))
|
||||||
|
([location-ids]
|
||||||
|
(->> location-ids
|
||||||
(mapcat (fn [l]
|
(mapcat (fn [l]
|
||||||
(for [settlement (settlements l)
|
(for [settlement (settlements l)
|
||||||
:let [[client loc] (location_id->client-location l)]]
|
:let [[client loc] (location_id->client-location l)]]
|
||||||
@@ -273,13 +276,15 @@
|
|||||||
:total (amount->money (:total_money settlement))
|
:total (amount->money (:total_money settlement))
|
||||||
:client [:client/code client]
|
:client [:client/code client]
|
||||||
:location loc
|
:location loc
|
||||||
:fee (- (reduce + 0 (map (fn [entry]
|
:fee (- (reduce + 0.0 (map (fn [entry]
|
||||||
(if (= (:type entry) "REFUND")
|
(if (= (:type entry) "REFUND")
|
||||||
(- (amount->money (:fee_money entry)))
|
(- (amount->money (:fee_money entry)))
|
||||||
(amount->money (:fee_money entry))))
|
(amount->money (:fee_money entry))))
|
||||||
(:entries settlement))))
|
(:entries settlement))))
|
||||||
:date (-> (:initiated_at settlement)
|
:date (-> (:initiated_at settlement)
|
||||||
(coerce/to-date))})))))
|
(coerce/to-date))})))
|
||||||
|
(filter :expected-deposit/date)))
|
||||||
|
)
|
||||||
|
|
||||||
(defn refunds [l]
|
(defn refunds [l]
|
||||||
(let [refunds (:refunds (:body (client/get (str "https://connect.squareup.com/v2/refunds?location_id=" l)
|
(let [refunds (:refunds (:body (client/get (str "https://connect.squareup.com/v2/refunds?location_id=" l)
|
||||||
@@ -328,7 +333,9 @@
|
|||||||
(catch Exception e
|
(catch Exception e
|
||||||
(log/error e))))))
|
(log/error e))))))
|
||||||
|
|
||||||
(defn upsert-settlements []
|
(defn upsert-settlements
|
||||||
|
([] (upsert-settlements nil))
|
||||||
|
([location-ids]
|
||||||
(lc/with-context {:source "Square settlements loading "}
|
(lc/with-context {:source "Square settlements loading "}
|
||||||
(try
|
(try
|
||||||
(let [existing (->> (d/query {:query {:find ['?external-id]
|
(let [existing (->> (d/query {:query {:find ['?external-id]
|
||||||
@@ -339,13 +346,15 @@
|
|||||||
set)
|
set)
|
||||||
_ (log/info (count existing) "settlements already exist")
|
_ (log/info (count existing) "settlements already exist")
|
||||||
to-create (filter #(not (existing (:expected-deposit/external-id %)))
|
to-create (filter #(not (existing (:expected-deposit/external-id %)))
|
||||||
(daily-settlements))]
|
(if location-ids
|
||||||
|
(daily-settlements location-ids)
|
||||||
|
(daily-settlements)))]
|
||||||
(doseq [x (partition-all 20 to-create)]
|
(doseq [x (partition-all 20 to-create)]
|
||||||
(log/info "Loading expected deposit" (count x))
|
(log/info "Loading expected deposit" (count x))
|
||||||
@(d/transact conn x)))
|
@(d/transact conn x)))
|
||||||
(catch Exception e
|
(catch Exception e
|
||||||
(log/error e)))
|
(log/error e)))
|
||||||
(log/info "Done loading settlements")))
|
(log/info "Done loading settlements"))))
|
||||||
|
|
||||||
(defn upsert-refunds []
|
(defn upsert-refunds []
|
||||||
(doseq [{location :id} (locations)]
|
(doseq [{location :id} (locations)]
|
||||||
|
|||||||
@@ -80,7 +80,7 @@
|
|||||||
value
|
value
|
||||||
(expense-accounts-field/can-replace-with-default? (:accounts data)))
|
(expense-accounts-field/can-replace-with-default? (:accounts data)))
|
||||||
[[:accounts] (expense-accounts-field/default-account (:accounts data)
|
[[:accounts] (expense-accounts-field/default-account (:accounts data)
|
||||||
@(re-frame/subscribe [::subs/vendor-default-account value (:client data)])
|
@(re-frame/subscribe [::subs/vendor-default-account (:id value) (:client data)])
|
||||||
(:amount data)
|
(:amount data)
|
||||||
locations)]
|
locations)]
|
||||||
[])))))
|
[])))))
|
||||||
@@ -414,6 +414,7 @@
|
|||||||
:field [:vendor]
|
:field [:vendor]
|
||||||
:disabled (or (boolean (:payment data))
|
:disabled (or (boolean (:payment data))
|
||||||
should-disable-for-client?)}])
|
should-disable-for-client?)}])
|
||||||
|
(with-meta
|
||||||
(field nil
|
(field nil
|
||||||
[expense-accounts-field
|
[expense-accounts-field
|
||||||
{:type "expense-accounts"
|
{:type "expense-accounts"
|
||||||
@@ -423,6 +424,10 @@
|
|||||||
:disabled (or (boolean (:payment data))
|
:disabled (or (boolean (:payment data))
|
||||||
should-disable-for-client?)
|
should-disable-for-client?)
|
||||||
:locations locations}])
|
:locations locations}])
|
||||||
|
{:key (str (:id (:vendor data)))})
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user