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
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
[reagent.core :as reagent]
|
||||
[vimsical.re-frame.fx.track :as track]))
|
||||
|
||||
(def default-read [:numeric-code :name :location :type :account_set :applicability :invoice-allowance :id [:client-overrides [:name [:client [:name :id]]]]])
|
||||
(def default-read [:numeric-code :name :location :type :account_set :applicability :invoice-allowance :vendor-allowance :id [:client-overrides [:name [:client [:name :id]]]]])
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -20,11 +20,12 @@
|
||||
(re-frame/reg-sub
|
||||
::request
|
||||
:<- [::forms/form ::form]
|
||||
(fn [{{:keys [id location type client-overrides applicability invoice-allowance numeric-code name account-set]} :data}]
|
||||
(fn [{{:keys [id location type client-overrides applicability invoice-allowance vendor-allowance numeric-code name account-set]} :data}]
|
||||
{:id id
|
||||
:type (keyword type)
|
||||
:applicability (keyword applicability)
|
||||
:invoice-allowance (keyword invoice-allowance)
|
||||
:vendor-allowance (keyword vendor-allowance)
|
||||
:location (if (clojure.string/blank? location)
|
||||
nil
|
||||
location)
|
||||
@@ -44,7 +45,6 @@
|
||||
(re-frame/reg-event-db
|
||||
::editing
|
||||
(fn [db [_ which complete-listener]]
|
||||
(println "WHICH" which)
|
||||
(-> db
|
||||
(forms/start-form ::form which complete-listener))))
|
||||
|
||||
@@ -66,7 +66,7 @@
|
||||
:operation/name "UpsertAccount"}
|
||||
:venia/queries [{:query/data [:upsert-account
|
||||
{:account request}
|
||||
[:id :type :name :account-set :numeric-code :location :applicability :invoice-allowance [:client-overrides [:name :id [:client [:id :name]]]]]]}]}
|
||||
[:id :type :name :account-set :numeric-code :location :applicability :invoice-allowance :vendor-allowance [:client-overrides [:name :id [:client [:id :name]]]]]]}]}
|
||||
:on-success [::edited]
|
||||
:on-error [::forms/save-error ::form]}})))
|
||||
|
||||
@@ -84,6 +84,7 @@
|
||||
[:location {:optional true} [:maybe :string]]
|
||||
[:applicability [:enum :global :optional :customized]]
|
||||
[:invoice-allowance [:enum :allowed :denied :warn :admin-only]]
|
||||
[:vendor-allowance [:enum :allowed :denied :warn :admin-only]]
|
||||
[:client-overrides {:optional true}
|
||||
[:maybe [:sequential account-customization-schema]]]]))
|
||||
|
||||
@@ -131,6 +132,15 @@
|
||||
:allow-nil? true
|
||||
:keywordize? true}]]
|
||||
|
||||
[form-builder/field-v2 {:field :vendor-allowance}
|
||||
"Vendor Allowance"
|
||||
[com/select-field {:options (map (fn [l]
|
||||
[l
|
||||
(str/capitalize (name l))])
|
||||
allowances)
|
||||
:allow-nil? true
|
||||
:keywordize? true}]]
|
||||
|
||||
[form-builder/section {:title "Client"}
|
||||
[:h2.subtitle "Client"]
|
||||
[form-builder/field-v2 {:field :applicability}
|
||||
|
||||
Reference in New Issue
Block a user