Makes logging unified
This commit is contained in:
@@ -12,7 +12,7 @@
|
||||
[clj-time.coerce :as coerce]
|
||||
[clj-time.core :as t]
|
||||
[clojure.core.cache :as cache]
|
||||
[clojure.tools.logging :as log]
|
||||
[auto-ap.logging :as alog]
|
||||
[datomic.api :as dc]
|
||||
[digest :as di]))
|
||||
|
||||
@@ -30,11 +30,11 @@
|
||||
|
||||
|
||||
(defn transaction->existing-payment [_ check-number client-id bank-account-id amount id]
|
||||
(log/info "Searching for a matching check for "
|
||||
{:client-id client-id
|
||||
(alog/info ::searching
|
||||
:client-id client-id
|
||||
:check-number check-number
|
||||
:bank-account-id bank-account-id
|
||||
:amount amount})
|
||||
:amount amount)
|
||||
(cond (not (and client-id bank-account-id))
|
||||
nil
|
||||
|
||||
@@ -57,7 +57,6 @@
|
||||
(rough-match client-id bank-account-id amount)))
|
||||
|
||||
(defn match-transaction-to-unfulfilled-autopayments [amount client-id]
|
||||
(log/info "trying to find uncleared autopay invoices")
|
||||
(let [candidate-invoices-vendor-groups (->> (dc/q {:find ['?vendor-id '?e '?total '?sd]
|
||||
:in ['$ '?client-id]
|
||||
:where ['[?e :invoice/client ?client-id]
|
||||
@@ -77,12 +76,15 @@
|
||||
(+ acc amount)) 0.0 consideration)
|
||||
(- amount))]
|
||||
consideration)]
|
||||
(log/info "Found " (count considerations) "considerations for transaction of" amount)
|
||||
considerations
|
||||
))
|
||||
(alog/info ::unfulfilled-autoapayment-considerations
|
||||
:count (count considerations)
|
||||
:amount amount)
|
||||
considerations))
|
||||
|
||||
(defn match-transaction-to-unpaid-invoices [amount client-id]
|
||||
(log/info "trying to find unpaid invoices for " client-id amount)
|
||||
(alog/info ::searching-unpaid-invoice
|
||||
:client-id client-id
|
||||
:amount amount)
|
||||
(let [candidate-invoices-vendor-groups (->> (dc/q {:find ['?vendor-id '?e '?outstanding-balance '?d]
|
||||
:in ['$ '?client-id]
|
||||
:where ['[?e :invoice/client ?client-id]
|
||||
@@ -102,7 +104,10 @@
|
||||
(+ acc amount)) 0.0 consideration)
|
||||
(- amount))]
|
||||
consideration)]
|
||||
(log/info "Found " (count considerations) "unpaid invoice considerations for transaction of" amount)
|
||||
(alog/info ::unpaid-invoice-considerations-found
|
||||
:client-id client-id
|
||||
:amount amount
|
||||
:count (count considerations))
|
||||
considerations))
|
||||
|
||||
(defn match-transaction-to-single-unfulfilled-autopayments [amount client-id]
|
||||
@@ -112,7 +117,9 @@
|
||||
[])))
|
||||
|
||||
(defn add-new-payment [transaction [[vendor] :as invoice-payments] bank-account-id client-id]
|
||||
(log/info "Adding a new payment for transaction " (:transaction/id transaction) " and invoices " invoice-payments)
|
||||
(alog/info ::adding-payment
|
||||
:transaction-id (:transaction/id transaction)
|
||||
:invoices (count invoice-payments))
|
||||
(let [payment-id (random-tempid)]
|
||||
(-> [[:upsert-transaction
|
||||
(assoc transaction
|
||||
@@ -279,7 +286,6 @@
|
||||
|
||||
|
||||
(defn get-existing [bank-account]
|
||||
(log/info "looking up bank account data for" bank-account)
|
||||
(into {}
|
||||
(dc/q '[:find ?tid ?as2
|
||||
:in $ ?ba
|
||||
@@ -314,7 +320,8 @@
|
||||
:import-batch/status :import-status/started
|
||||
:import-batch/user-name user}])) "import-batch")
|
||||
rule-applying-function (rm/rule-applying-fn (tr/get-all))]
|
||||
(log/info "Importing transactions from " source)
|
||||
(alog/info ::starting-transaction-import
|
||||
:source source)
|
||||
|
||||
(reify ImportBatch
|
||||
(import-transaction! [_ transaction]
|
||||
@@ -344,15 +351,17 @@
|
||||
@stats)
|
||||
|
||||
(fail! [_ error]
|
||||
(log/errorf "Couldn't complete import %d with error." import-id)
|
||||
(log/error error)
|
||||
(alog/error ::cant-complete-import
|
||||
:import-id import-id
|
||||
:error error)
|
||||
|
||||
@(dc/transact-async conn [(merge {:db/id import-id
|
||||
:import-batch/status :import-status/completed
|
||||
:import-batch/error-message (str error)}
|
||||
@stats)]))
|
||||
|
||||
(finish! [_]
|
||||
(log/infof "Finishing import batch %d for %s with stats %s " import-id (name source) (pr-str @stats))
|
||||
(alog/info ::finished :import-id import-id :source source :stats (pr-str @stats))
|
||||
@(dc/transact conn [(merge {:db/id import-id
|
||||
|
||||
:import-batch/status :import-status/completed}
|
||||
|
||||
Reference in New Issue
Block a user