diff --git a/src/clj/auto_ap/background/mail.clj b/src/clj/auto_ap/background/mail.clj index fa4e30c9..7cff2dbc 100644 --- a/src/clj/auto_ap/background/mail.clj +++ b/src/clj/auto_ap/background/mail.clj @@ -13,7 +13,6 @@ [clojure.tools.logging :as log] [config.core :refer [env]] [mount.core :as mount] - [unilog.context :as lc] [yang.scheduler :as scheduler]) (:import (java.util Properties UUID) diff --git a/src/clj/auto_ap/background/requests.clj b/src/clj/auto_ap/background/requests.clj index 49ac2fc7..6a0f85e2 100644 --- a/src/clj/auto_ap/background/requests.clj +++ b/src/clj/auto_ap/background/requests.clj @@ -3,7 +3,6 @@ [amazonica.aws.sqs :as sqs] [auto-ap.import.intuit :as i] [auto-ap.import.plaid :as p] - [auto-ap.import.yodlee :as y] [auto-ap.import.yodlee2 :as y2] [auto-ap.utils :refer [heartbeat]] [clojure.tools.logging :as log] diff --git a/src/clj/auto_ap/datomic.clj b/src/clj/auto_ap/datomic.clj index 2ade8607..c6aaa097 100644 --- a/src/clj/auto_ap/datomic.clj +++ b/src/clj/auto_ap/datomic.clj @@ -1,10 +1,10 @@ (ns auto-ap.datomic - (:require [auto-ap.utils :refer [default-pagination-size]] - [clj-time.coerce :as coerce] - [datomic.api :as d] - [clojure.tools.logging :as log] - [mount.core :as mount] - [config.core :refer [env]])) + (:require + [auto-ap.utils :refer [default-pagination-size]] + [clojure.tools.logging :as log] + [config.core :refer [env]] + [datomic.api :as d] + [mount.core :as mount])) (def uri (:datomic-url env)) @@ -20,13 +20,6 @@ (defn drop-database [] (d/delete-database uri)) -(defn merge-query [query-part-1 query-part-2] - (-> query-part-1 - (update-in [:query :find] into (get-in query-part-2 [:query :find])) - (update-in [:query :in] into (get-in query-part-2 [:query :in])) - (update-in [:query :where] into (get-in query-part-2 [:query :where])) - (update-in [:args] into (get-in query-part-2 [:args])))) - (defn remove-nils [m] (let [result (reduce-kv (fn [m k v] @@ -548,168 +541,7 @@ :where [?e :vendor/name]] (d/db (d/connect uri)))) -(defn load-vendors [vendors] - (->> vendors - (map - (fn [{:keys [primary-phone address email primary-contact secondary-email secondary-contact primary-email name default-expense-account id code secondary-phone invoice-reminder-schedule print-as]}] - (let [vendor-id (d/tempid :db.part/user) - address-id (d/tempid :db.part/user)] - (remove-nils #:vendor {:original-id id - :name name - :code (if (seq code) code nil) - :email email - :default-expense-account default-expense-account - :invoice-reminder-schedule nil - :address (remove-nils #:address {:street1 (:street1 address) - :street2 (:street2 address) - :city (:city address) - :state (:state address) - :zip (:zip address)}) - :primary-contact (remove-nils #:contact {:name primary-contact - :phone primary-phone - :email primary-email}) - :secondary-contact (remove-nils #:contact {:name secondary-contact - :phone secondary-phone - :email secondary-email})})))) - ) - ) -(defn load-clients [clients] - (->> clients - (map - (fn [{:keys [name address id code locations email bank-accounts signature-file] client-id :id}] - (remove-nils #:client {:original-id id - :name (str name) - :code nil - :email email - :signature-file signature-file - :locations locations - :address (remove-nils #:address {:street1 (:street1 address) - :street2 (:street2 address) - :city (:city address) - :state (:state address) - :zip (:zip address)}) - :bank-accounts (conj (map - (fn [{:keys [number id check-number bank-name bank-code routing name yodlee-account-id type] }] - (remove-nils #:bank-account {:number number - :original-id (str client-id "-" id) - :external-id id - :check-number check-number - :bank-name bank-name - :bank-code bank-code - :routing routing - :name name - :yodlee-account-id yodlee-account-id - :type (if type - (keyword "bank-account-type" type ) - :bank-account-type/check)})) - bank-accounts) - #:bank-account {:original-id (str client-id "-" 0) - :external-id 0 - :type :bank-account-type/cash})} ))))) - - -(defn load-invoices [invoices] - (->> invoices - (map - (fn [{:keys [id status total outstanding-balance invoice-number date customer-identifier company-id vendor-id default-location default-expense-account] invoice-id :id}] - [(remove-nils #:invoice {:original-id id - :invoice-number invoice-number - :date (coerce/to-date date) - :customer-identifier customer-identifier - :client [:client/original-id company-id] - :vendor (when vendor-id [:vendor/original-id vendor-id]) - - :default-location default-location - :default-expense-account default-expense-account - :total (double total) - :outstanding-balance (double outstanding-balance) - :status (keyword "invoice-status" status)})])))) - -(defn load-invoices-expense-accounts [invoices-expense-accounts] - (->> invoices-expense-accounts - (map - (fn [{:keys [id expense-account-id location amount invoice-id]}] - [(remove-nils #:invoice {:original-id invoice-id - :expense-accounts [(remove-nils #:invoice-expense-account {:original-id id - :expense-account-id expense-account-id - :location location - :amount (double amount)})]})])))) - - -(defn load-payments [checks] - (->> checks - (map - (fn [{:keys [id s3-uuid s3-key s3-url vendor-id company-id check-number memo date amount paid-to data bank-account-id status type] invoice-id :id}] - [(remove-nils #:payment {:original-id id - :s3-uuid s3-uuid - :s3-key s3-key - :s3-url s3-url - :vendor (when vendor-id [:vendor/original-id vendor-id]) - :client [:client/original-id company-id] - :bank-account (when (and bank-account-id - (not= "38-3" (str company-id "-" bank-account-id))) ;; TODO - 38-3 got removed at some ponitn - [:bank-account/original-id (str company-id "-" bank-account-id)]) - :check-number check-number - :memo memo - :date (coerce/to-date date) - :amount (double amount) - :paid-to paid-to - :pdf-data data - :status (keyword "payment-status" status) - :type (if type - (keyword "payment-type" type) - :payment-type/check)})])))) - -(defn load-invoices-payments [invoices-checks] - (->> invoices-checks - (map - (fn [{:keys [id invoice-id check-id amount]}] - [(remove-nils #:invoice-payment {:original-id id - :payment [:payment/original-id check-id] - :invoice [:invoice/original-id invoice-id] - :amount (double amount)})])))) - -(defn load-transactions [transactions] - (let [transactions (->> transactions - (map - (fn [{:keys [id amount description-original description-simple merchant-id merchant-name - date post-date type account-id status vendor-id company-id check-id check-number - bank-account-id]}] - (remove-nils #:transaction {:original-id id - :id id - :description-original description-original - :description-simple description-simple - :merchant-id merchant-id - :merchant-name merchant-name - :date (coerce/to-date date) - :post-date (coerce/to-date post-date) - :type type - :status status - :amount (double amount) - :account-id account-id - :check-number check-number - :vendor (when vendor-id [:vendor/original-id vendor-id]) - :client (when company-id [:client/original-id company-id]) - :payment (when check-id [:payment/original-id check-id]) - :bank-account (when (and bank-account-id - (not= "38-3" (str company-id "-" bank-account-id))) - [:bank-account/original-id (str company-id "-" bank-account-id)])}))) - (partition-all 10))] - (println "transactions: " (count transactions) "batches of 50") - transactions)) - -(defn load-users [users] - (->> users - (map - (fn [{:keys [id role provider-id provider companies name]}] - (remove-nils #:user {:original-id id - :name name - :role (keyword "user-role" role) - :provider-id provider-id - :provider provider - :clients (map (fn [c] [:client/original-id c]) companies)}))) - )) (defn query-vendors [] (d/q '[:find (pull ?e [*]) @@ -746,28 +578,28 @@ :where [?e :user/original-id]] (d/db (d/connect uri)))) -(defn migrate-vendors [conn] +(defn migrate-vendors [_] [[]]) -(defn migrate-clients [conn] +(defn migrate-clients [_] [[]]) -(defn migrate-invoices [conn] +(defn migrate-invoices [_] [[]]) -(defn migrate-payments [conn] +(defn migrate-payments [_] [[]]) -(defn migrate-invoices-payments [conn] +(defn migrate-invoices-payments [_] [[]]) -(defn migrate-invoices-expense-accounts [conn] +(defn migrate-invoices-expense-accounts [_] [[]]) -(defn migrate-transactions [conn] +(defn migrate-transactions [_] [[]]) -(defn migrate-users [conn] +(defn migrate-users [_] [[]]) (defn merge-query [query-part-1 query-part-2] @@ -780,7 +612,7 @@ (defn add-sorter-fields [q sort-map args] (log/info "sort-map" (pr-str sort-map)) (reduce - (fn [q {:keys [sort-key asc]}] + (fn [q {:keys [sort-key]}] (merge-query q {:query {:find [(symbol (str "?sort-" sort-key))] :where (sort-map diff --git a/src/clj/auto_ap/datomic/accounts.clj b/src/clj/auto_ap/datomic/accounts.clj index 4c47a8be..46b2478e 100644 --- a/src/clj/auto_ap/datomic/accounts.clj +++ b/src/clj/auto_ap/datomic/accounts.clj @@ -79,7 +79,7 @@ (d/db conn ) vendor-id))) -(defn get-account-by-numeric-code-and-sets [numeric-code sets] +(defn get-account-by-numeric-code-and-sets [numeric-code _] (let [query (cond-> {:query {:find ['(pull ?e [* {:account/type [:db/ident :db/id]}])] :in ['$ '?numeric-code] :where ['[?e :account/numeric-code ?numeric-code]]} @@ -122,7 +122,7 @@ true (apply-pagination args)))) -(defn graphql-results [ids db args] +(defn graphql-results [ids db _] (let [results (->> (d/pull-many db default-read ids) (group-by :db/id)) accounts (->> ids diff --git a/src/clj/auto_ap/datomic/bank_accounts.clj b/src/clj/auto_ap/datomic/bank_accounts.clj index a685a745..69aa2cab 100644 --- a/src/clj/auto_ap/datomic/bank_accounts.clj +++ b/src/clj/auto_ap/datomic/bank_accounts.clj @@ -1,8 +1,7 @@ (ns auto-ap.datomic.bank-accounts - (:require [datomic.api :as d] - [auto-ap.datomic :refer [uri]] - [clj-time.coerce :as c] - [clojure.set :refer [rename-keys]])) + (:require + [auto-ap.datomic :refer [uri]] + [datomic.api :as d])) (defn add-arg [query name value where & rest] (let [query (-> query diff --git a/src/clj/auto_ap/datomic/clients.clj b/src/clj/auto_ap/datomic/clients.clj index 157f96ce..8d281ed4 100644 --- a/src/clj/auto_ap/datomic/clients.clj +++ b/src/clj/auto_ap/datomic/clients.clj @@ -1,8 +1,8 @@ (ns auto-ap.datomic.clients - (:require [auto-ap.datomic :refer [conn uri]] - [clj-time.coerce :as coerce] - [clojure.tools.logging :as log] - [datomic.api :as d])) + (:require + [auto-ap.datomic :refer [conn uri]] + [clj-time.coerce :as coerce] + [datomic.api :as d])) (defn cleanse [e] (-> e diff --git a/src/clj/auto_ap/datomic/expected_deposit.clj b/src/clj/auto_ap/datomic/expected_deposit.clj index 6f894ee5..8d50ac71 100644 --- a/src/clj/auto_ap/datomic/expected_deposit.clj +++ b/src/clj/auto_ap/datomic/expected_deposit.clj @@ -1,10 +1,10 @@ (ns auto-ap.datomic.expected-deposit - (:require [auto-ap.datomic :refer [add-sorter-fields apply-pagination apply-sort-3 merge-query conn]] - [auto-ap.graphql.utils :refer [limited-clients]] - [clj-time.coerce :as c] - [datomic.api :as d] - [clj-time.core :as t])) - + (:require + [auto-ap.datomic + :refer [add-sorter-fields apply-pagination apply-sort-3 conn merge-query]] + [auto-ap.graphql.utils :refer [limited-clients]] + [clj-time.coerce :as c] + [datomic.api :as d])) (defn <-datomic [result] (let [transaction (first (:transaction/_expected-deposit result)) diff --git a/src/clj/auto_ap/datomic/invoices.clj b/src/clj/auto_ap/datomic/invoices.clj index d1acb46a..6cb46493 100644 --- a/src/clj/auto_ap/datomic/invoices.clj +++ b/src/clj/auto_ap/datomic/invoices.clj @@ -1,14 +1,15 @@ (ns auto-ap.datomic.invoices - (:require [datomic.api :as d] - [auto-ap.datomic :refer [uri merge-query apply-pagination apply-sort-3 add-sorter-fields conn]] - [auto-ap.graphql.utils :refer [limited-clients]] - [clojure.set :refer [rename-keys]] - [clj-time.coerce :as coerce] - [auto-ap.time-utils :refer [next-dom]] - [clj-time.core :as time] - [auto-ap.datomic.vendors :as d-vendors] - [clojure.tools.logging :as log] - [auto-ap.datomic.accounts :as d-accounts])) + (:require + [auto-ap.datomic + :refer [add-sorter-fields apply-pagination apply-sort-3 conn merge-query uri]] + [auto-ap.datomic.accounts :as d-accounts] + [auto-ap.datomic.vendors :as d-vendors] + [auto-ap.graphql.utils :refer [limited-clients]] + [auto-ap.time-utils :refer [next-dom]] + [clj-time.coerce :as coerce] + [clj-time.core :as time] + [clojure.set :refer [rename-keys]] + [datomic.api :as d])) (def default-read '[* {:invoice/client [:client/name :db/id :client/locations :client/code]} @@ -41,7 +42,7 @@ (->> (cond-> {:query {:find [] :in ['$] :where ['[?e :invoice/client]]} - :args [(d/db (d/connect uri))]} + :args [db]} (:exact-match-id args) (merge-query {:query {:in ['?e] @@ -162,7 +163,7 @@ (apply-pagination args)))) -(defn graphql-results [ids db args] +(defn graphql-results [ids db _] (let [results (->> (d/pull-many db default-read ids) (group-by :db/id)) @@ -218,10 +219,6 @@ (d/pull default-read id) (<-datomic))) -(defn update [update] - @(d/transact (d/connect uri) [update]) - (get-by-id (:db/id update) )) - (defn get-multi [ids] (map <-datomic (-> (d/db (d/connect uri)) diff --git a/src/clj/auto_ap/datomic/migrate.clj b/src/clj/auto_ap/datomic/migrate.clj index da9831ac..083aa41a 100644 --- a/src/clj/auto_ap/datomic/migrate.clj +++ b/src/clj/auto_ap/datomic/migrate.clj @@ -29,7 +29,7 @@ [filename] (-> (io/resource filename) (io/reader) (Util/readAll))) -(defn functions [conn] +(defn functions [_] [[{:db/ident :pay :db/doc "Data function that increments value of attribute a by amount." :db/fn (d/function '{:lang "clojure" @@ -47,7 +47,7 @@ :code [[:db/add e a (-> (d/entity db e) a (+ amount))]] })}]] ) -(defn fix-pay-function [conn] +(defn fix-pay-function [_] [[{:db/ident :pay :db/doc "Data function that increments value of attribute a by amount." :db/fn (d/function '{:lang "clojure" @@ -65,7 +65,7 @@ :db/valueType :db.type/string :db/cardinality :db.cardinality/one}]]) -(defn reset-function [conn] +(defn reset-function [_] [[{:db/ident :reset :db/doc "Resets a relationship to the values specified " :db/fn (d/function '{:lang "clojure" @@ -84,7 +84,7 @@ a vs})))})}]]) -(defn propose-invoice-fn [conn] +(defn propose-invoice-fn [_] [[{:db/ident :propose-invoice :db/doc "Adds an invoice if it's not found" :db/fn (d/function '{:lang "clojure" @@ -204,10 +204,8 @@ :requires [:auto-ap/add-import-status]} :auto-ap/fix-check-numbers {:txes-fn 'auto-ap.datomic.migrate.check-numbers/fix-check-numbers :requires [:auto-ap/add-import-status-existing-invoices]} - :auto-ap/add-new-vendors {:txes-fn 'auto-ap.datomic.migrate.add-new-vendors/add-new-vendors - :requires [:auto-ap/fix-check-numbers]} :auto-ap/add-account-visibility-fields {:txes-fn 'auto-ap.datomic.migrate.account-sorting/add-account-visibility-fields - :requires [:auto-ap/add-new-vendors]} + :requires [:auto-ap/fix-check-numbers]} :auto-ap/make-every-account-visible {:txes-fn 'auto-ap.datomic.migrate.account-sorting/make-every-account-visible :requires [:auto-ap/add-account-visibility-fields]} :auto-ap/add-general-ledger6 {:txes add-general-ledger/add-general-ledger @@ -542,7 +540,7 @@ (d/release conn)) (println "Done"))) -(defn -main [& args] +(defn -main [& _] (mount/start (mount/only #{#'conn})) (migrate conn) (mount/stop)) diff --git a/src/clj/auto_ap/datomic/migrate/account_sorting.clj b/src/clj/auto_ap/datomic/migrate/account_sorting.clj index 3a184146..90d0bd18 100644 --- a/src/clj/auto_ap/datomic/migrate/account_sorting.clj +++ b/src/clj/auto_ap/datomic/migrate/account_sorting.clj @@ -2,7 +2,7 @@ (:require [datomic.api :as d])) -(defn add-account-visibility-fields [conn] +(defn add-account-visibility-fields [_] [[ {:db/ident :bank-account/visible :db/valueType :db.type/boolean 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 06e17c4e..81800ff0 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 @@ -1,9 +1,9 @@ (ns auto-ap.datomic.migrate.add-bank-account-codes - (:require [datomic.api :as d] - [auto-ap.datomic :refer [uri]] - [clojure.string :as str])) + (:require + [clojure.string :as str] + [datomic.api :as d])) -(defn add-bank-account-codes-schema [conn] +(defn add-bank-account-codes-schema [_] [[{:db/ident :bank-account/code :db/valueType :db.type/string :db/unique :db.unique/identity 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 aa569463..3fa774e6 100644 --- a/src/clj/auto_ap/datomic/migrate/add_client_codes.clj +++ b/src/clj/auto_ap/datomic/migrate/add_client_codes.clj @@ -1,6 +1,7 @@ (ns auto-ap.datomic.migrate.add-client-codes - (:require [auto-ap.datomic :refer [uri]] - [datomic.api :as d])) + (:require + [datomic.api :as d])) + (def name->code (->> [["Moscini Pizza Inc" "MPI"] diff --git a/src/clj/auto_ap/datomic/migrate/add_new_vendors.clj b/src/clj/auto_ap/datomic/migrate/add_new_vendors.clj index 70c6bdaa..25ee41f1 100644 --- a/src/clj/auto_ap/datomic/migrate/add_new_vendors.clj +++ b/src/clj/auto_ap/datomic/migrate/add_new_vendors.clj @@ -1,28 +1,3 @@ -(ns auto-ap.datomic.migrate.add-new-vendors - (:require [datomic.api :as d] - [auto-ap.datomic :refer [uri]] - [clojure.data.csv :as csv] - [clojure.java.io :as io] - [clojure.string :as str]) - (:import [org.apache.commons.io.input BOMInputStream])) +(ns auto-ap.datomic.migrate.add-new-vendors) + -(defn add-new-vendors [conn] - [[]] - #_(let [[header & rows] (-> "vendor-list.csv" (io/resource) io/input-stream (BOMInputStream.) (io/reader) csv/read-csv) - headers (map read-string header) - new-vendors [(reduce - (fn [rows r] - (conj rows (reduce - (fn [r [header value]] - (condp = header - [:vendor/address] r - [:vendor/default-expense-account] (assoc-in r header (Integer/parseInt (str/replace value #"A" ""))) - [:vendor/invoice-reminder-schedule] r - (assoc-in r header value))) - {} - (map vector headers r)))) - [] - rows)]] - (println (ffirst new-vendors)) - new-vendors - )) diff --git a/src/clj/auto_ap/datomic/migrate/check_numbers.clj b/src/clj/auto_ap/datomic/migrate/check_numbers.clj index 40d09d79..04ed8e02 100644 --- a/src/clj/auto_ap/datomic/migrate/check_numbers.clj +++ b/src/clj/auto_ap/datomic/migrate/check_numbers.clj @@ -3,6 +3,6 @@ (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 client] max-check-numbers + [(for [[bank-account check-number max-check _] max-check-numbers :when (>= max-check check-number)] {:db/id bank-account :payment/check-number (inc max-check)})])) diff --git a/src/clj/auto_ap/datomic/migrate/invoice_converter.clj b/src/clj/auto_ap/datomic/migrate/invoice_converter.clj index 4b379669..462bf062 100644 --- a/src/clj/auto_ap/datomic/migrate/invoice_converter.clj +++ b/src/clj/auto_ap/datomic/migrate/invoice_converter.clj @@ -34,7 +34,7 @@ :location-match/matches ["campbell brewing company"]}]}]] [[]])) -(defn add-default-location [conn] +(defn add-default-location [_] [[{:db/ident :client/default-location :db/valueType :db.type/string :db/cardinality :db.cardinality/one diff --git a/src/clj/auto_ap/datomic/migrate/rename_codes.clj b/src/clj/auto_ap/datomic/migrate/rename_codes.clj index 7226f5e7..3b91e3a0 100644 --- a/src/clj/auto_ap/datomic/migrate/rename_codes.clj +++ b/src/clj/auto_ap/datomic/migrate/rename_codes.clj @@ -26,7 +26,7 @@ ) ) -(defn rename-codes-1 [conn] +(defn rename-codes-1 [_] (let [result (apply concat [(rename "WE" "WME" (d/connect uri)) (rename "HM" "HIM" (d/connect uri)) (rename "BES" "SBE" (d/connect uri)) diff --git a/src/clj/auto_ap/datomic/sales_orders.clj b/src/clj/auto_ap/datomic/sales_orders.clj index c43b4023..9f557304 100644 --- a/src/clj/auto_ap/datomic/sales_orders.clj +++ b/src/clj/auto_ap/datomic/sales_orders.clj @@ -1,7 +1,6 @@ (ns auto-ap.datomic.sales-orders (:require [auto-ap.datomic :refer [add-sorter-fields apply-pagination apply-sort-3 merge-query uri]] [auto-ap.graphql.utils :refer [limited-clients]] - [auto-ap.utils :refer [dollars=]] [clj-time.coerce :as c] [datomic.api :as d] [clojure.tools.logging :as log] @@ -98,7 +97,7 @@ true (apply-sort-3 (assoc args :default-asc? false)) true (apply-pagination args)))) -(defn graphql-results [ids db args] +(defn graphql-results [ids db _] (let [results (->> (d/pull-many db default-read ids) (group-by :db/id)) payments (->> ids diff --git a/src/clj/auto_ap/datomic/transaction_rules.clj b/src/clj/auto_ap/datomic/transaction_rules.clj index 56ceb8f8..074fa7e3 100644 --- a/src/clj/auto_ap/datomic/transaction_rules.clj +++ b/src/clj/auto_ap/datomic/transaction_rules.clj @@ -1,10 +1,10 @@ (ns auto-ap.datomic.transaction-rules - (:require [datomic.api :as d] - [auto-ap.datomic :refer [uri merge-query apply-sort-3 apply-pagination add-sorter-fields]] - [auto-ap.graphql.utils :refer [limited-clients]] - [clojure.set :refer [rename-keys]] - [clj-time.coerce :as c] - [clojure.string :as str])) + (:require + [auto-ap.datomic + :refer [add-sorter-fields apply-pagination apply-sort-3 merge-query uri]] + [auto-ap.graphql.utils :refer [limited-clients]] + [clojure.string :as str] + [datomic.api :as d])) (defn <-datomic [result] result) @@ -76,7 +76,7 @@ true (apply-sort-3 args) true (apply-pagination args)))) -(defn graphql-results [ids db args] +(defn graphql-results [ids db _] (let [results (->> (d/pull-many db default-read ids) (group-by :db/id)) transaction-rules (->> ids diff --git a/src/clj/auto_ap/datomic/transactions.clj b/src/clj/auto_ap/datomic/transactions.clj index f59ea98c..424edbe8 100644 --- a/src/clj/auto_ap/datomic/transactions.clj +++ b/src/clj/auto_ap/datomic/transactions.clj @@ -1,26 +1,16 @@ (ns auto-ap.datomic.transactions - (:require [datomic.api :as d] - [auto-ap.datomic :refer [uri merge-query apply-sort-3 apply-pagination add-sorter-fields conn]] - [auto-ap.graphql.utils :refer [limited-clients]] - [clj-time.coerce :as c] - [clj-time.coerce :as coerce] - [clojure.tools.logging :as log] - [clojure.string :as str] - [auto-ap.datomic.accounts :as d-accounts])) - -(defn sort-fn [sort-by] - (cond - (= "client" sort-by) - #(-> % :transaction/client :client/name) - - (= "account" sort-by) - #(vector (-> % :transaction/account :account/name) (-> % :db/id)) - - :else - (keyword "transaction" sort-by))) + (:require + [auto-ap.datomic + :refer [add-sorter-fields apply-pagination apply-sort-3 conn merge-query uri]] + [auto-ap.datomic.accounts :as d-accounts] + [auto-ap.graphql.utils :refer [limited-clients]] + [clj-time.coerce :as coerce] + [clojure.string :as str] + [clojure.tools.logging :as log] + [datomic.api :as d])) (defn potential-duplicate-ids [db args] - (if (and (:potential-duplicates args) + (when (and (:potential-duplicates args) (:bank-account-id args)) (->> (d/q '[:find ?tx ?amount ?date :in $ ?ba @@ -31,9 +21,9 @@ (not [?tx :transaction/approval-status :transaction-approval-status/suppressed])] db (:bank-account-id args)) - (group-by (fn [[tx amount date]] + (group-by (fn [[_ amount date]] [amount date])) - (filter (fn [[g txes]] + (filter (fn [[_ txes]] (> (count txes) 1))) (vals) @@ -183,7 +173,7 @@ true (apply-sort-3 (assoc args :default-asc? false)) true (apply-pagination args))))) -(defn graphql-results [ids db args] +(defn graphql-results [ids db _] (let [results (->> (d/pull-many db '[* {:transaction/client [:client/name :db/id :client/code] :transaction/approval-status [:db/ident :db/id] :transaction/bank-account [:bank-account/name :bank-account/code :bank-account/yodlee-account-id :db/id :bank-account/locations :bank-account/current-balance] @@ -201,8 +191,8 @@ {:account-client-override/client [:db/id]}]}]}] :transaction/yodlee-merchant [:db/id :yodlee-merchant/yodlee-id :yodlee-merchant/name]}] ids) - (map #(update % :transaction/date c/from-date)) - (map #(update % :transaction/post-date c/from-date)) + (map #(update % :transaction/date coerce/from-date)) + (map #(update % :transaction/post-date coerce/from-date)) (map #(update % :transaction/accounts (fn [tas] (map @@ -211,8 +201,8 @@ tas)))) (map (fn [transaction] (cond-> transaction - (:transaction/payment transaction) (update-in [:transaction/payment :payment/date] c/from-date) - (:transaction/expected-deposit transaction) (update-in [:transaction/expected-deposit :expected-deposit/date] c/from-date)) + (:transaction/payment transaction) (update-in [:transaction/payment :payment/date] coerce/from-date) + (:transaction/expected-deposit transaction) (update-in [:transaction/expected-deposit :expected-deposit/date] coerce/from-date)) )) (map #(dissoc % :transaction/id)) (group-by :db/id))] @@ -257,7 +247,7 @@ {:account-client-override/client [:db/id]}]}]}] :transaction/yodlee-merchant [:db/id :yodlee-merchant/yodlee-id :yodlee-merchant/name]}] id) - (update :transaction/date c/from-date) - (update :transaction/post-date c/from-date) + (update :transaction/date coerce/from-date) + (update :transaction/post-date coerce/from-date) (dissoc :transaction/id))) diff --git a/src/clj/auto_ap/datomic/users.clj b/src/clj/auto_ap/datomic/users.clj index 80273217..d403184a 100644 --- a/src/clj/auto_ap/datomic/users.clj +++ b/src/clj/auto_ap/datomic/users.clj @@ -1,8 +1,7 @@ (ns auto-ap.datomic.users - (:require [datomic.api :as d] - [auto-ap.datomic :refer [uri]] - [clojure.set :refer [rename-keys]] - [clj-time.coerce :as c])) + (:require + [auto-ap.datomic :refer [uri]] + [datomic.api :as d])) (defn add-arg [query name value where & rest] (let [query (-> query @@ -48,7 +47,7 @@ is-first-user? (assoc :user/role :user-role/admin))])] (get-by-id (-> new-user-trans :tempids (get "user"))))))) -(defn raw-graphql [args] +(defn raw-graphql [_] (let [query (cond-> {:query {:find ['(pull ?e [* {:user/clients [*]} {:user/role [:db/ident]}])] diff --git a/src/clj/auto_ap/datomic/yodlee2.clj b/src/clj/auto_ap/datomic/yodlee2.clj index d9270717..6e149aa4 100644 --- a/src/clj/auto_ap/datomic/yodlee2.clj +++ b/src/clj/auto_ap/datomic/yodlee2.clj @@ -1,12 +1,10 @@ (ns auto-ap.datomic.yodlee2 - (:require [datomic.api :as d] - [auto-ap.datomic :refer [uri remove-nils merge-query apply-pagination apply-sort-3 add-sorter-fields conn]] - [auto-ap.graphql.utils :refer [limited-clients]] - [auto-ap.parse :as parse] - [clj-time.coerce :as c] - [clojure.set :refer [rename-keys]] - [clojure.string :as str] - [clojure.tools.logging :as log])) + (:require + [auto-ap.datomic + :refer [add-sorter-fields apply-pagination apply-sort-3 merge-query uri]] + [auto-ap.graphql.utils :refer [limited-clients]] + [clj-time.coerce :as c] + [datomic.api :as d])) (def default-read '[*]) @@ -17,8 +15,8 @@ (->> (cond-> {:query {:find [] :in ['$] :where ['[?e :yodlee-provider-account/id]]} - :args [(d/db (d/connect uri))]} - + :args [db]} + (limited-clients (:id args)) (merge-query {:query {:in ['[?xx ...]] :where ['[?e :yodlee-provider-account/client ?xx]]} @@ -40,14 +38,13 @@ true (merge-query {:query {:find ['?e ] :where ['[?e :yodlee-provider-account/id]]}}) ) - (d/query) (apply-sort-3 args) (apply-pagination args))) -(defn graphql-results [ids db args] +(defn graphql-results [ids db _] (let [results (->> (d/pull-many db default-read ids) (group-by :db/id))] (->> ids diff --git a/src/clj/auto_ap/datomic/yodlee_merchants.clj b/src/clj/auto_ap/datomic/yodlee_merchants.clj index ab0295bf..5497a1e3 100644 --- a/src/clj/auto_ap/datomic/yodlee_merchants.clj +++ b/src/clj/auto_ap/datomic/yodlee_merchants.clj @@ -1,9 +1,9 @@ (ns auto-ap.datomic.yodlee-merchants - (:require [datomic.api :as d] - [auto-ap.graphql.utils :refer [->graphql]] - [auto-ap.datomic :refer [uri merge-query]])) + (:require + [auto-ap.datomic :refer [uri]] + [datomic.api :as d])) -(defn get-merchants [args] +(defn get-merchants [_] ;; TODO admin? (let [query {:query {:find ['(pull ?e [:yodlee-merchant/name :yodlee-merchant/yodlee-id :db/id])] :in ['$] diff --git a/src/clj/auto_ap/graphql.clj b/src/clj/auto_ap/graphql.clj index 0e12350f..be720633 100644 --- a/src/clj/auto_ap/graphql.clj +++ b/src/clj/auto_ap/graphql.clj @@ -1,28 +1,27 @@ (ns auto-ap.graphql (:require [auto-ap.datomic :refer [merge-query uri]] - [auto-ap.datomic.checks :as d-checks] [auto-ap.datomic.users :as d-users] [auto-ap.graphql.accounts :as gq-accounts] [auto-ap.graphql.checks :as gq-checks] - [auto-ap.graphql.ezcater :as gq-ezcater] [auto-ap.graphql.clients :as gq-clients] [auto-ap.graphql.expected-deposit :as gq-expected-deposit] + [auto-ap.graphql.ezcater :as gq-ezcater] [auto-ap.graphql.import-batch :as gq-import-batches] [auto-ap.graphql.intuit-bank-accounts :as gq-intuit-bank-accounts] - [auto-ap.graphql.reports :as gq-reports] [auto-ap.graphql.invoices :as gq-invoices] [auto-ap.graphql.ledger :as gq-ledger] + [auto-ap.graphql.plaid :as gq-plaid] + [auto-ap.graphql.reports :as gq-reports] [auto-ap.graphql.requests :as gq-requests] [auto-ap.graphql.sales-orders :as gq-sales-orders] [auto-ap.graphql.transaction-rules :as gq-transaction-rules] [auto-ap.graphql.transactions :as gq-transactions] [auto-ap.graphql.users :as gq-users] - [auto-ap.graphql.utils :refer [assert-admin assert-can-see-client]] + [auto-ap.graphql.utils :refer [assert-admin]] [auto-ap.graphql.vendors :as gq-vendors] [auto-ap.graphql.yodlee-merchants :as ym] [auto-ap.graphql.yodlee2 :as gq-yodlee2] - [auto-ap.graphql.plaid :as gq-plaid] [auto-ap.logging :refer [error-event info-event warn-event]] [auto-ap.time :as time] [clj-time.coerce :as coerce] @@ -30,14 +29,14 @@ [clojure.string :as str] [clojure.tools.logging :as log] [clojure.walk :as walk] + [com.unbounce.dogstatsd.core :as statsd] [com.walmartlabs.lacinia :refer [execute]] + [com.walmartlabs.lacinia.parser :as p] [com.walmartlabs.lacinia.schema :as schema] [com.walmartlabs.lacinia.util :refer [attach-resolvers]] [datomic.api :as d] [unilog.context :as lc] - [yang.time :refer [time-it]] - [com.unbounce.dogstatsd.core :as statsd] - [com.walmartlabs.lacinia.parser :as p]) + [yang.time :refer [time-it]]) (:import (clojure.lang IPersistentMap))) @@ -609,7 +608,7 @@ -(defn get-user [context args value] +(defn get-user [context args _] (assert-admin (:id context)) (let [users (d-users/get-graphql args)] @@ -619,7 +618,7 @@ -(defn get-expense-account-stats [context {:keys [client_id] } value] +(defn get-expense-account-stats [_ {:keys [client_id] } _] (let [result (cond-> {:query {:find ['?account '?account-name '(sum ?amount)] :in ['$] :where []} @@ -645,7 +644,7 @@ (<= x 60 ) :due-60 :else :due-later)) -(defn get-invoice-stats [context {:keys [client_id] } value] +(defn get-invoice-stats [_ {:keys [client_id] } _] (let [result (cond-> {:query {:find ['?name '(sum ?outstanding-balance) '(sum ?total)] :in ['$] :where []} @@ -687,7 +686,7 @@ (def first-week-a (coerce/to-date-time #inst "1999-12-27T00:00:00.000-07:00")) -(defn get-cash-flow [context {:keys [client_id]} value] +(defn get-cash-flow [_ {:keys [client_id]} _] (when client_id (let [{:client/keys [week-a-credits week-a-debits week-b-credits week-b-debits forecasted-transactions ]} (d/pull (d/db (d/connect uri)) '[*] client_id) total-cash (reduce @@ -841,7 +840,7 @@ (defn query-name [q] (try (str/join "__" (map name (:operations (p/operations (p/parse-query schema q))))) - (catch Exception e + (catch Exception _ "unknown query"))) (defn query diff --git a/src/clj/auto_ap/graphql/accounts.clj b/src/clj/auto_ap/graphql/accounts.clj index 8b180a65..1be12367 100644 --- a/src/clj/auto_ap/graphql/accounts.clj +++ b/src/clj/auto_ap/graphql/accounts.clj @@ -21,7 +21,7 @@ (defn get-all-graphql [context args _] (assert-admin (:id context)) (let [args (assoc args :id (:id context)) - [accounts accounts-count ] (d-accounts/get-graphql (assoc (<-graphql args) :per-page Integer/MAX_VALUE))] + [accounts _ ] (d-accounts/get-graphql (assoc (<-graphql args) :per-page Integer/MAX_VALUE))] (map ->graphql accounts))) (defn default-for-vendor [context args _] diff --git a/src/clj/auto_ap/graphql/checks.clj b/src/clj/auto_ap/graphql/checks.clj index 607c5020..10c3c0f5 100644 --- a/src/clj/auto_ap/graphql/checks.clj +++ b/src/clj/auto_ap/graphql/checks.clj @@ -10,7 +10,7 @@ [auto-ap.datomic.transactions :as d-transactions] [auto-ap.datomic.vendors :as d-vendors] [auto-ap.graphql.utils - :refer [->graphql <-graphql assert-admin assert-failure assert-can-see-client enum->keyword assert-not-locked assert-none-locked]] + :refer [->graphql <-graphql assert-admin assert-failure assert-can-see-client enum->keyword assert-not-locked]] [auto-ap.numeric :refer [num->words]] [auto-ap.time :refer [iso-date local-now parse]] [auto-ap.utils :refer [by dollars-0?]] @@ -296,7 +296,7 @@ (into (invoice-payments invoices invoice-amounts))))) -(defmethod invoices->entities :payment-type/balance-credit [invoices vendor client bank-account type index invoice-amounts] +(defmethod invoices->entities :payment-type/balance-credit [invoices invoice-amounts] (when (<= (->> invoices (map (comp invoice-amounts :db/id)) (reduce + 0.0)) diff --git a/src/clj/auto_ap/graphql/expected_deposit.clj b/src/clj/auto_ap/graphql/expected_deposit.clj index 73d76eb5..f3f0d356 100644 --- a/src/clj/auto_ap/graphql/expected_deposit.clj +++ b/src/clj/auto_ap/graphql/expected_deposit.clj @@ -3,23 +3,22 @@ [auto-ap.datomic.expected-deposit :as d-expected-deposit] [auto-ap.graphql.utils :refer [->graphql <-graphql assert-admin ident->enum-f result->page]] - [com.walmartlabs.lacinia.util :refer [attach-resolvers]] - [clojure.tools.logging :as log])) + [com.walmartlabs.lacinia.util :refer [attach-resolvers]])) (def status->graphql (ident->enum-f :expected-deposit/status)) -(defn get-expected-deposit [context args value] +(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 value] +(defn get-all-expected-deposits [context args _] (assert-admin (:id context)) (map (comp ->graphql status->graphql) (first (d-expected-deposit/get-graphql (assoc (<-graphql args) :count Integer/MAX_VALUE))))) -(defn get-expected-deposit-page [context args value] +(defn get-expected-deposit-page [context args _] (let [args (assoc args :id (:id context)) [expected-deposits expected-deposit-count] (d-expected-deposit/get-graphql (<-graphql args)) expected-deposits (map status->graphql expected-deposits)] diff --git a/src/clj/auto_ap/graphql/import_batch.clj b/src/clj/auto_ap/graphql/import_batch.clj index bf1b785c..f0ae7c6a 100644 --- a/src/clj/auto_ap/graphql/import_batch.clj +++ b/src/clj/auto_ap/graphql/import_batch.clj @@ -1,12 +1,14 @@ (ns auto-ap.graphql.import-batch - (:require [auto-ap.datomic + (:require + [auto-ap.datomic :refer [add-sorter-fields apply-pagination apply-sort-3 conn merge-query]] - [auto-ap.graphql.utils + [auto-ap.graphql.utils :refer [<-graphql assert-admin ident->enum-f result->page]] - [com.walmartlabs.lacinia.util :refer [attach-resolvers]] - [datomic.api :as d])) + [clj-time.coerce :as coerce] + [com.walmartlabs.lacinia.util :refer [attach-resolvers]] + [datomic.api :as d])) (def default-read '[:db/id :import-batch/external-id @@ -37,7 +39,7 @@ true (apply-sort-3 args) true (apply-pagination args)))) -(defn graphql-results [ids db args] +(defn graphql-results [ids db _] (let [results (->> (d/pull-many db default-read ids) (group-by :db/id))] (->> ids @@ -50,14 +52,14 @@ [(graphql-results ids-to-retrieve db args) matching-count])) -(defn get-import-batch-page [context args value] +(defn get-import-batch-page [context args _] (let [_ (assert-admin (:id context)) args (assoc (:filters args) :id (:id context)) [values matching-count] (get-graphql (<-graphql args))] (result->page (->> values (map (ident->enum-f :import-batch/source)) (map (ident->enum-f :import-batch/status)) - (map #(update % :import-batch/date clj-time.coerce/to-date-time))) + (map #(update % :import-batch/date coerce/to-date-time))) matching-count :data args))) diff --git a/src/clj/auto_ap/graphql/intuit_bank_accounts.clj b/src/clj/auto_ap/graphql/intuit_bank_accounts.clj index 320f52a5..d89f055f 100644 --- a/src/clj/auto_ap/graphql/intuit_bank_accounts.clj +++ b/src/clj/auto_ap/graphql/intuit_bank_accounts.clj @@ -1,10 +1,11 @@ (ns auto-ap.graphql.intuit-bank-accounts - (:require [auto-ap.graphql.utils :refer [->graphql <-graphql assert-admin]] - [auto-ap.datomic :refer [conn]] - [datomic.api :as d])) + (:require + [auto-ap.datomic :refer [conn]] + [auto-ap.graphql.utils :refer [->graphql assert-admin]] + [datomic.api :as d])) -(defn get-intuit-bank-accounts [context args value] - #_(assert-admin (:id context)) +(defn get-intuit-bank-accounts [context _ _] + (assert-admin (:id context)) (->graphql (map first (d/q '[:find (pull ?e [*]) :in $ :where [?e :intuit-bank-account/external-id]] diff --git a/src/clj/auto_ap/graphql/invoices.clj b/src/clj/auto_ap/graphql/invoices.clj index 277f15b1..5937a050 100644 --- a/src/clj/auto_ap/graphql/invoices.clj +++ b/src/clj/auto_ap/graphql/invoices.clj @@ -1,12 +1,11 @@ (ns auto-ap.graphql.invoices (:require [auto-ap.datomic - :refer [audit-transact audit-transact-batch conn remove-nils uri]] + :refer [audit-transact conn remove-nils uri]] [auto-ap.datomic.clients :as d-clients] [auto-ap.datomic.invoices :as d-invoices] [auto-ap.datomic.vendors :as d-vendors] [auto-ap.graphql.checks :as gq-checks] - [auto-ap.time :as atime] [auto-ap.graphql.utils :as u :refer [<-graphql diff --git a/src/clj/auto_ap/graphql/plaid.clj b/src/clj/auto_ap/graphql/plaid.clj index 763ebe07..4aacd627 100644 --- a/src/clj/auto_ap/graphql/plaid.clj +++ b/src/clj/auto_ap/graphql/plaid.clj @@ -16,14 +16,14 @@ [com.walmartlabs.lacinia.util :refer [attach-resolvers]] [datomic.api :as d])) -(defn plaid-link-token [context value args] +(defn plaid-link-token [context value _] (when-not (:client_id value) (throw (ex-info "Client ID is required" {:validation-error "Client ID is required"}))) (assert-can-see-client (:id context) (:client_id value)) (let [client-code (:client/code (d/pull (d/db conn) [:client/code] (:client_id value)))] {:token (p/get-link-token client-code)})) -(defn link-plaid [context value args] +(defn link-plaid [context value _] (when-not (:client_code value) (throw (ex-info "Client not provided" {:validation-error "Client not provided."}))) (when-not (:public_token value) @@ -91,7 +91,7 @@ true (apply-sort-3 args) true (apply-pagination args)))) -(defn graphql-results [ids db args] +(defn graphql-results [ids db _] (let [results (->> (d/pull-many db default-read ids) (group-by :db/id))] (->> ids @@ -106,7 +106,7 @@ -(defn get-plaid-item-page [context args value] +(defn get-plaid-item-page [context args _] (let [args (assoc args :id (:id context)) [plaid-items cnt] (get-graphql (<-graphql (assoc args :id (:id context))))] @@ -118,7 +118,7 @@ :start (:start args 0) :end (+ (:start args 0) (count plaid-items))})) -(defn delete-plaid-item [context args value] +(defn delete-plaid-item [context args _] (assert-admin (:id context)) (assert-present args :id) @(d/transact conn [[:db/retractEntity (:id args)]]) diff --git a/src/clj/auto_ap/graphql/requests.clj b/src/clj/auto_ap/graphql/requests.clj index 4a8db809..94521961 100644 --- a/src/clj/auto_ap/graphql/requests.clj +++ b/src/clj/auto_ap/graphql/requests.clj @@ -4,7 +4,7 @@ [auto-ap.graphql.utils :refer [assert-admin]] [config.core :refer [env]])) -(defn request-import [context value args] +(defn request-import [context value _] (assert-admin (:id context)) (:message-id (sqs/send-message {:queue-url (:requests-queue-url env) :message-body (:which value)} ))) diff --git a/src/clj/auto_ap/graphql/transaction_rules.clj b/src/clj/auto_ap/graphql/transaction_rules.clj index 6f1e95e5..6aff56a8 100644 --- a/src/clj/auto_ap/graphql/transaction_rules.clj +++ b/src/clj/auto_ap/graphql/transaction_rules.clj @@ -19,7 +19,6 @@ [auto-ap.rule-matching :as rm] [auto-ap.utils :refer [dollars=]] [clj-time.coerce :as c] - [clojure.set :as set] [clojure.string :as str] [datomic.api :as d])) diff --git a/src/clj/auto_ap/graphql/users.clj b/src/clj/auto_ap/graphql/users.clj index 50ff139a..05ec720d 100644 --- a/src/clj/auto_ap/graphql/users.clj +++ b/src/clj/auto_ap/graphql/users.clj @@ -9,7 +9,7 @@ :manager :user-role/manager :user :user-role/user}) -(defn edit-user [context {:keys [edit_user] :as args} value] +(defn edit-user [context {:keys [edit_user]} _] (assert-admin (:id context)) (let [user (d-users/get-by-id (:id edit_user)) new-clients (set (map #(Long/parseLong %) (:clients edit_user))) diff --git a/src/clj/auto_ap/graphql/utils.clj b/src/clj/auto_ap/graphql/utils.clj index d28b4a8f..2812606e 100644 --- a/src/clj/auto_ap/graphql/utils.clj +++ b/src/clj/auto_ap/graphql/utils.clj @@ -59,7 +59,7 @@ ([args key] (assert-present args key (name key))) ([args key name] - (if (not (get args key)) + (when (not (get args key)) (throw (ex-info (str "Missing field '" name "'.") {:validation-error (str "Missing field '" name "'.")}))))) @@ -87,8 +87,7 @@ (defn limited-clients [id] (cond - (or - (= (:user/role id) "none")) + (= (:user/role id) "none") [] (= (:user/role id) "admin") diff --git a/src/clj/auto_ap/graphql/vendors.clj b/src/clj/auto_ap/graphql/vendors.clj index 0cefcda7..41038667 100644 --- a/src/clj/auto_ap/graphql/vendors.clj +++ b/src/clj/auto_ap/graphql/vendors.clj @@ -11,7 +11,6 @@ enum->keyword is-admin? result->page]] - [auto-ap.utils :refer [by]] [clojure.set :as set] [clojure.string :as str] [clojure.tools.logging :as log] @@ -31,7 +30,7 @@ vendor-id)) (set (map :db/id (:user/clients id))))))) -(defn upsert-vendor [context {{:keys [id name hidden terms code print_as primary_contact secondary_contact address default_account_id invoice_reminder_schedule schedule_payment_dom terms_overrides account_overrides] :as in} :vendor} value] +(defn upsert-vendor [context {{:keys [id name hidden terms code print_as primary_contact secondary_contact address default_account_id invoice_reminder_schedule schedule_payment_dom terms_overrides account_overrides] :as in} :vendor} _] (when (and id (not (can-user-edit-vendor? id (:id context)))) (assert-failure "This vendor is managed by Integreat. Please reach out to ben@integreatconsult.com for your changes.")) @@ -145,7 +144,7 @@ (->graphql)) log/info))) -(defn merge-vendors [context {:keys [from to]} value] +(defn merge-vendors [context {:keys [from to]} _] (let [transaction (->> (d/query {:query {:find '[?x ?a2] :in '[$ ?vendor-from ] :where ['[?x ?a ?vendor-from] diff --git a/src/clj/auto_ap/graphql/yodlee2.clj b/src/clj/auto_ap/graphql/yodlee2.clj index cfc5877f..9f311f10 100644 --- a/src/clj/auto_ap/graphql/yodlee2.clj +++ b/src/clj/auto_ap/graphql/yodlee2.clj @@ -1,9 +1,9 @@ (ns auto-ap.graphql.yodlee2 (:require [auto-ap.datomic.yodlee2 :as d-yodlee2] - [auto-ap.graphql.utils :refer [->graphql <-graphql assert-admin]])) + [auto-ap.graphql.utils :refer [->graphql <-graphql]])) -(defn get-yodlee-provider-account-page [context args value] +(defn get-yodlee-provider-account-page [context args _] (let [args (assoc args :id (:id context)) [yodlee-provider-accounts cnt] (d-yodlee2/get-graphql (<-graphql (assoc args :id (:id context))))] {:yodlee_provider_accounts (map ->graphql yodlee-provider-accounts) @@ -12,10 +12,3 @@ :start (:start args 0) :end (+ (:start args 0) (count yodlee-provider-accounts))})) -(defn get-all-yodlee-provider-accounts [context args value] - (let [args (assoc args :id (:id context))] - (map - ->graphql - (first (d-yodlee2/get-graphql (assoc (<-graphql args) - :count Integer/MAX_VALUE)))))) - diff --git a/src/clj/auto_ap/graphql/yodlee_merchants.clj b/src/clj/auto_ap/graphql/yodlee_merchants.clj index 2b2c8cd8..75b9dd8a 100644 --- a/src/clj/auto_ap/graphql/yodlee_merchants.clj +++ b/src/clj/auto_ap/graphql/yodlee_merchants.clj @@ -2,6 +2,6 @@ (:require [auto-ap.graphql.utils :refer [->graphql <-graphql]] [auto-ap.datomic.yodlee-merchants :as d-yodlee-merchants])) -(defn get-yodlee-merchants [context args value] +(defn get-yodlee-merchants [_ args _] (->graphql (d-yodlee-merchants/get-merchants (<-graphql args)))) diff --git a/src/clj/auto_ap/import/manual.clj b/src/clj/auto_ap/import/manual.clj index e70aa623..f32534d3 100644 --- a/src/clj/auto_ap/import/manual.clj +++ b/src/clj/auto_ap/import/manual.clj @@ -1,15 +1,14 @@ (ns auto-ap.import.manual - (:require [auto-ap.datomic :refer [conn]] - [auto-ap.import.manual.common :as c] - [auto-ap.import.transactions :as t] - [clj-time.coerce :as coerce] - [clojure.data.csv :as csv] - [clojure.tools.logging :as log] - [datomic.api :as d] - [unilog.context :as lc])) + (:require + [auto-ap.datomic :refer [conn]] + [auto-ap.import.manual.common :as c] + [auto-ap.import.transactions :as t] + [clj-time.coerce :as coerce] + [clojure.data.csv :as csv] + [datomic.api :as d] + [unilog.context :as lc])) + -(defn manual-import-batch [transactions user] - ) (def columns [:status :raw-date :description-original :high-level-category nil nil :amount nil nil nil nil nil :bank-account-code :client-code]) @@ -19,9 +18,9 @@ (drop 1) (map (fn [row] (into {} (->> (map vector columns row) - (filter (fn [[k v]] k)))))))) + (filter (fn [[k _]] k)))))))) -(defn manual->transaction [{:keys [description-original amount bank-account-code date] :as transaction} bank-account-lookup client-lookup] +(defn manual->transaction [{:keys [description-original bank-account-code] :as transaction} bank-account-lookup client-lookup] (-> {:transaction/description-original description-original :transaction/status "POSTED"} (c/assoc-or-error :transaction/client #(if-let [client-id (client-lookup bank-account-code)] @@ -46,21 +45,21 @@ (d/q '[:find ?bac ?ba :in $ :where [?ba :bank-account/code ?bac]] - (d/db conn)))] - (let [import-batch (t/start-import-batch :import-source/manual user) - transactions (->> transactions - (map (fn [t] - (manual->transaction t bank-account-code->bank-account bank-account-code->client))) - (t/apply-synthetic-ids ))] - (try - (doseq [transaction transactions] - (when-not (seq (:errors transaction)) - (t/import-transaction! import-batch transaction))) + (d/db conn))) + import-batch (t/start-import-batch :import-source/manual user) + transactions (->> transactions + (map (fn [t] + (manual->transaction t bank-account-code->bank-account bank-account-code->client))) + (t/apply-synthetic-ids ))] + (try + (doseq [transaction transactions] + (when-not (seq (:errors transaction)) + (t/import-transaction! import-batch transaction))) - (t/finish! import-batch) - (assoc (t/get-stats import-batch) - :failed-validation (count (filter :errors transactions)) - :sample-error (first (first (map :errors (filter :errors transactions))))) - (catch Exception e - (t/fail! import-batch e) - (t/get-stats import-batch))))))) + (t/finish! import-batch) + (assoc (t/get-stats import-batch) + :failed-validation (count (filter :errors transactions)) + :sample-error (first (first (map :errors (filter :errors transactions))))) + (catch Exception e + (t/fail! import-batch e) + (t/get-stats import-batch)))))) diff --git a/src/clj/auto_ap/import/plaid.clj b/src/clj/auto_ap/import/plaid.clj index 0d9aaeab..356241d3 100644 --- a/src/clj/auto_ap/import/plaid.clj +++ b/src/clj/auto_ap/import/plaid.clj @@ -9,6 +9,7 @@ [clj-time.coerce :as coerce] [clj-time.core :as time] [datomic.api :as d] + [digest :as di] [mount.core :as mount] [unilog.context :as lc] [yang.scheduler :as scheduler])) @@ -28,7 +29,8 @@ (defn plaid->transaction [t] #:transaction {:description-original (:name t) :raw-id (:transaction_id t) - :id (digest/sha-256 (:transaction_id t)) + :id #_{:clj-kondo/ignore [:unresolved-var]} + (di/sha-256 (:transaction_id t)) :amount (if (= "credit" (:type (:account t))) (- (double (:amount t))) (double (:amount t))) @@ -36,7 +38,7 @@ :status "POSTED"}) -(defn import-plaid [] +(defn import-plaid-int [] (lc/with-context {:source "Import plaid transactions"} (let [import-batch (t/start-import-batch :import-source/plaid "Automated plaid user") end (atime/local-now) @@ -57,7 +59,7 @@ (catch Exception e (t/fail! import-batch e)))))) -(def import-plaid (allow-once import-plaid)) +(def import-plaid (allow-once import-plaid-int)) (mount/defstate import-worker :start (scheduler/every (* 1000 60 60 3) (heartbeat import-plaid "import-plaid")) diff --git a/src/clj/auto_ap/import/transactions.clj b/src/clj/auto_ap/import/transactions.clj index 6fd5a849..200ffacd 100644 --- a/src/clj/auto_ap/import/transactions.clj +++ b/src/clj/auto_ap/import/transactions.clj @@ -1,18 +1,19 @@ (ns auto-ap.import.transactions - (:require [auto-ap.datomic :refer [audit-transact conn remove-nils uri]] - [auto-ap.datomic.accounts :as a] - [auto-ap.datomic.checks :as d-checks] - [auto-ap.datomic.transaction-rules :as tr] - [auto-ap.datomic.transactions :as d-transactions] - [auto-ap.rule-matching :as rm] - [auto-ap.utils :refer [dollars=]] - [auto-ap.yodlee.core :as client] - [clj-time.coerce :as coerce] - [clj-time.core :as t] - [clojure.core.cache :as cache] - [clojure.tools.logging :as log] - [datomic.api :as d] - [digest :refer [sha-256]])) + (:require + [auto-ap.datomic :refer [audit-transact conn remove-nils uri]] + [auto-ap.datomic.accounts :as a] + [auto-ap.datomic.checks :as d-checks] + [auto-ap.datomic.transaction-rules :as tr] + [auto-ap.datomic.transactions :as d-transactions] + [auto-ap.rule-matching :as rm] + [auto-ap.time :as atime] + [auto-ap.utils :refer [dollars=]] + [clj-time.coerce :as coerce] + [clj-time.core :as t] + [clojure.core.cache :as cache] + [clojure.tools.logging :as log] + [datomic.api :as d] + [digest :as di])) (defn rough-match [client-id bank-account-id amount] (if (and client-id bank-account-id amount) @@ -35,7 +36,8 @@ (cond (not (and client-id bank-account-id)) nil - (:transaction/payment (d-transactions/get-by-id [:transaction/id (sha-256 (str id))])) + (:transaction/payment (d-transactions/get-by-id [:transaction/id #_{:clj-kondo/ignore [:unresolved-var]} + (di/sha-256 (str id))])) nil check-number @@ -119,7 +121,7 @@ :payment/type :payment-type/debit :payment/status :payment-status/cleared :db/id payment-id}) - (into (mapcat (fn [[vendor invoice-id invoice-amount]] + (into (mapcat (fn [[_ invoice-id invoice-amount]] [{:invoice-payment/invoice invoice-id :invoice-payment/payment payment-id :invoice-payment/amount invoice-amount} @@ -143,7 +145,7 @@ (if-let [[_ _ check-number] (re-find #"(?i)check(card|[^0-9]+([0-9]*))" description-original)] (try (Integer/parseInt check-number) - (catch NumberFormatException e + (catch NumberFormatException _ nil)) nil)) @@ -238,8 +240,7 @@ )))) (defn maybe-code [{:transaction/keys [client amount] :as transaction} apply-rules valid-locations] - (if-let [unpaid-invoices (seq (match-transaction-to-unpaid-invoices amount client))] - nil + (when (seq (match-transaction-to-unpaid-invoices amount client)) (apply-rules transaction valid-locations))) (defn transaction->txs [transaction bank-account apply-rules] @@ -294,7 +295,7 @@ (log/info "Importing transactions from " source) (reify ImportBatch - (import-transaction! [this transaction] + (import-transaction! [_ transaction] (let [bank-account (d/pull (d/db conn) [:bank-account/code :db/id @@ -318,10 +319,10 @@ {:user/name user :user/role ":admin"})))) - (get-stats [this] + (get-stats [_] @stats) - (fail! [this error] + (fail! [_ error] (log/errorf "Couldn't complete import %d with error." import-id) (log/error error) @(d/transact conn [(merge {:db/id import-id @@ -329,7 +330,7 @@ :import-batch/error-message (str error)} @stats)])) - (finish! [this] + (finish! [_] (log/infof "Finishing import batch %d for %s with stats %s " import-id (name source) (pr-str @stats)) @(d/transact conn [(merge {:db/id import-id @@ -339,7 +340,7 @@ (defn synthetic-key [{:transaction/keys [date bank-account description-original amount client] } index] - (str (str (some-> date coerce/to-date-time auto-ap.time/localize)) "-" bank-account "-" description-original "-" amount "-" index "-" client)) + (str (str (some-> date coerce/to-date-time atime/localize)) "-" bank-account "-" description-original "-" amount "-" index "-" client)) (defn apply-synthetic-ids [transactions] (->> transactions @@ -349,7 +350,8 @@ (map (fn [index transaction] (let [raw-id (synthetic-key transaction index)] (assoc transaction - :transaction/id (digest/sha-256 raw-id) + :transaction/id #_{:clj-kondo/ignore [:unresolved-var]} + (di/sha-256 raw-id) :transaction/raw-id raw-id))) (range) group))))) diff --git a/src/clj/auto_ap/import/yodlee.clj b/src/clj/auto_ap/import/yodlee.clj index 5e75f7f3..d7e46625 100644 --- a/src/clj/auto_ap/import/yodlee.clj +++ b/src/clj/auto_ap/import/yodlee.clj @@ -3,16 +3,14 @@ [auto-ap.datomic :refer [conn]] [auto-ap.import.transactions :as t] [auto-ap.time :as atime] - [auto-ap.utils :refer [allow-once heartbeat]] + [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 :refer [sha-256]] - [mount.core :as mount] - [yang.scheduler :as scheduler])) + [digest :as di])) (defn yodlee->transaction [transaction use-date-instead-of-post-date?] (let [{post-date :postDate @@ -31,7 +29,8 @@ date (atime/parse date "YYYY-MM-dd")] #:transaction {:post-date (coerce/to-date (atime/parse post-date "YYYY-MM-dd")) - :id (sha-256 (str id)) + :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? diff --git a/src/clj/auto_ap/import/yodlee2.clj b/src/clj/auto_ap/import/yodlee2.clj index 92e3622e..1576e530 100644 --- a/src/clj/auto_ap/import/yodlee2.clj +++ b/src/clj/auto_ap/import/yodlee2.clj @@ -12,7 +12,7 @@ [unilog.context :as lc] [yang.scheduler :as scheduler])) -(defn import-yodlee2 [] +(defn import-yodlee2-int [] (lc/with-context {:source "Import yodlee2 transactions"} (statsd/event {:title "Yodlee2 import started" :text "Starting" @@ -53,7 +53,7 @@ -(def import-yodlee2 (allow-once import-yodlee2)) +(def import-yodlee2 (allow-once import-yodlee2-int)) (mount/defstate import-worker diff --git a/src/clj/auto_ap/intuit/core.clj b/src/clj/auto_ap/intuit/core.clj index 7c2fac77..beacf634 100644 --- a/src/clj/auto_ap/intuit/core.clj +++ b/src/clj/auto_ap/intuit/core.clj @@ -1,38 +1,30 @@ (ns auto-ap.intuit.core - (:require [auto-ap.datomic :refer [conn remove-nils]] - [amazonica.aws.s3 :as s3] - [auto-ap.utils :refer [by]] - [clj-http.client :as client] - [clj-time.coerce :as coerce] - [clj-time.core :as time] - [clj-time.format :as f] - [config.core :refer [env] :as cfg ] - [clojure.string :as str] - [clojure.data.json :as json] - [clojure.java.io :as io] - [clojure.tools.logging :as log] - [datomic.api :as d] - [mount.core :as mount] - [unilog.context :as lc] - [yang.scheduler :as scheduler] - [clojure.core.async :as async] - [clojure.core.memoize :as m]) - (:import [org.apache.commons.codec.binary Base64])) + (:require + [amazonica.aws.s3 :as s3] + [clj-http.client :as client] + [clojure.core.memoize :as m] + [clojure.java.io :as io] + [clojure.string :as str] + [clojure.tools.logging :as log] + [config.core :as cfg :refer [env]]) + (:import + (org.apache.commons.codec.binary Base64))) +;; (def authorization-code "AB11638463964I0tYPR3A1inog2HL407u2bZBXHg6LEqCbILRO") +;; (def realm-id "4620816365202617680") -(def authorization-code "AB11638463964I0tYPR3A1inog2HL407u2bZBXHg6LEqCbILRO") -(def realm-id "4620816365202617680") +;; (def company-id "4620816365202617680") -(def company-id "4620816365202617680") - -(def base-url "https://sandbox-quickbooks.api.intuit.com/v3") +;; (def base-url "https://sandbox-quickbooks.api.intuit.com/v3") (def prod-client-id "ABFRwAiOqQiLN66HKplXfyRE3ipD390DHsrUquflRCiOa81mxa") (def prod-client-secret "xDUj04GeQXpLvrhxep1jjDYwjJWbzzOPrirUQTKF") -(def prod-redirect-uri "https://developer.intuit.com/v2/OAuth2Playground/RedirectUrl") -(def prod-authorization-code "AB11638464998wYuapsEGtIEnRqphrw0H97XUnvEG2dK4cGUyL") -(def prod-realm-id "123146163906404") + +;; (def prod-redirect-uri "https://developer.intuit.com/v2/OAuth2Playground/RedirectUrl") +;; (def prod-authorization-code "AB11638464998wYuapsEGtIEnRqphrw0H97XUnvEG2dK4cGUyL") +;; (def prod-realm-id "123146163906404") + ;; "refreshToken": "AB11647191065B0olWYQ61wfq8uszBusfe6Jpn7Au7qY5exkLL", ;; "accessToken":, ;; @@ -122,10 +114,9 @@ (defn get-all-transactions [start end] (let [token (get-fresh-access-token)] - (let [body (:body (client/get (str prod-base-url "/company/" prod-company-id "/reports/TransactionList" "?minorversion=63&start_date=" start "&end_date=" end) - {:headers (with-auth prod-base-headers token) - :as :json}))] - body))) + (:body (client/get (str prod-base-url "/company/" prod-company-id "/reports/TransactionList" "?minorversion=63&start_date=" start "&end_date=" end) + {:headers (with-auth prod-base-headers token) + :as :json})))) (def memoize-get-all-transactions (m/ttl get-all-transactions :ttl/threshold 60000)) diff --git a/src/clj/auto_ap/parse.clj b/src/clj/auto_ap/parse.clj index bd266b5b..1a5fe6f3 100644 --- a/src/clj/auto_ap/parse.clj +++ b/src/clj/auto_ap/parse.clj @@ -1,6 +1,5 @@ (ns auto-ap.parse (:require - [auto-ap.logging :refer [info-event]] [auto-ap.parse.csv :as csv] [auto-ap.parse.excel :as excel] [auto-ap.parse.templates :as t] diff --git a/src/clj/auto_ap/parse/csv.clj b/src/clj/auto_ap/parse/csv.clj index 3bab5e35..5f713b63 100644 --- a/src/clj/auto_ap/parse/csv.clj +++ b/src/clj/auto_ap/parse/csv.clj @@ -6,7 +6,7 @@ [clojure.tools.logging :as log])) (defn determine - [[header :as z]] + [[header]] (log/info "Importing with header" header) (let [csv-type (cond (str/includes? (second header) "Customer's PO No.") :mama-lus @@ -34,15 +34,16 @@ (defmulti parse-csv determine - :default (fn default [rows] + :default #_{:clj-kondo/ignore [:unused-binding]} + (fn default [rows] nil)) (defn parse-date-fallover [d fmts] - (if-let [valid-fmt (->> fmts + (when-let [valid-fmt (->> fmts (filter (fn [f] (try (u/parse-value :clj-time f d) - (catch Exception e + (catch Exception _ nil)) )) (first))] @@ -96,7 +97,7 @@ [rows] (transduce (comp (drop 1) - (map (fn [[_ po-number despatch-number invoice-number invoice-date customer value :as row]] + (map (fn [[_ po-number _ invoice-number invoice-date customer value :as row]] {:vendor-code "Mama Lu's Foods" :customer-identifier customer :invoice-number (str po-number "-" invoice-number ) @@ -112,7 +113,7 @@ [rows] (transduce (comp (drop 1) - (map (fn [[ po-number despatch-number invoice-number invoice-date customer value :as row]] + (map (fn [[ po-number _ invoice-number invoice-date customer value :as row]] {:vendor-code "Mama Lu's Foods" :customer-identifier customer :invoice-number (str po-number "-" invoice-number ) @@ -128,7 +129,7 @@ [rows] (transduce (comp - (filter (fn [[dt _ doc-number name _ status _ _ amount :as row]] + (filter (fn [[_ _ _ _ _ status _ _ _ ]] (= status "Billed"))) (map (fn [[dt _ doc-number name _ _ _ _ amount :as row]] {:vendor-code "PHILZ COFFEE, INC" @@ -161,11 +162,12 @@ [] (drop 1 rows))) +#_{:clj-kondo/ignore [:unused-binding]} (defmethod parse-csv nil [rows] nil) -(defn parse-file [file filename] +(defn parse-file [file _] (with-open [reader (io/reader file)] (let [rows (csv/read-csv reader :separator \,)] (parse-csv rows)))) diff --git a/src/clj/auto_ap/parse/excel.clj b/src/clj/auto_ap/parse/excel.clj index 635b197c..4130dfeb 100644 --- a/src/clj/auto_ap/parse/excel.clj +++ b/src/clj/auto_ap/parse/excel.clj @@ -39,7 +39,7 @@ extract)])) (defn parse-file - [file filename] + [file _] (let [wb (d/load-workbook file) text (->> wb (d/sheet-seq) diff --git a/src/clj/auto_ap/parse/util.clj b/src/clj/auto_ap/parse/util.clj index 9c5ad828..33e0dfc2 100644 --- a/src/clj/auto_ap/parse/util.clj +++ b/src/clj/auto_ap/parse/util.clj @@ -1,10 +1,9 @@ (ns auto-ap.parse.util - (:require [clj-fuzzy.metrics :as m] - [clojure.java.shell :as sh] - [clojure.string :as str] - [clj-time.format :as f] - [clj-time.core :as time] - [clojure.tools.logging :as log])) + (:require + [clj-time.core :as time] + [clj-time.format :as f] + [clojure.string :as str] + [clojure.tools.logging :as log])) (defmulti parse-value (fn [method _ _] method)) diff --git a/src/clj/auto_ap/plaid/core.clj b/src/clj/auto_ap/plaid/core.clj index 7a598361..55ee7ce4 100644 --- a/src/clj/auto_ap/plaid/core.clj +++ b/src/clj/auto_ap/plaid/core.clj @@ -26,7 +26,7 @@ :body :link_token)) -(defn exchange-public-token [public-token client-code] +(defn exchange-public-token [public-token _] (-> (client/post (str base-url "/item/public_token/exchange") {:as :json :headers {"Content-Type" "application/json"} diff --git a/src/clj/auto_ap/routes/auth.clj b/src/clj/auto_ap/routes/auth.clj index e8e3dee7..73146797 100644 --- a/src/clj/auto_ap/routes/auth.clj +++ b/src/clj/auto_ap/routes/auth.clj @@ -19,7 +19,7 @@ {:alg :hs512})) (defroutes routes - (GET "/oauth" {{:strs [code]} :query-params :keys [scheme] :as r {:strs [host]} :headers} + (GET "/oauth" {{:strs [code]} :query-params {:strs [host]} :headers} (try (let [auth (-> "https://accounts.google.com/o/oauth2/token" (http/post diff --git a/src/clj/auto_ap/routes/events.clj b/src/clj/auto_ap/routes/events.clj deleted file mode 100644 index 63fb04e1..00000000 --- a/src/clj/auto_ap/routes/events.clj +++ /dev/null @@ -1,14 +0,0 @@ -(ns auto-ap.routes.events - (:require [auto-ap.routes.utils :refer [wrap-secure]] - [config.core :refer [env]] - [clj-http.client :as http] - [clj-time.coerce :as c] - [clj-time.core :as time] - [clj-time.periodic :as p] - [clj-time.predicates :as pred] - [clojure.data.json :as json] - [compojure.core :refer [GET PUT POST context defroutes - wrap-routes]] - [clojure.tools.logging :as log] - [unilog.context :as lc]) - (:import (org.joda.time DateTime))) diff --git a/src/clj/auto_ap/routes/graphql.clj b/src/clj/auto_ap/routes/graphql.clj index 0bb973e1..13d686d7 100644 --- a/src/clj/auto_ap/routes/graphql.clj +++ b/src/clj/auto_ap/routes/graphql.clj @@ -1,13 +1,13 @@ (ns auto-ap.routes.graphql - (:require [auto-ap.routes.utils :refer [wrap-secure wrap-spec]] + (:require [auto-ap.routes.utils :refer [wrap-secure]] [auto-ap.graphql :as ql] [auto-ap.logging :refer [warn-event]] [buddy.auth :refer [throw-unauthorized]] [clojure.edn :as edn] - [compojure.core :refer [GET POST PUT context defroutes + [compojure.core :refer [GET POST context defroutes wrap-routes]] [clojure.tools.logging :as log])) -(defn handle-graphql [{:keys [request-method query-params body edn-params method] :as r}] +(defn handle-graphql [{:keys [request-method query-params] :as r}] (when (= "none" (:user/role (:identity r))) (throw-unauthorized)) diff --git a/src/clj/auto_ap/routes/yodlee2.clj b/src/clj/auto_ap/routes/yodlee2.clj index 16e4a0d4..7abf501c 100644 --- a/src/clj/auto_ap/routes/yodlee2.clj +++ b/src/clj/auto_ap/routes/yodlee2.clj @@ -13,7 +13,7 @@ (defroutes routes (wrap-routes (context "/yodlee2" [] - (GET "/fastlink" {:keys [query-params identity] :as request} + (GET "/fastlink" {:keys [query-params identity]} (assert-can-see-client identity (d/pull (d/db conn) [:db/id] [:client/code (get query-params "client")])) (let [token (if-let [client-id (get query-params "client-id")] @@ -27,9 +27,7 @@ :headers {"Content-Type" "application/edn"} :body (pr-str {:token token :url (:yodlee2-fastlink env)}) })) - (POST "/provider-accounts/refresh/" {:keys [query-params identity edn-params] - {:keys [id]} :route-params - :as request} + (POST "/provider-accounts/refresh/" {:keys [identity edn-params]} (assert-admin identity) (log/info "refreshing " edn-params) (try @@ -48,9 +46,8 @@ :body (pr-str {:message (.getMessage e) :error (.toString e)})}))) - (GET "/provider-accounts/:client/:id" {:keys [query-params identity edn-params] - {:keys [client id]} :route-params - :as request} + (GET "/provider-accounts/:client/:id" {:keys [identity] + {:keys [client id]} :route-params} (assert-admin identity) (log/info "looking-up " client id) (try @@ -68,7 +65,7 @@ :headers {"Content-Type" "application/edn"} :body (pr-str {:message (.getMessage e) :error (.toString e)})}))) - (POST "/provider-accounts/delete/" {:keys [edn-params identity] {:keys [id]} :route-params :as request} + (POST "/provider-accounts/delete/" {:keys [edn-params identity]} (assert-admin identity) (try (yodlee/delete-provider-account (-> (:client-id edn-params) diff --git a/src/clj/auto_ap/server.clj b/src/clj/auto_ap/server.clj index c331cb37..916110ef 100644 --- a/src/clj/auto_ap/server.clj +++ b/src/clj/auto_ap/server.clj @@ -1,5 +1,6 @@ (ns auto-ap.server (:gen-class) + #_{:clj-kondo/ignore [:unused-namespace]} (:require auto-ap.background.invoices [auto-ap.background.requests :as requests] [auto-ap.background.sysco :as sysco] @@ -84,7 +85,7 @@ (defn shutdown-mount [] (mount/stop)) - (defn -main [& args] + (defn -main [& _] (let [without (cond-> [] (not (env :run-web? )) (into [#'jetty #'jetty-stats]) diff --git a/src/clj/auto_ap/square/core.clj b/src/clj/auto_ap/square/core.clj index 80ea5395..1d7edc78 100644 --- a/src/clj/auto_ap/square/core.clj +++ b/src/clj/auto_ap/square/core.clj @@ -1,21 +1,23 @@ (ns auto-ap.square.core - (:require [auto-ap.datomic :refer [conn remove-nils]] - [auto-ap.utils :refer [heartbeat]] - [auto-ap.time :as atime] - [clj-http.client :as client] - [clj-time.coerce :as coerce] - [clj-time.core :as time] - [clj-time.periodic :as periodic] - [clj-time.format :as f] - [clojure.string :as str] - [clojure.data.json :as json] - [clojure.tools.logging :as log] - [datomic.api :as d] - [mount.core :as mount] - [unilog.context :as lc] - [yang.scheduler :as scheduler] - [clojure.core.async :as async] - [slingshot.slingshot :refer [try+]])) + (:require + [auto-ap.datomic :refer [conn remove-nils]] + [auto-ap.time :as atime] + [auto-ap.utils :refer [heartbeat]] + [clj-http.client :as client] + [clj-time.coerce :as coerce] + [clj-time.core :as time] + [clj-time.format :as f] + [clj-time.periodic :as periodic] + [clojure.core.async :as async] + [clojure.data.json :as json] + [clojure.set :as set] + [clojure.string :as str] + [clojure.tools.logging :as log] + [datomic.api :as d] + [mount.core :as mount] + [slingshot.slingshot :refer [try+]] + [unilog.context :as lc] + [yang.scheduler :as scheduler])) (defn client-base-headers [client] {"Square-Version" "2021-08-18" @@ -225,7 +227,7 @@ (and (or (> (count (:tenders order)) 0) (seq (:returns order))) (or (= #{} (set (map #(:status (:card_details %)) (:tenders order)))) - (not= #{} (clojure.set/difference + (not= #{} (set/difference (set (map #(:status (:card_details %)) (:tenders order))) #{"FAILED" "VOIDED"})))))) (filter (fn [order] @@ -519,7 +521,7 @@ (mark-integration-status client {:integration-status/state :integration-state/failed :integration-status/message (-> data :body str)})) - (catch Object e + (catch Object _ (log/warn &throw-context) (mark-integration-status client {:integration-status/state :integration-state/failed :integration-status/message (or (some-> (:wrapper &throw-context) (.getMessage )) diff --git a/src/clj/auto_ap/time.clj b/src/clj/auto_ap/time.clj index 15088774..3d1aa510 100644 --- a/src/clj/auto_ap/time.clj +++ b/src/clj/auto_ap/time.clj @@ -17,7 +17,7 @@ (try (time/from-time-zone (f/parse (f/formatter format) v) (time/time-zone-for-id "America/Los_Angeles")) - (catch Exception e + (catch Exception _ nil))) (defn unparse [v format] @@ -31,7 +31,7 @@ (try (f/unparse (f/with-zone (f/formatter format) (time/time-zone-for-id "America/Los_Angeles")) v) - (catch Exception e + (catch Exception _ nil))) diff --git a/src/clj/auto_ap/yodlee/core2.clj b/src/clj/auto_ap/yodlee/core2.clj index 9efa11c0..f59831b0 100644 --- a/src/clj/auto_ap/yodlee/core2.clj +++ b/src/clj/auto_ap/yodlee/core2.clj @@ -148,8 +148,7 @@ (defn get-provider-account [client-code id] - (let [cob-session (login-user (client-code->login client-code)) - batch-size 100] + (let [cob-session (login-user (client-code->login client-code))] (-> (str (:yodlee2-base-url env) "/providerAccounts/" id) diff --git a/src/clj/user.clj b/src/clj/user.clj index c8aab0eb..744d8745 100644 --- a/src/clj/user.clj +++ b/src/clj/user.clj @@ -1,24 +1,29 @@ (ns user - (:require [auto-ap.datomic :refer [uri]] - [config.core :refer [env]] - [auto-ap.utils :refer [by]] - [auto-ap.time :as atime] - [clojure.core.async :as async] - [unilog.context :as lc] - [auto-ap.square.core :as square] - [mount.core :as mount] - [auto-ap.server ] - [datomic.api :as d] - [clojure.data.csv :as csv] - [clj-time.coerce :as c] - [clj-time.core :as t] - [clj-time.periodic :as per] - [clojure.java.io :as io] - [clojure.string :as str] - - [amazonica.aws.s3 :as s3]) - (:import [org.apache.commons.io.input BOMInputStream])) + (:require + [amazonica.aws.s3 :as s3] + [auto-ap.datomic :refer [uri]] + [auto-ap.ledger :as l] + [auto-ap.server ] + [auto-ap.square.core :as square] + [auto-ap.time :as atime] + [auto-ap.utils :refer [by]] + [clj-time.coerce :as c] + [clj-time.core :as t] + [clj-time.periodic :as per] + [clojure.core.async :as async] + [clojure.data.csv :as csv] + [clojure.java.io :as io] + clojure.pprint + [clojure.string :as str] + [config.core :refer [env]] + [datomic.api :as d] + [mount.core :as mount] + nrepl.middleware.print + [unilog.context :as lc]) + (:import + [org.apache.commons.io.input BOMInputStream])) +#_{:clj-kondo/ignore [:clojure-lsp/unused-public-var]} (defn mark-until-date [client end] (let [conn (d/connect uri)] (doseq [p (->> @@ -60,6 +65,7 @@ @(d/transact conn p) (println "process 100")))) +#_{:clj-kondo/ignore [:clojure-lsp/unused-public-var]} (defn unapprove-all [] (let [conn (d/connect uri)] (doseq [p (->> @@ -76,12 +82,9 @@ @(d/transact conn p) (println "process 100")))) - - - +#_{:clj-kondo/ignore [:clojure-lsp/unused-public-var]} (defn load-accounts [conn] (let [[header & rows] (-> "master-account-list.csv" (io/resource) io/input-stream (BOMInputStream.) (io/reader) csv/read-csv) - headers (map read-string header) code->existing-account (by :account/numeric-code (map first (d/query {:query {:find ['(pull ?e [:account/numeric-code :db/id])] :in ['$] @@ -96,7 +99,7 @@ :where ['[?a :account/numeric-code ?ac]]} :args [(d/db conn) also-merge ]}))] (into (mapv - (fn [[entity id sunset-account]] + (fn [[entity id _]] [:db/add entity id old-account-id]) (d/query {:query {:find ['?e '?id '?a ] :in ['$ '?ac ] @@ -157,6 +160,7 @@ rows)] @(d/transact conn txes))) +#_{:clj-kondo/ignore [:clojure-lsp/unused-public-var]} (defn find-bad-accounts [] (set (map second (d/query {:query {:find ['(pull ?x [*]) '?z] :in ['$] @@ -165,6 +169,7 @@ '[?x ?a ?e]]} :args [(d/db (d/connect uri))]})))) +#_{:clj-kondo/ignore [:clojure-lsp/unused-public-var]} (defn delete-4-digit-accounts [] @(d/transact (d/connect uri) (transduce @@ -182,9 +187,10 @@ ) +#_{:clj-kondo/ignore [:clojure-lsp/unused-public-var]} (defn find-conflicting-accounts [] (filter - (fn [[k v]] + (fn [[_ v]] (> (count v) 1)) (reduce (fn [acc [e z]] @@ -195,15 +201,15 @@ :where ['[?e :account/numeric-code ?z]]} :args [(d/db (d/connect uri))]})))) +#_{:clj-kondo/ignore [:clojure-lsp/unused-public-var]} (defn customize-accounts [customer filename] (let [conn (d/connect uri) - [header & rows] (-> filename (io/resource) io/input-stream (BOMInputStream.) (io/reader) csv/read-csv) + [_ & rows] (-> filename (io/resource) io/input-stream (BOMInputStream.) (io/reader) csv/read-csv) [client-id] (first (d/query (-> {:query {:find ['?e] :in ['$ '?z] :where [['?e :client/code '?z]]} :args [(d/db (d/connect uri)) customer]}))) _ (println client-id) - headers (map read-string header) code->existing-account (by :account/numeric-code (map first (d/query {:query {:find ['(pull ?e [:account/numeric-code {:account/applicability [:db/ident]} :db/id])] @@ -218,7 +224,7 @@ - _ (if-let [bad-rows (seq (->> rows + _ (when-let [bad-rows (seq (->> rows (group-by (fn [[_ account]] account)) vals @@ -278,13 +284,7 @@ #_@(d/transact conn txes))) - -(defn attach-signature [client-code filename] - @(d/transact (d/connect uri) - [{:db/id [:client/code client-code] - :client/signature-file (str "https://s3.amazonaws.com/integreat-signature-images/" filename)}])) - - +#_{:clj-kondo/ignore [:clojure-lsp/unused-public-var]} (defn fix-transactions-without-locations [client-code location] (->> (d/query {:query {:find ['(pull ?e [*])] @@ -369,11 +369,13 @@ :args [(d/db (d/connect uri))]})]) +#_{:clj-kondo/ignore [:clojure-lsp/unused-public-var]} (defn go [] (require '[mount.core :as mount]) (require '[auto-ap.server]) (mount/start-without #'auto-ap.server/jetty)) +#_{:clj-kondo/ignore [:clojure-lsp/unused-public-var]} (defn entity-history [i] (vec (sort-by first (d/query {:query {:find ['?tx '?z '?v ] @@ -383,6 +385,7 @@ '[(= ?ad true)]]} :args [i (d/history (d/db (d/connect uri)))]})))) +#_{:clj-kondo/ignore [:clojure-lsp/unused-public-var]} (defn entity-history-with-revert [i] (vec (sort-by first (d/query {:query {:find ['?tx '?z '?v '?ad ] @@ -391,12 +394,14 @@ '[?a :db/ident ?z]]} :args [i (d/history (d/db (d/connect uri)))]})))) +#_{:clj-kondo/ignore [:clojure-lsp/unused-public-var]} (defn tx-detail [i] (map (juxt :e #(d/ident (d/db (d/connect uri)) (:a %)) :v) (:data (first (d/tx-range (d/log (d/connect uri)) i (inc i)))))) +#_{:clj-kondo/ignore [:clojure-lsp/unused-public-var]} (defn tx-range-detail [i] (map (juxt :e #(d/ident (d/db (d/connect uri)) (:a %)) :v) @@ -405,14 +410,17 @@ (+ i 100))))) +#_{:clj-kondo/ignore [:clojure-lsp/unused-public-var]} (defn start-db [] (mount.core/start (mount.core/only #{#'auto-ap.datomic/conn}))) +#_{:clj-kondo/ignore [:clojure-lsp/unused-public-var]} (defn touch-transaction-ledger [e] @(d/transact auto-ap.datomic/conn [[:db/retractEntity [:journal-entry/original-entity e]]]) - @(d/transact auto-ap.datomic/conn [(auto-ap.ledger/entity-change->ledger (d/db auto-ap.datomic/conn) - [:transaction e])])) + @(d/transact auto-ap.datomic/conn [(l/entity-change->ledger (d/db auto-ap.datomic/conn) + [:transaction e])])) +#_{:clj-kondo/ignore [:clojure-lsp/unused-public-var]} (defn mismatched-transactions [] (let [jel-accounts (reduce (fn [acc [e lia]] @@ -444,6 +452,7 @@ +#_{:clj-kondo/ignore [:clojure-lsp/unused-public-var]} (defn spit-csv [columns data ] (csv/write-csv *out* (into [(map name columns)] @@ -451,32 +460,34 @@ ((apply juxt columns) r ))))) +#_{:clj-kondo/ignore [:clojure-lsp/unused-public-var]} (defn find-queries [words] - (let [obj (s3/list-objects-v2 :bucket-name (:data-bucket env) - :prefix (str "queries/"))] - (let [concurrent 30 - output-chan (async/chan)] - (async/pipeline-blocking concurrent - output-chan - (comp - (map #(do - [(:key %) - (str (slurp (:object-content (s3/get-object + (let [obj (s3/list-objects-v2 :bucket-name (:data-bucket env) + :prefix (str "queries/")) + concurrent 30 + output-chan (async/chan)] + (async/pipeline-blocking concurrent + output-chan + (comp + (map #(do + [(:key %) + (str (slurp (:object-content (s3/get-object :bucket-name (:data-bucket env) :key (:key %)))))])) - - (filter #(->> words - (every? (fn [w] (str/includes? (second %) w))))) - (map first) - (map #(str/replace % #"queries/" "")) - ) - (async/to-chan (:object-summaries obj)) - true - (fn [e] - (println "failed " e))) - (async/> words + (every? (fn [w] (str/includes? (second %) w))))) + (map first) + (map #(str/replace % #"queries/" "")) + ) + (async/to-chan! (:object-summaries obj)) + true + (fn [e] + (println "failed " e))) + (async/> - (for [[invoice-id invoice-expense-account-id target-account target-date amount expense-account location] (drop 1 data) + (for [[invoice-id invoice-expense-account-id target-account target-date amount _ location] (drop 1 data) :let [ invoice-id (Long/parseLong invoice-id) @@ -567,7 +579,7 @@ target-expense-account-location location - [[payment-id payment-amount invoice-payment]] (vec (d/q + [[_ _ invoice-payment]] (vec (d/q '[:find ?p ?a ?ip :in $ ?i :where [?ip :invoice-payment/invoice ?i] @@ -613,6 +625,7 @@ vec))) +#_{:clj-kondo/ignore [:clojure-lsp/unused-public-var]} (defn get-schema [prefix] (->> (d/q '[:find ?i :in $ ?p @@ -621,6 +634,7 @@ (mapcat identity) vec)) +#_{:clj-kondo/ignore [:clojure-lsp/unused-public-var]} (defn get-idents [] (->> (d/q '[:find ?i :in $ @@ -631,6 +645,7 @@ (sort) vec)) +#_{:clj-kondo/ignore [:clojure-lsp/unused-public-var]} (defn init-repl [] (set! nrepl.middleware.print/*print-fn* clojure.pprint/pprint)) diff --git a/src/cljc/auto_ap/client_routes.cljc b/src/cljc/auto_ap/client_routes.cljc index 81881eab..9f9118ee 100644 --- a/src/cljc/auto_ap/client_routes.cljc +++ b/src/cljc/auto_ap/client_routes.cljc @@ -1,5 +1,4 @@ -(ns auto-ap.client-routes - (:require [bidi.bidi :as bidi])) +(ns auto-ap.client-routes) (def routes ["/" {"" :index "login/" :login diff --git a/src/cljc/auto_ap/entities/account.cljc b/src/cljc/auto_ap/entities/account.cljc deleted file mode 100644 index fd6d4611..00000000 --- a/src/cljc/auto_ap/entities/account.cljc +++ /dev/null @@ -1,16 +0,0 @@ -(ns auto-ap.entities.account - (:require [clojure.spec.alpha :as s] - [clojure.string :as str] - [auto-ap.entities.shared :as shared])) - -(s/def ::account-set string?) -(s/def ::numeric-code (s/or :numeric-string? (s/and string? - #(re-matches shared/numeric-regex %)) - :numeric? int?)) -(s/def ::name string?) -(s/def ::location (s/nilable (s/and string? - #(re-matches shared/only-upper-case %)))) -(s/def ::type #{:dividend :expense :asset :liability :equity :revenue}) - -(s/def ::account (s/keys :req-un [::account-set ::numeric-code ::name ::type ::location])) - diff --git a/src/cljc/auto_ap/entities/address.cljc b/src/cljc/auto_ap/entities/address.cljc deleted file mode 100644 index 1614fe0c..00000000 --- a/src/cljc/auto_ap/entities/address.cljc +++ /dev/null @@ -1,19 +0,0 @@ -(ns auto-ap.entities.address - (:require [clojure.spec.alpha :as s] - [clojure.string :as str])) - -(s/def ::street1 (s/nilable string?)) -(s/def ::street2 (s/nilable string?)) -(s/def ::city (s/nilable string?)) -(s/def ::state (s/nilable (s/or - :empty (s/and string? #{""}) - :filled (s/and string? - #(re-matches #"[a-zA-Z]{2}" %))))) -(s/def ::zip (s/nilable string?)) - -(s/def ::address (s/keys :opt-un [::email - ::street1 - ::street2 - ::city - ::state - ::zip])) diff --git a/src/cljc/auto_ap/entities/clients.cljc b/src/cljc/auto_ap/entities/clients.cljc deleted file mode 100644 index 99386259..00000000 --- a/src/cljc/auto_ap/entities/clients.cljc +++ /dev/null @@ -1,58 +0,0 @@ -(ns auto-ap.entities.clients - (:require [clojure.spec.alpha :as s] - [auto-ap.entities.shared :as shared] - [clojure.string :as str] - [auto-ap.entities.address :as address])) - -(def email-regex #"^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,63}$") -(s/def ::id int) - -(s/def ::name ::shared/required-identifier) -(s/def ::code (s/and ::shared/required-identifier - #(re-matches #"[A-Z0-9\-]+" %))) -(s/def ::address (s/nilable ::address/address)) - -(s/def ::bank-name ::shared/required-identifier) -(s/def ::bank-code (s/nilable string?)) -(s/def ::routing (s/nilable string?)) -(s/def ::number ::shared/required-identifier) -(s/def ::type keyword?) -(s/def ::number string?) -(s/def ::yodlee-account-id string?) - -(s/def ::checking-bank-account (s/and (s/keys :req-un [::code ::name ::bank-name ::number ::type] - :opt-un [::bank-code ::routing]) - #(= (:type %) :check))) - -(s/def ::credit-account (s/and (s/keys :req-un [::code ::name ::bank-name ::number ::type] - :opt-un []) - #(= (:type %) :credit))) - -(s/def ::cash-account (s/and (s/keys :req-un [::type ::code ::name]) - #(= (:type %) :cash))) -(s/def ::bank-account (s/or :cash ::cash-account - :checking ::checking-bank-account - :credit ::credit-account)) -(s/def ::bank-accounts (s/coll-of ::bank-account)) -;; disabled because graphql defaults to string representation -#_(s/def ::weekly-debits (s/nilable double?)) -#_(s/def ::weekly-credits (s/nilable double?)) - -(s/def ::location string?) -(s/def ::locations (s/coll-of ::location :min-count 1)) - -(s/def ::email (s/nilable (s/and string? (s/or :is-email #(re-matches email-regex %) - :is-empty #(= % ""))))) - - -(s/def ::client (s/keys :req-un [::name ::code ::locations] - :opt-un [::email - ::address - #_::weekly-debits - #_::weekely-credits - ::bank-accounts - ::id])) - - -(def client-spec (apply hash-map (drop 1 (s/form ::client)))) -(def all-keys (map #(keyword (name %)) (concat (:req-un client-spec) (:opt-un client-spec)))) diff --git a/src/cljc/auto_ap/entities/contact.cljc b/src/cljc/auto_ap/entities/contact.cljc deleted file mode 100644 index 0c94f10a..00000000 --- a/src/cljc/auto_ap/entities/contact.cljc +++ /dev/null @@ -1,14 +0,0 @@ -(ns auto-ap.entities.contact - (:require [clojure.spec.alpha :as s] - [clojure.string :as str] - [auto-ap.entities.address :as address])) - -(def email-regex #"^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,63}$") - -(s/def ::id (s/nilable string?)) -(s/def ::name (s/nilable string?)) -(s/def ::email (s/nilable (s/and string? (s/or :is-email #(re-matches email-regex %) - :is-empty #(= % ""))))) -(s/def ::phone (s/nilable string?)) - -(s/def ::contact (s/keys :opt-un [::name ::email ::phone ::id])) diff --git a/src/cljc/auto_ap/entities/invoice.cljc b/src/cljc/auto_ap/entities/invoice.cljc deleted file mode 100644 index 60526b0f..00000000 --- a/src/cljc/auto_ap/entities/invoice.cljc +++ /dev/null @@ -1,5 +0,0 @@ -(ns auto-ap.entities.invoice - (:require [clojure.spec.alpha :as s] - [auto-ap.entities.shared :as shared])) - - diff --git a/src/cljc/auto_ap/entities/invoices_expense_accounts.cljc b/src/cljc/auto_ap/entities/invoices_expense_accounts.cljc deleted file mode 100644 index 9a54b23c..00000000 --- a/src/cljc/auto_ap/entities/invoices_expense_accounts.cljc +++ /dev/null @@ -1,11 +0,0 @@ -(ns auto-ap.entities.invoices-expense-accounts - (:require [clojure.spec.alpha :as s] - [clojure.string :as str] - [auto-ap.entities.shared :as shared])) - -(s/def ::vendor-id string?) -(s/def ::account-id string?) -(s/def ::amount ::shared/money) -(s/def ::location string?) - -(s/def ::invoices-expense-account (s/keys :opt-un [::vendor-id ::account-id ::amount ::location])) diff --git a/src/cljc/auto_ap/entities/shared.cljc b/src/cljc/auto_ap/entities/shared.cljc index 3a0adc33..516ab87f 100644 --- a/src/cljc/auto_ap/entities/shared.cljc +++ b/src/cljc/auto_ap/entities/shared.cljc @@ -1,31 +1,2 @@ -(ns auto-ap.entities.shared - (:require [clojure.spec.alpha :as s] - [clojure.string :as str] - )) +(ns auto-ap.entities.shared) -(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 numeric-regex #"^[0-9]+$") -(def only-upper-case #"^[A-Z]+$") - -(s/def ::identifier (s/nilable string?)) -(s/def ::date - #?(:cljs - (s/or :dt? #(instance? goog.date.DateTime %) - :d? #(instance? goog.date.Date %) - :str? (s/and string? #(re-matches date-regex %))) - :clj (s/or :dt? #(instance? org.joda.time.DateTime %) - :ldt? #(instance? org.joda.time.LocalDateTime %) - :ldt? #(instance? org.joda.time.LocalDate %) - :str? (s/and string? #(re-matches date-regex %))))) - -(s/def ::required some?) -(s/def ::has-id (s/and map? - #(:id %))) -(s/def ::required-identifier (s/and string? - #(not (str/blank? %)))) - -(s/def ::money (s/or :string (s/and string? - #(re-matches money-regex %)) - :float float? - :int int?)) diff --git a/src/cljc/auto_ap/entities/transaction_rule.cljc b/src/cljc/auto_ap/entities/transaction_rule.cljc deleted file mode 100644 index f88d4ca5..00000000 --- a/src/cljc/auto_ap/entities/transaction_rule.cljc +++ /dev/null @@ -1,43 +0,0 @@ -(ns auto-ap.entities.transaction-rule - (:require [auto-ap.entities.transaction-rule-account :as transaction-rule-account] - [clojure.spec.alpha :as s] - [clojure.string :as str])) - -(s/def ::client (s/nilable map?)) -(s/def ::description (s/nilable (s/and string? - #( #?@(:clj (try - (re-pattern %) - true - (catch Exception _ - false)) - :cljs (try - (re-pattern %) - true - (catch js/Error _ - false))))))) -(s/def ::amount-gte (s/or :double (s/nilable double?) - :string (s/nilable string?))) -(s/def ::amount-lte (s/or :double (s/nilable double?) - :string (s/nilable string?))) -(s/def ::dom-gte (s/nilable int?)) -(s/def ::dom-lte (s/nilable int?)) -(s/def ::note (s/nilable string?)) -(s/def ::bank-account (s/nilable map?)) -(s/def ::vendor (s/nilable map?)) -(s/def ::yodlee-merchant (s/nilable map?)) -(s/def ::accounts (s/coll-of ::transaction-rule-account/transaction-rule-account :min-count 1)) - -(s/def ::transaction-rule (s/and (s/keys :req-un [::client - ::description - ::amount-gte - ::amount-lte - ::dom-gte - ::dom-lte - ::note - ::bank-account - ::vendor - ::accounts] - :opt-un [::yodlee-merchant]) - - (s/or :description-required #(not (str/blank? (:description %))) - :merchant-required #(not (nil? (:yodlee-merchant %)))))) diff --git a/src/cljc/auto_ap/entities/transaction_rule_account.cljc b/src/cljc/auto_ap/entities/transaction_rule_account.cljc deleted file mode 100644 index bcca931f..00000000 --- a/src/cljc/auto_ap/entities/transaction_rule_account.cljc +++ /dev/null @@ -1,13 +0,0 @@ -(ns auto-ap.entities.transaction-rule-account - (:require [clojure.spec.alpha :as s] - [clojure.string :as str])) - - - -(s/def ::account map?) -(s/def ::location (s/and string? - not-empty)) - -(s/def ::transaction-rule-account (s/keys :req-un [::account - ::location] - :opt-un [])) diff --git a/src/cljc/auto_ap/entities/vendors.cljc b/src/cljc/auto_ap/entities/vendors.cljc deleted file mode 100644 index 3c0844e3..00000000 --- a/src/cljc/auto_ap/entities/vendors.cljc +++ /dev/null @@ -1,43 +0,0 @@ -(ns auto-ap.entities.vendors - (:require [clojure.spec.alpha :as s] - [clojure.string :as str] - [auto-ap.entities.contact :as contact] - [auto-ap.entities.address :as address])) - -(s/def ::id string?) -(s/def ::identifier (s/nilable string?)) (s/def ::required-identifier (s/and string? - #(not (str/blank? %)))) - -(s/def ::name ::required-identifier) -(s/def ::hidden boolean?) -(s/def ::print-as (s/nilable string?)) -(s/def ::terms (s/nilable int?)) -(s/def ::dom (s/nilable int?)) - -(s/def ::invoice-reminder-schedule (s/nilable #{"Weekly" "Never" nil})) - -(s/def ::primary-contact (s/nilable ::contact/contact)) -(s/def ::secondary-contact (s/nilable ::contact/contact)) -(s/def ::address (s/nilable ::address/address)) -(s/def ::default-account-id (s/nilable string?)) - -(s/def ::code (s/nilable string?)) - -(s/def ::vendor (s/and - (s/keys :req-un [::name] - :opt-un [::code - ::default-account-id - ::terms - ::hidden - ::id - ::print-as - ::primary-contact - ::secondary-contact - ::address]) - - (s/or :hidden #(= (:hidden %) true) - :has-expense-account #(not (nil? (:id (:default-account %))))))) - - -(def vendor-spec (apply hash-map (drop 1 (s/form ::vendor)))) -(def all-keys (map #(keyword (name %)) (concat (:req-un vendor-spec) (:opt-un vendor-spec)))) diff --git a/src/cljs/auto_ap/effects.cljs b/src/cljs/auto_ap/effects.cljs index 3837a89d..557d4c2b 100644 --- a/src/cljs/auto_ap/effects.cljs +++ b/src/cljs/auto_ap/effects.cljs @@ -1,18 +1,20 @@ (ns auto-ap.effects (:require-macros [cljs.core.async.macros :refer [go]]) - (:require [re-frame.core :as re-frame] - [cljs-http.client :as http] - [cljs-time.coerce :as c] - [cljs-time.core :as time] - [cljs-time.format :as format] - [cljs.core.async :refer [str standard]] - [auto-ap.status :as status] - [pushy.core :as pushy])) + (:require + [auto-ap.history :as p] + [auto-ap.status :as status] + [auto-ap.views.utils :refer [date->str standard]] + [cemerick.url :as url] + [cljs-http.client :as http] + [cljs-time.coerce :as c] + [cljs-time.core :as time] + [cljs-time.format :as format] + [cljs.core.async :refer [query (->> uri-params - (filter (fn [[k v]] (and v + (url/map->query (->> uri-params + (filter (fn [[_ v]] (and v (or (not (seqable? v)) (not-empty v)))) ) (map diff --git a/src/cljs/auto_ap/effects/forward.cljs b/src/cljs/auto_ap/effects/forward.cljs index b8845949..604c7b09 100644 --- a/src/cljs/auto_ap/effects/forward.cljs +++ b/src/cljs/auto_ap/effects/forward.cljs @@ -7,17 +7,17 @@ ::register (let [process-one-entry (fn [{:as m :keys [id events event-fn]}] (let [_ (assert (map? m) (str "re-frame: effects handler for :forward-events expected a map or a list of maps. Got: " m)) - _ (assert (= #{:id :events :event-fn} (-> m keys set)) (str "re-frame: effects handler for :forward-events given wrong map keys" (-> m keys set)))] - (let [post-event-callback-fn (fn [event-v _] - (when (events (first event-v)) - (re-frame/dispatch (event-fn event-v))))] - (re-frame/add-post-event-callback post-event-callback-fn) - (swap! id->listen-fn assoc id post-event-callback-fn))))] + _ (assert (= #{:id :events :event-fn} (-> m keys set)) (str "re-frame: effects handler for :forward-events given wrong map keys" (-> m keys set))) + post-event-callback-fn (fn [event-v _] + (when (events (first event-v)) + (re-frame/dispatch (event-fn event-v))))] + (re-frame/add-post-event-callback post-event-callback-fn) + (swap! id->listen-fn assoc id post-event-callback-fn)))] (fn [val] (cond (map? val) (process-one-entry val) (sequential? val) (doall (map process-one-entry val)) - :else (re-frame/console :error ":forward-events expected a map or a list of maps, but got: " val))))) + :else (re-frame/console :error ":forward-events expected a map or a list of maps, but got: " val))))) @@ -25,11 +25,11 @@ ::dispose (let [process-one-entry (fn [{:as m :keys [id]}] (let [_ (assert (map? m) (str "re-frame: effects handler for :forward-events expected a map or a list of maps. Got: " m)) - _ (assert (= #{:id} (-> m keys set)) (str "re-frame: effects handler for :forward-events given wrong map keys" (-> m keys set)))] - (let [f (@id->listen-fn id) - _ (assert (some? f) (str ":forward-events asked to unregister an unknown id: " id))] - (re-frame/remove-post-event-callback f) - (swap! id->listen-fn dissoc id))))] + _ (assert (= #{:id} (-> m keys set)) (str "re-frame: effects handler for :forward-events given wrong map keys" (-> m keys set))) + f (@id->listen-fn id) + _ (assert (some? f) (str ":forward-events asked to unregister an unknown id: " id))] + (re-frame/remove-post-event-callback f) + (swap! id->listen-fn dissoc id)))] (fn [val] (cond (map? val) (process-one-entry val) diff --git a/src/cljs/auto_ap/events.cljs b/src/cljs/auto_ap/events.cljs index ff28338c..709b958b 100644 --- a/src/cljs/auto_ap/events.cljs +++ b/src/cljs/auto_ap/events.cljs @@ -3,12 +3,12 @@ [auto-ap.db :as db] [auto-ap.routes :as routes] [auto-ap.utils :refer [by]] - [auto-ap.views.utils :refer [with-user parse-jwt]] + [auto-ap.views.pages.data-page :as data-page] + [auto-ap.views.utils :refer [parse-jwt with-user]] [bidi.bidi :as bidi] [clojure.string :as str] [goog.crypt.base64 :as b64] - [re-frame.core :as re-frame] - [goog.crypt.base64 :as base64])) + [re-frame.core :as re-frame])) (defn jwt->data [token] (js->clj (.parse js/JSON (b64/decodeString (second (str/split token #"\." )))))) @@ -131,14 +131,6 @@ (.setItem js/localStorage "last-client-id" (:id client)) (assoc db :client (:id client)))) -(re-frame/reg-event-db - ::change-form - (fn [db [_ location field value]] - (if value - (assoc-in db (into location field) value) - (update-in db (into location (butlast field)) dissoc (last field))))) - - (re-frame/reg-event-fx ::set-active-route (fn [{:keys [db]} [_ handler params route-params]] @@ -164,7 +156,7 @@ :menu nil :query-params params :route-params route-params) - (auto-ap.views.pages.data-page/dispose-all))}))) + (data-page/dispose-all))}))) (re-frame/reg-event-fx diff --git a/src/cljs/auto_ap/forms.cljs b/src/cljs/auto_ap/forms.cljs index 638333e1..85ad369f 100644 --- a/src/cljs/auto_ap/forms.cljs +++ b/src/cljs/auto_ap/forms.cljs @@ -105,7 +105,7 @@ (re-frame/reg-event-db ::attempted-submit - (fn [db [_ form & paths]] + (fn [db [_ form ]] (assoc-in db [::forms form :attempted-submit?] true))) (defn change-handler [form customize-fn] @@ -154,16 +154,17 @@ (defn triggers-loading [form] (re-frame/enrich - (fn [db event] + (fn [db _] (loading db form)))) + (defn triggers-stop [form] (re-frame/enrich - (fn [db event] + (fn [db _] (stop-form db form)))) (defn triggers-stop-loading [form] (re-frame/enrich - (fn [db event] + (fn [db _] (assoc-in db [::forms form :status] nil)))) (defn save-succeeded [db id] diff --git a/src/cljs/auto_ap/forms/builder.cljs b/src/cljs/auto_ap/forms/builder.cljs index 66bcd1ec..ca631d27 100644 --- a/src/cljs/auto_ap/forms/builder.cljs +++ b/src/cljs/auto_ap/forms/builder.cljs @@ -24,7 +24,7 @@ {:errors (merge (-> me/default-errors (assoc ::m/missing-key {:error/message "Required"} ::m/invalid-type {:error/fn - (fn [a b] + (fn [a _] (if (nil? (:value a)) "Required" "Invalid"))})) @@ -210,7 +210,7 @@ (r/as-element (into [:<>] (r/children (r/current-component)))))) -(defn vertical-control [{:keys [is-small? required?]}] +(defn vertical-control [{:keys [required?]}] (let [[label & children] (r/children (r/current-component))] (consume Consumer ["fullwidth?"] diff --git a/src/cljs/auto_ap/history.cljs b/src/cljs/auto_ap/history.cljs index 63177fd8..6e46d440 100644 --- a/src/cljs/auto_ap/history.cljs +++ b/src/cljs/auto_ap/history.cljs @@ -3,7 +3,6 @@ [pushy.core :as pushy] [auto-ap.routes :as routes] [auto-ap.views.utils :as u] - [cemerick.url :refer [url]] [re-frame.core :as re-frame])) (defn parse-url [url] diff --git a/src/cljs/auto_ap/status.cljs b/src/cljs/auto_ap/status.cljs index 6e1c78ed..ece87d4c 100644 --- a/src/cljs/auto_ap/status.cljs +++ b/src/cljs/auto_ap/status.cljs @@ -109,7 +109,7 @@ (re-frame/reg-event-db ::completed [(re-frame/path [::status]) ] - (fn [db [_ single which]] + (fn [db [_ single _]] (assoc db single {:state nil :error nil}))) @@ -135,21 +135,19 @@ info-states (->> states (filter #(:info %)))] [:<> - (if (seq error-states) + (when (seq error-states) [:div.notification.is-danger.is-light (for [state states state (:error state)] - (do - ^{:key (:message state)} - [:p (or (:message state) - (:error state) - "An unexpected error occured.")]))]) - (if (seq info-states) + ^{:key (:message state)} + [:p (or (:message state) + (:error state) + "An unexpected error occured.")])]) + (when (seq info-states) [:div.notification.is-info.is-light (for [state states] - (do - ^{:key (:info state)} - [:p (:info state)]))])])) + ^{:key (:info state)} + [:p (:info state)])])])) (defn big-loader [status] (when (= :loading (:state status)) diff --git a/src/cljs/auto_ap/views/components/address.cljs b/src/cljs/auto_ap/views/components/address.cljs index fa92e600..d8332b29 100644 --- a/src/cljs/auto_ap/views/components/address.cljs +++ b/src/cljs/auto_ap/views/components/address.cljs @@ -1,6 +1,5 @@ (ns auto-ap.views.components.address (:require - [auto-ap.entities.address :as address] [auto-ap.forms.builder :as form-builder] [auto-ap.views.components.level :as level])) @@ -20,8 +19,7 @@ [:p.help "City"] [:input.input.is-expanded {:type "text" :placeholder "Cupertino" - :field [:city] - :spec ::address/city}]] + :field [:city]}]] [form-builder/field-v2 {:field :state} [:p.help "State"] [:input.input {:type "text" diff --git a/src/cljs/auto_ap/views/components/admin/side_bar.cljs b/src/cljs/auto_ap/views/components/admin/side_bar.cljs index f615777a..86fef4ed 100644 --- a/src/cljs/auto_ap/views/components/admin/side_bar.cljs +++ b/src/cljs/auto_ap/views/components/admin/side_bar.cljs @@ -7,7 +7,7 @@ [re-frame.core :as re-frame] [reagent.core :as r])) -(defn admin-side-bar [params ] +(defn admin-side-bar [] (let [ap @(re-frame/subscribe [::subs/active-page])] [:div [:p.menu-label "General"] @@ -45,12 +45,6 @@ [:a {:href (bidi/path-for routes/routes :admin-rules), :class (str "item" (active-when ap = :admin-rules))} [:span {:class "icon icon-cog-play-1" :style {:font-size "25px"}}] [:span {:class "name"} "Rules"]]] - - - - - - [:ul ]] [:p.menu-label "Import"] [:ul.menu-list diff --git a/src/cljs/auto_ap/views/components/buttons.cljs b/src/cljs/auto_ap/views/components/buttons.cljs index 1fe1b55b..6cb5fb2c 100644 --- a/src/cljs/auto_ap/views/components/buttons.cljs +++ b/src/cljs/auto_ap/views/components/buttons.cljs @@ -2,7 +2,7 @@ (:require [auto-ap.views.utils :refer [dispatch-event]] [reagent.core :as r])) -(defn fa-icon [{:keys [event icon class on-click] :as params}] +(defn fa-icon [{:keys [event icon on-click] :as params}] [:a.button (cond-> params true (dissoc :event :icon) (and (not on-click) @@ -15,7 +15,7 @@ -(defn sl-icon [{:keys [event icon class on-click] :as params}] +(defn sl-icon [{:keys [event icon on-click] :as params}] [:a.button (cond-> params true (dissoc :event :icon) (and (not on-click) @@ -28,7 +28,7 @@ [:span.icon [:i.fa.fa-plus]] [:span name]]) -(defn dropdown [{:keys [event icon class on-click] :as params}] +(defn dropdown [{:keys [event on-click] :as params}] [:a.button (cond-> params true (dissoc :event :icon) (and (not on-click) diff --git a/src/cljs/auto_ap/views/components/dropdown.cljs b/src/cljs/auto_ap/views/components/dropdown.cljs index cffe8e5e..9573b0c1 100644 --- a/src/cljs/auto_ap/views/components/dropdown.cljs +++ b/src/cljs/auto_ap/views/components/dropdown.cljs @@ -5,7 +5,7 @@ [re-frame.core :as re-frame] [auto-ap.subs :as subs])) -(defn drop-down-contents [{:keys [id]} children ] +(defn drop-down-contents [{:keys [id]}] (let [toggle-fn (fn [] (re-frame/dispatch [::events/toggle-menu id]))] (r/create-class {:component-did-mount (fn [] (.addEventListener js/document "click" toggle-fn)) :component-will-unmount (fn [] (.removeEventListener js/document "click" toggle-fn)) @@ -13,8 +13,8 @@ (fn [children] children)}))) -(defn drop-down [{:keys [ header id is-right? class]} child] - (let [menu-active? (re-frame/subscribe [::subs/menu-active? id])] +(defn drop-down [{:keys [ id ]} _] + (let [_ (re-frame/subscribe [::subs/menu-active? id])] (r/create-class {:reagent-render (fn [{:keys [header id is-right? class] :or {is-right? true}} child] (let [menu-active? @(re-frame/subscribe [::subs/menu-active? id])] diff --git a/src/cljs/auto_ap/views/components/grid.cljs b/src/cljs/auto_ap/views/components/grid.cljs index 3c5870fa..8c272a32 100644 --- a/src/cljs/auto_ap/views/components/grid.cljs +++ b/src/cljs/auto_ap/views/components/grid.cljs @@ -1,13 +1,13 @@ (ns auto-ap.views.components.grid - (:require [reagent.core :as r] - [auto-ap.views.utils :refer [appearing copy-to-clipboard]] - [auto-ap.utils :refer [default-pagination-size]] - [react :as react] - [re-frame.core :as re-frame] - [auto-ap.views.pages.data-page :as data-page] - [auto-ap.views.components.buttons :as buttons] - [auto-ap.subs :as subs] - [react-dom :as react-dom])) + (:require + [auto-ap.subs :as subs] + [auto-ap.utils :refer [default-pagination-size]] + [auto-ap.views.pages.data-page :as data-page] + [auto-ap.views.utils :refer [copy-to-clipboard]] + [re-frame.core :as re-frame] + [react :as react] + [reagent.core :as r])) + (set! *warn-on-infer* true) (defonce ^js/React.Context grid-context ( react/createContext "default")) @@ -60,7 +60,7 @@ :else y)) -(defn paginator [{:keys [start per-page end count total on-change] :as g}] +(defn paginator [{:keys [start per-page end total on-change]}] (let [per-page (or per-page default-pagination-size) max-buttons 5 buttons-before (Math/floor (/ max-buttons 2)) @@ -72,7 +72,7 @@ [:li [:a.pagination-link {:class (when (= current-page x) "is-current") - :on-click (fn [e] (on-change {:start (* x per-page) + :on-click (fn [_] (on-change {:start (* x per-page) :per-page per-page}))} (inc x)]])) @@ -117,11 +117,11 @@ [:a.tag.is-medium.is-delete {:on-click (fn [] (on-change {:sort (filter #(not= sort-key (:sort-key %)) sort)}))}]]])]) -(defn controls [{:keys [start end count total per-page action-buttons] :as para}] +(defn controls [{:keys [start end count total action-buttons]}] (let [children (r/children (r/current-component))] [:> Consumer {} (fn [consume] - (let [{:strs [on-params-change params] :as consume} (js->clj consume)] + (let [{:strs [on-params-change params]} (js->clj consume)] (r/as-element (into [:div {:style {:margin-bottom "1rem"}} [:div.level @@ -174,8 +174,8 @@ :checked (if (get checked id) "checked" "") - :on-change (fn [x e] - (if id + :on-change (fn [_ _] + (when id (let [checked (or checked #{})] ;; TODO only map once everything is moved over to data-page (if (map? checked) @@ -199,7 +199,7 @@ ]]))) (map r/as-element children))))])) -(defn button-cell [params] +(defn button-cell [] (apply r/create-element "td" #js {"style" #js {"overflow" "visible"}} (map r/as-element (r/children (r/current-component))))) @@ -244,13 +244,13 @@ children)))))])) -(defn sortable-header-cell [{:keys [style class sort-key sort-name asc]}] +(defn sortable-header-cell [{:keys [style class sort-key sort-name]}] (let [children (r/children (r/current-component))] [:> Consumer {} (fn [consume] - (let [{:strs [on-params-change params] :as consume} (js->clj consume)] + (let [{:strs [on-params-change params]} (js->clj consume)] (r/as-element (conj (into - [:th {:on-click (fn [e] + [:th {:on-click (fn [_] (on-params-change (toggle-sort-by {:sort (:sort params)} sort-key sort-name))) :style (assoc style diff --git a/src/cljs/auto_ap/views/components/layouts.cljs b/src/cljs/auto_ap/views/components/layouts.cljs index 0ab3265e..f7e01186 100644 --- a/src/cljs/auto_ap/views/components/layouts.cljs +++ b/src/cljs/auto_ap/views/components/layouts.cljs @@ -27,7 +27,7 @@ :ref (fn [n] (reset! !child n)) :tab-index 0 - :onBlur (fn [e] + :onBlur (fn [_] (js/setTimeout (fn [] (println @!child) (println (.-activeElement js/document)) @@ -120,7 +120,7 @@ (re-frame/dispatch [::events/swap-client client])) } name])]])) -(defn navbar [ap] +(defn navbar [] (let [navbar-menu-shown? (r/atom false)] (fn [ap] (let [user (re-frame/subscribe [::subs/user]) diff --git a/src/cljs/auto_ap/views/components/modal.cljs b/src/cljs/auto_ap/views/components/modal.cljs index 5a4b3818..d476f6c9 100644 --- a/src/cljs/auto_ap/views/components/modal.cljs +++ b/src/cljs/auto_ap/views/components/modal.cljs @@ -1,10 +1,8 @@ (ns auto-ap.views.components.modal - (:require [re-frame.core :as re-frame] - [reagent.core :as r] - [auto-ap.events :as events] - [auto-ap.subs :as subs] - [auto-ap.status :as status] - [auto-ap.views.utils :refer [with-keys appearing dispatch-event]])) + (:require + [auto-ap.status :as status] + [auto-ap.views.utils :refer [appearing dispatch-event]] + [re-frame.core :as re-frame])) (re-frame/reg-sub ::modal-state @@ -18,7 +16,7 @@ (re-frame/reg-event-fx ::modal-closed - (fn [{:keys [db]} [_ state]] + (fn [{:keys [db]} [_ _]] (let [[_ status-id] (some-> db ::state :confirm :status-from )] (cond-> {:db (dissoc db ::state)} status-id (assoc :dispatch [::status/completed status-id]))))) @@ -27,7 +25,7 @@ (defn global-modal [] (let [state (re-frame/subscribe [::modal-state])] (fn [] - (if (:visible? @state) + (when (:visible? @state) (let [{:keys [title body status-from foot class cancel? confirm]} @state] [:div.modal.is-active (cond-> {} class (assoc :class class)) diff --git a/src/cljs/auto_ap/views/components/multi.cljs b/src/cljs/auto_ap/views/components/multi.cljs index 6d45ba95..cd3981dc 100644 --- a/src/cljs/auto_ap/views/components/multi.cljs +++ b/src/cljs/auto_ap/views/components/multi.cljs @@ -1,16 +1,13 @@ (ns auto-ap.views.components.multi (:require - [cemerick.url] #_{:clj-kondo/ignore [:unused-namespace]} [reagent.core :as reagent] - [react :as react] - [auto-ap.entities.shared :as shared] [auto-ap.views.utils :refer [appearing-group]] [auto-ap.forms.builder :as form-builder])) ;; TODO just embrace the fact that it will need to be remounted, and use index based keys -(defn multi-field-v2-internal [{:keys [template key-fn allow-change? disable-new? disable-remove? schema on-change disabled new-text] prop-value :value :as props} ] +(defn multi-field-v2-internal [{:keys [template key-fn allow-change? disable-new? disable-remove? schema on-change disabled new-text] prop-value :value } ] (let [prop-value (if (seq prop-value) (vec prop-value) [])] diff --git a/src/cljs/auto_ap/views/components/paginator.cljs b/src/cljs/auto_ap/views/components/paginator.cljs deleted file mode 100644 index c56638af..00000000 --- a/src/cljs/auto_ap/views/components/paginator.cljs +++ /dev/null @@ -1,55 +0,0 @@ -(ns auto-ap.views.components.paginator - (:require [re-frame.core :as re-frame] - [auto-ap.subs :as subs] - [auto-ap.views.utils :refer [date->str]] - [reagent.core :as reagent] - [clojure.string :as str] - [cljs-time.format :as format])) - - -(defn bound [x y z] - (cond - (< z x) - x - (< y x) - x - (> y z) - z - :else - y)) - -(defn paginator [{:keys [start end count total on-change]}] - (let [per-page 100 - max-buttons 5 - buttons-before (Math/floor (/ max-buttons 2)) - total-pages (Math/ceil (/ total per-page)) - current-page (Math/floor (/ start per-page)) - first-page-button (bound 0 (- current-page buttons-before) (- total-pages max-buttons)) - all-buttons (into [] (for [x (range total-pages)] - ^{:key x} - [:li - [:a.pagination-link {:class (when (= current-page x) - "is-current") - :on-click (fn [e] (on-change {:start (* x per-page)}))} - (inc x)]])) - - - last-page-button (Math/min total-pages (+ max-buttons first-page-button)) - - extended-last-page-button (when (not= last-page-button total-pages) - (list - ^ {:key -1} [:li [:span.pagination-ellipsis "…"]] - ^ {:key -2} (last all-buttons))) - - extended-first-page-button (when (not= first-page-button 0) - (list - ^{:key -1} (first all-buttons) - ^{:key -2} [:li [:span.pagination-ellipsis "…"]]))] - - - [:nav.pagination {:role "pagination"} - [:ul.pagination-list - extended-first-page-button - (apply list (subvec all-buttons first-page-button last-page-button)) - extended-last-page-button - "Showing " (Math/min (inc start) total) "-" end "/" total]])) diff --git a/src/cljs/auto_ap/views/components/percentage_field.cljs b/src/cljs/auto_ap/views/components/percentage_field.cljs index 4a43dee6..7ff18035 100644 --- a/src/cljs/auto_ap/views/components/percentage_field.cljs +++ b/src/cljs/auto_ap/views/components/percentage_field.cljs @@ -1,6 +1,5 @@ (ns auto-ap.views.components.percentage-field (:require [reagent.core :as r] - [auto-ap.views.utils :refer [->short$]] [clojure.string :as str] [react :as react])) (def good-% #"^\d{1,3}$") diff --git a/src/cljs/auto_ap/views/components/sort_by_list.cljs b/src/cljs/auto_ap/views/components/sort_by_list.cljs deleted file mode 100644 index 267f5aaf..00000000 --- a/src/cljs/auto_ap/views/components/sort_by_list.cljs +++ /dev/null @@ -1,21 +0,0 @@ -(ns auto-ap.views.components.sort-by-list - (:require [re-frame.core :as re-frame] - [auto-ap.subs :as subs] - [auto-ap.views.utils :refer [date->str]] - [reagent.core :as reagent] - [clojure.string :as str] - [cljs-time.format :as format])) - -(defn sort-by-list [{:keys [sort on-change]}] - [:div.field.is-grouped.is-grouped-multiline - (for [{:keys [sort-key sort-name asc]} sort] - ^{:key sort-key} - [:div.control - [:div.tags.has-addons - [:div.tag.is-medium [:span.icon (if asc - [:i.fa.fa-sort-up] - [:i.fa.fa-sort-down])] - [:span sort-name] ] - [:a.tag.is-medium.is-delete {:on-click (fn [] - (on-change {:sort (filter #(not= sort-key (:sort-key %)) sort)}))}]]])]) - diff --git a/src/cljs/auto_ap/views/components/sorter.cljs b/src/cljs/auto_ap/views/components/sorter.cljs deleted file mode 100644 index a385c4d9..00000000 --- a/src/cljs/auto_ap/views/components/sorter.cljs +++ /dev/null @@ -1,49 +0,0 @@ -(ns auto-ap.views.components.sorter - (:require [re-frame.core :as re-frame] - [auto-ap.subs :as subs] - [auto-ap.views.utils :refer [date->str]] - [reagent.core :as reagent] - [clojure.string :as str] - [cljs-time.format :as format])) -(defn toggle-sort-by [params sort-key sort-name asc] - (let [[found? sort] (reduce - (fn [[found? sort] sort-item] - (if (= sort-key (:sort-key sort-item)) - [true (conj sort - (update sort-item :asc not))] - [found? (conj sort sort-item)])) - [false []] - (:sort params)) - sort (if found? - sort - (conj sort {:sort-key sort-key - :sort-name sort-name - :asc true}))] - - (-> params - (assoc :sort sort)))) - -(defn sort-icon [which sort asc] - (let [sort-item (first (filter #(= which (:sort-key %)) sort))] - (cond - (and sort-item (:asc sort-item)) - [:span.icon - [:i.fa.fa-sort-up]] - - (and sort-item (not (:asc sort-item))) - [:span.icon - [:i.fa.fa-sort-down]] - - :else - [:span.icon - [:i.fa.fa-sort]]))) - - -(defn sorted-column [{:keys [on-sort sort-key sort sort-name asc style class]} & rest] - [:th {:on-click (fn [e] - (on-sort - (toggle-sort-by {:sort sort} sort-key sort-name asc))) - :style style - :class class} - rest - (sort-icon sort-key sort asc)]) diff --git a/src/cljs/auto_ap/views/components/vendor_dialog.cljs b/src/cljs/auto_ap/views/components/vendor_dialog.cljs index d6e7fbe3..51e37781 100644 --- a/src/cljs/auto_ap/views/components/vendor_dialog.cljs +++ b/src/cljs/auto_ap/views/components/vendor_dialog.cljs @@ -166,7 +166,7 @@ -(defn form-content [{:keys [data]}] +(defn form-content [] (let [is-admin? @(re-frame/subscribe [::subs/is-admin?]) clients @(re-frame/subscribe [::subs/client-refs])] [form-builder/builder {:submit-event [::save] diff --git a/src/cljs/auto_ap/views/pages/admin.cljs b/src/cljs/auto_ap/views/pages/admin.cljs index 2cebbf5d..16c31be3 100644 --- a/src/cljs/auto_ap/views/pages/admin.cljs +++ b/src/cljs/auto_ap/views/pages/admin.cljs @@ -1,12 +1,7 @@ (ns auto-ap.views.pages.admin - (:require-macros [cljs.core.async.macros :refer [go]]) - (:require [re-frame.core :as re-frame] - [reagent.core :as reagent] - [auto-ap.subs :as subs] - [auto-ap.events :as events] - [auto-ap.views.components.admin.side-bar :refer [admin-side-bar]] - [auto-ap.views.components.layouts :refer [side-bar-layout]] - [auto-ap.views.utils :refer [login-url]])) + (:require + [auto-ap.views.components.admin.side-bar :refer [admin-side-bar]] + [auto-ap.views.components.layouts :refer [side-bar-layout]])) (defn admin-page [] [side-bar-layout {:side-bar [admin-side-bar {}] diff --git a/src/cljs/auto_ap/views/pages/admin/accounts.cljs b/src/cljs/auto_ap/views/pages/admin/accounts.cljs index 45be819d..4ad7eef1 100644 --- a/src/cljs/auto_ap/views/pages/admin/accounts.cljs +++ b/src/cljs/auto_ap/views/pages/admin/accounts.cljs @@ -1,25 +1,20 @@ (ns auto-ap.views.pages.admin.accounts - (:require [auto-ap.forms :as forms] - [auto-ap.subs :as subs] - [auto-ap.utils :refer [replace-by]] - [auto-ap.views.components.admin.side-bar :refer [admin-side-bar]] - [auto-ap.views.pages.admin.accounts.side-bar :as side-bar] - [auto-ap.views.pages.admin.accounts.table :as table] - [auto-ap.views.utils :refer [dispatch-event action-cell-width with-user]] - [auto-ap.views.components.layouts - :refer - [appearing-side-bar side-bar-layout]] - [auto-ap.views.pages.admin.accounts.form :as account-form] - [re-frame.core :as re-frame] - [auto-ap.views.components.grid :as grid] - [auto-ap.status :as status] - [auto-ap.views.components.buttons :as buttons] - [reagent.core :as reagent] - [clojure.string :as str] - [vimsical.re-frame.fx.track :as track] - [auto-ap.views.pages.data-page :as data-page] - [clojure.set :as set] - [auto-ap.effects.forward :as forward])) + (:require + [auto-ap.effects.forward :as forward] + [auto-ap.forms :as forms] + [auto-ap.views.components.admin.side-bar :refer [admin-side-bar]] + [auto-ap.views.components.buttons :as buttons] + [auto-ap.views.components.layouts + :refer [appearing-side-bar side-bar-layout]] + [auto-ap.views.pages.admin.accounts.form :as account-form] + [auto-ap.views.pages.admin.accounts.side-bar :as side-bar] + [auto-ap.views.pages.admin.accounts.table :as table] + [auto-ap.views.pages.data-page :as data-page] + [auto-ap.views.utils :refer [with-user]] + [clojure.set :as set] + [re-frame.core :as re-frame] + [reagent.core :as reagent] + [vimsical.re-frame.fx.track :as track])) (def default-read [:numeric-code :name :location :type :account_set :applicability :id [:client-overrides [:name [:client [:name :id]]]]]) diff --git a/src/cljs/auto_ap/views/pages/admin/accounts/side_bar.cljs b/src/cljs/auto_ap/views/pages/admin/accounts/side_bar.cljs index 283c83a4..dc07b107 100644 --- a/src/cljs/auto_ap/views/pages/admin/accounts/side_bar.cljs +++ b/src/cljs/auto_ap/views/pages/admin/accounts/side_bar.cljs @@ -1,10 +1,8 @@ (ns auto-ap.views.pages.admin.accounts.side-bar (:require - [re-frame.core :as re-frame] - [auto-ap.subs :as subs] + [auto-ap.views.pages.data-page :as data-page] [auto-ap.views.utils :refer [dispatch-value-change]] - [auto-ap.views.pages.data-page :as data-page])) - + [re-frame.core :as re-frame])) (defn accounts-side-bar [{:keys [data-page]}] [:div diff --git a/src/cljs/auto_ap/views/pages/admin/accounts/table.cljs b/src/cljs/auto_ap/views/pages/admin/accounts/table.cljs index c6a110a8..42328cac 100644 --- a/src/cljs/auto_ap/views/pages/admin/accounts/table.cljs +++ b/src/cljs/auto_ap/views/pages/admin/accounts/table.cljs @@ -1,12 +1,11 @@ (ns auto-ap.views.pages.admin.accounts.table (:require - [auto-ap.status :as status] [auto-ap.views.components.buttons :as buttons] [auto-ap.views.components.grid :as grid] [auto-ap.views.pages.admin.accounts.form :as account-form] + [auto-ap.views.pages.data-page :as data-page] [auto-ap.views.utils :refer [action-cell-width]] - [re-frame.core :as re-frame] - [auto-ap.views.pages.data-page :as data-page])) + [re-frame.core :as re-frame])) (defn accounts-table [{:keys [data-page]}] (let [{:keys [data]} @(re-frame/subscribe [::data-page/page data-page])] @@ -24,7 +23,7 @@ [grid/header-cell {} "Location"] [grid/header-cell {:style {:width (action-cell-width 1)}} ]]] [grid/body - (for [{:keys [id numeric-code name type location class] :as account} (:data data)] + (for [{:keys [id numeric-code name type location] :as account} (:data data)] ^{:key id} [grid/row {:class (:class account) :id id} [grid/cell {} numeric-code] diff --git a/src/cljs/auto_ap/views/pages/admin/clients/form.cljs b/src/cljs/auto_ap/views/pages/admin/clients/form.cljs index aa0599e4..eb3a78ce 100644 --- a/src/cljs/auto_ap/views/pages/admin/clients/form.cljs +++ b/src/cljs/auto_ap/views/pages/admin/clients/form.cljs @@ -1,6 +1,5 @@ (ns auto-ap.views.pages.admin.clients.form (:require - [auto-ap.entities.clients :as entity] [auto-ap.events :as events] [auto-ap.forms :as forms] [auto-ap.forms.builder :as form-builder] @@ -21,7 +20,6 @@ [cljs-time.core :as t] [re-frame.core :as re-frame] [reagent.core :as r] - [react-signature-canvas] [vimsical.re-frame.cofx.inject :as inject] [auto-ap.schema :as schema] [malli.core :as m])) @@ -178,7 +176,7 @@ :identifier identifier :amount amount}) (:forecasted-transactions new-client-data)) - :bank-accounts (map-indexed (fn [i {:keys [number name check-number plaid-account intuit-bank-account include-in-reports type id code numeric-code start-date bank-name routing bank-code new? sort-order visible yodlee-account-id locations yodlee-account use-date-instead-of-post-date]}] + :bank-accounts (map-indexed (fn [i {:keys [number name check-number plaid-account intuit-bank-account include-in-reports type id code numeric-code start-date bank-name routing bank-code new? visible locations yodlee-account use-date-instead-of-post-date]}] {:number number :name name :check-number check-number @@ -526,8 +524,7 @@ "Client code" [:input.input {:type "code" :style {:width "5em"} - :disabled (boolean (:id new-client)) - :spec ::entity/code}]] + :disabled (boolean (:id new-client))}]] [form-builder/field-v2 {:field :locations} "Locations" diff --git a/src/cljs/auto_ap/views/pages/admin/clients/side_bar.cljs b/src/cljs/auto_ap/views/pages/admin/clients/side_bar.cljs index c95a2713..467e313f 100644 --- a/src/cljs/auto_ap/views/pages/admin/clients/side_bar.cljs +++ b/src/cljs/auto_ap/views/pages/admin/clients/side_bar.cljs @@ -13,7 +13,7 @@ ::filters :<- [::specific-filters] :<- [::subs/query-params] - (fn [[specific-filters vendors-by-id query-params] ] + (fn [[specific-filters _ query-params] ] (let [url-filters (-> query-params (select-keys #{:name :code})) @@ -32,7 +32,7 @@ :<- [::settled-filters] :<- [::filters] :<- [::subs/active-page] - (fn [[settled-filters filters ap ]] + (fn [[settled-filters filters _ ]] (let [filters (or settled-filters filters)] {:name (:name filters) :code (:code filters)}))) @@ -44,7 +44,7 @@ (re-frame/reg-event-fx ::filters-settled - (fn [{:keys [db]} [_ & params]] + (fn [{:keys [db]} _] {:db (assoc db ::settled-filters @(re-frame/subscribe [::filters]))})) (re-frame/reg-event-fx diff --git a/src/cljs/auto_ap/views/pages/admin/import_batches.cljs b/src/cljs/auto_ap/views/pages/admin/import_batches.cljs index e299ba64..53ecd15c 100644 --- a/src/cljs/auto_ap/views/pages/admin/import_batches.cljs +++ b/src/cljs/auto_ap/views/pages/admin/import_batches.cljs @@ -1,29 +1,22 @@ (ns auto-ap.views.pages.admin.import-batches - (:require [auto-ap.forms :as forms] - [auto-ap.subs :as subs] - [auto-ap.views.components.admin.side-bar :refer [admin-side-bar]] - [auto-ap.views.components.layouts :refer [appearing-side-bar side-bar-layout]] - [auto-ap.views.pages.admin.import-batches.table :as table] - [auto-ap.views.utils :refer [dispatch-event with-user]] - [vimsical.re-frame.cofx.inject :as inject] - [vimsical.re-frame.fx.track :as track] - [auto-ap.events :as events] - [auto-ap.utils :refer [replace-by merge-by]] - [re-frame.core :as re-frame] - [auto-ap.status :as status] - [auto-ap.effects.forward :as forward] - [auto-ap.views.pages.data-page :as data-page] - [clojure.set :as set] - [auto-ap.views.components.buttons :as buttons] - [clojure.string :as str])) - + (:require + [auto-ap.status :as status] + [auto-ap.subs :as subs] + [auto-ap.views.components.admin.side-bar :refer [admin-side-bar]] + [auto-ap.views.components.layouts :refer [side-bar-layout]] + [auto-ap.views.pages.admin.import-batches.table :as table] + [auto-ap.views.pages.data-page :as data-page] + [auto-ap.views.utils :refer [dispatch-event with-user]] + [clojure.set :as set] + [re-frame.core :as re-frame] + [vimsical.re-frame.fx.track :as track])) (def default-read [:user-name :date :source :status :id :imported :suppressed :extant]) (re-frame/reg-event-fx ::params-change [with-user ] - (fn [{:keys [db user] :as cofx} [_ params]] + (fn [{:keys [user]} [_ params]] {:graphql {:token user :owns-state {:single [::data-page/page ::page]} :query-obj {:venia/queries [{:query/data [:import_batch_page @@ -54,30 +47,13 @@ (re-frame/reg-event-fx ::request-intuit [with-user ] - (fn [{:keys [db user] :as cofx} [_ params]] + (fn [{:keys [user]} [_ _]] {:graphql {:token user :owns-state {:single ::intuit} :query "mutation RequestIntuitImport{request_import(which: \":intuit\")}" :on-success [::success-intuit] }})) - - -(re-frame/reg-event-db - ::success-yodlee - (fn [db [_ n]] - (assoc db ::msg (str "Your job " (:request-import n) " has been scheduled." )))) - -(re-frame/reg-event-fx - ::request-yodlee - [with-user ] - (fn [{:keys [db user] :as cofx} [_ params]] - {:graphql {:token user - :owns-state {:single ::yodlee} - :query "mutation RequestIntuitImport{request_import(which: \":yodlee\")}" - :on-success [::success-yodlee] - }})) - (re-frame/reg-event-db ::success-yodlee2 (fn [db [_ n]] @@ -86,7 +62,7 @@ (re-frame/reg-event-fx ::request-yodlee2 [with-user ] - (fn [{:keys [db user] :as cofx} [_ params]] + (fn [{:keys [user]} [_ _]] {:graphql {:token user :owns-state {:single ::yodlee2} :query "mutation RequestIntuitImport{request_import(which: \":yodlee2\")}" @@ -103,7 +79,7 @@ (re-frame/reg-event-fx ::request-plaid [with-user ] - (fn [{:keys [db user] :as cofx} [_ params]] + (fn [{:keys [user]} [_ _]] {:graphql {:token user :owns-state {:single ::plaid} :query "mutation RequestIntuitImport{request_import(which: \":plaid\")}" @@ -112,7 +88,7 @@ (re-frame/reg-event-fx ::mounted - (fn [{:keys [db]}] + (fn [_] {::track/register {:id ::params :subscription [::data-page/params ::page] :event-fn (fn [params] @@ -131,7 +107,6 @@ (fn [] (let [user @(re-frame/subscribe [::subs/user]) intuit-request-import-status @(re-frame/subscribe [::status/single ::intuit]) - yodlee-request-import-status @(re-frame/subscribe [::status/single ::yodlee]) yodlee2-request-import-status @(re-frame/subscribe [::status/single ::yodlee2]) plaid-request-import-status @(re-frame/subscribe [::status/single ::plaid]) message @(re-frame/subscribe [::msg])] @@ -143,13 +118,7 @@ [:div [:div.is-pulled-right [:div.buttons - [:button.button.is-primary-two {:aria-haspopup true - :type "button" - :on-click (dispatch-event [::request-yodlee]) - :disabled (status/disabled-for yodlee-request-import-status) - :class (status/class-for yodlee-request-import-status)} - - "Start Yodlee Import"] + [:button.button.is-primary-two {:aria-haspopup true :type "button" :on-click (dispatch-event [::request-yodlee2]) diff --git a/src/cljs/auto_ap/views/pages/admin/import_batches/table.cljs b/src/cljs/auto_ap/views/pages/admin/import_batches/table.cljs index 212e715a..86841e3b 100644 --- a/src/cljs/auto_ap/views/pages/admin/import_batches/table.cljs +++ b/src/cljs/auto_ap/views/pages/admin/import_batches/table.cljs @@ -31,13 +31,7 @@ (fn [[specific-table-params query-params]] (merge (select-keys query-params #{:start :sort}) specific-table-params ))) -(re-frame/reg-event-fx - ::params-changed - [(re-frame/path [::table-params])] - (fn [{table-params :db} [_ params :as z]] - {:db (merge table-params params)})) - -(defn table* [{:keys [id data-page]}] +(defn table* [{:keys [data-page]}] (let [{:keys [data]} @(re-frame/subscribe [::data-page/page data-page])] [grid/grid {:data-page data-page :column-count 6} @@ -82,7 +76,7 @@ :icon "fa-external-link"}]] ])]]])) -(defn table [params] +(defn table [] (r/create-class {:component-will-unmount (dispatch-event [::unmounted]) :reagent-render (fn [params] [table* params])})) diff --git a/src/cljs/auto_ap/views/pages/admin/plaid/table.cljs b/src/cljs/auto_ap/views/pages/admin/plaid/table.cljs index bad6a6f2..84170e08 100644 --- a/src/cljs/auto_ap/views/pages/admin/plaid/table.cljs +++ b/src/cljs/auto_ap/views/pages/admin/plaid/table.cljs @@ -1,46 +1,24 @@ (ns auto-ap.views.pages.admin.plaid.table - (:require [auto-ap.status :as status] - [auto-ap.subs :as subs] - [auto-ap.views.components.buttons :as buttons] - [auto-ap.views.components.grid :as grid] - [auto-ap.views.components.modal :as modal] - [auto-ap.views.pages.admin.users.form :as form] - [auto-ap.views.utils :refer [->$ action-cell-width date->str with-user dispatch-event]] - [re-frame.core :as re-frame] - [auto-ap.forms :as forms] - [auto-ap.views.pages.data-page :as data-page])) - - -#_(re-frame/reg-event-fx - ::refreshed - [with-user ] - (fn [{:keys [user db]} [_ provider-account ]] - ;; this is tracked in yodlee main, for refreshing - {})) - -#_(re-frame/reg-event-fx - ::request-refresh - [with-user ] - (fn [{:keys [user db]} [_ provider-account client-id ]] - {:http {:token user - :method :post - :headers {"Content-Type" "application/edn"} - :uri (str "/api/yodlee2/provider-accounts/refresh/") - :owns-state {:multi ::refresh - :which provider-account} - :body {:client-id client-id - :provider-account-id provider-account} - :on-success [::refreshed provider-account]}})) + (:require + [auto-ap.status :as status] + [auto-ap.subs :as subs] + [auto-ap.views.components.buttons :as buttons] + [auto-ap.views.components.grid :as grid] + [auto-ap.views.components.modal :as modal] + [auto-ap.views.pages.data-page :as data-page] + [auto-ap.views.utils + :refer [->$ action-cell-width date->str dispatch-event with-user]] + [re-frame.core :as re-frame])) (re-frame/reg-event-fx ::plaid-item-deleted - (fn [{:keys [db]} [_ i result]] + (fn [_ _] {:dispatch [::modal/modal-closed ]})) (re-frame/reg-event-fx ::delete-plaid-item [with-user ] - (fn [{:keys [user db]} [_ id ]] + (fn [{:keys [user]} [_ id ]] {:graphql {:token user :owns-state {:single ::delete-plaid-item} :query-obj @@ -55,7 +33,7 @@ (re-frame/reg-event-fx ::delete-requested [with-user] - (fn [{:keys [user db]} [_ id]] + (fn [_ [_ id]] {:dispatch [::modal/modal-requested {:title "Delete Provider account " :body [:div "Are you sure you want to delete " id "?"] @@ -66,21 +44,14 @@ :close-event [::status/completed ::delete-plaid-item]} :cancel? true}]})) -(re-frame/reg-event-fx - ::params-changed - (fn [{:keys [db]} [_ p]] - {:db (assoc db ::params p)})) - (re-frame/reg-sub ::params (fn [db] (-> db ::params))) -(defn table [{:keys [status data-page]}] +(defn table [{:keys [data-page]}] (let [{:keys [data]} @(re-frame/subscribe [::data-page/page data-page]) - params @(re-frame/subscribe [::params]) - is-admin? @(re-frame/subscribe [::subs/is-admin?]) - statuses @(re-frame/subscribe [::status/multi ::refresh])] + is-admin? @(re-frame/subscribe [::subs/is-admin?])] [grid/grid {:data-page data-page :column-count 5} [grid/controls data] @@ -93,7 +64,7 @@ [grid/header-cell {} "Accounts"] [grid/header-cell {:style {:width (action-cell-width 1)}} ]]] [grid/body - (for [{:keys [id name accounts status last-updated clients] :as c} (:data data)] + (for [{:keys [id name accounts status last-updated] :as c} (:data data)] ^{:key (str name "-" id )} [grid/row {:class (:class c) :id id} [grid/cell {} id] diff --git a/src/cljs/auto_ap/views/pages/admin/rules/results_modal.cljs b/src/cljs/auto_ap/views/pages/admin/rules/results_modal.cljs index f65961d7..bfc1651e 100644 --- a/src/cljs/auto_ap/views/pages/admin/rules/results_modal.cljs +++ b/src/cljs/auto_ap/views/pages/admin/rules/results_modal.cljs @@ -1,7 +1,5 @@ (ns auto-ap.views.pages.admin.rules.results-modal - (:require [auto-ap.events :as events] - [auto-ap.subs :as subs] - [auto-ap.views.utils :refer [date->str dispatch-event with-user]] + (:require [auto-ap.views.utils :refer [date->str dispatch-event with-user]] [auto-ap.views.pages.transactions.common :refer [transaction-read]] [re-frame.core :as re-frame] [auto-ap.views.components.modal :as modal] @@ -37,11 +35,10 @@ (count checked) 0))) -(defn results-body [params] +(defn results-body [] (let [runnable? @(re-frame/subscribe [::runnable?]) checked @(re-frame/subscribe [::checked]) - all-checked @(re-frame/subscribe [::all-checked]) - checked-count @(re-frame/subscribe [::checked-count])] + all-checked @(re-frame/subscribe [::all-checked])] [:table.table.is-fullwidth.compact [:tr (when runnable? @@ -71,7 +68,6 @@ (defn foot [params] (let [runnable? @(re-frame/subscribe [::runnable?]) - checked @(re-frame/subscribe [::checked]) all-checked @(re-frame/subscribe [::all-checked]) checked-count @(re-frame/subscribe [::checked-count]) status @(re-frame/subscribe [::status/single ::apply])] @@ -115,8 +111,8 @@ (re-frame/reg-event-db ::toggle-all - (fn [db [_ which]] - (let [{::keys [all-checked checked test-results]} db] + (fn [db [_ _]] + (let [{::keys [all-checked test-results]} db] (assoc db ::all-checked (not all-checked) ::checked (if all-checked diff --git a/src/cljs/auto_ap/views/pages/admin/rules/table.cljs b/src/cljs/auto_ap/views/pages/admin/rules/table.cljs index 509522ca..a09ef48d 100644 --- a/src/cljs/auto_ap/views/pages/admin/rules/table.cljs +++ b/src/cljs/auto_ap/views/pages/admin/rules/table.cljs @@ -16,7 +16,7 @@ (re-frame/reg-event-fx ::run-clicked [with-user] - (fn [{:keys [user db]} [_ which]] + (fn [{:keys [user]} [_ which]] {:graphql {:token user :owns-state {:multi ::run @@ -36,7 +36,7 @@ (re-frame/reg-event-fx ::succeeded-run - (fn [{:keys [db]} [_ transaction-rule-id result]] + (fn [_ [_ transaction-rule-id result]] {:dispatch [::results-modal/opening (:run-transaction-rule result) transaction-rule-id true]})) (re-frame/reg-sub @@ -56,13 +56,6 @@ (fn [[specific-table-params query-params]] (merge (select-keys query-params #{:start :sort}) specific-table-params ))) -(re-frame/reg-event-fx - ::params-changed - [(re-frame/path [::table-params])] - (fn [{table-params :db} [_ params :as z]] - {:db (merge table-params params)})) - - (re-frame/reg-event-fx ::deleted-transaction-rule (fn [] @@ -71,7 +64,7 @@ (re-frame/reg-event-fx ::delete-transaction-rule [with-user] - (fn [{:keys [db user]} [_ id]] + (fn [{:keys [user]} [_ id]] {:graphql {:token user :owns-state {:single ::delete-transaction-rule} @@ -97,9 +90,9 @@ -(defn table* [{:keys [id data-page]}] +(defn table* [{:keys [data-page]}] (let [{:keys [data]} @(re-frame/subscribe [::data-page/page data-page]) - selected-client @(re-frame/subscribe [::subs/client]) + _ @(re-frame/subscribe [::subs/client]) states @(re-frame/subscribe [::status/multi ::run])] [grid/grid {:data-page data-page :column-count 6} @@ -152,7 +145,7 @@ [buttons/sl-icon {:event [::request-delete r] :icon :icon-bin-2}] [buttons/fa-icon {:event [::form/editing r] :icon :fa-pencil}]]]])]]])) -(defn table [params] +(defn table [] (r/create-class {:component-will-unmount (dispatch-event [::unmounted]) :reagent-render (fn [params] [table* params])})) diff --git a/src/cljs/auto_ap/views/pages/admin/users.cljs b/src/cljs/auto_ap/views/pages/admin/users.cljs index 4c925c47..331777a4 100644 --- a/src/cljs/auto_ap/views/pages/admin/users.cljs +++ b/src/cljs/auto_ap/views/pages/admin/users.cljs @@ -53,7 +53,7 @@ (re-frame/reg-event-fx ::unmounted - (fn [{:keys [db]} _] + (fn [_ _] {::forward/dispose {:id ::edited-user}})) diff --git a/src/cljs/auto_ap/views/pages/admin/vendors/side_bar.cljs b/src/cljs/auto_ap/views/pages/admin/vendors/side_bar.cljs index 25a2d5a9..39821a9d 100644 --- a/src/cljs/auto_ap/views/pages/admin/vendors/side_bar.cljs +++ b/src/cljs/auto_ap/views/pages/admin/vendors/side_bar.cljs @@ -1,10 +1,8 @@ (ns auto-ap.views.pages.admin.vendors.side-bar (:require - [re-frame.core :as re-frame] - [auto-ap.subs :as subs] + [auto-ap.views.pages.data-page :as data-page] [auto-ap.views.utils :refer [dispatch-value-change]] - [auto-ap.views.pages.data-page :as data-page])) - + [re-frame.core :as re-frame])) (defn vendor-side-bar [{:keys [data-page]}] [:div diff --git a/src/cljs/auto_ap/views/pages/check.cljs b/src/cljs/auto_ap/views/pages/check.cljs deleted file mode 100644 index 406c593f..00000000 --- a/src/cljs/auto_ap/views/pages/check.cljs +++ /dev/null @@ -1,165 +0,0 @@ -(ns auto-ap.views.pages.check - (:require-macros [cljs.core.async.macros :refer [go]]) - (:require [re-frame.core :as re-frame] - [reagent.core :as reagent] - [auto-ap.subs :as subs] - [auto-ap.events :as events] - [auto-ap.views.utils :refer [login-url]] - [cljs.reader :as edn] - [auto-ap.routes :as routes] - [bidi.bidi :as bidi] - [goog.string :as gstring])) - -(re-frame/reg-sub - ::checks - (fn [db] - (-> db ::checks))) - -(defn check-page [] - (let [checks @(re-frame/subscribe [::checks])] - [:div - (for [{:keys [vendor-name paid-to client check date amount memo]} checks - - - :let [amount (gstring/format "--%.2f--" amount)]] - [:div - [:div.columns - (let [{:keys [name address1 city state zip bank]} client] - (list - [:div.column.is-4 - [:p name] - [:p address1] - [:p city ", " state zip]] - [:div.column.is-7 - - [:p.has-text-centered (:name bank)] - [:p.has-text-centered (:acct bank)] - ])) - - [:div.column - check] - ] - [:div.columns - [:div.column.is-11] - [:div.column date] - ] - [:div.columns - [:div.column - "PAY" - ] - [:div.column - "TO THE ORDER OF"] - [:div.column.is-9 - vendor-name] - [:div.column - - amount]] - - [:div.columns - [:div.column] - [:div.column.is-8 {:style {"border-bottom" "1px solid black"}} "One thousand two hundred thirty four and fifty six cents"] - [:div.column.is-3]] - - [:div.columns - [:div.column ""]] - [:div.columns - [:div.column " "]] - - - [:div.columns - [:div.column - "MEMO"] - [:div.column.is-7 {:style {"border-bottom" "1px solid black"}} - memo] - [:div.column.is-4]] - - [:div.columns - [:div.column.is-2 ] - [:div.column.is-10 {:style {"font-family" "MICR" "font-size" "20pt"}} - (str "c" check "c a" (:acct-number (:bank client)) "a 10302c")]] - - - [:div.columns - [:div.column " "]] - - [:div.columns - [:div.column " "]] - - [:div.columns - [:div.column " "]] - - [:div.columns - [:div.column " "]] - - [:div.columns - [:div.column] - [:div.column.is-10 - (let [{:keys [name address1 city state zip bank]} client] - (list - [:p name] - [:p address1] - [:p city ", " state zip] - )) - - - - ] - [:div.column - check]] - - [:div.columns - [:div.column " "]] - [:div.columns - [:div.column " "]] - [:div.columns - [:div.column " "]] - [:div.columns - [:div.column " "]] - [:div.columns - [:div.column " "]] - - [:div.columns - [:div.column] - [:div.column.is-5 - vendor-name] - [:div.column - [:p.has-text-right "Paid to:"] - [:p.has-text-right "Amount:"] - [:p.has-text-right "Date:"]] - - [:div.column.is-5 - [:p paid-to] - [:p amount] - [:p date]]] - - [:div.columns - [:div.column "MEMO"] - [:div.column.is-11 - memo - ]] - - [:div.columns - [:div.column " "]] - - [:div.columns - [:div.column.is-6] - [:div.column - [:p.has-text-right "Check:"] - [:p.has-text-right "Vendor:"] - [:p.has-text-right "Bank Account:"] - [:p.has-text-right "Paid To:"] - [:p.has-text-right "Amount:"] - [:p.has-text-right "Date:"]] - - [:div.column.is-5 - [:p check] - [:p vendor-name] - [:p (:name (:bank client))] - [:p paid-to] - [:p amount] - [:p date]]] - [:div.columns - [:div.column "MEMO"] - [:div.column.is-11 - memo]] - [:footer]])])) diff --git a/src/cljs/auto_ap/views/pages/company/plaid.cljs b/src/cljs/auto_ap/views/pages/company/plaid.cljs index 346fd1e3..979eb6f0 100644 --- a/src/cljs/auto_ap/views/pages/company/plaid.cljs +++ b/src/cljs/auto_ap/views/pages/company/plaid.cljs @@ -3,16 +3,15 @@ [auto-ap.effects.forward :as forward] [auto-ap.status :as status] [auto-ap.subs :as subs] - [auto-ap.views.pages.company.side-bar :refer [company-side-bar]] - [auto-ap.views.components.grid :as grid] [auto-ap.views.components.layouts :refer [side-bar-layout]] [auto-ap.views.pages.admin.plaid.table :as table] + [auto-ap.views.pages.company.side-bar :refer [company-side-bar]] + [auto-ap.views.pages.data-page :as data-page] [auto-ap.views.utils :refer [dispatch-event with-user]] + [clojure.set :as set] [re-frame.core :as re-frame] [react-plaid-link :refer [usePlaidLink]] [reagent.core :as reagent] - [auto-ap.views.pages.data-page :as data-page] - [clojure.set :as set] [vimsical.re-frame.fx.track :as track])) (re-frame/reg-sub @@ -36,17 +35,10 @@ (fn [db] (::plaid-items db))) -(re-frame/reg-event-fx - ::params-change - (fn [_ [_ params]] - {:set-uri-params params})) - - (re-frame/reg-event-fx ::data-requested (fn [{:keys [db]} [_ params]] - (println "PRAAMS" params) {:graphql {:token (:user db) :owns-state {:single ::page} :query-obj {:venia/queries [{:query/data [:plaid-item-page {:client-id (:id @(re-frame/subscribe [::subs/client])) @@ -72,7 +64,7 @@ {:dispatch [::data-requested] ::forward/register {:id ::plaid-item-deleted :events #{::table/plaid-item-deleted} - :event-fn (fn [[_ query-result]] + :event-fn (fn [[_ _]] [::data-requested])} ::track/register {:id ::params :subscription [::data-page/params ::page] @@ -84,7 +76,7 @@ (re-frame/reg-event-fx ::unmounted - (fn [{:keys [db]} _] + (fn [_ _] {::forward/dispose {:id ::plaid-item-deleted} ::track/dispose [{:id ::params}]})) @@ -92,7 +84,7 @@ (re-frame/reg-event-fx ::get-link-token [with-user] - (fn [{:keys [db]} [_ client]] + (fn [{:keys [db]} [_ _]] {:graphql {:token (:user db) :owns-state {:single ::get-link-token} :query-obj {:venia/queries [[:plaid-link-token {:client-id (:id @(re-frame/subscribe [::subs/client]))} diff --git a/src/cljs/auto_ap/views/pages/company/yodlee2/table.cljs b/src/cljs/auto_ap/views/pages/company/yodlee2/table.cljs index 9b922be3..3e37b22e 100644 --- a/src/cljs/auto_ap/views/pages/company/yodlee2/table.cljs +++ b/src/cljs/auto_ap/views/pages/company/yodlee2/table.cljs @@ -107,7 +107,7 @@ [grid/header-cell {} "Accounts"] [grid/header-cell {:style {:width (action-cell-width 3)}} ]]] [grid/body - (for [{:keys [id name accounts status detailed-status last-updated clients] :as c} (:data page)] + (for [{:keys [id name accounts status detailed-status last-updated] :as c} (:data page)] ^{:key (str name "-" id )} [grid/row {:class (:class c) :id id} [grid/cell {} id] diff --git a/src/cljs/auto_ap/views/pages/data_page.cljs b/src/cljs/auto_ap/views/pages/data_page.cljs index 810eb75f..78c55665 100644 --- a/src/cljs/auto_ap/views/pages/data_page.cljs +++ b/src/cljs/auto_ap/views/pages/data_page.cljs @@ -1,8 +1,10 @@ (ns auto-ap.views.pages.data-page - (:require [auto-ap.status :as status] - [auto-ap.subs :as subs] - [auto-ap.utils :refer [deep-merge replace-by]] - [re-frame.core :as re-frame])) + (:require + [auto-ap.status :as status] + [auto-ap.subs :as subs] + [auto-ap.utils :refer [deep-merge replace-by]] + [auto-ap.views.utils :as u] + [re-frame.core :as re-frame])) (re-frame/reg-sub ::checked @@ -68,7 +70,7 @@ (re-frame/subscribe [::table-params id]) (re-frame/subscribe [::additional-params id])]) (fn [[client filters table-params additional-params]] - (let [query-params (auto-ap.views.utils/query-params)] + (let [query-params (u/query-params)] (cond-> {} client (assoc :client-id (:id client)) (seq query-params) (merge query-params) @@ -80,7 +82,7 @@ ::received (fn [{:keys [db]} [_ id data]] (let [uri-params (dissoc @(re-frame/subscribe [::params id]) :client-id) - current-uri-params (auto-ap.views.utils/query-params)] + current-uri-params (u/query-params)] (cond-> {:db (-> db (assoc-in [::data id] data) (assoc :query-params uri-params))} (not= uri-params current-uri-params) (assoc :set-uri-params uri-params))))) @@ -130,13 +132,13 @@ (re-frame/reg-event-fx ::table-params-changed - (fn [{:keys [db]} [_ which params :as z]] + (fn [{:keys [db]} [_ which params]] {:db (update-in db [::table-params which] merge params)})) (re-frame/reg-event-fx ::additional-params-changed - (fn [{:keys [db]} [_ which params :as z]] + (fn [{:keys [db]} [_ which params]] {:db (-> db (update-in [::additional-params which] merge params) (assoc-in [::table-params which :start] 0))})) @@ -158,7 +160,7 @@ ::filter (fn [[_ id]] [(re-frame/subscribe [::filters id])]) - (fn [[filters] [_ id which]] + (fn [[filters] [_ _ which]] (get filters which))) diff --git a/src/cljs/auto_ap/views/pages/error.cljs b/src/cljs/auto_ap/views/pages/error.cljs index 2fbb886a..bae67777 100644 --- a/src/cljs/auto_ap/views/pages/error.cljs +++ b/src/cljs/auto_ap/views/pages/error.cljs @@ -1,11 +1,4 @@ -(ns auto-ap.views.pages.error - (:require [re-frame.core :as re-frame] - [auto-ap.views.components.layouts :refer [side-bar-layout]])) - -(re-frame/reg-sub - ::error - (fn [db] - (:initial-error db))) +(ns auto-ap.views.pages.error) (defn error-page [] [:div.container diff --git a/src/cljs/auto_ap/views/pages/index.cljs b/src/cljs/auto_ap/views/pages/index.cljs deleted file mode 100644 index 8f2b4939..00000000 --- a/src/cljs/auto_ap/views/pages/index.cljs +++ /dev/null @@ -1,7 +0,0 @@ -(ns auto-ap.views.pages.index - (:require [bidi.bidi :as bidi] - [auto-ap.routes :as routes])) - -(defn index-page [] - [:div - [:h1.title "Dashboard"]]) diff --git a/src/cljs/auto_ap/views/pages/invoices/advanced_print_checks.cljs b/src/cljs/auto_ap/views/pages/invoices/advanced_print_checks.cljs index 31fa9fd6..1bbddbae 100644 --- a/src/cljs/auto_ap/views/pages/invoices/advanced_print_checks.cljs +++ b/src/cljs/auto_ap/views/pages/invoices/advanced_print_checks.cljs @@ -12,7 +12,6 @@ :refer [does-amount-exceed-outstanding? invoice-read]] [auto-ap.views.utils :refer [coerce-float dispatch-event with-user]] [malli.core :as m] - [malli.error :as me] [re-frame.core :as re-frame])) (def advanced-print-schema (m/schema @@ -23,7 +22,7 @@ :string [:map [:amount schema/money]]]]] - [:fn (fn [{:keys [invoices invoice-amounts] :as z}] + [:fn (fn [{:keys [invoices invoice-amounts]}] (if (seq (filter (fn [{:keys [id outstanding-balance]}] (does-amount-exceed-outstanding? (get-in invoice-amounts [id :amount]) outstanding-balance )) diff --git a/src/cljs/auto_ap/views/pages/invoices/form.cljs b/src/cljs/auto_ap/views/pages/invoices/form.cljs index 99cd372a..15862168 100644 --- a/src/cljs/auto_ap/views/pages/invoices/form.cljs +++ b/src/cljs/auto_ap/views/pages/invoices/form.cljs @@ -3,39 +3,32 @@ [auto-ap.events :as events] [auto-ap.forms :as forms] [auto-ap.forms.builder :as form-builder] + [auto-ap.schema :as schema] [auto-ap.status :as status] [auto-ap.subs :as subs] [auto-ap.time-utils :refer [next-dom]] [auto-ap.utils :refer [dollars=]] - [auto-ap.schema :as schema] + [auto-ap.views.components :as com] + [auto-ap.views.components.dropdown :refer [drop-down]] [auto-ap.views.components.expense-accounts-field :as eaf - :refer [recalculate-amounts - expense-accounts-field-v2]] + :refer [expense-accounts-field-v2 recalculate-amounts]] [auto-ap.views.components.layouts :as layouts] [auto-ap.views.components.level :refer [left-stack]] [auto-ap.views.components.modal :as modal] - [auto-ap.views.components.dropdown :refer [drop-down]] [auto-ap.views.components.money-field :refer [money-field]] - [auto-ap.views.components.switch-field :refer [switch-field]] [auto-ap.views.components.typeahead :refer [typeahead-v3]] [auto-ap.views.components.typeahead.vendor - :refer [search-backed-typeahead]] [auto-ap.views.pages.invoices.common :refer [invoice-read]] - [auto-ap.views.utils - :refer [date-picker - dispatch-event - with-user]] + [auto-ap.views.utils :refer [date-picker dispatch-event with-user]] [cljs-time.core :as c] [clojure.string :as str] + [malli.core :as m] [re-frame.core :as re-frame] [reagent.core :as r] - [malli.core :as m] [vimsical.re-frame.cofx.inject :as inject] - [vimsical.re-frame.fx.track :as track] - [auto-ap.views.components :as com])) - + [vimsical.re-frame.fx.track :as track])) (def schema (m/schema [:map @@ -321,7 +314,7 @@ {::track/dispose [{:id ::client} {:id ::vendor-change}]})) -(defn form-content [params] +(defn form-content [] [layouts/side-bar {:on-close (dispatch-event [::forms/form-closing ::form ])} (let [{:keys [data]} @(re-frame/subscribe [::forms/form ::form]) can-submit? (boolean @(re-frame/subscribe [::can-submit])) diff --git a/src/cljs/auto_ap/views/pages/ledger/balance_sheet.cljs b/src/cljs/auto_ap/views/pages/ledger/balance_sheet.cljs index c167d3c5..160f31d5 100644 --- a/src/cljs/auto_ap/views/pages/ledger/balance_sheet.cljs +++ b/src/cljs/auto_ap/views/pages/ledger/balance_sheet.cljs @@ -1,31 +1,27 @@ (ns auto-ap.views.pages.ledger.balance-sheet (:require [auto-ap.forms :as forms] + [auto-ap.forms.builder :as form-builder] [auto-ap.ledger.reports :as l-reports] [auto-ap.status :as status] - [clojure.string :as str] [auto-ap.subs :as subs] - [auto-ap.views.components.modal :as modal] + [auto-ap.views.components :as com] [auto-ap.views.components.layouts :refer [appearing-side-bar side-bar-layout]] - [auto-ap.views.components.switch-field :refer [switch-field]] + [auto-ap.views.components.modal :as modal] [auto-ap.views.pages.data-page :as data-page] + [auto-ap.views.pages.ledger.report-table :as rtable] [auto-ap.views.pages.ledger.side-bar :refer [ledger-side-bar]] [auto-ap.views.pages.ledger.table :as ledger-table] [auto-ap.views.utils - :refer [date-picker - dispatch-event - local-now - with-user]] + :refer [date-picker dispatch-event local-now with-user]] [cljs-time.core :as t] [clojure.set :as set] + [clojure.string :as str] [re-frame.core :as re-frame] [reagent.core :as reagent] - [vimsical.re-frame.fx.track :as track] [vimsical.re-frame.cofx.inject :as inject] - [auto-ap.views.pages.ledger.report-table :as rtable] - [auto-ap.forms.builder :as form-builder] - [auto-ap.views.components :as com])) + [vimsical.re-frame.fx.track :as track])) (defn data-params->query-params [params] (when params diff --git a/src/cljs/auto_ap/views/pages/ledger/external_import.cljs b/src/cljs/auto_ap/views/pages/ledger/external_import.cljs index 8a5d150f..9a659158 100644 --- a/src/cljs/auto_ap/views/pages/ledger/external_import.cljs +++ b/src/cljs/auto_ap/views/pages/ledger/external_import.cljs @@ -119,10 +119,9 @@ ;; COMPONENTS -(defn textarea->table [{:keys [headings value on-change read-only-headings]} & children] +(defn textarea->table [{:keys [read-only-headings]} & children] (let [text-form (r/atom "") - include-headers (r/atom true) - table-form (r/atom nil)] + include-headers (r/atom true)] (fn [{:keys [headings value on-change row-filter]}] [:div (when (> (count value) 2000) diff --git a/src/cljs/auto_ap/views/pages/ledger/external_ledger.cljs b/src/cljs/auto_ap/views/pages/ledger/external_ledger.cljs index 7551c603..64b0eb5f 100644 --- a/src/cljs/auto_ap/views/pages/ledger/external_ledger.cljs +++ b/src/cljs/auto_ap/views/pages/ledger/external_ledger.cljs @@ -34,7 +34,7 @@ (re-frame/reg-event-fx ::params-change [with-user] - (fn [{:keys [user db]} [_ params]] + (fn [{:keys [user]} [_ params]] {:graphql {:token user :owns-state {:single [::data-page/page ::page]} :query-obj {:venia/queries [[:ledger-page @@ -63,21 +63,21 @@ (re-frame/reg-event-fx ::unmounted - (fn [{:keys [db]} _] + (fn [_ _] {:dispatch-n [[::data-page/dispose ::page] [::status/dispose-single ::delete-selected]] ::track/dispose {:id ::params}})) (re-frame/reg-event-fx ::mounted - (fn [{:keys [db]} _] + (fn [_ _] {::track/register {:id ::params :subscription [::data-page/params ::page] :event-fn (fn [params] [::params-change params])}})) (re-frame/reg-event-fx ::delete-successful - (fn [cofx [_ result params]] + (fn [_ [_ result params]] {:dispatch-n [[::params-change params] [::status/info ::delete-selected (:message (:delete-external-ledger result))]]})) @@ -102,7 +102,7 @@ [::delete-successful result params])}}))) (defn ledger-content [] - (let [current-client @(re-frame/subscribe [::subs/client]) + (let [_ @(re-frame/subscribe [::subs/client]) params @(re-frame/subscribe [::data-page/params ::page]) checked @(re-frame/subscribe [::data-page/checked ::page])] [:div diff --git a/src/cljs/auto_ap/views/pages/ledger/external_ledger_table.cljs b/src/cljs/auto_ap/views/pages/ledger/external_ledger_table.cljs index 093617fd..f5127975 100644 --- a/src/cljs/auto_ap/views/pages/ledger/external_ledger_table.cljs +++ b/src/cljs/auto_ap/views/pages/ledger/external_ledger_table.cljs @@ -1,16 +1,12 @@ (ns auto-ap.views.pages.ledger.external-ledger-table - (:require [auto-ap.subs :as subs] - [auto-ap.views.components.paginator :refer [paginator]] - [auto-ap.views.components.sorter :refer [sorted-column]] - [auto-ap.views.components.sort-by-list :refer [sort-by-list]] - [auto-ap.views.utils :refer [date->str dispatch-event nf]] - [goog.string :as gstring] - [re-frame.core :as re-frame] - [auto-ap.views.components.grid :as grid] - [auto-ap.views.pages.data-page :as data-page])) + (:require + [auto-ap.subs :as subs] + [auto-ap.views.components.grid :as grid] + [auto-ap.views.pages.data-page :as data-page] + [auto-ap.views.utils :refer [date->str nf]] + [re-frame.core :as re-frame])) - -(defn external-ledger-row [{{:keys [client vendor alternate-description status date amount id source external-id line-items] :as i} :row +(defn external-ledger-row [{{:keys [client vendor alternate-description date amount id source external-id line-items] :as i} :row :keys [selected-client bank-accounts-by-id]}] [:<> [grid/row {:class (:class i) :id id :checkable? true :entity i} @@ -46,8 +42,8 @@ [grid/cell {:class "has-text-right"} (when debit (nf debit ))] [grid/cell {:class "has-text-right"} (when credit (nf credit ))]])]]) -(defn table [{:keys [id data-page status vendors on-check-changed expense-event]}] - (let [{:keys [data status params]} @(re-frame/subscribe [::data-page/page data-page]) +(defn table [{:keys [data-page]}] + (let [{:keys [data params]} @(re-frame/subscribe [::data-page/page data-page]) selected-client @(re-frame/subscribe [::subs/client]) bank-accounts-by-id @(re-frame/subscribe [::subs/bank-accounts-by-id])] [grid/grid {:data-page data-page @@ -68,7 +64,7 @@ [grid/sortable-header-cell {:sort-key "amount" :sort-name "Amount" :class "has-text-right" :style {:width "7em"}} "Debit"] [grid/sortable-header-cell {:sort-key "amount" :sort-name "Amount" :class "has-text-right" :style {:width "7em"}} "Credit"]]] [grid/body - (for [{:keys [client vendor status date amount id line-items] :as i} (:data data)] + (for [{:keys [id] :as i} (:data data)] ^{:key id} [external-ledger-row {:row i :selected-client selected-client diff --git a/src/cljs/auto_ap/views/pages/ledger/profit_and_loss.cljs b/src/cljs/auto_ap/views/pages/ledger/profit_and_loss.cljs index eecd0704..3c3f479a 100644 --- a/src/cljs/auto_ap/views/pages/ledger/profit_and_loss.cljs +++ b/src/cljs/auto_ap/views/pages/ledger/profit_and_loss.cljs @@ -254,7 +254,7 @@ NOTE: Please review the transactions we may have question for you here: https:// active (reagent/atom nil)] (fn [] (let [{:keys [data]} @(re-frame/subscribe [::forms/form ::form]) - {:keys [periods selected-preset include-deltas column-per-location]} data] + {:keys [selected-preset include-deltas column-per-location]} data] [form-builder/builder {:can-submit [::can-submit] :change-event [::change] :submit-event [::report-requested] diff --git a/src/cljs/auto_ap/views/pages/ledger/report_table.cljs b/src/cljs/auto_ap/views/pages/ledger/report_table.cljs index c5c3e629..a5513370 100644 --- a/src/cljs/auto_ap/views/pages/ledger/report_table.cljs +++ b/src/cljs/auto_ap/views/pages/ledger/report_table.cljs @@ -1,6 +1,5 @@ (ns auto-ap.views.pages.ledger.report-table (:require - [auto-ap.utils :refer [dollars-0?]] [clojure.string :as str] [auto-ap.views.utils :refer [->$ ->% dispatch-event]])) diff --git a/src/cljs/auto_ap/views/pages/ledger/side_bar.cljs b/src/cljs/auto_ap/views/pages/ledger/side_bar.cljs index d15c3174..03552973 100644 --- a/src/cljs/auto_ap/views/pages/ledger/side_bar.cljs +++ b/src/cljs/auto_ap/views/pages/ledger/side_bar.cljs @@ -6,7 +6,6 @@ :refer [bank-account-filter]] [auto-ap.views.components.date-range-filter :refer [date-range-filter]] [auto-ap.views.components.number-filter :refer [number-filter]] - [auto-ap.views.components.typeahead :refer [typeahead-v3]] [auto-ap.views.components.typeahead.vendor :refer [search-backed-typeahead]] [auto-ap.views.pages.data-page :as data-page] diff --git a/src/cljs/auto_ap/views/pages/login.cljs b/src/cljs/auto_ap/views/pages/login.cljs index dfbd0f34..abfb9547 100644 --- a/src/cljs/auto_ap/views/pages/login.cljs +++ b/src/cljs/auto_ap/views/pages/login.cljs @@ -1,13 +1,7 @@ (ns auto-ap.views.pages.login - (:require-macros [cljs.core.async.macros :refer [go]]) - (:require [re-frame.core :as re-frame] - [reagent.core :as reagent] - [auto-ap.subs :as subs] - [auto-ap.events :as events] - [auto-ap.views.utils :refer [login-url]] - [cljs.reader :as edn] - [auto-ap.routes :as routes] - [bidi.bidi :as bidi])) + (:require + [auto-ap.views.utils :refer [login-url]] + [re-frame.core :as re-frame])) (re-frame/reg-sub ::logout-reason diff --git a/src/cljs/auto_ap/views/pages/needs_activation.cljs b/src/cljs/auto_ap/views/pages/needs_activation.cljs index a6780034..ffead368 100644 --- a/src/cljs/auto_ap/views/pages/needs_activation.cljs +++ b/src/cljs/auto_ap/views/pages/needs_activation.cljs @@ -1,14 +1,7 @@ (ns auto-ap.views.pages.needs-activation - (:require-macros [cljs.core.async.macros :refer [go]]) - (:require [re-frame.core :as re-frame] - [reagent.core :as reagent] - [auto-ap.subs :as subs] - [auto-ap.events :as events] - [auto-ap.views.utils :refer [login-url dispatch-event]] - [cljs.reader :as edn] - [auto-ap.routes :as routes] - [bidi.bidi :as bidi] - [goog.string :as gstring])) + (:require + [auto-ap.views.utils :refer [login-url]] + [re-frame.core :as re-frame])) (re-frame/reg-event-fx ::relogin diff --git a/src/cljs/auto_ap/views/pages/payments/side_bar.cljs b/src/cljs/auto_ap/views/pages/payments/side_bar.cljs index 2133c2fe..2f070481 100644 --- a/src/cljs/auto_ap/views/pages/payments/side_bar.cljs +++ b/src/cljs/auto_ap/views/pages/payments/side_bar.cljs @@ -10,8 +10,8 @@ [re-frame.core :as re-frame])) (defn side-bar [{:keys [data-page]}] - (let [ap @(re-frame/subscribe [::subs/active-page]) - user @(re-frame/subscribe [::subs/user])] + (let [_ @(re-frame/subscribe [::subs/active-page]) + _ @(re-frame/subscribe [::subs/user])] [:div [:div [:p.menu-label "Vendor"] diff --git a/src/cljs/auto_ap/views/pages/pos/expected_deposits/table.cljs b/src/cljs/auto_ap/views/pages/pos/expected_deposits/table.cljs index 5c7f60b8..f6691a55 100644 --- a/src/cljs/auto_ap/views/pages/pos/expected_deposits/table.cljs +++ b/src/cljs/auto_ap/views/pages/pos/expected_deposits/table.cljs @@ -65,7 +65,7 @@ (defn table [{:keys [data-page]}] (let [selected-client @(re-frame/subscribe [::subs/client]) - {:keys [data status]} @(re-frame/subscribe [::data-page/page data-page])] + {:keys [data]} @(re-frame/subscribe [::data-page/page data-page])] [grid/grid {:data-page data-page :column-count (if selected-client 7 8)} [grid/controls data] diff --git a/src/cljs/auto_ap/views/pages/pos/sales_orders.cljs b/src/cljs/auto_ap/views/pages/pos/sales_orders.cljs index 4d34af1c..7efe3182 100644 --- a/src/cljs/auto_ap/views/pages/pos/sales_orders.cljs +++ b/src/cljs/auto_ap/views/pages/pos/sales_orders.cljs @@ -18,7 +18,7 @@ (re-frame/reg-event-fx ::params-change [with-user] - (fn [{:keys [user db ]}[_ params]] + (fn [{:keys [user]}[_ params]] {:graphql {:token user :owns-state {:single [::data-page/page ::page]} :query-obj {:venia/queries [[:sales_order_page diff --git a/src/cljs/auto_ap/views/pages/pos/table.cljs b/src/cljs/auto_ap/views/pages/pos/table.cljs index 7355baad..8536da47 100644 --- a/src/cljs/auto_ap/views/pages/pos/table.cljs +++ b/src/cljs/auto_ap/views/pages/pos/table.cljs @@ -90,7 +90,7 @@ (defn table [{:keys [data-page]}] (let [selected-client @(re-frame/subscribe [::subs/client]) - {:keys [data status]} @(re-frame/subscribe [::data-page/page data-page])] + {:keys [data]} @(re-frame/subscribe [::data-page/page data-page])] [grid/grid {:data-page data-page :column-count (if selected-client 7 8)} [grid/controls data diff --git a/src/cljs/auto_ap/views/pages/transactions/manual.cljs b/src/cljs/auto_ap/views/pages/transactions/manual.cljs index 06198a34..58c5c889 100644 --- a/src/cljs/auto_ap/views/pages/transactions/manual.cljs +++ b/src/cljs/auto_ap/views/pages/transactions/manual.cljs @@ -1,14 +1,14 @@ (ns auto-ap.views.pages.transactions.manual - (:require [auto-ap.events :as events] - [auto-ap.forms :as forms] - [auto-ap.status :as status] - [auto-ap.subs :as subs] - [auto-ap.views.components.modal :as modal] - [auto-ap.views.utils :refer [dispatch-event with-user]] - [re-frame.core :as re-frame] - [auto-ap.forms.builder :as form-builder] - [auto-ap.schema :as schema] - [malli.core :as m])) + (:require + [auto-ap.forms :as forms] + [auto-ap.forms.builder :as form-builder] + [auto-ap.schema :as schema] + [auto-ap.status :as status] + [auto-ap.subs :as subs] + [auto-ap.views.components.modal :as modal] + [auto-ap.views.utils :refer [dispatch-event with-user]] + [malli.core :as m] + [re-frame.core :as re-frame])) (re-frame/reg-sub ::can-submit diff --git a/src/cljs/auto_ap/views/pages/transactions/table.cljs b/src/cljs/auto_ap/views/pages/transactions/table.cljs index 0eb233c6..e343310d 100644 --- a/src/cljs/auto_ap/views/pages/transactions/table.cljs +++ b/src/cljs/auto_ap/views/pages/transactions/table.cljs @@ -27,12 +27,6 @@ {:dispatch [::edit/editing which (:potential-payment-matches matches) (:potential-autopay-invoices-matches matches) (:potential-unpaid-invoices-matches matches) (:potential-transaction-rule-matches matches)]})) -(re-frame/reg-event-fx - ::editing-matches-failed - (fn [_ [_ which payment-matches]] - {:dispatch - [::edit/editing which payment-matches]})) - (re-frame/reg-event-fx ::intend-to-edit [with-role] @@ -68,12 +62,6 @@ (fn [db] (::table-params db))) -(re-frame/reg-event-fx - ::params-changed - [(re-frame/path [::table-params])] - (fn [{table-params :db} [_ params :as z]] - {:db (merge table-params params)})) - (defn table [{:keys [data-page check-boxes? action-buttons]}] (let [selected-client @(re-frame/subscribe [::subs/client]) {:keys [data params]} @(re-frame/subscribe [::data-page/page data-page]) @@ -101,7 +89,6 @@ [grid/row {:class (:class i) :id id :entity i} (when-not selected-client [grid/cell {} (:name client)]) - #_[:td description-original] [grid/cell {} (:name bank-account )] diff --git a/src/cljs/auto_ap/views/pages/unpaid_invoices.cljs b/src/cljs/auto_ap/views/pages/unpaid_invoices.cljs index b11b33b9..ea5fb11e 100644 --- a/src/cljs/auto_ap/views/pages/unpaid_invoices.cljs +++ b/src/cljs/auto_ap/views/pages/unpaid_invoices.cljs @@ -29,9 +29,8 @@ [goog.string :as gstring] [re-frame.core :as re-frame] [reagent.core :as r] - [vimsical.re-frame.fx.track :as track] [vimsical.re-frame.cofx.inject :as inject] - [react-dom :as react-dom])) + [vimsical.re-frame.fx.track :as track])) (re-frame/reg-event-fx ::params-change @@ -51,7 +50,7 @@ (re-frame/reg-event-fx ::unmounted - (fn [{:keys [db]} _] + (fn [_ _] {:dispatch-n [[::data-page/dispose :invoices] [::forms/form-closing ::form/form]] ::forward/dispose [{:id ::updated} @@ -60,7 +59,7 @@ (re-frame/reg-event-fx ::mounted - (fn [{:keys [db]} _] + (fn [_ _] {::track/register [{:id ::params :subscription [::data-page/params :invoices] :event-fn (fn [params] @@ -111,7 +110,7 @@ (re-frame/reg-event-fx ::pay-invoices-from-balance [with-user (re-frame/inject-cofx ::inject/sub [::data-page/checked :invoices])] - (fn [{:keys [db user] ::data-page/keys [checked] :as cofx} _] + (fn [{:keys [db user] ::data-page/keys [checked]} _] {:graphql {:token user :owns-state {:single ::print-checks} @@ -135,7 +134,7 @@ (re-frame/reg-event-fx ::checks-printed - (fn [{:keys [db]} [_ invoices pdf-url]] + (fn [_ [_ invoices pdf-url]] {:dispatch-n (cond->> [[::data-page/reset-checked :invoices]] true (into (mapv (fn [i] @@ -150,14 +149,14 @@ (re-frame/reg-event-fx ::new-invoice-clicked - (fn [{:keys [db]} _] + (fn [_ _] {:dispatch [::form/adding {:client @(re-frame/subscribe [::subs/client]) :status :unpaid #_#_:date (date->str (c/now) standard) :location (first (:locations @(re-frame/subscribe [::subs/client])))}]})) (re-frame/reg-event-fx ::voided-selected - (fn [cofx [_]] + (fn [_ [_]] {:dispatch-n [[::modal/modal-closed] [::params-change @(re-frame/subscribe [::data-page/params ::page])] [::data-page/reset-checked :invoices]]})) @@ -242,7 +241,7 @@ :is-right? true} [:div (list - (for [{:keys [id number name type]} (->> (:bank-accounts current-client) (filter :visible) (sort-by :sort-order))] + (for [{:keys [id name type]} (->> (:bank-accounts current-client) (filter :visible) (sort-by :sort-order))] (if (= :cash type) ^{:key id} [:a.dropdown-item {:on-click (dispatch-event [::print-checks id :cash]) :disabled (status/disabled-for print-checks-status)} "With cash"] @@ -276,7 +275,7 @@ (defn unpaid-invoices-content [{:keys [status]}] (let [page @(re-frame/subscribe [::data-page/page :invoices]) - current-client @(re-frame/subscribe [::subs/client])] + _ @(re-frame/subscribe [::subs/client])] [:div [:h1.title (str (str/capitalize (name (or status :all))) " invoices")] [status/status-notification {:statuses [[::status/single ::print-checks] @@ -297,28 +296,28 @@ :main [unpaid-invoices-content params] :right-side-bar [appearing-side-bar {:visible? invoice-bar-active?} [form/form {}]]}])) -(defn unpaid-invoices-page [params] +(defn unpaid-invoices-page [] (r/create-class {:display-name "unpaid-invoices-page" :component-will-unmount #(re-frame/dispatch-sync [::unmounted]) :component-did-mount #(re-frame/dispatch [::mounted]) :reagent-render layout})) -(defn paid-invoices-page [params] +(defn paid-invoices-page [] (r/create-class {:display-name "paid-invoices-page" :component-will-unmount #(re-frame/dispatch-sync [::unmounted]) :component-did-mount #(re-frame/dispatch [::mounted]) :reagent-render layout})) -(defn voided-invoices-page [params] +(defn voided-invoices-page [] (r/create-class {:display-name "voided-invoices-page" :component-will-unmount #(re-frame/dispatch-sync [::unmounted]) :component-did-mount #(re-frame/dispatch [::mounted]) :reagent-render layout})) -(defn all-invoices-page [params] +(defn all-invoices-page [] (r/create-class {:display-name "all-invoices-page" :component-will-unmount #(re-frame/dispatch-sync [::unmounted]) diff --git a/src/cljs/auto_ap/views/utils.cljs b/src/cljs/auto_ap/views/utils.cljs index 257ffa3e..6882f8a8 100644 --- a/src/cljs/auto_ap/views/utils.cljs +++ b/src/cljs/auto_ap/views/utils.cljs @@ -5,20 +5,21 @@ [cljs-time.core :as t] [cljs-time.format :as format] [cljs.tools.reader.edn :as edn] - [clojure.spec.alpha :as s] [clojure.string :as str] [goog.crypt.base64 :as base64] [re-frame.core :as re-frame] [react-transition-group :as react-transition-group] #_{:clj-kondo/ignore [:unused-namespace]} - [reagent.core :as reagent] - [reagent.core :as r] [react :as react] - [auto-ap.entities.shared :as shared]) + [reagent.core :as r]) (:import (goog.i18n NumberFormat) (goog.i18n.NumberFormat Format))) + +(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)) @@ -98,32 +99,24 @@ (when d (format/unparse format d)))) -(defn date-time->str [d] - (when d - (format/unparse pretty-long d))) - (defn str->date [d f] (when d (format/parse f d))) -(defn with-keys [children] - (map-indexed (fn [i c] ^{:key i} c) children)) - - (def css-transition-group - (reagent/adapt-react-class react-transition-group/CSSTransition)) + (r/adapt-react-class react-transition-group/CSSTransition)) (def transition - (reagent/adapt-react-class react-transition-group/Transition)) + (r/adapt-react-class react-transition-group/Transition)) (def transition-group - (reagent/adapt-react-class react-transition-group/TransitionGroup)) + (r/adapt-react-class react-transition-group/TransitionGroup)) (def switch-transition - (reagent/adapt-react-class react-transition-group/SwitchTransition)) + (r/adapt-react-class react-transition-group/SwitchTransition)) (defn appearing [{:keys [visible? enter-class exit-class timeout]}] - (let [final-state (reagent/atom visible?)] + (let [final-state (r/atom visible?)] (fn [{:keys [visible?]} & children] [css-transition-group {:in visible? :class-names {:exit exit-class :enter enter-class} :timeout timeout :onEnter (fn [] (reset! final-state true )) :onExited (fn [] (reset! final-state false))} (if (or @final-state visible?) @@ -210,7 +203,7 @@ ;; if it's a perfect match, change it on the spot ;; especially important for calendar clicking, don't ;; want to wait for blur - (when (or (re-matches shared/date-regex (.. e -target -value)) + (when (or (re-matches date-regex (.. e -target -value)) (nil? (.. e -target -value))) (swap-external-value (some-> (.. e -target -value) coerce-date)))) diff --git a/test/clj/auto_ap/import/manual_test.clj b/test/clj/auto_ap/import/manual_test.clj index 381287e3..5b149e24 100644 --- a/test/clj/auto_ap/import/manual_test.clj +++ b/test/clj/auto_ap/import/manual_test.clj @@ -1,11 +1,7 @@ (ns auto-ap.import.manual-test - (:require [auto-ap.datomic :refer [conn uri]] - [auto-ap.import.manual :as sut] - [auto-ap.time :as time] - [clj-time.coerce :as coerce] - [clojure.test :as t] - [datomic.api :as d] - [auto-ap.datomic.migrate :as m])) + (:require + [auto-ap.import.manual :as sut] + [clojure.test :as t])) (def raw-tsv "Status Date Original Description High Level Category Category-Subcategory End Here Amount Amount Split Type Note Account Name SLO Acct Name SLO F1 Code Comp ID posted 8/23/2021 MOUNTAIN MIKES PIZZA - -24.27 -24.27 - - MVSC - BofA Corp Card Sean - 7187 MVSC - BofA Corp Card Sean - 7187 MVSC-6 MVSC diff --git a/test/clj/auto_ap/import/transactions_test.clj b/test/clj/auto_ap/import/transactions_test.clj index cca532c9..8b20db8d 100644 --- a/test/clj/auto_ap/import/transactions_test.clj +++ b/test/clj/auto_ap/import/transactions_test.clj @@ -4,6 +4,7 @@ [auto-ap.import.transactions :as sut] [clojure.test :as t] [datomic.api :as d] + [digest :as di] [clj-time.coerce :as coerce])) (defn wrap-setup @@ -18,12 +19,12 @@ (t/use-fixtures :each wrap-setup) -(defn noop-rule [transaction locations] +(defn noop-rule [transaction _] transaction) (def base-transaction #:transaction {:date #inst "2020-01-02T00:00:00-08:00" :raw-id "1" - :id (digest/sha-256 "1") + :id (di/sha-256 "1") :amount 12.0 :description-original "original-description" :status "POSTED" @@ -99,7 +100,7 @@ result)))) (t/testing "Should match an uncleared check" - (let [{:strs [bank-account-id client-id payment-id]} (->> [#:payment {:status :payment-status/pending + (let [{:strs [bank-account-id payment-id]} (->> [#:payment {:status :payment-status/pending :date #inst "2019-01-01" :bank-account "bank-account-id" :client "client-id" @@ -265,7 +266,7 @@ deref :tempids)] (t/testing "Should find a single invoice that matches exactly" - (let [{:strs [client-id invoice-id]} (->> [#:invoice {:status :invoice-status/paid + (let [{:strs [client-id]} (->> [#:invoice {:status :invoice-status/paid :vendor vendor1-id :scheduled-payment #inst "2019-01-04" :date #inst "2019-01-01" @@ -281,7 +282,7 @@ )) (t/testing "Should not match paid invoice that isn't a scheduled payment" - (let [{:strs [client-id invoice-id]} (->> [#:invoice {:status :invoice-status/paid + (let [{:strs [client-id]} (->> [#:invoice {:status :invoice-status/paid :vendor vendor1-id :date #inst "2019-01-01" :client "client-id" @@ -296,7 +297,7 @@ (t/is (= [] invoices-matches)))) (t/testing "Should not match unpaid invoice" - (let [{:strs [client-id invoice-id]} (->> [#:invoice {:status :invoice-status/unpaid + (let [{:strs [client-id]} (->> [#:invoice {:status :invoice-status/unpaid :scheduled-payment #inst "2019-01-04" :vendor vendor1-id :date #inst "2019-01-01" @@ -312,7 +313,7 @@ (t/is (= [] invoices-matches)))) (t/testing "Should not match invoice that already has a payment" - (let [{:strs [client-id invoice-id]} (->> [#:invoice {:status :invoice-status/paid + (let [{:strs [client-id]} (->> [#:invoice {:status :invoice-status/paid :scheduled-payment #inst "2019-01-04" :vendor vendor1-id :date #inst "2019-01-01" @@ -330,7 +331,7 @@ client-id)] (t/is (= [] invoices-matches)))) (t/testing "Should match multiple invoices for same vendor that total to transaction amount" - (let [{:strs [client-id invoice1-id invoice2-id]} (->> [#:invoice {:status :invoice-status/paid + (let [{:strs [client-id]} (->> [#:invoice {:status :invoice-status/paid :vendor vendor1-id :scheduled-payment #inst "2019-01-04" :date #inst "2019-01-01" @@ -352,7 +353,7 @@ (t/is (= 2 (count invoices-matches)) (str "Expected " (vec invoices-matches) " to have a singular match of two invoices.")))) (t/testing "Should not match if there are multiple candidate matches" - (let [{:strs [client-id invoice1-id invoice2-id]} (->> [#:invoice {:status :invoice-status/paid + (let [{:strs [client-id]} (->> [#:invoice {:status :invoice-status/paid :vendor vendor1-id :scheduled-payment #inst "2019-01-04" :date #inst "2019-01-01" @@ -375,7 +376,7 @@ (str "Expected " (vec invoices-matches) " to not match due to multiple possibilities.")))) (t/testing "Should not match if invoices are for different vendors" - (let [{:strs [client-id invoice1-id invoice2-id]} (->> [#:invoice {:status :invoice-status/paid + (let [{:strs [client-id]} (->> [#:invoice {:status :invoice-status/paid :vendor vendor1-id :scheduled-payment #inst "2019-01-04" :date #inst "2019-01-01" @@ -398,7 +399,7 @@ (str "Expected " (vec invoices-matches) " to only consider invoices for the same vendor.")))) (t/testing "Should only consider invoices chronologically" - (let [{:strs [client-id invoice1-id invoice2-id]} (->> [#:invoice {:status :invoice-status/paid + (let [{:strs [client-id]} (->> [#:invoice {:status :invoice-status/paid :vendor vendor1-id :scheduled-payment #inst "2019-01-04" :date #inst "2019-01-01" diff --git a/test/clj/auto_ap/integration/graphql.clj b/test/clj/auto_ap/integration/graphql.clj index 5a330f20..14365476 100644 --- a/test/clj/auto_ap/integration/graphql.clj +++ b/test/clj/auto_ap/integration/graphql.clj @@ -5,9 +5,7 @@ [clojure.test :as t :refer [deftest is testing use-fixtures]] [clj-time.core :as time] [datomic.api :as d] - [auto-ap.datomic :refer [uri conn]] - [buddy.sign.jwt :as jwt] - [config.core :refer [env]])) + [auto-ap.datomic :refer [uri conn]])) (defn wrap-setup [f] (with-redefs [auto-ap.datomic/uri "datomic:mem://datomic-transactor:4334/invoice"] diff --git a/test/clj/auto_ap/integration/graphql/clients.clj b/test/clj/auto_ap/integration/graphql/clients.clj index bdf5906c..64367210 100644 --- a/test/clj/auto_ap/integration/graphql/clients.clj +++ b/test/clj/auto_ap/integration/graphql/clients.clj @@ -1,12 +1,11 @@ (ns auto-ap.integration.graphql.clients - (:require [auto-ap.graphql.clients :as sut] - [auto-ap.datomic :refer [uri conn]] - [auto-ap.datomic.migrate :as m] - [auto-ap.ledger :as ledger] - - [clojure.test :as t :refer [deftest is testing use-fixtures]] - [datomic.api :as d] - [clj-time.core :as time])) + (:require + [auto-ap.datomic :refer [conn uri]] + [auto-ap.datomic.migrate :as m] + [auto-ap.graphql.clients :as sut] + [clj-time.core :as time] + [clojure.test :as t :refer [deftest is testing use-fixtures]] + [datomic.api :as d])) (defn wrap-setup [f] diff --git a/test/clj/auto_ap/integration/graphql/vendors.clj b/test/clj/auto_ap/integration/graphql/vendors.clj index 5dfb48db..e53d1c8a 100644 --- a/test/clj/auto_ap/integration/graphql/vendors.clj +++ b/test/clj/auto_ap/integration/graphql/vendors.clj @@ -44,7 +44,7 @@ (deftest vendors (testing "vendors" - (let [{:strs [vendor client]} (:tempids @(d/transact (d/connect uri) [{:vendor/name "Test" :db/id "vendor"} + (let [{:strs [vendor]} (:tempids @(d/transact (d/connect uri) [{:vendor/name "Test" :db/id "vendor"} {:db/id "client" :client/code "DEF"}]))] (testing "it should find vendors" diff --git a/test/clj/auto_ap/integration/rule_matching.clj b/test/clj/auto_ap/integration/rule_matching.clj index f4c07a0b..0205b778 100644 --- a/test/clj/auto_ap/integration/rule_matching.clj +++ b/test/clj/auto_ap/integration/rule_matching.clj @@ -1,11 +1,10 @@ (ns auto-ap.integration.rule-matching - (:require [auto-ap.rule-matching :as sut] - [datomic.api :as d] - [auto-ap.datomic :refer [uri]] - [auto-ap.datomic.migrate :as m] - [clojure.test :as t] - [clojure.tools.logging :as log] - [clojure.set :as set])) + (:require + [auto-ap.datomic :refer [uri]] + [auto-ap.datomic.migrate :as m] + [auto-ap.rule-matching :as sut] + [clojure.test :as t] + [datomic.api :as d])) (defn wrap-setup [f] @@ -19,6 +18,7 @@ (t/use-fixtures :each wrap-setup) +#_{:clj-kondo/ignore [:unused-binding]} (defn noop-rule [transaction locations] transaction) diff --git a/test/clj/auto_ap/ledger_test.clj b/test/clj/auto_ap/ledger_test.clj index 762bd8ca..601dd469 100644 --- a/test/clj/auto_ap/ledger_test.clj +++ b/test/clj/auto_ap/ledger_test.clj @@ -1,9 +1,9 @@ (ns auto-ap.ledger-test - (:require [auto-ap.datomic :refer [conn uri]] - [auto-ap.datomic.migrate :as m] - [auto-ap.ledger :as sut] - [clojure.test :as t] - [datomic.api :as d])) + (:require + [auto-ap.datomic :refer [uri]] + [auto-ap.datomic.migrate :as m] + [clojure.test :as t] + [datomic.api :as d])) (defn wrap-setup [f]