fixed warnings.

This commit is contained in:
2022-07-26 05:56:41 -07:00
parent f6f73a6110
commit 96c80853ef
133 changed files with 670 additions and 1640 deletions

View File

@@ -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)

View File

@@ -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]

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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))

View File

@@ -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))

View File

@@ -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))

View File

@@ -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

View File

@@ -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

View File

@@ -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"]

View File

@@ -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
))

View File

@@ -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)})]))

View File

@@ -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

View File

@@ -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))

View File

@@ -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

View File

@@ -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

View File

@@ -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)))

View File

@@ -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]}])]

View File

@@ -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

View File

@@ -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 ['$]

View File

@@ -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

View File

@@ -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 _]

View File

@@ -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))

View File

@@ -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)]

View File

@@ -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)))

View File

@@ -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]]

View File

@@ -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

View File

@@ -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)]])

View File

@@ -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)} )))

View File

@@ -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]))

View File

@@ -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)))

View File

@@ -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")

View File

@@ -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]

View File

@@ -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))))))

View File

@@ -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))))

View File

@@ -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))))))

View File

@@ -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"))

View File

@@ -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)))))

View File

@@ -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?

View File

@@ -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

View File

@@ -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))

View File

@@ -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]

View File

@@ -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))))

View File

@@ -39,7 +39,7 @@
extract)]))
(defn parse-file
[file filename]
[file _]
(let [wb (d/load-workbook file)
text (->> wb
(d/sheet-seq)

View File

@@ -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))

View File

@@ -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"}

View File

@@ -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

View File

@@ -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)))

View File

@@ -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))

View File

@@ -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)

View File

@@ -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])

View File

@@ -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 ))

View File

@@ -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)))

View File

@@ -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)

View File

@@ -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/<!! (async/into [] output-chan)))))
(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/<!! (async/into [] output-chan))))
#_{:clj-kondo/ignore [:clojure-lsp/unused-public-var]}
(defn historical-load-sales [client-code days]
(let [client (d/pull (d/db auto-ap.datomic/conn)
square/square-read
@@ -508,6 +519,7 @@
(square/upsert-settlements client square-location)))))
#_{:clj-kondo/ignore [:clojure-lsp/unused-public-var]}
(defn load-sales-for-day [date]
(doseq [client (d/q [:find [(list 'pull '?e square/square-read ) '...]
:where ['?e :client/square-locations ]]
@@ -537,7 +549,7 @@
]))
(into {}))]
(->>
(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))