Add vendor pre-population for bulk code and individual edit forms
- Add vendor-changed HTMX handlers for both bulk code and individual edit - Pre-populate default account at 100% when vendor is selected and no accounts exist - Fix render-accounts-section to render from step-params correctly - Change bulk code vendor-changed from hx-get to hx-post to include form data - Add routes for vendor-changed endpoints - Update e2e tests to cover vendor pre-population - Run lein cljfmt fix across codebase
This commit is contained in:
@@ -1,9 +1,9 @@
|
||||
(ns auto-ap.ssr.admin.clients
|
||||
(:require
|
||||
[auto-ap.datomic
|
||||
:refer [add-sorter-fields apply-pagination apply-sort-3
|
||||
audit-transact conn merge-query pull-attr pull-id
|
||||
pull-many query2]]
|
||||
:refer [add-sorter-fields apply-pagination apply-sort-3
|
||||
audit-transact conn merge-query pull-attr pull-id
|
||||
pull-many query2]]
|
||||
[auto-ap.graphql.utils :refer [extract-client-ids]]
|
||||
[auto-ap.logging :as alog]
|
||||
[auto-ap.query-params :refer [wrap-copy-qp-pqp]]
|
||||
@@ -11,7 +11,7 @@
|
||||
[auto-ap.routes.indicators :as indicators]
|
||||
[auto-ap.routes.queries :as q]
|
||||
[auto-ap.routes.utils
|
||||
:refer [wrap-admin wrap-client-redirect-unauthenticated]]
|
||||
:refer [wrap-admin wrap-client-redirect-unauthenticated]]
|
||||
[auto-ap.solr :as solr]
|
||||
[auto-ap.square.core3 :as square]
|
||||
[auto-ap.ssr-routes :as ssr-routes]
|
||||
@@ -26,11 +26,11 @@
|
||||
[auto-ap.ssr.indicators :as i]
|
||||
[auto-ap.ssr.svg :as svg]
|
||||
[auto-ap.ssr.utils
|
||||
:refer [apply-middleware-to-all-handlers entity-id
|
||||
form-validation-error html-response many-entity
|
||||
many-entity-custom modal-response ref->enum-schema strip
|
||||
temp-id wrap-entity wrap-merge-prior-hx
|
||||
wrap-schema-enforce]]
|
||||
:refer [apply-middleware-to-all-handlers entity-id
|
||||
form-validation-error html-response many-entity
|
||||
many-entity-custom modal-response ref->enum-schema strip
|
||||
temp-id wrap-entity wrap-merge-prior-hx
|
||||
wrap-schema-enforce]]
|
||||
[auto-ap.time :as atime]
|
||||
[bidi.bidi :as bidi]
|
||||
[cheshire.core :as cheshire]
|
||||
@@ -47,7 +47,6 @@
|
||||
(:import
|
||||
[java.util UUID]))
|
||||
|
||||
|
||||
;; TODO make more reusable malli schemas, use unions if it would be helpful
|
||||
;; TODO copy save logic from graphql version
|
||||
;; TODO cash drawer shift
|
||||
@@ -67,8 +66,6 @@
|
||||
[:enum
|
||||
"" "all" "only-mine"]]]]]))
|
||||
|
||||
|
||||
|
||||
(defn filters [request]
|
||||
[:form {"hx-trigger" "change delay:500ms, keyup changed from:.hot-filter delay:1000ms"
|
||||
"hx-get" (bidi/path-for ssr-routes/only-routes
|
||||
@@ -178,7 +175,6 @@
|
||||
:where ['[?e :client/groups ?g]]}
|
||||
:args [(clojure.string/upper-case (:group query-params))]})
|
||||
|
||||
|
||||
(not (str/blank? (some-> query-params :code)))
|
||||
(merge-query {:query {:in ['?code]
|
||||
:where ['[?e :client/code ?code]]}
|
||||
@@ -293,8 +289,6 @@
|
||||
|
||||
(def row* (partial helper/row* grid-page))
|
||||
|
||||
|
||||
|
||||
(def bank-account-schema [:and [:map
|
||||
[:db/id [:or entity-id temp-id]]
|
||||
[:bank-account/name :string]
|
||||
@@ -383,10 +377,10 @@
|
||||
[:maybe (many-entity-custom {}
|
||||
[:and
|
||||
[:map
|
||||
|
||||
|
||||
[:db/id [:or entity-id temp-id]]
|
||||
[:bank-account/name :string]
|
||||
|
||||
|
||||
[:bank-account/code :string]
|
||||
[:bank-account/type [:maybe (ref->enum-schema "bank-account-type")]]
|
||||
[:bank-account/numeric-code {:optional true} [:maybe :int]]
|
||||
@@ -401,15 +395,15 @@
|
||||
[:bank-account/intuit-bank-account {:optional true} [:maybe entity-id]]
|
||||
[:bank-account/include-in-reports {:default false}
|
||||
[:boolean {:decode/string {:enter #(if (= % "on") true
|
||||
|
||||
|
||||
(boolean %))}}]]
|
||||
[:bank-account/visible {:default false}
|
||||
[:boolean {:decode/string {:enter #(if (= % "on") true
|
||||
|
||||
|
||||
(boolean %))}}]]
|
||||
[:bank-account/use-date-instead-of-post-date? {:default false}
|
||||
[:boolean {:decode/string {:enter #(if (= % "on") true
|
||||
|
||||
|
||||
(boolean %))}}]]
|
||||
[:bank-account/start-date {:optional true} [:maybe {:decode/arbitrary (fn [m]
|
||||
(if (string? m)
|
||||
@@ -443,10 +437,6 @@
|
||||
[:client/week-b-credits {:optional true} [:maybe :double]]
|
||||
[:client/week-b-debits {:optional true} [:maybe :double]]]))
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
(defn email-contact-row [email-contact-cursor]
|
||||
(com/data-grid-row
|
||||
(-> {:x-data (hx/json {:show (boolean (not (fc/field-value (:new? email-contact-cursor))))})
|
||||
@@ -526,12 +516,10 @@
|
||||
(com/data-grid-cell {:class "align-top"}
|
||||
(com/a-icon-button {"@click.prevent.stop" "$refs.p.remove()"} svg/x))))
|
||||
|
||||
|
||||
(defn- dialog-header [step]
|
||||
[:div.flex [:div.p-2 (mm/step-name step)] [:p.ml-2.rounded.bg-gray-50.p-2.dark:bg-gray-600
|
||||
[:span {:x-text "clientName"}]]])
|
||||
|
||||
|
||||
(defrecord InfoModal [linear-wizard]
|
||||
mm/ModalWizardStep
|
||||
(step-name [_]
|
||||
@@ -598,7 +586,6 @@
|
||||
(mm/default-step-footer linear-wizard this :validation-route ::route/navigate)
|
||||
:validation-route ::route/navigate)))
|
||||
|
||||
|
||||
(defn match-row [_]
|
||||
(com/data-grid-row
|
||||
{:x-ref "p"
|
||||
@@ -644,8 +631,6 @@
|
||||
(com/data-grid-cell {:class "align-top"}
|
||||
(com/a-icon-button {"@click.prevent.stop" "show=false; setTimeout(() => $refs.p.remove(), 500)"} svg/x))))
|
||||
|
||||
|
||||
|
||||
(defrecord MatchesModal [linear-wizard]
|
||||
mm/ModalWizardStep
|
||||
(step-name [_]
|
||||
@@ -699,7 +684,6 @@
|
||||
(step-key [_]
|
||||
:contact)
|
||||
|
||||
|
||||
(edit-path [_ _]
|
||||
[])
|
||||
|
||||
@@ -798,7 +782,6 @@
|
||||
:to (mm/encode-step-key [:bank-account (fc/field-value (:db/id bank-account))])})}
|
||||
svg/pencil)]])])
|
||||
|
||||
|
||||
(defmulti bank-account-card (comp deref :bank-account/type))
|
||||
(defmethod bank-account-card :bank-account-type/cash [bank-account]
|
||||
(bank-account-card-base {:bg-color "bg-green-50"
|
||||
@@ -821,7 +804,6 @@
|
||||
:icon svg/check
|
||||
:bank-account bank-account}))
|
||||
|
||||
|
||||
(defmulti bank-account-form (comp deref :bank-account/type))
|
||||
(defmethod bank-account-form :bank-account-type/cash [bank-account]
|
||||
[:div
|
||||
@@ -904,8 +886,6 @@
|
||||
:checked (fc/field-value)}
|
||||
"Visible for payment"))]])
|
||||
|
||||
|
||||
|
||||
(defn- plaid-account-select [client-id]
|
||||
(fc/with-field :bank-account/plaid-account
|
||||
(com/validated-field {:errors (fc/field-errors)
|
||||
@@ -1048,7 +1028,6 @@
|
||||
[:div#days-indicator
|
||||
(i/days-ago* (some-> (fc/field-value)))]])
|
||||
|
||||
|
||||
(fc/with-field :bank-account/include-in-reports
|
||||
(com/checkbox {:name (fc/field-name)
|
||||
:value (boolean (fc/field-value))
|
||||
@@ -1224,8 +1203,6 @@
|
||||
(yodlee-account-select (:db/id (:snapshot fc/*form-data*)))
|
||||
(intuit-account-select (:db/id (:snapshot fc/*form-data*)))])
|
||||
|
||||
|
||||
|
||||
(defn new-bank-account-card []
|
||||
[:div {:class "w-[30em]"}
|
||||
(com/card {:class "w-full border-dotted bg-gray-50"}
|
||||
@@ -1255,7 +1232,6 @@
|
||||
|
||||
(edit-path [_ _] [])
|
||||
|
||||
|
||||
(step-schema [_]
|
||||
(mut/select-keys (mm/form-schema linear-wizard) #{}))
|
||||
|
||||
@@ -1284,7 +1260,6 @@
|
||||
:validation-route ::route/navigate)]
|
||||
:validation-route ::route/navigate)))
|
||||
|
||||
|
||||
(defn square-location-table []
|
||||
[:div#square-locations
|
||||
[:div.htmx-indicator
|
||||
@@ -1367,7 +1342,7 @@
|
||||
:hx-include "#square-token"
|
||||
:hx-trigger "click"
|
||||
:hx-indicator "#square-locations"
|
||||
:hx-target "#square-locations" }
|
||||
:hx-target "#square-locations"}
|
||||
"Refresh")]
|
||||
|
||||
(fc/with-field :client/square-locations
|
||||
@@ -1447,8 +1422,6 @@
|
||||
(filterv #(not= (get-in multi-form-state [:step-params :db/id]) (:db/id %)) bank-accounts)))
|
||||
(mm/select-state [] nil))))
|
||||
|
||||
|
||||
|
||||
(defrecord CashFlowModal [linear-wizard]
|
||||
mm/ModalWizardStep
|
||||
(step-name [_]
|
||||
@@ -1663,7 +1636,6 @@
|
||||
#(mm/select-state % [] {})
|
||||
#(assoc-in % [:snapshot :client/bank-accounts] new-bank-accounts)))))))
|
||||
|
||||
|
||||
(def sales-summary-query
|
||||
"[:find ?d4 (sum ?total) (sum ?tax) (sum ?tip) (sum ?service-charge) (sum ?discount) (sum ?returns)
|
||||
:with ?s
|
||||
@@ -1792,9 +1764,6 @@
|
||||
[?cds :cash-drawer-shift/opened-cash ?opened-cash]
|
||||
[(iol-ion.query/excel-date ?date) ?d4]]")
|
||||
|
||||
|
||||
|
||||
|
||||
(defn setup-sales-queries-impl [client-id]
|
||||
(let [{client-code :client/code feature-flags :client/feature-flags} (dc/pull (dc/db conn) '[:client/code :client/feature-flags] client-id)
|
||||
is-new-square? ((set feature-flags) "new-square")]
|
||||
@@ -1840,7 +1809,6 @@
|
||||
(cheshire/generate-string (format (slurp (io/resource which)) url)))}
|
||||
children))
|
||||
|
||||
|
||||
(defn biweekly-sales-powerquery [request]
|
||||
(setup-sales-queries-impl (:db/id (:route-params request)))
|
||||
(modal-response
|
||||
@@ -1872,7 +1840,6 @@
|
||||
|
||||
(com/modal-footer {} [:div])))))
|
||||
|
||||
|
||||
(def key->handler
|
||||
(apply-middleware-to-all-handlers
|
||||
{::route/page (helper/page-route grid-page)
|
||||
|
||||
Reference in New Issue
Block a user