Adds ability to filter by category, adds invoice allowance as an account option
This commit is contained in:
@@ -7,10 +7,13 @@
|
||||
[clojure.tools.logging :as log]))
|
||||
|
||||
(defn <-datomic [a]
|
||||
(update a :account/applicability :db/ident))
|
||||
(-> a
|
||||
(update :account/applicability :db/ident)
|
||||
(update :account/invoice-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/client-overrides [:db/id
|
||||
:account-client-override/name
|
||||
{:account-client-override/client [:db/id :client/name]}]}])
|
||||
|
||||
@@ -166,6 +166,17 @@
|
||||
{:db/id i
|
||||
:account-client-override/search-terms n})))])
|
||||
|
||||
(defn backfill-account-options [conn]
|
||||
[(->> (d/q '[:find [?a ...]
|
||||
:in $
|
||||
:where [?a :account/name]]
|
||||
(d/db conn))
|
||||
(map (fn [i]
|
||||
{:db/id i
|
||||
:account/invoice-allowance :allowance/allowed})))
|
||||
])
|
||||
|
||||
|
||||
(defn migrate [conn]
|
||||
(let [
|
||||
norms-map (merge {:auto-ap/base-schema {:txes auto-ap.datomic/base-schema}
|
||||
@@ -529,7 +540,23 @@
|
||||
:db/fulltext true}]]
|
||||
:requires [:auto-ap/add-account-overrides]}
|
||||
: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
|
||||
: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]}}
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -63,6 +63,12 @@
|
||||
'[?client-id :client/code ?client-code]]}
|
||||
:args [(:client-code args)]})
|
||||
|
||||
(:category args)
|
||||
(merge-query {:query {:in ['?category]
|
||||
:where ['[?e :sales-order/line-items ?li]
|
||||
'[?li :order-line-item/category ?category]]}
|
||||
:args [(:category args)]})
|
||||
|
||||
(:processor args)
|
||||
(merge-query {:query {:in ['?processor]
|
||||
:where ['[?e :sales-order/charges ?chg]
|
||||
|
||||
@@ -246,6 +246,7 @@
|
||||
|
||||
:account {:fields {:id {:type :id}
|
||||
:numeric_code {:type 'Int}
|
||||
:invoice_allowance {:type :allowance}
|
||||
:type {:type :ident}
|
||||
:applicability {:type :applicability}
|
||||
:account_set {:type 'String}
|
||||
@@ -500,6 +501,7 @@
|
||||
{:fields {:id {:type :id}
|
||||
:type {:type :account_type}
|
||||
:applicability {:type :applicability}
|
||||
:invoice_allowance {:type :allowance}
|
||||
:numeric_code {:type 'Int}
|
||||
:location {:type 'String}
|
||||
:account_set {:type 'String}
|
||||
@@ -517,6 +519,10 @@
|
||||
:integration_state {:values [{:enum-value :failed}
|
||||
{:enum-value :success}
|
||||
{:enum-value :unauthorized}]}
|
||||
:allowance {:values [{:enum-value :allowed}
|
||||
{:enum-value :denied}
|
||||
{:enum-value :warn}
|
||||
{:enum-value :admin_only}]}
|
||||
:tin_type {:values [{:enum-value :ein}
|
||||
{:enum-value :ssn}]}
|
||||
:type_1099 {:values [{:enum-value :none}
|
||||
|
||||
@@ -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 type]} :account} (<-graphql args)]
|
||||
(let [{{:keys [id client-overrides numeric-code location applicability account-set name invoice-allowance type]} :account} (<-graphql args)]
|
||||
(when-not id
|
||||
(when (seq (d/query {:query {:find ['?e]
|
||||
:in '[$ ?account-set ?numeric-code]
|
||||
@@ -51,6 +51,8 @@
|
||||
:account/type (keyword "account-type" (clojure.core/name type))
|
||||
:account/applicability (or (enum->keyword applicability "account-applicability")
|
||||
:account-applicability/global)
|
||||
|
||||
:account/invoice-allowance (some-> invoice-allowance (enum->keyword "allowance"))
|
||||
:account/account-set account-set
|
||||
:account/location location
|
||||
:account/numeric-code (when-not id
|
||||
|
||||
@@ -76,6 +76,7 @@
|
||||
:total_gte {:type :money}
|
||||
:type_name {:type 'String}
|
||||
:processor {:type :processor}
|
||||
:category {:type 'String}
|
||||
:start {:type 'Int}
|
||||
:per_page {:type 'Int}
|
||||
:sort {:type '(list :sort_item)}}
|
||||
|
||||
@@ -381,11 +381,12 @@
|
||||
|
||||
#_{:clj-kondo/ignore [:clojure-lsp/unused-public-var]}
|
||||
(defn tx-detail [i]
|
||||
(map (juxt :e #(d/ident (d/db (d/connect uri)) (:a %)) :v :added?)
|
||||
(map (juxt :e #(d/ident (d/db (d/connect uri)) (:a %)) :v :added)
|
||||
(:data (first
|
||||
(d/tx-range (d/log (d/connect uri))
|
||||
i
|
||||
(inc i))))))
|
||||
|
||||
#_{:clj-kondo/ignore [:clojure-lsp/unused-public-var]}
|
||||
(defn tx-range-detail [i]
|
||||
(map (juxt :e #(d/ident (d/db (d/connect uri)) (:a %)) :v)
|
||||
|
||||
@@ -171,8 +171,7 @@
|
||||
"1099 data entry is now ready!"]]
|
||||
|
||||
(when (> (count @clients) 1)
|
||||
[client-dropdown]
|
||||
)])]
|
||||
[client-dropdown])])]
|
||||
(when-not is-initial-loading
|
||||
[login-dropdown])]
|
||||
|
||||
|
||||
@@ -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 :id [:client-overrides [:name [:client [:name :id]]]]])
|
||||
(def default-read [:numeric-code :name :location :type :account_set :applicability :invoice-allowance :id [:client-overrides [:name [:client [:name :id]]]]])
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -15,14 +15,16 @@
|
||||
|
||||
(def types [:dividend :expense :asset :liability :equity :revenue])
|
||||
(def applicabilities [:global :optional :customized])
|
||||
(def allowances [:allowed :denied :warn :admin-only])
|
||||
|
||||
(re-frame/reg-sub
|
||||
::request
|
||||
:<- [::forms/form ::form]
|
||||
(fn [{{:keys [id location type client-overrides applicability numeric-code name account-set]} :data}]
|
||||
(fn [{{:keys [id location type client-overrides applicability invoice-allowance numeric-code name account-set]} :data}]
|
||||
{:id id
|
||||
:type (keyword type)
|
||||
:applicability (keyword applicability)
|
||||
:invoice-allowance (keyword invoice-allowance)
|
||||
:location (if (clojure.string/blank? location)
|
||||
nil
|
||||
location)
|
||||
@@ -64,7 +66,7 @@
|
||||
:operation/name "UpsertAccount"}
|
||||
:venia/queries [{:query/data [:upsert-account
|
||||
{:account request}
|
||||
[:id :type :name :account-set :numeric-code :location :applicability [:client-overrides [:name :id [:client [:id :name]]]]]]}]}
|
||||
[:id :type :name :account-set :numeric-code :location :applicability :invoice-allowance [:client-overrides [:name :id [:client [:id :name]]]]]]}]}
|
||||
:on-success [::edited]
|
||||
:on-error [::forms/save-error ::form]}})))
|
||||
|
||||
@@ -81,6 +83,7 @@
|
||||
[:type [:enum :dividend :expense :asset :liability :equity :revenue]]
|
||||
[:location {:optional true} [:maybe :string]]
|
||||
[:applicability [:enum :global :optional :customized]]
|
||||
[:invoice-allowance [:enum :allowed :denied :warn :admin-only]]
|
||||
[:client-overrides {:optional true}
|
||||
[:maybe [:sequential account-customization-schema]]]]))
|
||||
|
||||
@@ -119,6 +122,15 @@
|
||||
"Location"
|
||||
[:input.input.known-field.location {:type "text"}]]
|
||||
|
||||
[form-builder/field-v2 {:field :invoice-allowance}
|
||||
"Invoice 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}
|
||||
|
||||
@@ -26,6 +26,7 @@
|
||||
:sort (:sort params)
|
||||
:per-page (:per-page params)
|
||||
:type-name (:type-name params)
|
||||
:category (:category params)
|
||||
:total-gte (:amount-gte (:total-range params))
|
||||
:total-lte (:amount-lte (:total-range params))
|
||||
:date-range (:date-range params)
|
||||
|
||||
@@ -1,12 +1,14 @@
|
||||
(ns auto-ap.views.pages.pos.side-bar
|
||||
(:require [auto-ap.routes :as routes]
|
||||
(:require
|
||||
[auto-ap.routes :as routes]
|
||||
[auto-ap.subs :as subs]
|
||||
[auto-ap.views.utils :refer [active-when dispatch-event]]
|
||||
[auto-ap.views.components.date-range-filter :refer [date-range-filter]]
|
||||
[auto-ap.views.components.number-filter :refer [number-filter]]
|
||||
[auto-ap.views.pages.data-page :as data-page]
|
||||
[auto-ap.views.utils
|
||||
:refer [active-when dispatch-event dispatch-value-change]]
|
||||
[bidi.bidi :as bidi]
|
||||
[re-frame.core :as re-frame]
|
||||
[auto-ap.views.pages.data-page :as data-page]))
|
||||
[re-frame.core :as re-frame]))
|
||||
|
||||
(defn side-bar [{:keys [data-page]}]
|
||||
(let [ap @(re-frame/subscribe [::subs/active-page])]
|
||||
@@ -92,7 +94,12 @@
|
||||
[:a.panel-block {:on-click (dispatch-event [::data-page/filter-changed data-page :processor "na"])}
|
||||
[:span.panel-icon #_[:img.level-item {:src "/img/grubhub.png"}]]
|
||||
"No Processor"]
|
||||
]]])
|
||||
]]
|
||||
[:p.menu-label "Category"]
|
||||
[:div.field
|
||||
[:div.control [:input.input {:placeholder "Fries"
|
||||
:value @(re-frame/subscribe [::data-page/filter data-page :category])
|
||||
:on-change (dispatch-value-change [::data-page/filter-changed data-page :category])} ]]]])
|
||||
|
||||
(when-let [exact-match-id @(re-frame/subscribe [::data-page/filter data-page :exact-match-id])]
|
||||
[:div
|
||||
|
||||
Reference in New Issue
Block a user