vendors can be updated through datomic.

This commit is contained in:
Bryce Covert
2018-11-09 13:30:27 -08:00
parent de8563a60b
commit 8ea4ea0c73
12 changed files with 141 additions and 276 deletions

View File

@@ -0,0 +1,14 @@
(ns auto-ap.entities.contact
(:require [clojure.spec.alpha :as s]
[clojure.string :as str]
[auto-ap.entities.address :as address]))
(def email-regex #"^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,63}$")
(s/def ::id (s/nilable string?))
(s/def ::name (s/nilable string?))
(s/def ::email (s/nilable (s/and string? (s/or :is-email #(re-matches email-regex %)
:is-empty #(= % "")))))
(s/def ::phone (s/nilable string?))
(s/def ::contact (s/keys :opt-un [::name ::email ::phone ::id]))

View File

@@ -1,28 +1,20 @@
(ns auto-ap.entities.vendors
(:require [clojure.spec.alpha :as s]
[clojure.string :as str]
[auto-ap.entities.contact :as contact]
[auto-ap.entities.address :as address]))
(def email-regex #"^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,63}$")
(s/def ::id int)
(s/def ::id string?)
(s/def ::identifier (s/nilable string?)) (s/def ::required-identifier (s/and string?
#(not (str/blank? %))))
(s/def ::name ::required-identifier)
(s/def ::print-as (s/nilable string?))
(s/def ::email (s/nilable (s/and string? (s/or :is-email #(re-matches email-regex %)
:is-empty #(= % "")))))
(s/def ::phone (s/nilable string?))
(s/def ::invoice-reminder-schedule (s/nilable #{"Weekly" "Never" nil}))
(s/def ::primary-contact (s/nilable ::identifier))
(s/def ::primary-email (s/nilable ::email))
(s/def ::primary-phone (s/nilable ::phone))
(s/def ::secondary-contact (s/nilable ::identifier))
(s/def ::secondary-email (s/nilable ::email))
(s/def ::secondary-phone (s/nilable ::phone))
(s/def ::primary-contact (s/nilable ::contact/contact))
(s/def ::secondary-contact (s/nilable ::contact/contact))
(s/def ::address (s/nilable ::address/address))
(s/def ::default-expense-account int?)
@@ -35,14 +27,8 @@
::print-as
::invoice-reminder-schedule
::primary-contact
::primary-email
::primary-phone
::secondary-contact
::secondary-email
::secondary-phone
::address
]))
::address]))
(def vendor-spec (apply hash-map (drop 1 (s/form ::vendor))))