fixed warnings.

This commit is contained in:
2022-07-26 05:56:41 -07:00
parent f6f73a6110
commit 96c80853ef
133 changed files with 670 additions and 1640 deletions

View File

@@ -1,5 +1,4 @@
(ns auto-ap.client-routes
(:require [bidi.bidi :as bidi]))
(ns auto-ap.client-routes)
(def routes ["/" {"" :index
"login/" :login

View File

@@ -1,16 +0,0 @@
(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]))

View File

@@ -1,19 +0,0 @@
(ns auto-ap.entities.address
(:require [clojure.spec.alpha :as s]
[clojure.string :as str]))
(s/def ::street1 (s/nilable string?))
(s/def ::street2 (s/nilable string?))
(s/def ::city (s/nilable string?))
(s/def ::state (s/nilable (s/or
:empty (s/and string? #{""})
:filled (s/and string?
#(re-matches #"[a-zA-Z]{2}" %)))))
(s/def ::zip (s/nilable string?))
(s/def ::address (s/keys :opt-un [::email
::street1
::street2
::city
::state
::zip]))

View File

@@ -1,58 +0,0 @@
(ns auto-ap.entities.clients
(:require [clojure.spec.alpha :as s]
[auto-ap.entities.shared :as shared]
[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 int)
(s/def ::name ::shared/required-identifier)
(s/def ::code (s/and ::shared/required-identifier
#(re-matches #"[A-Z0-9\-]+" %)))
(s/def ::address (s/nilable ::address/address))
(s/def ::bank-name ::shared/required-identifier)
(s/def ::bank-code (s/nilable string?))
(s/def ::routing (s/nilable string?))
(s/def ::number ::shared/required-identifier)
(s/def ::type keyword?)
(s/def ::number string?)
(s/def ::yodlee-account-id string?)
(s/def ::checking-bank-account (s/and (s/keys :req-un [::code ::name ::bank-name ::number ::type]
:opt-un [::bank-code ::routing])
#(= (:type %) :check)))
(s/def ::credit-account (s/and (s/keys :req-un [::code ::name ::bank-name ::number ::type]
:opt-un [])
#(= (:type %) :credit)))
(s/def ::cash-account (s/and (s/keys :req-un [::type ::code ::name])
#(= (:type %) :cash)))
(s/def ::bank-account (s/or :cash ::cash-account
:checking ::checking-bank-account
:credit ::credit-account))
(s/def ::bank-accounts (s/coll-of ::bank-account))
;; disabled because graphql defaults to string representation
#_(s/def ::weekly-debits (s/nilable double?))
#_(s/def ::weekly-credits (s/nilable double?))
(s/def ::location string?)
(s/def ::locations (s/coll-of ::location :min-count 1))
(s/def ::email (s/nilable (s/and string? (s/or :is-email #(re-matches email-regex %)
:is-empty #(= % "")))))
(s/def ::client (s/keys :req-un [::name ::code ::locations]
:opt-un [::email
::address
#_::weekly-debits
#_::weekely-credits
::bank-accounts
::id]))
(def client-spec (apply hash-map (drop 1 (s/form ::client))))
(def all-keys (map #(keyword (name %)) (concat (:req-un client-spec) (:opt-un client-spec))))

View File

@@ -1,14 +0,0 @@
(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,5 +0,0 @@
(ns auto-ap.entities.invoice
(:require [clojure.spec.alpha :as s]
[auto-ap.entities.shared :as shared]))

View File

@@ -1,11 +0,0 @@
(ns auto-ap.entities.invoices-expense-accounts
(:require [clojure.spec.alpha :as s]
[clojure.string :as str]
[auto-ap.entities.shared :as shared]))
(s/def ::vendor-id string?)
(s/def ::account-id string?)
(s/def ::amount ::shared/money)
(s/def ::location string?)
(s/def ::invoices-expense-account (s/keys :opt-un [::vendor-id ::account-id ::amount ::location]))

View File

@@ -1,31 +1,2 @@
(ns auto-ap.entities.shared
(:require [clojure.spec.alpha :as s]
[clojure.string :as str]
))
(ns auto-ap.entities.shared)
(def date-regex #"[2]{1}[0-9]{3}-[0-9]{1,2}-[0-9]{1,2}")
(def money-regex #"\-?[0-9]+(\.[0-9]{2})?$")
(def numeric-regex #"^[0-9]+$")
(def only-upper-case #"^[A-Z]+$")
(s/def ::identifier (s/nilable string?))
(s/def ::date
#?(:cljs
(s/or :dt? #(instance? goog.date.DateTime %)
:d? #(instance? goog.date.Date %)
:str? (s/and string? #(re-matches date-regex %)))
:clj (s/or :dt? #(instance? org.joda.time.DateTime %)
:ldt? #(instance? org.joda.time.LocalDateTime %)
:ldt? #(instance? org.joda.time.LocalDate %)
:str? (s/and string? #(re-matches date-regex %)))))
(s/def ::required some?)
(s/def ::has-id (s/and map?
#(:id %)))
(s/def ::required-identifier (s/and string?
#(not (str/blank? %))))
(s/def ::money (s/or :string (s/and string?
#(re-matches money-regex %))
:float float?
:int int?))

View File

@@ -1,43 +0,0 @@
(ns auto-ap.entities.transaction-rule
(:require [auto-ap.entities.transaction-rule-account :as transaction-rule-account]
[clojure.spec.alpha :as s]
[clojure.string :as str]))
(s/def ::client (s/nilable map?))
(s/def ::description (s/nilable (s/and string?
#( #?@(:clj (try
(re-pattern %)
true
(catch Exception _
false))
:cljs (try
(re-pattern %)
true
(catch js/Error _
false)))))))
(s/def ::amount-gte (s/or :double (s/nilable double?)
:string (s/nilable string?)))
(s/def ::amount-lte (s/or :double (s/nilable double?)
:string (s/nilable string?)))
(s/def ::dom-gte (s/nilable int?))
(s/def ::dom-lte (s/nilable int?))
(s/def ::note (s/nilable string?))
(s/def ::bank-account (s/nilable map?))
(s/def ::vendor (s/nilable map?))
(s/def ::yodlee-merchant (s/nilable map?))
(s/def ::accounts (s/coll-of ::transaction-rule-account/transaction-rule-account :min-count 1))
(s/def ::transaction-rule (s/and (s/keys :req-un [::client
::description
::amount-gte
::amount-lte
::dom-gte
::dom-lte
::note
::bank-account
::vendor
::accounts]
:opt-un [::yodlee-merchant])
(s/or :description-required #(not (str/blank? (:description %)))
:merchant-required #(not (nil? (:yodlee-merchant %))))))

View File

@@ -1,13 +0,0 @@
(ns auto-ap.entities.transaction-rule-account
(:require [clojure.spec.alpha :as s]
[clojure.string :as str]))
(s/def ::account map?)
(s/def ::location (s/and string?
not-empty))
(s/def ::transaction-rule-account (s/keys :req-un [::account
::location]
:opt-un []))

View File

@@ -1,43 +0,0 @@
(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]))
(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 ::hidden boolean?)
(s/def ::print-as (s/nilable string?))
(s/def ::terms (s/nilable int?))
(s/def ::dom (s/nilable int?))
(s/def ::invoice-reminder-schedule (s/nilable #{"Weekly" "Never" nil}))
(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-account-id (s/nilable string?))
(s/def ::code (s/nilable string?))
(s/def ::vendor (s/and
(s/keys :req-un [::name]
:opt-un [::code
::default-account-id
::terms
::hidden
::id
::print-as
::primary-contact
::secondary-contact
::address])
(s/or :hidden #(= (:hidden %) true)
:has-expense-account #(not (nil? (:id (:default-account %)))))))
(def vendor-spec (apply hash-map (drop 1 (s/form ::vendor))))
(def all-keys (map #(keyword (name %)) (concat (:req-un vendor-spec) (:opt-un vendor-spec))))