Adds the ability to change searching
This commit is contained in:
1665
scratch-sessions/bad_accounts_for_invoices.clj
Normal file
1665
scratch-sessions/bad_accounts_for_invoices.clj
Normal file
File diff suppressed because it is too large
Load Diff
@@ -9,11 +9,13 @@
|
|||||||
(defn <-datomic [a]
|
(defn <-datomic [a]
|
||||||
(-> a
|
(-> a
|
||||||
(update :account/applicability :db/ident)
|
(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]
|
(def default-read ['* {:account/type [:db/ident :db/id]
|
||||||
:account/applicability [:db/ident :db/id]
|
:account/applicability [:db/ident :db/id]
|
||||||
:account/invoice-allowance [: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-overrides [:db/id
|
||||||
:account-client-override/name
|
:account-client-override/name
|
||||||
{:account-client-override/client [:db/id :client/name]}]}])
|
{:account-client-override/client [:db/id :client/name]}]}])
|
||||||
|
|||||||
@@ -176,6 +176,16 @@
|
|||||||
:account/invoice-allowance :allowance/allowed})))
|
: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]
|
(defn migrate [conn]
|
||||||
(let [
|
(let [
|
||||||
@@ -541,22 +551,32 @@
|
|||||||
:requires [:auto-ap/add-account-overrides]}
|
:requires [:auto-ap/add-account-overrides]}
|
||||||
:auto-ap/add-search-terms-accounts {:txes-fn `add-account-search-terms
|
:auto-ap/add-search-terms-accounts {:txes-fn `add-account-search-terms
|
||||||
:requires [:auto-ap/fulltext-accounts]}
|
:requires [:auto-ap/fulltext-accounts]}
|
||||||
:auto-ap/add-account-options {:txes [[{:db/ident :account/invoice-allowance
|
:auto-ap/add-account-options {:txes [[{:db/ident :account/invoice-allowance
|
||||||
:db/valueType :db.type/ref
|
:db/valueType :db.type/ref
|
||||||
:db/cardinality :db.cardinality/one
|
:db/cardinality :db.cardinality/one
|
||||||
:db/doc "Whether this account can be used for invoices"}
|
:db/doc "Whether this account can be used for invoices"}
|
||||||
{:db/ident :allowance/allowed
|
{:db/ident :allowance/allowed
|
||||||
:db/doc "Allowed to be used"}
|
:db/doc "Allowed to be used"}
|
||||||
{:db/ident :allowance/denied
|
{:db/ident :allowance/denied
|
||||||
:db/doc "Denied usage"}
|
:db/doc "Denied usage"}
|
||||||
{:db/ident :allowance/warn
|
{:db/ident :allowance/warn
|
||||||
:db/doc "Warn on usage"}
|
:db/doc "Warn on usage"}
|
||||||
{:db/ident :allowance/admin-only
|
{:db/ident :allowance/admin-only
|
||||||
:db/doc "Only admins can use it"}
|
:db/doc "Only admins can use it"}]]
|
||||||
:requires [:auto-ap/add-search-terms-accounts]]]}
|
:requires [:auto-ap/add-search-terms-accounts]}
|
||||||
:auto-ap/backfill-account-options {:txes-fn `backfill-account-options
|
: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}
|
:account {:fields {:id {:type :id}
|
||||||
:numeric_code {:type 'Int}
|
:numeric_code {:type 'Int}
|
||||||
:invoice_allowance {:type :allowance}
|
:invoice_allowance {:type :allowance}
|
||||||
|
:vendor_allowance {:type :allowance}
|
||||||
:type {:type :ident}
|
:type {:type :ident}
|
||||||
:applicability {:type :applicability}
|
:applicability {:type :applicability}
|
||||||
:account_set {:type 'String}
|
:account_set {:type 'String}
|
||||||
@@ -502,6 +503,7 @@
|
|||||||
:type {:type :account_type}
|
:type {:type :account_type}
|
||||||
:applicability {:type :applicability}
|
:applicability {:type :applicability}
|
||||||
:invoice_allowance {:type :allowance}
|
:invoice_allowance {:type :allowance}
|
||||||
|
:vendor_allowance {:type :allowance}
|
||||||
:numeric_code {:type 'Int}
|
:numeric_code {:type 'Int}
|
||||||
:location {:type 'String}
|
:location {:type 'String}
|
||||||
:account_set {:type 'String}
|
:account_set {:type 'String}
|
||||||
|
|||||||
@@ -30,7 +30,7 @@
|
|||||||
(->graphql (d-accounts/clientize result (:client_id args)))))
|
(->graphql (d-accounts/clientize result (:client_id args)))))
|
||||||
|
|
||||||
(defn upsert-account [context 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-not id
|
||||||
(when (seq (d/query {:query {:find ['?e]
|
(when (seq (d/query {:query {:find ['?e]
|
||||||
:in '[$ ?account-set ?numeric-code]
|
:in '[$ ?account-set ?numeric-code]
|
||||||
@@ -53,6 +53,7 @@
|
|||||||
:account-applicability/global)
|
:account-applicability/global)
|
||||||
|
|
||||||
:account/invoice-allowance (some-> invoice-allowance (enum->keyword "allowance"))
|
:account/invoice-allowance (some-> invoice-allowance (enum->keyword "allowance"))
|
||||||
|
:account/vendor-allowance (some-> vendor-allowance (enum->keyword "allowance"))
|
||||||
:account/account-set account-set
|
:account/account-set account-set
|
||||||
:account/location location
|
:account/location location
|
||||||
:account/numeric-code (when-not id
|
:account/numeric-code (when-not id
|
||||||
|
|||||||
@@ -16,7 +16,7 @@
|
|||||||
[reagent.core :as reagent]
|
[reagent.core :as reagent]
|
||||||
[vimsical.re-frame.fx.track :as track]))
|
[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
|
(re-frame/reg-sub
|
||||||
::request
|
::request
|
||||||
:<- [::forms/form ::form]
|
:<- [::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
|
{:id id
|
||||||
:type (keyword type)
|
:type (keyword type)
|
||||||
:applicability (keyword applicability)
|
:applicability (keyword applicability)
|
||||||
:invoice-allowance (keyword invoice-allowance)
|
:invoice-allowance (keyword invoice-allowance)
|
||||||
|
:vendor-allowance (keyword vendor-allowance)
|
||||||
:location (if (clojure.string/blank? location)
|
:location (if (clojure.string/blank? location)
|
||||||
nil
|
nil
|
||||||
location)
|
location)
|
||||||
@@ -44,7 +45,6 @@
|
|||||||
(re-frame/reg-event-db
|
(re-frame/reg-event-db
|
||||||
::editing
|
::editing
|
||||||
(fn [db [_ which complete-listener]]
|
(fn [db [_ which complete-listener]]
|
||||||
(println "WHICH" which)
|
|
||||||
(-> db
|
(-> db
|
||||||
(forms/start-form ::form which complete-listener))))
|
(forms/start-form ::form which complete-listener))))
|
||||||
|
|
||||||
@@ -66,7 +66,7 @@
|
|||||||
:operation/name "UpsertAccount"}
|
:operation/name "UpsertAccount"}
|
||||||
:venia/queries [{:query/data [:upsert-account
|
:venia/queries [{:query/data [:upsert-account
|
||||||
{:account request}
|
{: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-success [::edited]
|
||||||
:on-error [::forms/save-error ::form]}})))
|
:on-error [::forms/save-error ::form]}})))
|
||||||
|
|
||||||
@@ -84,6 +84,7 @@
|
|||||||
[:location {:optional true} [:maybe :string]]
|
[:location {:optional true} [:maybe :string]]
|
||||||
[:applicability [:enum :global :optional :customized]]
|
[:applicability [:enum :global :optional :customized]]
|
||||||
[:invoice-allowance [:enum :allowed :denied :warn :admin-only]]
|
[:invoice-allowance [:enum :allowed :denied :warn :admin-only]]
|
||||||
|
[:vendor-allowance [:enum :allowed :denied :warn :admin-only]]
|
||||||
[:client-overrides {:optional true}
|
[:client-overrides {:optional true}
|
||||||
[:maybe [:sequential account-customization-schema]]]]))
|
[:maybe [:sequential account-customization-schema]]]]))
|
||||||
|
|
||||||
@@ -131,6 +132,15 @@
|
|||||||
:allow-nil? true
|
:allow-nil? true
|
||||||
:keywordize? 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"}
|
[form-builder/section {:title "Client"}
|
||||||
[:h2.subtitle "Client"]
|
[:h2.subtitle "Client"]
|
||||||
[form-builder/field-v2 {:field :applicability}
|
[form-builder/field-v2 {:field :applicability}
|
||||||
|
|||||||
Reference in New Issue
Block a user