added suggestions
This commit is contained in:
@@ -7,8 +7,7 @@
|
||||
:refer [->graphql assert-admin can-see-client? is-admin?]]
|
||||
[auto-ap.routes.queries :as q]
|
||||
[auto-ap.square.core :as square]
|
||||
[auto-ap.utils :refer [by heartbeat]]
|
||||
[auto-ap.yodlee.core :refer [in-memory-cache]]
|
||||
[auto-ap.utils :refer [heartbeat]]
|
||||
[clj-time.coerce :as coerce]
|
||||
[clojure.java.io :as io]
|
||||
[clojure.string :as str]
|
||||
@@ -253,6 +252,7 @@
|
||||
(catch Exception e
|
||||
(log/error "Can't refresh current balance" e)))))
|
||||
|
||||
#_{:clj-kondo/ignore [:clojure-lsp/unused-public-var]}
|
||||
(defn refresh-all-current-balance []
|
||||
(lc/with-context {:source "current-balance-cache"}
|
||||
(build-current-balance (->> (d/query {:query {:find ['?ba]
|
||||
@@ -285,9 +285,7 @@
|
||||
(update c :client/bank-accounts
|
||||
(fn [bank-accounts]
|
||||
(mapv (fn [ba]
|
||||
;; TODO remove when new yodlee replaces
|
||||
(assoc ba :bank-account/yodlee-balance-old (get-in (by :id (mapcat :accounts @in-memory-cache) )
|
||||
[(:bank-account/yodlee-account-id ba) :balance :amount])))
|
||||
(assoc ba :bank-account/yodlee-balance-old nil))
|
||||
bank-accounts))))))))
|
||||
|
||||
|
||||
|
||||
@@ -7,11 +7,6 @@
|
||||
|
||||
(def status->graphql (ident->enum-f :expected-deposit/status))
|
||||
|
||||
(defn get-expected-deposit [context args _]
|
||||
(let [args (assoc args :id (:id context))
|
||||
[sales-orders sales-orders-count] (d-expected-deposit/get-graphql (<-graphql args))]
|
||||
(result->page sales-orders sales-orders-count :data args)))
|
||||
|
||||
(defn get-all-expected-deposits [context args _]
|
||||
(assert-admin (:id context))
|
||||
(map
|
||||
|
||||
@@ -42,37 +42,6 @@
|
||||
journal-entries)]
|
||||
(result->page journal-entries journal-entries-count :journal_entries (:filters args))))
|
||||
|
||||
;; TODO a better way to do this might be to accumulate ALL credits and ALL debits, and then just do for credits: balance = credits - debits. and for debits balance = debits - credits
|
||||
(defn credit-account? [account]
|
||||
(or
|
||||
(#{:account-type/liability
|
||||
:account-type/equity
|
||||
:account-type/revenue}
|
||||
(:db/ident (:account/type account)))
|
||||
(#{:bank-account-type/credit}
|
||||
(-> account :bank-account/type :db/ident ))))
|
||||
|
||||
(defn debit-account? [account]
|
||||
|
||||
(or (#{:account-type/asset
|
||||
:account-type/dividend
|
||||
:account-type/expense}
|
||||
(:db/ident (:account/type account)))
|
||||
(#{:bank-account-type/check :bank-account-type/cash}
|
||||
(-> account :bank-account/type :db/ident ))))
|
||||
|
||||
(defn expense-account? [account]
|
||||
(= :account-type/expense (:db/ident (:account/type account))))
|
||||
|
||||
(defn account-name [account client]
|
||||
(let [overriden-name (->>
|
||||
(:account/client-overrides account)
|
||||
(filter (fn [co]
|
||||
(= (:db/id (:account-client-override/client co)) (:db/id client))))
|
||||
(map :account-client-override/name)
|
||||
first)]
|
||||
|
||||
(or overriden-name (:account/name account))))
|
||||
|
||||
(defn roll-up-until
|
||||
([lookup-account all-ledger-entries end-date]
|
||||
@@ -527,6 +496,7 @@
|
||||
(build-running-balance-cache))
|
||||
|
||||
|
||||
#_{:clj-kondo/ignore [:clojure-lsp/unused-public-var]}
|
||||
(mount/defstate running-balance-cache-worker
|
||||
:start (scheduler/every (* 15 60 1000) (heartbeat refresh-running-balance-cache "running-balance-cache"))
|
||||
:stop (scheduler/stop running-balance-cache-worker))
|
||||
|
||||
@@ -105,9 +105,6 @@
|
||||
((ident->enum-f :transaction-rule/transaction-approval-status))
|
||||
(->graphql))))
|
||||
|
||||
(defn tr [z x]
|
||||
(re-find (re-pattern z) x))
|
||||
|
||||
(defn -test-transaction-rule [id {:keys [:transaction-rule/description :transaction-rule/client :transaction-rule/bank-account :transaction-rule/amount-lte :transaction-rule/amount-gte :transaction-rule/dom-lte :transaction-rule/dom-gte :transaction-rule/yodlee-merchant]} include-coded? count]
|
||||
(->>
|
||||
(d/query
|
||||
|
||||
@@ -119,6 +119,7 @@
|
||||
(>= (compare locked-until (coerce/to-date date)) 0))
|
||||
(assert-failure (str "Integreat has locked finances prior to " (-> locked-until coerce/to-date-time (atime/unparse-local atime/normal-date)) ".")))))
|
||||
|
||||
#_{:clj-kondo/ignore [:clojure-lsp/unused-public-var]}
|
||||
(defn assert-none-locked [client-id dates]
|
||||
(doseq [d dates]
|
||||
(assert-not-locked client-id d)))
|
||||
|
||||
Reference in New Issue
Block a user