diff --git a/src/clj/auto_ap/background/metrics.clj b/src/clj/auto_ap/background/metrics.clj index 12f42e5b..75a33cf2 100644 --- a/src/clj/auto_ap/background/metrics.clj +++ b/src/clj/auto_ap/background/metrics.clj @@ -41,10 +41,12 @@ (lc/pull-context "container") (lc/pull-context "ip"))) +#_{:clj-kondo/ignore [:clojure-lsp/unused-public-var]} (mount/defstate logging-context :start (set-logging-context) :stop (stop-logging-context)) +#_{:clj-kondo/ignore [:clojure-lsp/unused-public-var]} (mount/defstate metrics-setup :start (statsd/setup! :host "127.0.0.1" :port 8125 :prefix "integreat.app" :tags (into #{(str "env:" (:dd-env env)) (str "service:" (:dd-service env))} diff --git a/src/clj/auto_ap/background/requests.clj b/src/clj/auto_ap/background/requests.clj index 6a0f85e2..7625cfe7 100644 --- a/src/clj/auto_ap/background/requests.clj +++ b/src/clj/auto_ap/background/requests.clj @@ -30,6 +30,7 @@ (= ":plaid" body) (p/import-plaid))))) +#_{:clj-kondo/ignore [:clojure-lsp/unused-public-var]} (defn fake-message [] (sqs/send-message {:queue-url (:requests-queue-url env) :message-body ":intuit"} )) diff --git a/src/clj/auto_ap/background/sysco.clj b/src/clj/auto_ap/background/sysco.clj index f9734c16..47289bac 100644 --- a/src/clj/auto_ap/background/sysco.clj +++ b/src/clj/auto_ap/background/sysco.clj @@ -100,6 +100,7 @@ (s3/delete-object {:bucket-name bucket-name :key k})) +#_{:clj-kondo/ignore [:clojure-lsp/unused-public-var]} (defn unmark-key [k] (s3/copy-object {:source-bucket-name bucket-name :destination-bucket-name bucket-name diff --git a/src/clj/auto_ap/datomic.clj b/src/clj/auto_ap/datomic.clj index c6aaa097..8f957c7a 100644 --- a/src/clj/auto_ap/datomic.clj +++ b/src/clj/auto_ap/datomic.clj @@ -14,9 +14,11 @@ #_(def uri "datomic:mem://datomic-transactor:4334/invoice") +#_{:clj-kondo/ignore [:clojure-lsp/unused-public-var]} (defn create-database [] (d/create-database uri)) +#_{:clj-kondo/ignore [:clojure-lsp/unused-public-var]} (defn drop-database [] (d/delete-database uri)) @@ -535,70 +537,35 @@ [ address-schema contact-schema vendor-schema client-schema bank-account-schema invoice-schema invoice-expense-account-schema payment-schema invoice-payment-schema transaction-schema user-schema]) - -(defn query-entities [] - (d/q '[:find (pull ?e [:vendor/name]) - :where [?e :vendor/name]] - (d/db (d/connect uri)))) - - - -(defn query-vendors [] - (d/q '[:find (pull ?e [*]) - :where [?e :vendor/original-id]] - (d/db (d/connect uri)))) -(defn query-clients [] - (d/q '[:find (pull ?e [*]) - :where [?e :client/original-id]] - (d/db (d/connect uri)))) - -(defn query-invoices [] - (d/q '[:find (pull ?e [* {:invoice/vendor [*] - :invoice/expense-accounts [*]}]) - :where [?e :invoice/original-id]] - (d/db (d/connect uri)))) - -(defn query-payments [] - (d/q '[:find (pull ?e [* {:invoice-payment/_payment [* {:invoice-payment/invoice [*]}]}]) - :where [?e :payment/original-id]] - (d/db (d/connect uri)))) - -(defn query-check-payments [] - (d/q '[:find (pull ?e [* {:invoice-payment/payment [*]}]) - :where [?e :invoice-payment/original-id]] - (d/db (d/connect uri)))) - -(defn query-transactions [] - (d/q '[:find (pull ?e [*]) - :where [?e :transaction/original-id]] - (d/db (d/connect uri)))) - -(defn query-users [] - (d/q '[:find (pull ?e [*]) - :where [?e :user/original-id]] - (d/db (d/connect uri)))) - +#_{:clj-kondo/ignore [:clojure-lsp/unused-public-var]} (defn migrate-vendors [_] [[]]) +#_{:clj-kondo/ignore [:clojure-lsp/unused-public-var]} (defn migrate-clients [_] [[]]) +#_{:clj-kondo/ignore [:clojure-lsp/unused-public-var]} (defn migrate-invoices [_] [[]]) +#_{:clj-kondo/ignore [:clojure-lsp/unused-public-var]} (defn migrate-payments [_] [[]]) +#_{:clj-kondo/ignore [:clojure-lsp/unused-public-var]} (defn migrate-invoices-payments [_] [[]]) +#_{:clj-kondo/ignore [:clojure-lsp/unused-public-var]} (defn migrate-invoices-expense-accounts [_] [[]]) +#_{:clj-kondo/ignore [:clojure-lsp/unused-public-var]} (defn migrate-transactions [_] [[]]) +#_{:clj-kondo/ignore [:clojure-lsp/unused-public-var]} (defn migrate-users [_] [[]]) diff --git a/src/clj/auto_ap/datomic/clients.clj b/src/clj/auto_ap/datomic/clients.clj index 8d281ed4..b899f28c 100644 --- a/src/clj/auto_ap/datomic/clients.clj +++ b/src/clj/auto_ap/datomic/clients.clj @@ -85,12 +85,3 @@ :args [(d/db (d/connect uri)) code]})) (first) (first))) - -(defn assoc-image [code image] - @(d/transact (d/connect uri) - [{ :client/code code - :client/signature-file (str "https://s3.amazonaws.com/integreat-signature-images/" image)}])) - - -#_(d/pull (d/db (d/connect uri)) '[*] [:client/code "FTLO"]) -#_(assoc-image "FTLO" "Fratello.jpg" ) diff --git a/src/clj/auto_ap/datomic/expected_deposit.clj b/src/clj/auto_ap/datomic/expected_deposit.clj index 8d50ac71..8518060b 100644 --- a/src/clj/auto_ap/datomic/expected_deposit.clj +++ b/src/clj/auto_ap/datomic/expected_deposit.clj @@ -124,8 +124,3 @@ [(->> (graphql-results ids-to-retrieve db args)) matching-count])) - -(defn get-by-id [id] - (->> - (d/pull (d/db conn) default-read id) - (<-datomic))) diff --git a/src/clj/auto_ap/datomic/ledger.clj b/src/clj/auto_ap/datomic/ledger.clj index fb0f2da9..894df445 100644 --- a/src/clj/auto_ap/datomic/ledger.clj +++ b/src/clj/auto_ap/datomic/ledger.clj @@ -5,52 +5,17 @@ [clj-time.coerce :as c] [auto-ap.datomic.accounts :as d-accounts])) -(def export-read - [:journal-entry/external-id - :journal-entry/cleared - :journal-entry/alternate-description - :journal-entry/date - :journal-entry/note - :journal-entry/amount - :journal-entry/source - :journal-entry/cleared-against - :journal-entry/original-entity - {:journal-entry/client [:client/name :client/code :db/id] - :journal-entry/vendor [:vendor/name :db/id] - :journal-entry/line-items [:journal-entry-line/location - :journal-entry-line/debit - :journal-entry-line/credit - {:journal-entry-line/account [:bank-account/include-in-reports - :bank-account/bank-name - :bank-account/code - :bank-account/visible - :bank-account/name - :bank-account/number - :account/code - :account/name - :account/numeric-code - :account/location - {:account/client-overrides [:account-client-override/name - {:account-client-override/client [:db/id]}]} - {:account/type [:db/ident :db/id]} - {:bank-account/type [:db/ident :db/id]}]}]}]) - (defn raw-graphql-ids [db args] (let [query (cond-> {:query {:find [] :in ['$ ] :where []} :args [db]} - (:client-id args) (merge-query {:query {:in ['?client-id] :where ['[?e :journal-entry/client ?client-id]]} :args [(:client-id args)]}) - - - - (:only-external args) (merge-query {:query {:where ['(not [?e :journal-entry/original-entity ])]}}) diff --git a/src/clj/auto_ap/datomic/migrate.clj b/src/clj/auto_ap/datomic/migrate.clj index 083aa41a..8f2f919d 100644 --- a/src/clj/auto_ap/datomic/migrate.clj +++ b/src/clj/auto_ap/datomic/migrate.clj @@ -23,12 +23,14 @@ (:import (datomic Util))) +#_{:clj-kondo/ignore [:clojure-lsp/unused-public-var]} (defn read-dtm "Reads a dtm file (i.e., an edn file with datomic tags in it) from the classpath and returns a vector of all forms contained within." [filename] (-> (io/resource filename) (io/reader) (Util/readAll))) +#_{:clj-kondo/ignore [:clojure-lsp/unused-public-var]} (defn functions [_] [[{:db/ident :pay :db/doc "Data function that increments value of attribute a by amount." @@ -47,6 +49,7 @@ :code [[:db/add e a (-> (d/entity db e) a (+ amount))]] })}]] ) +#_{:clj-kondo/ignore [:clojure-lsp/unused-public-var]} (defn fix-pay-function [_] [[{:db/ident :pay :db/doc "Data function that increments value of attribute a by amount." diff --git a/src/clj/auto_ap/datomic/migrate/account_sorting.clj b/src/clj/auto_ap/datomic/migrate/account_sorting.clj index 90d0bd18..f9377339 100644 --- a/src/clj/auto_ap/datomic/migrate/account_sorting.clj +++ b/src/clj/auto_ap/datomic/migrate/account_sorting.clj @@ -2,6 +2,7 @@ (:require [datomic.api :as d])) +#_{:clj-kondo/ignore [:clojure-lsp/unused-public-var]} (defn add-account-visibility-fields [_] [[ {:db/ident :bank-account/visible @@ -13,6 +14,7 @@ :db/cardinality :db.cardinality/one :db/doc "The sort order of the bank account"}]]) +#_{:clj-kondo/ignore [:clojure-lsp/unused-public-var]} (defn make-every-account-visible [conn] (let [all-account-ids (d/query {:query {:find ['?e] diff --git a/src/clj/auto_ap/datomic/migrate/add_bank_account_codes.clj b/src/clj/auto_ap/datomic/migrate/add_bank_account_codes.clj index 81800ff0..c14207f8 100644 --- a/src/clj/auto_ap/datomic/migrate/add_bank_account_codes.clj +++ b/src/clj/auto_ap/datomic/migrate/add_bank_account_codes.clj @@ -3,6 +3,7 @@ [clojure.string :as str] [datomic.api :as d])) +#_{:clj-kondo/ignore [:clojure-lsp/unused-public-var]} (defn add-bank-account-codes-schema [_] [[{:db/ident :bank-account/code :db/valueType :db.type/string @@ -11,6 +12,7 @@ :db/doc "A bank account's computer-friendly name"}]]) +#_{:clj-kondo/ignore [:clojure-lsp/unused-public-var]} (defn add-bank-account-codes [conn] (let [db (d/db conn) all-bank-accounts (d/query {:query {:find ['?b '?original-id '?client-code] diff --git a/src/clj/auto_ap/datomic/migrate/add_client_codes.clj b/src/clj/auto_ap/datomic/migrate/add_client_codes.clj index 3fa774e6..4448a5b7 100644 --- a/src/clj/auto_ap/datomic/migrate/add_client_codes.clj +++ b/src/clj/auto_ap/datomic/migrate/add_client_codes.clj @@ -33,6 +33,7 @@ ["Iguanas Burritozilla" "IBC"]] (into {})) ) +#_{:clj-kondo/ignore [:clojure-lsp/unused-public-var]} (defn add-client-codes [a] [(->> (d/query {:query {:find '[?name ?e] :in ['$] diff --git a/src/clj/auto_ap/datomic/migrate/add_general_ledger.clj b/src/clj/auto_ap/datomic/migrate/add_general_ledger.clj index 114ecd5a..5f8dee4a 100644 --- a/src/clj/auto_ap/datomic/migrate/add_general_ledger.clj +++ b/src/clj/auto_ap/datomic/migrate/add_general_ledger.clj @@ -1,25 +1,10 @@ (ns auto-ap.datomic.migrate.add-general-ledger - (:require [datomic.api :as d] - [auto-ap.datomic :refer [remove-nils]] - [auto-ap.datomic.accounts :as accounts] - [auto-ap.expense-accounts :as expense-accounts] - [auto-ap.ledger :as ledger] - [auto-ap.utils :refer [by]] - [clojure.java.io :as io] - [clojure.string :as str]) - (:import [org.apache.commons.io.input BOMInputStream])) - -(defn test-run [txs-set] - #_(println "processing " (count txs-set)) - (doseq [[i tx] (map vector (range) txs-set)] - @(d/transact (d/connect auto-ap.datomic/uri) - tx) - (when (= 0 (mod i 100)) - (println "processed " i) - (println "sample: " (first tx)) - ))) - - + (:require + [auto-ap.datomic :refer [remove-nils]] + [auto-ap.datomic.accounts :as accounts] + [auto-ap.expense-accounts :as expense-accounts] + [auto-ap.ledger :as ledger] + [datomic.api :as d])) (def add-general-ledger [[{:db/ident :journal-entry/source @@ -195,7 +180,8 @@ :account/location location :account/account-set "default"}))))]) -(defn add-general-ledger-fns [conn] +#_{:clj-kondo/ignore [:clojure-lsp/unused-public-var]} +(defn add-general-ledger-fns [_] [[{:db/ident :replace-general-ledger :db/doc "Deletes the general ledger entries for an entity" :db/fn (d/function '{:lang "clojure" @@ -208,6 +194,7 @@ (into [] (map (fn [i] [:db/retractEntity i ]) ids)))})}]] ) +#_{:clj-kondo/ignore [:clojure-lsp/unused-public-var]} (defn bulk-load-invoice-ledger [conn] (let [invoice-ids (map first (d/query {:query {:find '[?e] :in '[$] @@ -219,6 +206,7 @@ z)) +#_{:clj-kondo/ignore [:clojure-lsp/unused-public-var]} (defn bulk-load-transaction-ledger [conn] (let [transaction-ids (map first (d/query {:query {:find '[?e] :in '[$] @@ -258,6 +246,7 @@ :db/cardinality :db.cardinality/one :db/doc "The account will be used when a bill is created."}]]) +#_{:clj-kondo/ignore [:clojure-lsp/unused-public-var]} (defn convert-vendors [conn] (let [vendors (d/query {:query {:find '[?v ?expense-account-id] :in '[$] @@ -269,6 +258,7 @@ :vendor/default-account (accounts/get-account-by-numeric-code-and-sets expense-account-id ["default"])})) vendors)])) +#_{:clj-kondo/ignore [:clojure-lsp/unused-public-var]} (defn convert-invoices [conn] (let [invoice-expense-accounts (d/query {:query {:find '[?iea ?expense-account-id] :in '[$] @@ -280,7 +270,8 @@ :invoice-expense-account/account (accounts/get-account-by-numeric-code-and-sets expense-account-id ["default"])})) invoice-expense-accounts)])) -(defn convert-transactions [conn] +#_{:clj-kondo/ignore [:clojure-lsp/unused-public-var]} +(defn convert-transactions [_] (println "here") (let [matched-transactions (d/query {:query {:find '[?transaction ?v ?amount] :in '[$] @@ -442,34 +433,3 @@ {:db/id v :vendor/hidden false}) vendors))]) - - - -(defn reset-ledger [conn] - (let [results (->> (d/query {:query {:find '[?e] - :in '[$] - :where ['[?e :journal-entry/original-entity ]]} - :args [(d/db conn)]}) - (map (fn [[id]] - [:db/retractEntity id])) - (partition-all 100))] - results)) - -(defn reset-manual-ledger [conn] - (let [results (->> (d/query {:query {:find '[?e] - :in '[$] - :where ['[?e :journal-entry/external-id ]]} - :args [(d/db conn)]}) - (mapv (fn [[id]] - [:db/retractEntity id])) - (partition-all 100))] - results)) - - - - -#_(convert-accounts (d/connect auto-ap.datomic/uri)) - -#_(do (doseq [tran (convert-transactions (d/connect auto-ap.datomic/uri))] - @(d/transact (d/connect auto-ap.datomic/uri) tran)) - (println "done.")) diff --git a/src/clj/auto_ap/datomic/migrate/check_numbers.clj b/src/clj/auto_ap/datomic/migrate/check_numbers.clj index 04ed8e02..007296c8 100644 --- a/src/clj/auto_ap/datomic/migrate/check_numbers.clj +++ b/src/clj/auto_ap/datomic/migrate/check_numbers.clj @@ -1,6 +1,7 @@ (ns auto-ap.datomic.migrate.check-numbers (:require [datomic.api :as d])) +#_{:clj-kondo/ignore [:clojure-lsp/unused-public-var]} (defn fix-check-numbers [conn] (let [max-check-numbers (d/query {:query {:find '[?e ?check-number (max ?d)] :in ['$] :where ['[?e :bank-account/check-number ?check-number] '[?c :payment/bank-account ?e] '[?c :payment/check-number ?d]]} :args [(d/db conn)]})] [(for [[bank-account check-number max-check _] max-check-numbers diff --git a/src/clj/auto_ap/datomic/migrate/invoice_converter.clj b/src/clj/auto_ap/datomic/migrate/invoice_converter.clj index 462bf062..33cc94f9 100644 --- a/src/clj/auto_ap/datomic/migrate/invoice_converter.clj +++ b/src/clj/auto_ap/datomic/migrate/invoice_converter.clj @@ -23,6 +23,7 @@ :db/doc "The location of the location match"} ]]) +#_{:clj-kondo/ignore [:clojure-lsp/unused-public-var]} (defn add-starter [conn] (if (seq (d/query {:query {:find '[?e] :in ['$] @@ -34,12 +35,14 @@ :location-match/matches ["campbell brewing company"]}]}]] [[]])) +#_{:clj-kondo/ignore [:clojure-lsp/unused-public-var]} (defn add-default-location [_] [[{:db/ident :client/default-location :db/valueType :db.type/string :db/cardinality :db.cardinality/one :db/doc "The default location if one can't be found"}]]) +#_{:clj-kondo/ignore [:clojure-lsp/unused-public-var]} (defn add-default-location-2 [conn] (if (seq (d/query {:query {:find '[?e] :in ['$] @@ -58,6 +61,7 @@ {:db/ident :import-status/pending} {:db/ident :import-status/imported}]]) +#_{:clj-kondo/ignore [:clojure-lsp/unused-public-var]} (defn add-import-status-existing-invoices [conn] (let [existing-invoices (->> (d/query {:query {:find ['?e] :in ['$] diff --git a/src/clj/auto_ap/datomic/migrate/rename_codes.clj b/src/clj/auto_ap/datomic/migrate/rename_codes.clj index 3b91e3a0..e3a7c9a3 100644 --- a/src/clj/auto_ap/datomic/migrate/rename_codes.clj +++ b/src/clj/auto_ap/datomic/migrate/rename_codes.clj @@ -26,6 +26,7 @@ ) ) +#_{:clj-kondo/ignore [:clojure-lsp/unused-public-var]} (defn rename-codes-1 [_] (let [result (apply concat [(rename "WE" "WME" (d/connect uri)) (rename "HM" "HIM" (d/connect uri)) diff --git a/src/clj/auto_ap/datomic/sales_orders.clj b/src/clj/auto_ap/datomic/sales_orders.clj index 9f557304..ecfde7bc 100644 --- a/src/clj/auto_ap/datomic/sales_orders.clj +++ b/src/clj/auto_ap/datomic/sales_orders.clj @@ -127,7 +127,3 @@ matching-count (summarize-orders ids-to-retrieve)])) -(defn get-by-id [id] - (->> - (d/pull (d/db (d/connect uri)) default-read id) - (<-datomic))) diff --git a/src/clj/auto_ap/datomic/users.clj b/src/clj/auto_ap/datomic/users.clj index d403184a..c2ac8c4b 100644 --- a/src/clj/auto_ap/datomic/users.clj +++ b/src/clj/auto_ap/datomic/users.clj @@ -76,7 +76,3 @@ true (drop (:start args 0)) true (take (:count args 500))))) -(defn count-graphql [args] - - (->> (raw-graphql args) - (count))) diff --git a/src/clj/auto_ap/datomic/vendors.clj b/src/clj/auto_ap/datomic/vendors.clj index 4c5a3462..c72998d9 100644 --- a/src/clj/auto_ap/datomic/vendors.clj +++ b/src/clj/auto_ap/datomic/vendors.clj @@ -42,31 +42,6 @@ :vendor/default-account [:db/id :account/numeric-code :account/name] :vendor-usage/_vendor [:vendor-usage/client :vendor-usage/count]}]) -(defn get-usages [args] - (->> (cond-> {:query {:find ['?v '?c '(count ?e)] - :in ['$] - :where ['[?v :vendor/name] - '(or-join [?v ?c ?e] - (and - [?e :invoice/vendor ?v] - [?e :invoice/client ?c]) - (and - [?e :transaction/vendor ?v] - [?e :transaction/client ?c]) - (and - [?e :journal-entry/vendor ?v] - [?e :journal-entry/client ?c]))]} - :args [(d/db conn)]} - - (limited-clients (:id args)) - (merge-query {:query {:in ['?xx] - :where [['(get ?xx ?c)]]} - :args [(set (map :db/id (limited-clients (:id args))))]})) - (d/query) - (reduce - (fn [usages [v c cnt]] - (update usages v (fnil conj []) {:client-id c :count cnt})) - {}))) (defn raw-graphql-ids [db args] (let [query (cond-> {:query {:find [] diff --git a/src/clj/auto_ap/datomic/yodlee2.clj b/src/clj/auto_ap/datomic/yodlee2.clj index 6e149aa4..93249860 100644 --- a/src/clj/auto_ap/datomic/yodlee2.clj +++ b/src/clj/auto_ap/datomic/yodlee2.clj @@ -59,8 +59,3 @@ [(->> (graphql-results ids-to-retrieve db args)) matching-count])) -(defn get-by-id [id] - (-> (d/db (d/connect uri)) - (d/pull default-read id) - (<-datomic))) - diff --git a/src/clj/auto_ap/ezcater/core.clj b/src/clj/auto_ap/ezcater/core.clj index 783c654b..dc3353b0 100644 --- a/src/clj/auto_ap/ezcater/core.clj +++ b/src/clj/auto_ap/ezcater/core.clj @@ -92,6 +92,7 @@ [[:subscription [:parentId :parentEntity :eventEntity :eventKey]]]]]})) ))) +#_{:clj-kondo/ignore [:clojure-lsp/unused-public-var]} (defn upsert-ezcater ([] (upsert-ezcater (get-integrations))) ([integrations] diff --git a/src/clj/auto_ap/graphql.clj b/src/clj/auto_ap/graphql.clj index be720633..2612d03e 100644 --- a/src/clj/auto_ap/graphql.clj +++ b/src/clj/auto_ap/graphql.clj @@ -591,23 +591,6 @@ node)) m)) -(defn <-graphql [m] - (walk/postwalk - (fn [node] - (cond - - (keyword? node) - (kebab node) - - :else - node)) - m)) - - - - - - (defn get-user [context args _] (assert-admin (:id context)) @@ -638,12 +621,6 @@ (for [[account-id account-name total] result] {:account {:id account-id :name account-name} :total total}))) -(defn categorize [x] - (cond (<= x 0) :due - (<= x 30 ) :due-30 - (<= x 60 ) :due-60 - :else :due-later)) - (defn get-invoice-stats [_ {:keys [client_id] } _] (let [result (cond-> {:query {:find ['?name '(sum ?outstanding-balance) '(sum ?total)] :in ['$] diff --git a/src/clj/auto_ap/graphql/clients.clj b/src/clj/auto_ap/graphql/clients.clj index a66765c2..134efda2 100644 --- a/src/clj/auto_ap/graphql/clients.clj +++ b/src/clj/auto_ap/graphql/clients.clj @@ -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)))))))) diff --git a/src/clj/auto_ap/graphql/expected_deposit.clj b/src/clj/auto_ap/graphql/expected_deposit.clj index f3f0d356..56d444d1 100644 --- a/src/clj/auto_ap/graphql/expected_deposit.clj +++ b/src/clj/auto_ap/graphql/expected_deposit.clj @@ -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 diff --git a/src/clj/auto_ap/graphql/ledger.clj b/src/clj/auto_ap/graphql/ledger.clj index f03f1f2c..00f55322 100644 --- a/src/clj/auto_ap/graphql/ledger.clj +++ b/src/clj/auto_ap/graphql/ledger.clj @@ -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)) diff --git a/src/clj/auto_ap/graphql/transaction_rules.clj b/src/clj/auto_ap/graphql/transaction_rules.clj index 6aff56a8..f703bb4e 100644 --- a/src/clj/auto_ap/graphql/transaction_rules.clj +++ b/src/clj/auto_ap/graphql/transaction_rules.clj @@ -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 diff --git a/src/clj/auto_ap/graphql/utils.clj b/src/clj/auto_ap/graphql/utils.clj index 2812606e..1a74081d 100644 --- a/src/clj/auto_ap/graphql/utils.clj +++ b/src/clj/auto_ap/graphql/utils.clj @@ -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))) diff --git a/src/clj/auto_ap/handler.clj b/src/clj/auto_ap/handler.clj index 344e5b2e..2a0f1485 100644 --- a/src/clj/auto_ap/handler.clj +++ b/src/clj/auto_ap/handler.clj @@ -15,7 +15,7 @@ [clojure.string :as str] [clojure.tools.logging :as log] #_{:clj-kondo/ignore [:refer-all]} - [compojure.core :refer :all] + [compojure.core :refer [defroutes GET routes context ANY]] [compojure.route :as route] [config.core :refer [env]] [mount.core :as mount] @@ -31,6 +31,7 @@ (def running? (atom false)) +#_{:clj-kondo/ignore [:clojure-lsp/unused-public-var]} (mount/defstate manage-running? :start (reset! running? true) :stop (reset! running? false)) @@ -85,6 +86,7 @@ (log/info "Beginning request" (:uri request))) (handler request)))) +#_{:clj-kondo/ignore [:clojure-lsp/unused-public-var]} (def app (-> #'app-routes (wrap-logging) diff --git a/src/clj/auto_ap/import/intuit.clj b/src/clj/auto_ap/import/intuit.clj index 6fd83912..d0642a7e 100644 --- a/src/clj/auto_ap/import/intuit.clj +++ b/src/clj/auto_ap/import/intuit.clj @@ -5,7 +5,7 @@ [auto-ap.import.transactions :as t] [auto-ap.intuit.core :as i] [auto-ap.time :as atime] - [auto-ap.utils :refer [allow-once heartbeat]] + [auto-ap.utils :refer [heartbeat]] [clj-time.coerce :as coerce] [clj-time.core :as time] [clojure.string :as str] @@ -76,8 +76,6 @@ :priority :normal} nil))))) -(def upsert-transactions (allow-once upsert-transactions)) - (defn upsert-accounts [] (let [token (i/get-fresh-access-token) bank-accounts (i/get-bank-accounts token)] diff --git a/src/clj/auto_ap/import/manual/common.clj b/src/clj/auto_ap/import/manual/common.clj index ff6e205d..41464ab5 100644 --- a/src/clj/auto_ap/import/manual/common.clj +++ b/src/clj/auto_ap/import/manual/common.clj @@ -20,13 +20,6 @@ (catch Exception e (throw (Exception. (str "Could not parse expense account from value '" (:account-numeric-code i) "'") e))))) -(defn parse-account-id [i] - (try - (Long/parseLong (second - (re-matches #"[^0-9,\\-]*([0-9,\\-]+)[^0-9,]*" (:bank-account-id i)))) - (catch Exception e - (throw (Exception. (str "Could not parse account from value '" (:bank-account-id i) "'") e))))) - (defn parse-date [{:keys [raw-date]}] (when-not (re-find #"\d{1,2}/\d{1,2}/\d{4}" raw-date) diff --git a/src/clj/auto_ap/import/transactions.clj b/src/clj/auto_ap/import/transactions.clj index 200ffacd..e12a2a79 100644 --- a/src/clj/auto_ap/import/transactions.clj +++ b/src/clj/auto_ap/import/transactions.clj @@ -222,6 +222,7 @@ :location "A" :amount (Math/abs (double amount))}]))) +#_{:clj-kondo/ignore [:clojure-lsp/unused-public-var]} (defn maybe-autopay-invoices [{:transaction/keys [amount client bank-account] :as transaction}] (when-let [autopay-invoices-matches (seq (match-transaction-to-unfulfilled-autopayments amount client))] (add-new-payment transaction autopay-invoices-matches bank-account client))) @@ -356,18 +357,3 @@ (range) group))))) -(defn add-single-transaction [bank-account-code tx] - (let [bank-account (d/pull (d/db conn) - [:bank-account/code - :db/id - :bank-account/locations - :bank-account/start-date - {:client/_bank-accounts [:client/code :client/locations :db/id]} ] - [:bank-account/code bank-account-code])] - - (transaction->txs (-> (merge {:transaction/amount 100.0 :transaction/description-original "boring" :transaction/approval-status :transaction-approval-status/approved :transaction/status "POSTED"} - tx) - (assoc :transaction/bank-account (:db/id bank-account))) - bank-account - (rm/rule-applying-fn (tr/get-all))))) - diff --git a/src/clj/auto_ap/import/yodlee.clj b/src/clj/auto_ap/import/yodlee.clj deleted file mode 100644 index d7e46625..00000000 --- a/src/clj/auto_ap/import/yodlee.clj +++ /dev/null @@ -1,85 +0,0 @@ -(ns auto-ap.import.yodlee - (:require - [auto-ap.datomic :refer [conn]] - [auto-ap.import.transactions :as t] - [auto-ap.time :as atime] - [auto-ap.utils :refer [allow-once]] - [auto-ap.yodlee.core :as client] - [clj-time.coerce :as coerce] - [clojure.string :as str] - [clojure.tools.logging :as log] - [com.unbounce.dogstatsd.core :as statsd] - [datomic.api :as d] - [digest :as di])) - -(defn yodlee->transaction [transaction use-date-instead-of-post-date?] - (let [{post-date :postDate - account-id :accountId - date :date - id :id - {amount :amount} :amount - {description-original :original - description-simple :simple} :description - base-type :baseType - type :type - status :status} transaction - amount (if (= "DEBIT" base-type) - (- amount) - amount) - date (atime/parse date "YYYY-MM-dd")] - #:transaction - {:post-date (coerce/to-date (atime/parse post-date "YYYY-MM-dd")) - :id #_{:clj-kondo/ignore [:unresolved-var]} - (di/sha-256 (str id)) - :raw-id (str id) - :account-id account-id - :date (if use-date-instead-of-post-date? - (coerce/to-date (atime/parse post-date "YYYY-MM-dd")) - (coerce/to-date date)) - :amount (double amount) - :description-original (some-> description-original (str/replace #"\s+" " ")) - :description-simple (some-> description-simple (str/replace #"\s+" " ")) - :type type - :status status})) - -(defn import-yodlee [] - (statsd/event {:title "Yodlee import started" - :text "Starting" - :priority :low} - nil) - (let [import-batch (t/start-import-batch :import-source/yodlee "Automated yodlee user")] - (try - (let [account-lookup (d/q '[:find ?ya ?ba ?ud ?c - :in $ - :where [?ba :bank-account/yodlee-account-id ?ya] - [(get-else $ ?ba :bank-account/use-date-instead-of-post-date? false) ?ud] - [?c :client/bank-accounts ?ba]] - (d/db conn))] - (doseq [[yodlee-account bank-account use-date-instead-of-post-date? client-id] account-lookup - transaction (try - (client/get-specific-transactions yodlee-account (client/get-auth-header)) - (catch Exception e - (log/warn e) - []))] - (t/import-transaction! import-batch (assoc (yodlee->transaction transaction use-date-instead-of-post-date?) - :transaction/bank-account bank-account - :transaction/client client-id))) - - (t/finish! import-batch)) - (statsd/event {:title "Yodlee import Finished" - :text (pr-str (t/get-stats import-batch)) - :priority :low} - nil) - (catch Exception e - (t/fail! import-batch e) - (statsd/event {:title "Yodlee import failed" - :text (str e) - :alert-type :warning - :priority :normal} - nil))))) - -(def import-yodlee (allow-once import-yodlee)) - -#_(mount/defstate import-worker - :start (scheduler/every (* 1000 60 60 8) (heartbeat import-yodlee "import-yodlee")) - :stop (scheduler/stop import-worker)) diff --git a/src/clj/auto_ap/import/yodlee2.clj b/src/clj/auto_ap/import/yodlee2.clj index 1576e530..42a2a1ca 100644 --- a/src/clj/auto_ap/import/yodlee2.clj +++ b/src/clj/auto_ap/import/yodlee2.clj @@ -3,15 +3,48 @@ [auto-ap.datomic :refer [conn]] [auto-ap.import.common :refer [wrap-integration]] [auto-ap.import.transactions :as t] - [auto-ap.import.yodlee :as y] [auto-ap.utils :refer [allow-once heartbeat]] [auto-ap.yodlee.core2 :as client2] + [auto-ap.time :as atime ] + [clojure.string :as str] + [clj-time.coerce :as coerce] + [digest :as di] [com.unbounce.dogstatsd.core :as statsd] [datomic.api :as d] [mount.core :as mount] [unilog.context :as lc] [yang.scheduler :as scheduler])) +(defn yodlee->transaction [transaction use-date-instead-of-post-date?] + (let [{post-date :postDate + account-id :accountId + date :date + id :id + {amount :amount} :amount + {description-original :original + description-simple :simple} :description + base-type :baseType + type :type + status :status} transaction + amount (if (= "DEBIT" base-type) + (- amount) + amount) + date (atime/parse date "YYYY-MM-dd")] + #:transaction + {:post-date (coerce/to-date (atime/parse post-date "YYYY-MM-dd")) + :id #_{:clj-kondo/ignore [:unresolved-var]} + (di/sha-256 (str id)) + :raw-id (str id) + :account-id account-id + :date (if use-date-instead-of-post-date? + (coerce/to-date (atime/parse post-date "YYYY-MM-dd")) + (coerce/to-date date)) + :amount (double amount) + :description-original (some-> description-original (str/replace #"\s+" " ")) + :description-simple (some-> description-simple (str/replace #"\s+" " ")) + :type type + :status status})) + (defn import-yodlee2-int [] (lc/with-context {:source "Import yodlee2 transactions"} (statsd/event {:title "Yodlee2 import started" @@ -33,7 +66,7 @@ (doseq [[yodlee-account bank-account client-code use-date-instead-of-post-date?] account-lookup transaction (wrap-integration #(client2/get-specific-transactions client-code yodlee-account) bank-account)] - (t/import-transaction! import-batch (assoc (y/yodlee->transaction transaction use-date-instead-of-post-date?) + (t/import-transaction! import-batch (assoc (yodlee->transaction transaction use-date-instead-of-post-date?) :transaction/bank-account bank-account :transaction/client [:client/code client-code]))) diff --git a/src/clj/auto_ap/intuit/core.clj b/src/clj/auto_ap/intuit/core.clj index beacf634..41385f02 100644 --- a/src/clj/auto_ap/intuit/core.clj +++ b/src/clj/auto_ap/intuit/core.clj @@ -49,20 +49,24 @@ :metadata {:content-type "application/text" :content-length (count (.getBytes t))})) +#_{:clj-kondo/ignore [:clojure-lsp/unused-public-var]} (defn copy-prod-refresh-token [] (set-refresh-token (slurp (:object-content (s3/get-object :bucket-name "data.prod.app.integreatconsult.com" :key "intuit/refresh-token"))))) +#_{:clj-kondo/ignore [:clojure-lsp/unused-public-var]} (defn init-tokens [access refresh] (set-access-token access) (set-refresh-token refresh)) +#_{:clj-kondo/ignore [:clojure-lsp/unused-public-var]} (defn lookup-access-token [] (slurp (:object-content (s3/get-object :bucket-name (:data-bucket env) :key "intuit/access-token")))) +#_{:clj-kondo/ignore [:clojure-lsp/unused-public-var]} (defn lookup-refresh-token [] (slurp (:object-content (s3/get-object :bucket-name (:data-bucket env) diff --git a/src/clj/auto_ap/ledger.clj b/src/clj/auto_ap/ledger.clj index 9625e61c..39ddf05b 100644 --- a/src/clj/auto_ap/ledger.clj +++ b/src/clj/auto_ap/ledger.clj @@ -25,19 +25,6 @@ #_#_(namespaces "expected-deposit" ) [[:expected-deposit e]] :else nil))) - - -(defn infer-entity [_ [_ changes]] - (let [namespaces (->> changes - (map :a) - (map namespace) - set)] - (cond (namespaces "invoice" ) :invoice - (namespaces "invoice-expense-account" ) :invoice-expense-account - (namespaces "transaction-account" ) :transaction-account - #_#_(namespaces "expected-deposit" ) :expected-deposit - :else nil))) - (defmulti entity-change->ledger (fn [_ [type]] type)) diff --git a/src/clj/auto_ap/pdf/ledger.clj b/src/clj/auto_ap/pdf/ledger.clj index 3a8649e9..d921283c 100644 --- a/src/clj/auto_ap/pdf/ledger.clj +++ b/src/clj/auto_ap/pdf/ledger.clj @@ -136,6 +136,7 @@ (into [new-table] (split-table remaining n)))))) +#_{:clj-kondo/ignore [:clojure-lsp/unused-public-var]} (defn break-apart-tables [pnl-data tables] (for [table tables table (split-table table (if (:include-deltas (:args pnl-data)) diff --git a/src/clj/auto_ap/routes/auth.clj b/src/clj/auto_ap/routes/auth.clj index 73146797..2b743ac7 100644 --- a/src/clj/auto_ap/routes/auth.clj +++ b/src/clj/auto_ap/routes/auth.clj @@ -10,6 +10,7 @@ (def google-client-id "264081895820-0nndcfo3pbtqf30sro82vgq5r27h8736.apps.googleusercontent.com") (def google-client-secret "OC-WemHurPXYpuIw5cT-B90g") +#_{:clj-kondo/ignore [:clojure-lsp/unused-public-var]} (defn make-api-token [] (jwt/sign {:user "API" :exp (time/plus (time/now) (time/days 1000)) diff --git a/src/clj/auto_ap/routes/utils.clj b/src/clj/auto_ap/routes/utils.clj index 8b997750..31ed48c0 100644 --- a/src/clj/auto_ap/routes/utils.clj +++ b/src/clj/auto_ap/routes/utils.clj @@ -1,6 +1,5 @@ (ns auto-ap.routes.utils - (:require [buddy.auth :refer [authenticated?]] - [clojure.spec.alpha :as s])) + (:require [buddy.auth :refer [authenticated?]])) (defn wrap-secure [handler] (fn [request] @@ -8,11 +7,3 @@ (handler request) {:status 401 :body "not authenticated"}))) - -(defn wrap-spec [handler spec] - (fn [request] - (if (not (s/valid? spec (:edn-params request))) - {:status 400 - :body (pr-str (s/explain-data spec (:edn-params request))) - :headers {"Content-Type" "application/edn"}} - (handler request)))) diff --git a/src/clj/auto_ap/routes/yodlee.clj b/src/clj/auto_ap/routes/yodlee.clj deleted file mode 100644 index 74054f0e..00000000 --- a/src/clj/auto_ap/routes/yodlee.clj +++ /dev/null @@ -1,83 +0,0 @@ -(ns auto-ap.routes.yodlee - (:require - [auto-ap.graphql.utils :refer [assert-admin]] - [auto-ap.routes.utils :refer [wrap-secure]] - [auto-ap.yodlee.core :as yodlee] - [clojure.tools.logging :as log] - [compojure.core :refer [context defroutes GET POST wrap-routes]] - [config.core :refer [env]])) - -(defroutes routes - (wrap-routes - (context "/yodlee" [] - (GET "/fastlink" {:keys [identity]} - (assert-admin identity) - (let [[session token] (yodlee/get-access-token)] - {:status 200 - :headers {"Content-Type" "application/edn"} - :body (pr-str {:session session - :token token - :app (:yodlee-app env) - - :url (:yodlee-fastlink env)})})) - - (GET "/accounts" {:keys [identity]} - (assert-admin identity) - {:status 200 - :headers {"Content-Type" "application/edn"} - :body (pr-str (yodlee/get-accounts (yodlee/get-auth-header)))}) - - (GET "/provider-accounts" {:keys [identity]} - (assert-admin identity) - (log/info "working on provider accounts...") - {:status 200 - :headers {"Content-Type" "application/edn"} - :body (pr-str @yodlee/in-memory-cache)}) - (POST "/reauthenticate/:id" {:keys [identity] {:keys [id]} :route-params - data :edn-params} - (assert-admin identity) - (try - {:status 200 - :headers {"Content-Type" "application/edn"} - :body (pr-str (yodlee/reauthenticate-and-recache (Long/parseLong id) data (yodlee/get-auth-header)))} - (catch Exception e - (log/error e) - {:status 500 - :headers {"Content-Type" "application/edn"} - :body (pr-str {:message (.getMessage e) - :error (.toString e)})}))) - (POST "/provider-accounts/refresh/:id" {:keys [identity] {:keys [id]} :route-params} - (assert-admin identity) - (try - (yodlee/refresh-provider-account (Long/parseLong id) (yodlee/get-auth-header)) - {:status 200 - :headers {"Content-Type" "application/edn"} - :body (pr-str @yodlee/in-memory-cache)} - (catch Exception e - {:status 400 - :headers {"Content-Type" "application/edn"} - :body (pr-str {:message (.getMessage e) - :error (.toString e)})}))) - (POST "/provider-accounts/delete/:id" {:keys [identity] {:keys [id]} :route-params} - (assert-admin identity) - (try - (yodlee/delete-and-uncache-provider-account (Long/parseLong id) (yodlee/get-auth-header)) - {:status 200 - :headers {"Content-Type" "application/edn"} - :body (pr-str @yodlee/in-memory-cache)} - (catch Exception e - {:status 400 - :headers {"Content-Type" "application/edn"} - :body (pr-str {:message (.getMessage e) - :error (.toString e)})}))) - (POST "/provider-accounts/:id" {:keys [identity] {:keys [id]} :route-params} - (assert-admin identity) - (try - {:status 200 - :headers {"Content-Type" "application/edn"} - :body (pr-str (yodlee/update-yodlee (Long/parseLong id) (yodlee/get-auth-header)))} - (catch Exception e - {:status 400 - :headers {"Content-Type" "application/edn"} - :body (pr-str e)})))) - wrap-secure)) diff --git a/src/clj/auto_ap/server.clj b/src/clj/auto_ap/server.clj index 916110ef..206f9041 100644 --- a/src/clj/auto_ap/server.clj +++ b/src/clj/auto_ap/server.clj @@ -10,7 +10,6 @@ [auto-ap.handler :refer [app]] [auto-ap.import.intuit :as intuit] [auto-ap.import.plaid :as plaid] - [auto-ap.import.yodlee :as yodlee] [auto-ap.import.yodlee2 :as yodlee2] [auto-ap.ledger :as ledger] [auto-ap.square.core :as square] diff --git a/src/clj/auto_ap/square/core.clj b/src/clj/auto_ap/square/core.clj index 1d7edc78..244af25b 100644 --- a/src/clj/auto_ap/square/core.clj +++ b/src/clj/auto_ap/square/core.clj @@ -98,6 +98,7 @@ "sort_order" "DESC" }}}) +#_{:clj-kondo/ignore [:clojure-lsp/unused-public-var]} (defn get-order ([client location order-id] (log/info "Searching for" (:square-location/client-location location)) @@ -482,6 +483,7 @@ (d/transact conn) deref)))) +#_{:clj-kondo/ignore [:clojure-lsp/unused-public-var]} (defn reset [] (->> (d/query {:query {:find ['?e] diff --git a/src/clj/auto_ap/time.clj b/src/clj/auto_ap/time.clj index 3d1aa510..e544f1d0 100644 --- a/src/clj/auto_ap/time.clj +++ b/src/clj/auto_ap/time.clj @@ -11,7 +11,6 @@ (def normal-date "MM/dd/yyyy") (def iso-date "yyyy-MM-dd") -(def iso-date-time (:date-hour-minute-second-ms f/formatters)) (defn parse [v format] (try diff --git a/src/clj/auto_ap/yodlee/core.clj b/src/clj/auto_ap/yodlee/core.clj deleted file mode 100644 index 2f35310c..00000000 --- a/src/clj/auto_ap/yodlee/core.clj +++ /dev/null @@ -1,426 +0,0 @@ -#_{:clj-kondo/ignore [:unused-namespace]} -(ns auto-ap.yodlee.core - (:require - [auto-ap.utils :refer [by]] - [clj-http.client :as client] - [clojure.core.async :as async] - [clojure.data.json :as json] - [clojure.tools.logging :as log] - [config.core :refer [env]] - [mount.core :as mount] - [unilog.context :as lc] - [yang.scheduler :as scheduler])) - -(def known-bad-yodlee-ids ;; these yodlee ids are ones we wish we could manually delete - (set [ - 3432269925 - 3432269925 - 3440074569 - 3440074568 - 3451368964 - 3453413513 - 3453413398 - 3325396245 - 3451368962 - 2987488002 - 3021618678 - 3021618674 - 3025625892 - 3052944039 - 3052944035 - 3079067192 - 3079067193 - 3079067193 - 3122287847 - 3122287842 - 3189405320 - 3189405320 - 3189405321 - 3189405321 - 3189405319 - 3189405319 - 3248171256 - 3248171256 - 3248171257 - 3248171257 - 3248171254 - 3291944265 - 3291944267 - 3291944267 - 3310943251 - 3387770449 - 3387770447 - 3432269929])) - -(defn auth-header - ([cob-session] (str "{cobSession=" cob-session "}")) - ([cob-session user-session] (str "{cobSession=" cob-session ",userSession=" user-session "}"))) - -(def other-config - (if (:yodlee-proxy-host env) - {:proxy-host (:yodlee-proxy-host env) - :proxy-port (:yodlee-proxy-port env) - :retry-handler (fn [ex _ _] - (log/error "yodlee Error." ex) - false) - :socket-timeout 60000 - :connection-timeout 60000} - {:retry-handler (fn [ex _ _] - (log/error "yodlee Error." ex) - false) - :socket-timeout 60000 - :connection-timeout 60000})) - -(defn retry-thrice - ([x] (retry-thrice x 0)) - ([x i] - (try - (x) - (catch Exception e - (if (>= i 3) - (throw e) - (do - (Thread/sleep 5000) - (retry-thrice x (inc i)))))))) - - -(def base-headers {"Api-Version" "1.1" - "Cobrand-Name" (:yodlee-cobrand-name env) - "Content-Type" "application/json"}) - - -(defn login-cobrand [] - (retry-thrice - (fn [] - (-> (str (:yodlee-base-url env) "/cobrand/login") - (client/post (merge {:headers base-headers - :body - (json/write-str {:cobrand {:cobrandLogin (:yodlee-cobrand-login env) - :cobrandPassword (:yodlee-cobrand-password env) - :locale "en_US"}}) - :as :json} - other-config)) - :body - :session - :cobSession)))) - - -(defn login-user - ([cob-session] (login-user cob-session (:yodlee-user-login env) (:yodlee-user-password env))) - ([cob-session user password] - (retry-thrice - (fn [] - (-> (str (:yodlee-base-url env) "/user/login") - (client/post (merge {:headers (merge base-headers {"Authorization" (auth-header cob-session)}) - :body - (json/write-str {:user {:loginName user - :password password - :locale "en_US"}}) - :as :json} - other-config)) - :body - :user - :session - :userSession))))) - - -(defn get-auth-header [] - (let [cob-session (login-cobrand) - user-session (login-user cob-session)] - {"Authorization" (auth-header cob-session user-session)})) - - -(defn get-accounts [auth-header] - (retry-thrice - (fn [] - (-> (str (:yodlee-base-url env) "/accounts") - (client/get (merge {:headers (merge base-headers auth-header) - :as :json} - other-config)) - :body - :account)))) - - -(defn get-accounts-for-provider-account [provider-account-id auth-header] - (try - (retry-thrice - (fn [] - (-> (str (:yodlee-base-url env) "/accounts?providerAccountId=" provider-account-id) - (client/get (merge {:headers (merge base-headers auth-header) - :as :json} - other-config)) - :body - :account))) - (catch Exception e - (log/error (str "Couldn't get accounts for provider account '" provider-account-id "'") - e) - []))) - - -#_{:clj-kondo/ignore [:clojure-lsp/unused-public-var]} -(defn get-account [i auth-header] - (retry-thrice - (fn [] - (-> (str (:yodlee-base-url env) (str "/accounts/" i)) - (client/get (merge {:headers (merge base-headers auth-header) - :as :json} - other-config)) - :body - :account)))) - - -(defn get-provider-accounts [auth-header] - (retry-thrice - (fn [] - (-> (str (:yodlee-base-url env) "/providerAccounts") - (client/get (merge {:headers (merge base-headers auth-header) - :as :json} - other-config)) - :body - :providerAccount)))) - - -#_{:clj-kondo/ignore [:clojure-lsp/unused-public-var]} -(defn get-provider-account [id auth-header] - (retry-thrice - (fn [] - (-> (str (:yodlee-base-url env) "/providerAccounts/" id) - (client/get (merge {:headers (merge base-headers auth-header) - :as :json} - other-config)) - :body - :providerAccount)))) - - -(defn get-provider-account-detail [id auth-header] - (retry-thrice - (fn [] - (-> (str (:yodlee-base-url env) "/providerAccounts/" id) - (client/get (merge {:headers (merge base-headers auth-header) - :query-params {"include" "credentials,preferences"} - :as :json} - other-config)) - :body - :providerAccount - first)))) - - -(defn update-provider-account [pa auth-header] - (retry-thrice - (fn [] - (-> (str (:yodlee-base-url env) "/providerAccounts?providerAccountIds=" pa) - (client/put (merge {:headers (merge base-headers auth-header) - :body "{\"dataSetName\": [\"BASIC_AGG_DATA\"]}" - :as :json} - other-config)))))) - - -(defn delete-provider-account [id auth-header] - (retry-thrice - (fn [] - (-> (str (:yodlee-base-url env) "/providerAccounts/" id) - (client/delete (merge {:headers (merge base-headers auth-header) - :as :json} - other-config)) - :body - :providerAccount - first)))) - - -(defn get-transaction-page - ([account batch-size skip auth-header] - (retry-thrice - (fn [] - (-> (str (:yodlee-base-url env) "/transactions?top=" batch-size "&skip=" skip "&accountId=" account) - (client/get (merge {:headers (merge base-headers auth-header) - :as :json} - other-config)) - :body - :transaction)))) - ([account start end batch-size skip auth-header] - (-> (str (:yodlee-base-url env) "/transactions?top=" batch-size "&fromDate=" start "&toDate=" end "&skip=" skip "&accountId=" account) - (client/get (merge {:headers (merge base-headers auth-header) - :as :json} - other-config)) - :body - :transaction))) - - -#_{:clj-kondo/ignore [:clojure-lsp/unused-public-var]} -(defn count-specific-transactions [account auth-header] - (retry-thrice - (fn [] - (-> (str (:yodlee-base-url env) "/transactions/count?accountId=" account) - (client/get (merge {:headers (merge base-headers auth-header) - :as :json} - other-config)) - :body - :transaction)))) - - -(defn get-access-token [] - (try - (let [cob-session (login-cobrand) - user-session (login-user cob-session) - token (-> - (str (:yodlee-base-url env) "/user/accessTokens?appIds=" 10003600) - - (client/get - (merge {:headers (merge base-headers {"Authorization" (auth-header cob-session user-session)}) - :as :json} - other-config)) - (doto log/info) - :body - :user - :accessTokens - first - :value)] - [user-session token]) - (catch Exception e - (log/error e) - (throw e)))) - - -#_{:clj-kondo/ignore [:clojure-lsp/unused-public-var]} -(defn create-user [] - (let [cob-session (login-cobrand)] - (-> (str (:yodlee-base-url env) "/user/register") - (client/post (merge {:headers (merge base-headers {"Authorization" (auth-header cob-session)}) - :body (json/write-str {:user {:loginName "brycesPersoonal2" - :password "kV@mdv3TU11" - :email "yodleepersonal2@brycecovertoperations.com"}}) - :as :json} - other-config)) - :body))) - - -(defn reauthenticate [pa data auth-header] - (try - (retry-thrice - (fn [] - (-> (str (:yodlee-base-url env) "/providerAccounts?providerAccountIds=" pa) - (client/put (merge {:headers (merge base-headers auth-header) - :body (json/write-str data) - :as :json} - other-config))))) - (catch Exception e - (log/error e)))) - - -;; helpers - - -(defn get-specific-transactions [account auth-header] - (log/infof "Getting yodlee transactions for account %s" account) - (let [batch-size 100] - (loop [transactions [] - skip 0] - (let [transaction-batch (get-transaction-page account batch-size skip auth-header)] - (if (seq transaction-batch) - (recur (concat transactions transaction-batch) (+ batch-size skip)) - transactions))))) - - -#_{:clj-kondo/ignore [:clojure-lsp/unused-public-var]} -(defn get-specific-transactions-with-date [account start end auth-header] - (let [batch-size 100] - (loop [transactions [] - skip 0] - (let [transaction-batch (get-transaction-page account start end batch-size skip auth-header)] - (if (seq transaction-batch) - (recur (concat transactions transaction-batch) (+ batch-size skip)) - transactions))))) - - -(defn get-provider-accounts-with-details [auth-header] - (let [provider-accounts (get-provider-accounts auth-header) - concurrent 10 - output-chan (async/chan)] - (async/pipeline-blocking concurrent - output-chan - (map (fn [provider-account] - (lc/with-context {:provider-account-id (:id provider-account)} - (get-provider-account-detail (:id provider-account) auth-header)))) - (async/to-chan! provider-accounts) - true - (fn [e] - (lc/with-context {:source "Yodlee"} - (log/error "Yodlee pipeline error" e)))) - (async/> accounts - (reduce - (fn [provider-accounts [which accounts]] - (assoc-in provider-accounts [which :accounts] accounts)) - provider-accounts) - vals))) - - -(mount/defstate in-memory-cache - :start (atom [])) - - -#_{:clj-kondo/ignore [:clojure-lsp/unused-public-var]} -(defn refresh-in-memory-cache [] - (lc/with-context {:source "refreshing-in-memory-cache"} - (try - (log/info "Refreshing Yodlee in memory cache") - (reset! in-memory-cache (get-provider-accounts-with-accounts (get-auth-header))) - (catch Exception e - (log/error e))))) - - -#_(mount/defstate in-memory-cache-worker - :start (scheduler/every (* 5 60 1000) refresh-in-memory-cache) - :stop (scheduler/stop in-memory-cache-worker)) - - -(defn refresh-provider-account [id auth-header] - (swap! in-memory-cache - (fn [i] - (-> (by :id i) - (assoc id (assoc (get-provider-account-detail id auth-header) - :accounts (get-accounts-for-provider-account id auth-header))) - vals)))) - - -(defn delete-and-uncache-provider-account [id auth-header] - (delete-provider-account id auth-header) - (swap! in-memory-cache - (fn [i] - (-> (by :id i) - (dissoc id) - vals)))) - - -(defn update-yodlee [id auth-header] - (update-provider-account id auth-header) - (refresh-provider-account id auth-header)) - - -(defn reauthenticate-and-recache [pa data auth-header] - (reauthenticate pa data auth-header) - (refresh-provider-account pa auth-header)) - - diff --git a/src/cljc/auto_ap/ledger/reports.cljc b/src/cljc/auto_ap/ledger/reports.cljc index 3dad705f..ba642746 100644 --- a/src/cljc/auto_ap/ledger/reports.cljc +++ b/src/cljc/auto_ap/ledger/reports.cljc @@ -114,15 +114,6 @@ "ZZZZZZ" (:location x))])))) -(defn locations [pnl-data] - (->> (client-locations pnl-data) - (map second) - set - (sort-by (fn [x] - (if (= x "HQ" ) - "ZZZZZZ" - x))))) - (defn aggregate-accounts [pnl-data] (reduce (fnil + 0.0) 0.0 (map :amount (:data pnl-data)))) diff --git a/src/cljc/auto_ap/utils.cljc b/src/cljc/auto_ap/utils.cljc index bd5a49c9..721c3860 100644 --- a/src/cljc/auto_ap/utils.cljc +++ b/src/cljc/auto_ap/utils.cljc @@ -5,6 +5,7 @@ [clojure.tools.logging :as log] [unilog.context :as lc])])) +#_{:clj-kondo/ignore [:clojure-lsp/unused-public-var]} (defn by ([f xs] (by f identity xs)) @@ -14,15 +15,7 @@ {} xs))) -(defn replace-if [f candidate existing] - (reduce - (fn [xs x] - (if (f x candidate) - (conj xs candidate) - (conj xs x))) - [] - existing)) - +#_{:clj-kondo/ignore [:clojure-lsp/unused-public-var]} (defn replace-by [xs f x] (let [found? (atom false) replaced (mapv @@ -36,34 +29,15 @@ replaced (into [x] replaced)))) - -(defn remove-by [xs f x] - (into [] - (filter - (fn [t] - (if (= (f t) (f x)) - false - true)) - xs))) -(defn merge-by [xs f x] - (let [found? (atom false) - replaced (mapv - (fn [t] - (if (= (f t) (f x)) - (do (reset! found? true) - (merge t x)) - t)) - xs)] - (if @found? - replaced - (into [x] replaced)))) - +#_{:clj-kondo/ignore [:clojure-lsp/unused-public-var]} (defn dollars-0? [amt] (< -0.001 amt 0.001)) +#_{:clj-kondo/ignore [:clojure-lsp/unused-public-var]} (defn dollars= [amt1 amt2] (dollars-0? (- amt1 amt2) )) +#_{:clj-kondo/ignore [:clojure-lsp/unused-public-var]} (defn deep-merge [v & vs] (letfn [(rec-merge [v1 v2] (if (and (map? v1) (map? v2)) @@ -73,8 +47,10 @@ (reduce #(rec-merge %1 %2) v vs) (last vs)))) +#_{:clj-kondo/ignore [:clojure-lsp/unused-public-var]} (def default-pagination-size 20) +#_{:clj-kondo/ignore [:clojure-lsp/unused-public-var]} (defn allow-once [f] (let [in-progress? (atom false)] (fn [] @@ -86,22 +62,22 @@ (reset! in-progress? false))))))) +#_{:clj-kondo/ignore [:clojure-lsp/unused-public-var]} (defn heartbeat [f id] (fn [] - #?(:clj (do - (lc/with-context {:source id} - (try - (log/info "Starting background process " id) - (f) - (log/info "Completed background process " id) + #?(:clj (lc/with-context {:source id} + (try + (log/info "Starting background process " id) + (f) + (log/info "Completed background process " id) + (statsd/service-check {:name (str id) + :status :ok} + nil) + (catch Exception e + (log/error e) (statsd/service-check {:name (str id) - :status :ok} - nil) - (catch Exception e - (log/error e) - (statsd/service-check {:name (str id) - :status :critical} - nil))))) + :status :critical} + nil)))) :cljs (do (println "Heartbeat for " id) (f))))) diff --git a/src/cljs/auto_ap/config.cljs b/src/cljs/auto_ap/config.cljs index 82f3cdf7..10ea94d9 100644 --- a/src/cljs/auto_ap/config.cljs +++ b/src/cljs/auto_ap/config.cljs @@ -1,4 +1,5 @@ (ns auto-ap.config) +#_{:clj-kondo/ignore [:clojure-lsp/unused-public-var]} (def debug? ^boolean goog.DEBUG) diff --git a/src/cljs/auto_ap/effects.cljs b/src/cljs/auto_ap/effects.cljs index 557d4c2b..2e594ea2 100644 --- a/src/cljs/auto_ap/effects.cljs +++ b/src/cljs/auto_ap/effects.cljs @@ -39,15 +39,6 @@ [k v]))) (into {} ))))))) -(re-frame/reg-fx - :new-window - (fn [url] - (.open js/window url))) - -#_(re-frame/reg-fx - :dispatch-sync - (fn [event] - (re-frame/dispatch-sync event))) (re-frame/reg-fx :set-local-storage @@ -121,47 +112,6 @@ (conj on-success) (re-frame/dispatch)))))))) -(re-frame/reg-fx - :https - (fn [{:keys [requests on-success on-failure owns-state]}] - (go - (when (:multi owns-state) - (re-frame/dispatch-sync [::status/loading-multi (:multi owns-state) (:which owns-state)])) - - (when (:single owns-state) - (re-frame/dispatch-sync [::status/loading (:single owns-state)])) - (let [results (->> - (for [{:keys [method body headers uri token]} requests] - (go - (let [headers (if token - (assoc headers "Authorization" (str "Token " token)) - headers) - response (= (:status response) 400) - :error - :success)))) - (async/merge) - (async/reduce conj []) - (async/snake [s] (str/replace s #"-" "_")) diff --git a/src/cljs/auto_ap/events.cljs b/src/cljs/auto_ap/events.cljs index 709b958b..3b5a12f4 100644 --- a/src/cljs/auto_ap/events.cljs +++ b/src/cljs/auto_ap/events.cljs @@ -76,17 +76,6 @@ (fn [db [_ which]] (update-in db [:menu which :active?] #(not %)))) -(re-frame/reg-event-fx - ::logged-in - (fn [{:keys [db]} [_ token user]] - {:graphql {:token token - :query-obj {:venia/queries [[:client (client-query token)]]} - - :on-success [::received-initial] - :on-error [::failed-initial]} - :db (assoc db - :user (assoc user :token token) - :is-initial-loading? true)})) (re-frame/reg-event-fx ::received-initial diff --git a/src/cljs/auto_ap/forms.cljs b/src/cljs/auto_ap/forms.cljs index 85ad369f..52202bb8 100644 --- a/src/cljs/auto_ap/forms.cljs +++ b/src/cljs/auto_ap/forms.cljs @@ -2,7 +2,6 @@ (:require [re-frame.core :as re-frame] [re-frame.interceptor :as i] [auto-ap.status :as status] - [auto-ap.views.utils :refer [dispatch-event]] [malli.core :as m])) @@ -20,13 +19,6 @@ :data (get-in f)))) -(re-frame/reg-sub - ::loading-class - (fn [db [_ x]] - (if (#{"loading" :loading} (get-in db [::forms x :status]) ) - "is-loading" - ""))) - (defn start-form ([db form data] (start-form db form data nil)) @@ -131,17 +123,13 @@ (assoc-in [::forms form :error] (or (:message (first result)) result))))) - -(defn ^:deprecated side-bar-form [{:keys [form]} children] - [:div [:a.delete.is-pulled-right {:on-click (dispatch-event [::form-closing form])}] [:div children]]) - - ;; TODO ^:deprecated (defn loading [db id] (-> db (assoc-in [::forms id :status] :loading) (assoc-in [::forms id :error] nil))) +#_{:clj-kondo/ignore [:clojure-lsp/unused-public-var]} (defn settles [{:keys [event time key]}] (i/->interceptor :id :settles diff --git a/src/cljs/auto_ap/reload.cljs b/src/cljs/auto_ap/reload.cljs index 123bd257..b0fe0ee1 100644 --- a/src/cljs/auto_ap/reload.cljs +++ b/src/cljs/auto_ap/reload.cljs @@ -1,5 +1,6 @@ (ns ^:figwheel-hooks auto-ap.reload) +#_{:clj-kondo/ignore [:clojure-lsp/unused-public-var]} (defn ^:after-load reload [] (println "RELOADING") (@(resolve 'auto-ap.core/mount-root))) diff --git a/src/cljs/auto_ap/schema.cljs b/src/cljs/auto_ap/schema.cljs index b3ae551e..ae8fd5be 100644 --- a/src/cljs/auto_ap/schema.cljs +++ b/src/cljs/auto_ap/schema.cljs @@ -13,14 +13,6 @@ (def not-empty-string (m/schema [:re {:error/message "Required"} #"\S+"])) (def code-string (m/schema [:re #"[A-Z0-9\-]+"])) -(def positive-integer (m/schema [:int {:min 1}])) (def integer-code (m/schema [:int {:min 10000 :max 99999}])) -(def expense-account (m/schema [:map - [:id :string] - [:account reference] - [:location :string] - [:amount money]])) - - (def approval-status (m/schema [:enum :unapproved :requires-feedback :approved :excluded])) diff --git a/src/cljs/auto_ap/subs.cljs b/src/cljs/auto_ap/subs.cljs index a8900709..8a32c7b7 100644 --- a/src/cljs/auto_ap/subs.cljs +++ b/src/cljs/auto_ap/subs.cljs @@ -8,7 +8,7 @@ [minisearch :as ms])) (set! *warn-on-infer* true) -#_{:clj-kondo/ignore [:unresolved-symbol]} +#_{:clj-kondo/ignore [:clojure-lsp/unused-public-var :unresolved-symbol]} (def MiniSearch (if ms (aget ms "default") nil)) @@ -29,15 +29,6 @@ (fn [c] (map #(select-keys % [:id :name]) c))) -(re-frame/reg-sub - ::all-accounts - (fn [db] - (:accounts db))) - -(re-frame/reg-sub - ::all-accounts-by-id - (fn [db] - (by :id (:accounts db)))) (re-frame/reg-sub ::bank-accounts @@ -101,10 +92,6 @@ (fn [db [_ id]] (-> db :menu (get id) :active?))) -(re-frame/reg-sub - ::menu - (fn [db] - (:menu db))) (re-frame/reg-sub ::is-initial-loading? @@ -175,8 +162,3 @@ (if (= 500 (:status error)) "System error occured. If you are stuck, please notify ben@integreatconsult.com." (:message error))))) - -(re-frame/reg-sub - ::yodlee-merchants - (fn [db] - (:yodlee-merchants db))) diff --git a/src/cljs/auto_ap/views/components/vendor_dialog.cljs b/src/cljs/auto_ap/views/components/vendor_dialog.cljs index 51e37781..c2ce51a7 100644 --- a/src/cljs/auto_ap/views/components/vendor_dialog.cljs +++ b/src/cljs/auto_ap/views/components/vendor_dialog.cljs @@ -18,8 +18,7 @@ [auto-ap.views.utils :refer [dispatch-event str->int with-is-admin? with-user]] [malli.core :as m] - [re-frame.core :as re-frame] - [reagent.core :as r])) + [re-frame.core :as re-frame])) ;; Remaining cleanup todos: ;; test minification @@ -131,11 +130,6 @@ {:dispatch-n [[::forms/attempted-submit ::vendor-form] [::status/error ::vendor-form [{:message "Please fix the errors and try again."}]]]}))) -(defn pull-left [] - (into [:div {:style {:position "relative" - :left "-40px"}}] - (r/children (r/current-component)))) - (defn contact-field [{:keys [name field]}] [form-builder/with-scope {:scope field} [form-builder/vertical-control diff --git a/src/cljs/auto_ap/views/pages/admin/users.cljs b/src/cljs/auto_ap/views/pages/admin/users.cljs index 331777a4..d8a6c1a3 100644 --- a/src/cljs/auto_ap/views/pages/admin/users.cljs +++ b/src/cljs/auto_ap/views/pages/admin/users.cljs @@ -22,11 +22,6 @@ (fn [db] (::users db))) -(re-frame/reg-event-fx - ::params-change - (fn [_ [_ params]] - {:set-uri-params params})) - (re-frame/reg-sub ::page :<- [::params] diff --git a/src/cljs/auto_ap/views/pages/admin/vendors/table.cljs b/src/cljs/auto_ap/views/pages/admin/vendors/table.cljs index 994482f0..78e2f05a 100644 --- a/src/cljs/auto_ap/views/pages/admin/vendors/table.cljs +++ b/src/cljs/auto_ap/views/pages/admin/vendors/table.cljs @@ -1,6 +1,5 @@ (ns auto-ap.views.pages.admin.vendors.table (:require - [auto-ap.subs :as subs] [auto-ap.views.components.buttons :as buttons] [auto-ap.views.components.grid :as grid] [auto-ap.views.components.vendor-dialog :as vendor-dialog] @@ -9,10 +8,7 @@ [re-frame.core :as re-frame])) (defn vendors-table [{:keys [data-page]}] - (let [{:keys [data]} @(re-frame/subscribe [::data-page/page data-page]) - accounts @(re-frame/subscribe [::subs/all-accounts-by-id])] - (println "DATA COUNT" (keys data)) - + (let [{:keys [data]} @(re-frame/subscribe [::data-page/page data-page])] [grid/grid {:data-page data-page :column-count 4} [grid/controls data] @@ -33,7 +29,7 @@ [:div.mx-2.tag.is-info.is-light total-usage " usages, " (count (:usage v)) " clients" ] [:div.mx-2.tag.is-warning.is-light "Unused"]))] [grid/cell {} (:email (:primary-contact v))] - [grid/cell {} (-> v :default-account :id accounts :name)] + [grid/cell {} (-> v :default-account :name)] [grid/cell {} [buttons/fa-icon {:event [::vendor-dialog/started v] :icon "fa-pencil"}]]])]]])) diff --git a/src/cljs/auto_ap/views/pages/company/plaid.cljs b/src/cljs/auto_ap/views/pages/company/plaid.cljs index 979eb6f0..2d71cdfd 100644 --- a/src/cljs/auto_ap/views/pages/company/plaid.cljs +++ b/src/cljs/auto_ap/views/pages/company/plaid.cljs @@ -30,12 +30,6 @@ (fn [table-params] table-params)) -(re-frame/reg-sub - ::plaid-items - (fn [db] - (::plaid-items db))) - - (re-frame/reg-event-fx ::data-requested (fn [{:keys [db]} [_ params]] @@ -119,11 +113,6 @@ (-> db (assoc-in [::link-token] (:token (:plaid-link-token link-token)))))) -(re-frame/reg-event-db - ::received - (fn [db [_ d]] - (assoc-in db [::plaid-items] (:plaid-item-page d)))) - (defn plaid-item-table [] [table/table {:data-page ::page diff --git a/src/cljs/auto_ap/views/pages/data_page.cljs b/src/cljs/auto_ap/views/pages/data_page.cljs index 78c55665..a5b5fb88 100644 --- a/src/cljs/auto_ap/views/pages/data_page.cljs +++ b/src/cljs/auto_ap/views/pages/data_page.cljs @@ -127,9 +127,6 @@ :filters filters :table-params table-params})) -(defn in-page-entities [which] - (re-frame/path [::data which :data ] )) - (re-frame/reg-event-fx ::table-params-changed (fn [{:keys [db]} [_ which params]] diff --git a/src/cljs/auto_ap/views/pages/import_invoices.cljs b/src/cljs/auto_ap/views/pages/import_invoices.cljs index 68a7de8e..acc4d171 100644 --- a/src/cljs/auto_ap/views/pages/import_invoices.cljs +++ b/src/cljs/auto_ap/views/pages/import_invoices.cljs @@ -151,16 +151,6 @@ []]]} :on-success [::invalidated]}})) -(re-frame/reg-event-fx - ::approve-invoices - (fn [cofx [_ on-success]] - {:http {:method :post - :token (-> cofx :db :user) - :uri (str "/api/invoices/approve" - (when-let [client-id (:id @(re-frame/subscribe [::subs/client]))] - (str "?client=" client-id))) - :on-success on-success}})) - (defn approve-reject-button [checked] [:div.buttons [:button.button.is-primary {:on-click (dispatch-event [::approve-invoices-clicked checked]) diff --git a/src/cljs/auto_ap/views/pages/transactions/bulk_updates.cljs b/src/cljs/auto_ap/views/pages/transactions/bulk_updates.cljs index 7e61fe1b..b2e59e28 100644 --- a/src/cljs/auto_ap/views/pages/transactions/bulk_updates.cljs +++ b/src/cljs/auto_ap/views/pages/transactions/bulk_updates.cljs @@ -18,16 +18,8 @@ [auto-ap.events :as events] [vimsical.re-frame.cofx.inject :as inject] [auto-ap.forms.builder :as form-builder] - [malli.core :as m] - [auto-ap.schema :as schema] [auto-ap.views.components :as com])) -(re-frame/reg-sub - ::can-submit - :<- [::forms/form ::form] - (fn [{ {:keys []} :data}] - true)) - (re-frame/reg-event-fx ::coded (fn [_ [_ _ _]] @@ -107,15 +99,10 @@ {::track/dispose {:id ::vendor-change}})) -(def bulk-update-schema - (m/schema - [:map - [:vendor schema/reference]])) (defn form-content [_] (let [{:keys [data]} @(re-frame/subscribe [::forms/form ::form])] [form-builder/builder {:submit-event [::code-selected] :change-event [::changed] - :can-submit [::can-submit] :id ::form} diff --git a/src/cljs/auto_ap/views/pages/transactions/manual.cljs b/src/cljs/auto_ap/views/pages/transactions/manual.cljs index 58c5c889..118208ed 100644 --- a/src/cljs/auto_ap/views/pages/transactions/manual.cljs +++ b/src/cljs/auto_ap/views/pages/transactions/manual.cljs @@ -10,12 +10,6 @@ [malli.core :as m] [re-frame.core :as re-frame])) -(re-frame/reg-sub - ::can-submit - :<- [::forms/form ::form] - (fn [{ {:keys [data]} :data}] - (not-empty data))) - (def schema (m/schema [:map [:data schema/not-empty-string]])) diff --git a/src/cljs/auto_ap/views/utils.cljs b/src/cljs/auto_ap/views/utils.cljs index 6882f8a8..86d2bab0 100644 --- a/src/cljs/auto_ap/views/utils.cljs +++ b/src/cljs/auto_ap/views/utils.cljs @@ -18,7 +18,6 @@ (def date-regex #"[2]{1}[0-9]{3}-[0-9]{1,2}-[0-9]{1,2}") -(def money-regex #"\-?[0-9]+(\.[0-9]{2})?$") (def nff (NumberFormat. Format/CURRENCY)) @@ -54,9 +53,6 @@ )) -(defn active-when= [active-page candidate] - (when (= active-page candidate) " is-active")) - (defn active-when [active-page f & rest] (when (apply f (into [active-page] rest)) " is-active")) @@ -72,12 +68,6 @@ (re-frame/dispatch (conj event (.. e -target -value))))) -(defn delayed-dispatch [e] - (fn [_] - (js/setTimeout #(re-frame/dispatch e) 151) - false)) - - (defn dispatch-event [event] (fn [e] (when (.-stopPropagation e) @@ -286,9 +276,6 @@ (js/document.execCommand "copy") (.removeChild js/document.body el))) -(defn account->match-text [x] - (str (:numeric-code x) " - " (:name x))) - (defn str->int [x] (cond (nil? x) diff --git a/test/clj/auto_ap/import/transactions_test.clj b/test/clj/auto_ap/import/transactions_test.clj index 8b20db8d..3e8240e9 100644 --- a/test/clj/auto_ap/import/transactions_test.clj +++ b/test/clj/auto_ap/import/transactions_test.clj @@ -24,7 +24,8 @@ (def base-transaction #:transaction {:date #inst "2020-01-02T00:00:00-08:00" :raw-id "1" - :id (di/sha-256 "1") + :id #_{:clj-kondo/ignore [:unresolved-var]} + (di/sha-256 "1") :amount 12.0 :description-original "original-description" :status "POSTED" diff --git a/test/clj/auto_ap/import/yodlee_test.clj b/test/clj/auto_ap/import/yodlee_test.clj index 4c1d2b91..be1e03d2 100644 --- a/test/clj/auto_ap/import/yodlee_test.clj +++ b/test/clj/auto_ap/import/yodlee_test.clj @@ -1,5 +1,5 @@ (ns auto-ap.import.yodlee-test - (:require [auto-ap.import.yodlee :as sut] + (:require [auto-ap.import.yodlee2 :as sut] [clojure.test :as t])) diff --git a/test/clj/auto_ap/integration/graphql/clients.clj b/test/clj/auto_ap/integration/graphql/clients.clj index 64367210..ca1eef33 100644 --- a/test/clj/auto_ap/integration/graphql/clients.clj +++ b/test/clj/auto_ap/integration/graphql/clients.clj @@ -17,12 +17,14 @@ (d/release conn) (d/delete-database uri)))) +#_{:clj-kondo/ignore [:clojure-lsp/unused-public-var]} (defn admin-token [] {:user "TEST ADMIN" :exp (time/plus (time/now) (time/days 1)) :user/role "admin" :user/name "TEST ADMIN"}) +#_{:clj-kondo/ignore [:clojure-lsp/unused-public-var]} (defn user-token [client-id] {:user "TEST USER" :exp (time/plus (time/now) (time/days 1)) diff --git a/test/clj/auto_ap/integration/graphql/vendors.clj b/test/clj/auto_ap/integration/graphql/vendors.clj index e53d1c8a..9c2e571d 100644 --- a/test/clj/auto_ap/integration/graphql/vendors.clj +++ b/test/clj/auto_ap/integration/graphql/vendors.clj @@ -23,6 +23,7 @@ :user/role "admin" :user/name "TEST ADMIN"}) +#_{:clj-kondo/ignore [:clojure-lsp/unused-public-var]} (defn user-token [client-id] {:user "TEST USER" :exp (time/plus (time/now) (time/days 1)) @@ -31,14 +32,6 @@ :user/clients [{:db/id client-id}]}) - - - -(defn new-invoice [args] - (merge {:invoice/total 100.0 - :invoice/invoice-number (.toString (java.util.UUID/randomUUID))} - args)) - (use-fixtures :each wrap-setup) diff --git a/test/clj/auto_ap/integration/rule_matching.clj b/test/clj/auto_ap/integration/rule_matching.clj index 0205b778..0882faf3 100644 --- a/test/clj/auto_ap/integration/rule_matching.clj +++ b/test/clj/auto_ap/integration/rule_matching.clj @@ -18,10 +18,6 @@ (t/use-fixtures :each wrap-setup) -#_{:clj-kondo/ignore [:unused-binding]} -(defn noop-rule [transaction locations] - transaction) - (def base-transaction #:transaction {:amount -12.0 :date #inst "2014-01-02T08:00:00.000-00:00" :bank-account 456