Allows undoing autopayments

This commit is contained in:
2025-02-03 13:34:19 -08:00
parent 329a1dc0d4
commit f1036e257c
4 changed files with 58 additions and 10 deletions

View File

@@ -73,6 +73,12 @@
(throw (ex-info message
{:validation-error message}))))
(defn assert-failure-ssr
([message]
(throw (ex-info message
{:validation-error message
:type :warning}))))
(defn assert-power-user [id]
(when-not (#{"power-user" "admin"} (:user/role id))
(alog/warn ::unauthorized :user id :role "power-user")
@@ -126,6 +132,12 @@
(>= (compare locked-until (coerce/to-date date)) 0))
(assert-failure (str "Integreat has locked finances prior to " (-> locked-until coerce/to-date-time (atime/unparse-local atime/normal-date)) ".")))))
(defn assert-not-locked-ssr [client-id date]
(let [locked-until (get-locked-until client-id)]
(when (and locked-until
(>= (compare locked-until (coerce/to-date date)) 0))
(assert-failure-ssr (str "Integreat has locked finances prior to " (-> locked-until coerce/to-date-time (atime/unparse-local atime/normal-date)) ".")))))
#_{:clj-kondo/ignore [:clojure-lsp/unused-public-var]}
(defn assert-none-locked [client-id dates]
(doseq [d dates]