Fixing minor bugs.
This commit is contained in:
@@ -10,7 +10,8 @@
|
||||
[clojure.string :as str]
|
||||
[auto-ap.datomic.transactions :as d-transactions]
|
||||
[auto-ap.rule-matching :as rm]
|
||||
[clj-time.coerce :as coerce])
|
||||
[clj-time.coerce :as coerce]
|
||||
[clojure.tools.logging :as log])
|
||||
(:import [java.time.temporal ChronoField]))
|
||||
|
||||
|
||||
@@ -126,7 +127,7 @@
|
||||
(merge-query {:query {:in ['?description-regex]
|
||||
:where ['[?e :transaction/description-original ?do]
|
||||
'[(re-find ?description-regex ?do)]]}
|
||||
:args [(re-pattern description)]})
|
||||
:args [(rm/->pattern description)]})
|
||||
|
||||
yodlee-merchant
|
||||
(merge-query {:query {:in ['?yodlee-merchant-id]
|
||||
@@ -187,6 +188,7 @@
|
||||
|
||||
(defn test-transaction-rule [{:keys [id]} {{:keys [description note client_id bank_account_id amount_lte amount_gte dom_lte dom_gte yodlee_merchant_id]} :transaction_rule :as z} value]
|
||||
(assert-admin id)
|
||||
(log/info "HI")
|
||||
(-test-transaction-rule id #:transaction-rule {:description description
|
||||
:client (when client_id {:db/id client_id})
|
||||
:bank-account (when bank_account_id {:db/id bank_account_id})
|
||||
|
||||
@@ -10,7 +10,8 @@
|
||||
[auto-ap.datomic.transactions :as d-transactions]
|
||||
[auto-ap.datomic.clients :as d-clients]
|
||||
[auto-ap.time :as time]
|
||||
[auto-ap.datomic.transaction-rules :as tr]))
|
||||
[auto-ap.datomic.transaction-rules :as tr]
|
||||
[clojure.tools.logging :as log]))
|
||||
|
||||
(defn rule-applies? [transaction {:keys [:transaction-rule/description
|
||||
:transaction-rule/dom-gte :transaction-rule/dom-lte
|
||||
@@ -82,16 +83,19 @@
|
||||
(recur rules)))
|
||||
[])))
|
||||
|
||||
(defn ->pattern [x]
|
||||
(. java.util.regex.Pattern (compile x java.util.regex.Pattern/CASE_INSENSITIVE)))
|
||||
|
||||
(defn group-rules-by-priority [rules]
|
||||
(->> rules
|
||||
(map (fn [r] (update r :transaction-rule/description #(some-> % re-pattern))))
|
||||
(map (fn [r] (update r :transaction-rule/description #(some-> % ->pattern))))
|
||||
(group-by rule-priority)
|
||||
(sort-by first)
|
||||
(map second)))
|
||||
|
||||
(defn get-matching-rules [transaction all-rules]
|
||||
(->> all-rules
|
||||
(map (fn [r] (update r :transaction-rule/description #(some-> % re-pattern))))
|
||||
(map (fn [r] (update r :transaction-rule/description #(some-> % ->pattern))))
|
||||
(filter #(rule-applies? transaction %))))
|
||||
|
||||
(defn apply-rule [transaction rule valid-locations]
|
||||
|
||||
Reference in New Issue
Block a user