make it possible to revert yodlee account id.

This commit is contained in:
Bryce Covert
2020-12-15 08:39:51 -08:00
parent d7e99205fc
commit c2407a73c6
3 changed files with 72 additions and 52 deletions

View File

@@ -26,7 +26,11 @@
(mapv (fn [lm] [:db/retractEntity (:db/id lm)]) (:client/location-matches client))
(mapv (fn [m] [:db/retract (:db/id client) :client/matches m]) (:client/matches client)))
(:id context)))
transactions [(remove-nils {:db/id id
reverts (->> (:bank_accounts edit_client)
(filter #(nil? (:yodlee_account_id %)))
(filter #(:bank-account/yodlee-account-id (d/entity (d/db conn) (:id %))))
(map (fn [ba] [:db/retract (:id ba) :bank-account/yodlee-account-id (:bank-account/yodlee-account-id (d/entity (d/db conn) (:id ba)))])))
transactions (into [(remove-nils {:db/id id
:client/code (if (str/blank? (:client/code client))
(:code edit_client)
(:client/code client))
@@ -79,6 +83,7 @@
:forecasted-transaction/amount (:amount %)}
)
(:forecasted_transactions edit_client))]]
reverts)
_ (log/info "upserting client" transactions)
result (audit-transact transactions (:id context))]
(-> result :tempids (get id) (or id) d-clients/get-by-id

View File

@@ -103,7 +103,7 @@
{:headers {"Square-Version" "2020-08-12"
"Authorization" "Bearer EAAAEO2xSqesDutZz71hz3eulKmrlKTiEqG3uZ4j25x5GYlOluQ2cj2JxNUXqXD7"
"Content-Type" "application/json"}
:body (json/write-str (cond-> {"location_ids" [l] "limit" 4000}
:body (json/write-str (cond-> {"location_ids" [l] "limit" 10000}
d (merge (pc d))))
:as :json})
:body
@@ -127,6 +127,20 @@
"4X8T65741AEPS" ["NGVZ" "NP"]
"KMVFQ9CRCXJ10" ["NGZO" "VT"]} location))
;; to get totals:
(comment
(reduce
(fn [total i]
(+ total (+ (- (:sales-order/total i)
(:sales-order/tax i)
(:sales-order/tip i)
(:sales-order/service-charge i))
(:sales-order/returns i)
(:sales-order/discount i)
)))
0.0))
(defn daily-results [d]
(->> (locations)
(map :id)

View File

@@ -8,7 +8,8 @@
[cljs-time.coerce :as coerce]
[cljs-time.core :as t]
[clojure.spec.alpha :as s]
[re-frame.core :as re-frame]))
[re-frame.core :as re-frame]
[clojure.string :as str]))
(re-frame/reg-sub
::can-submit
@@ -63,7 +64,7 @@
:sort-order sort-order
:visible visible
:locations (mapv :location locations)
:yodlee-account-id (when yodlee-account-id
:yodlee-account-id (when-not (str/blank? yodlee-account-id)
(js/parseInt yodlee-account-id))
:code (if new?
(str (:code new-client-data) "-" code)