Adds ability to filter by category, adds invoice allowance as an account option

This commit is contained in:
2023-01-31 08:51:10 -08:00
parent d94aac317e
commit e13a32b0aa
12 changed files with 199 additions and 134 deletions

View File

@@ -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])]

View File

@@ -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]]]]])

View File

@@ -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}

View File

@@ -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)

View File

@@ -1,12 +1,14 @@
(ns auto-ap.views.pages.pos.side-bar
(: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]]
[bidi.bidi :as bidi]
[re-frame.core :as re-frame]
[auto-ap.views.pages.data-page :as data-page]))
(:require
[auto-ap.routes :as routes]
[auto-ap.subs :as subs]
[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]))
(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