Supports editing expense accounts
This commit is contained in:
16
src/cljc/auto_ap/entities/account.cljc
Normal file
16
src/cljc/auto_ap/entities/account.cljc
Normal file
@@ -0,0 +1,16 @@
|
||||
(ns auto-ap.entities.account
|
||||
(:require [clojure.spec.alpha :as s]
|
||||
[clojure.string :as str]
|
||||
[auto-ap.entities.shared :as shared]))
|
||||
|
||||
(def numeric-regex #"^[0-9]+$")
|
||||
|
||||
(s/def ::account-set string?)
|
||||
(s/def ::numeric-code (s/or :numericstring? (s/and string?
|
||||
#(re-matches numeric-regex %))
|
||||
:numeric? int?))
|
||||
(s/def ::name string?)
|
||||
(s/def ::type #{:dividend :expense :asset :liability :equities :revenue})
|
||||
|
||||
(s/def ::account (s/keys :req-un [::account-set ::numeric-code ::name ::type]))
|
||||
|
||||
@@ -19,12 +19,18 @@
|
||||
existing))
|
||||
|
||||
(defn replace-by [xs f x]
|
||||
(mapv
|
||||
(fn [t]
|
||||
(if (= (f t) (f x))
|
||||
x
|
||||
t))
|
||||
xs))
|
||||
(let [found? (atom false)
|
||||
replaced (mapv
|
||||
(fn [t]
|
||||
(if (= (f t) (f x))
|
||||
(do (reset! found? true)
|
||||
(println "found" (f t) t (f x) x)
|
||||
x)
|
||||
t))
|
||||
xs)]
|
||||
(if @found?
|
||||
replaced
|
||||
(conj replaced x))))
|
||||
|
||||
(defn dollars-0? [amt]
|
||||
(< -0.001 amt 0.001))
|
||||
|
||||
Reference in New Issue
Block a user