create manual ledger experience
This commit is contained in:
@@ -1,20 +1,21 @@
|
||||
(ns auto-ap.ssr.utils
|
||||
(:require [auto-ap.datomic :refer [all-schema conn]]
|
||||
[auto-ap.logging :as alog]
|
||||
[auto-ap.time :as atime]
|
||||
[clj-time.coerce :as coerce]
|
||||
[clj-time.core :as time]
|
||||
[clojure.string :as str]
|
||||
[datomic.api :as dc]
|
||||
[hiccup2.core :as hiccup]
|
||||
[hiccup.compiler :refer [HtmlRenderer render-html]]
|
||||
[malli.core :as mc]
|
||||
[malli.core :as m]
|
||||
[malli.error :as me]
|
||||
[malli.registry :as mr]
|
||||
[malli.transform :as mt2]
|
||||
[slingshot.slingshot :refer [throw+ try+]]
|
||||
[taoensso.encore :refer [filter-vals]]))
|
||||
(:require
|
||||
[auto-ap.datomic :refer [all-schema conn pull-attr]]
|
||||
[auto-ap.logging :as alog]
|
||||
[auto-ap.time :as atime]
|
||||
[clj-time.coerce :as coerce]
|
||||
[clj-time.core :as time]
|
||||
[clojure.string :as str]
|
||||
[datomic.api :as dc]
|
||||
[hiccup.compiler :refer [HtmlRenderer render-html]]
|
||||
[hiccup2.core :as hiccup]
|
||||
[malli.core :as mc]
|
||||
[malli.core :as m]
|
||||
[malli.error :as me]
|
||||
[malli.registry :as mr]
|
||||
[malli.transform :as mt2]
|
||||
[slingshot.slingshot :refer [throw+ try+]]
|
||||
[taoensso.encore :refer [filter-vals]]))
|
||||
|
||||
(defrecord OOBElements [elements]
|
||||
HtmlRenderer
|
||||
@@ -663,3 +664,23 @@
|
||||
(defn wrap-implied-route-param [handler & {:as route-params}]
|
||||
(fn [request]
|
||||
(handler (update-in request [:route-params] merge route-params))))
|
||||
|
||||
(defn check-allowance [account-id allowance-key]
|
||||
(let [allowance (allowance-key (dc/pull (dc/db conn) '[{[:account/invoice-allowance :xform iol-ion.query/ident] [:db/ident]
|
||||
[:account/vendor-allowance :xform iol-ion.query/ident] [:db/ident]
|
||||
[:account/default-allowance :xform iol-ion.query/ident] [:db/ident]}]
|
||||
account-id))]
|
||||
(not= :allowance/denied
|
||||
allowance)))
|
||||
|
||||
(defn check-location-belongs [location account]
|
||||
(let [account-location (pull-attr (dc/db conn) :account/location account)]
|
||||
(when (and (seq account-location)
|
||||
(not= location
|
||||
account-location))
|
||||
(throw (ex-info "Exception." {:type (str "expected " account-location)})))
|
||||
(when (and (empty? account-location)
|
||||
(= "A" location))
|
||||
|
||||
(throw (ex-info "Exception." {:type "'A' not allowed"})))
|
||||
true))
|
||||
Reference in New Issue
Block a user