fixed warnings.
This commit is contained in:
@@ -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)))))
|
||||
|
||||
Reference in New Issue
Block a user