(ns auto-ap.entities.account
  (:require [clojure.spec.alpha :as s]
            [clojure.string :as str]
            [auto-ap.entities.shared :as shared]))

(s/def ::account-set string?)
(s/def ::numeric-code (s/or :numeric-string? (s/and string?
                                                    #(re-matches shared/numeric-regex %))
                            :numeric? int?))
(s/def ::name string?)
(s/def ::location  (s/nilable (s/and string?
                                     #(re-matches shared/only-upper-case %))))
(s/def ::type #{:dividend :expense :asset :liability :equity :revenue})

(s/def ::account (s/keys :req-un [::account-set ::numeric-code ::name ::type ::location]))

