Adds the ability to change searching
This commit is contained in:
@@ -9,11 +9,13 @@
|
||||
(defn <-datomic [a]
|
||||
(-> a
|
||||
(update :account/applicability :db/ident)
|
||||
(update :account/invoice-allowance :db/ident)))
|
||||
(update :account/invoice-allowance :db/ident)
|
||||
(update :account/vendor-allowance :db/ident)))
|
||||
|
||||
(def default-read ['* {:account/type [:db/ident :db/id]
|
||||
:account/applicability [:db/ident :db/id]
|
||||
:account/invoice-allowance [:db/ident :db/id]
|
||||
:account/vendor-allowance [:db/ident :db/id]
|
||||
:account/client-overrides [:db/id
|
||||
:account-client-override/name
|
||||
{:account-client-override/client [:db/id :client/name]}]}])
|
||||
|
||||
@@ -176,6 +176,16 @@
|
||||
:account/invoice-allowance :allowance/allowed})))
|
||||
])
|
||||
|
||||
(defn backfill-account-options2 [conn]
|
||||
[(->> (d/q '[:find [?a ...]
|
||||
:in $
|
||||
:where [?a :account/name]]
|
||||
(d/db conn))
|
||||
(map (fn [i]
|
||||
{:db/id i
|
||||
:account/vendor-allowance :allowance/allowed})))
|
||||
])
|
||||
|
||||
|
||||
(defn migrate [conn]
|
||||
(let [
|
||||
@@ -541,22 +551,32 @@
|
||||
:requires [:auto-ap/add-account-overrides]}
|
||||
:auto-ap/add-search-terms-accounts {:txes-fn `add-account-search-terms
|
||||
:requires [:auto-ap/fulltext-accounts]}
|
||||
:auto-ap/add-account-options {:txes [[{:db/ident :account/invoice-allowance
|
||||
:db/valueType :db.type/ref
|
||||
:db/cardinality :db.cardinality/one
|
||||
:db/doc "Whether this account can be used for invoices"}
|
||||
{:db/ident :allowance/allowed
|
||||
:db/doc "Allowed to be used"}
|
||||
{:db/ident :allowance/denied
|
||||
:db/doc "Denied usage"}
|
||||
{:db/ident :allowance/warn
|
||||
:db/doc "Warn on usage"}
|
||||
{:db/ident :allowance/admin-only
|
||||
:db/doc "Only admins can use it"}
|
||||
:requires [:auto-ap/add-search-terms-accounts]]]}
|
||||
:auto-ap/add-account-options {:txes [[{:db/ident :account/invoice-allowance
|
||||
:db/valueType :db.type/ref
|
||||
:db/cardinality :db.cardinality/one
|
||||
:db/doc "Whether this account can be used for invoices"}
|
||||
{:db/ident :allowance/allowed
|
||||
:db/doc "Allowed to be used"}
|
||||
{:db/ident :allowance/denied
|
||||
:db/doc "Denied usage"}
|
||||
{:db/ident :allowance/warn
|
||||
:db/doc "Warn on usage"}
|
||||
{:db/ident :allowance/admin-only
|
||||
:db/doc "Only admins can use it"}]]
|
||||
:requires [:auto-ap/add-search-terms-accounts]}
|
||||
:auto-ap/backfill-account-options {:txes-fn `backfill-account-options
|
||||
|
||||
:requires [:auto-ap/add-account-options]}}
|
||||
|
||||
:requires [:auto-ap/add-account-options]}
|
||||
|
||||
:auto-ap/add-vendor-account-options {:txes [[{:db/ident :account/vendor-allowance
|
||||
:db/valueType :db.type/ref
|
||||
:db/cardinality :db.cardinality/one
|
||||
:db/doc "Whether this account can be used for vendors"}
|
||||
]]
|
||||
:requires [:auto-ap/backfill-account-options]}
|
||||
:auto-ap/backfill-account-options2 {:txes-fn `backfill-account-options2
|
||||
|
||||
:requires [:auto-ap/add-vendor-account-options]}}
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -247,6 +247,7 @@
|
||||
:account {:fields {:id {:type :id}
|
||||
:numeric_code {:type 'Int}
|
||||
:invoice_allowance {:type :allowance}
|
||||
:vendor_allowance {:type :allowance}
|
||||
:type {:type :ident}
|
||||
:applicability {:type :applicability}
|
||||
:account_set {:type 'String}
|
||||
@@ -502,6 +503,7 @@
|
||||
:type {:type :account_type}
|
||||
:applicability {:type :applicability}
|
||||
:invoice_allowance {:type :allowance}
|
||||
:vendor_allowance {:type :allowance}
|
||||
:numeric_code {:type 'Int}
|
||||
:location {:type 'String}
|
||||
:account_set {:type 'String}
|
||||
|
||||
@@ -30,7 +30,7 @@
|
||||
(->graphql (d-accounts/clientize result (:client_id args)))))
|
||||
|
||||
(defn upsert-account [context args _]
|
||||
(let [{{:keys [id client-overrides numeric-code location applicability account-set name invoice-allowance type]} :account} (<-graphql args)]
|
||||
(let [{{:keys [id client-overrides numeric-code location applicability account-set name invoice-allowance vendor-allowance type]} :account} (<-graphql args)]
|
||||
(when-not id
|
||||
(when (seq (d/query {:query {:find ['?e]
|
||||
:in '[$ ?account-set ?numeric-code]
|
||||
@@ -53,6 +53,7 @@
|
||||
:account-applicability/global)
|
||||
|
||||
:account/invoice-allowance (some-> invoice-allowance (enum->keyword "allowance"))
|
||||
:account/vendor-allowance (some-> vendor-allowance (enum->keyword "allowance"))
|
||||
:account/account-set account-set
|
||||
:account/location location
|
||||
:account/numeric-code (when-not id
|
||||
|
||||
Reference in New Issue
Block a user