First cut at bulk coding

This commit is contained in:
2022-03-07 09:33:46 -08:00
parent 0f61cfa6cc
commit 52f8c08569
4 changed files with 202 additions and 141 deletions

View File

@@ -1,17 +1,4 @@
(ns auto-ap.rule-matching
(:require [auto-ap.yodlee.core :as client]
[auto-ap.utils :refer [by]]
[datomic.api :as d]
[auto-ap.datomic :refer [uri remove-nils]]
[auto-ap.datomic.accounts :as a]
[clj-time.coerce :as coerce]
[digest :refer [sha-256]]
[auto-ap.datomic.checks :as d-checks]
[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]
[clojure.tools.logging :as log]))
(ns auto-ap.rule-matching)
(defn ->pattern [x]
(. java.util.regex.Pattern (compile x java.util.regex.Pattern/CASE_INSENSITIVE)))
@@ -101,7 +88,7 @@
(filter #(rule-applies? transaction %))))
(defn spread-cents [cents n]
(let [default-spread (for [x (range n)]
(let [default-spread (for [_ (range n)]
(int (* cents (/ 1.0 n))))
short-by (- cents (reduce + 0 default-spread)) ;; amount that was lost in the differenc
adjusted-spread (map
@@ -157,5 +144,4 @@
(let [matching-rules (get-matching-rules-by-priority rules-by-priority transaction )]
(if-let [top-match (and (= (count matching-rules) 1) (first matching-rules))]
(apply-rule transaction top-match valid-locations)
transaction))))))