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:
2026-05-21 14:45:19 -07:00
parent 8bd0cee1b1
commit ba87805d4c
210 changed files with 8694 additions and 9627 deletions

View File

@@ -25,7 +25,7 @@
[:maybe clj-date-schema]]
[:end-date {:optional true}
[:maybe clj-date-schema]]
[:client {:optional true :default nil} [:maybe [:entity-map {:pull [:db/id :client/name]}]]] ]
[:client {:optional true :default nil} [:maybe [:entity-map {:pull [:db/id :client/name]}]]]]
default-grid-fields-schema)]))
(defn filters [params]
@@ -36,7 +36,7 @@
"hx-indicator" "#cash-drawer-shift-table"
#_#_:hx-disabled-elt "find fieldset"}
[:fieldset.space-y-6
[:fieldset.space-y-6
(date-range-field* params)
(total-field* params)]])
@@ -52,15 +52,14 @@
:where '[[(iol-ion.query/scan-cash-drawer-shifts $ ?clients ?start-date ?end-date) [[?e _ ?sort-default] ...]]]}
:args [db [(:trimmed-clients request)
(some-> (:start-date query-params) c/to-date)
(some-> (:end-date query-params) c/to-date )]]}
(some-> (:end-date query-params) c/to-date)]]}
(:sort query-params) (add-sorter-fields {"client" ['[?e :cash-drawer-shift/client ?c]
'[?c :client/name ?sort-client]]
"date" ['[?e :cash-drawer-shift/date ?sort-date]]
"paid-in" ['[?e :cash-drawer-shift/paid-in ?sort-paid-in]]
"paid-out" ['[?e :cash-drawer-shift/paid-out ?sort-paid-out]]
"expected-cash" ['[?e :cash-drawer-shift/expected-cash ?sort-expected-cash]]
"opened-cash" ['[?e :cash-drawer-shift/opened-cash ?sort-opened-cash]]
}
"opened-cash" ['[?e :cash-drawer-shift/opened-cash ?sort-opened-cash]]}
query-params)
(:exact-match-id query-params)
@@ -71,7 +70,7 @@
true
(merge-query {:query {:find ['?sort-default '?e]
:where ['[?e :cash-drawer-shift/date ?sort-default]]}}))]
(cond->> (query2 query)
true (apply-sort-3 query-params)
true (apply-pagination query-params))))
@@ -80,8 +79,8 @@
(let [results (->> (pull-many db default-read ids)
(group-by :db/id))
cash-drawer-shifts (->> ids
(map results)
(map first))]
(map results)
(map first))]
cash-drawer-shifts))
(defn fetch-page [request]
@@ -109,7 +108,7 @@
"Cash Drawer Shifts"]]
:title "Cash drawer shifts"
:entity-name "Cash drawer shift"
:query-schema query-schema
:query-schema query-schema
:route :pos-cash-drawer-shift-table
:headers [{:key "client"
:name "Client"
@@ -138,12 +137,11 @@
:sort-key "opened-cash"
:render #(some->> % :cash-drawer-shift/opened-cash (format "$%.2f"))}]}))
(def row* (partial helper/row* grid-page))
(def table* (partial helper/table* grid-page))
(def key->handler
(apply-middleware-to-all-handlers
(apply-middleware-to-all-handlers
{:pos-cash-drawer-shifts (helper/page-route grid-page)
:pos-cash-drawer-shift-table (helper/table-route grid-page)}
(fn [h]

View File

@@ -5,30 +5,30 @@
[auto-ap.ssr.svg :as svg]))
(defn date-range-field* [request]
(dr/date-range-field {:value {:start (:start-date (:query-params request))
:end (:end-date (:query-params request))}
:id "date-range"}))
:end (:end-date (:query-params request))}
:id "date-range"}))
(defn processor-field* [request]
(com/field {:label "Processor"}
(com/radio-card {:size :small
:name "processor"
:value (:processor (:query-params request))
:options [{:value ""
:content "All"}
{:value "square"
:content [:div.flex.space-x-2 [:img.align-center {:src "/img/square.png" :style {:width "16px" :height "16px"}}] [:div "Square"]]}
{:value "doordash"
:content [:div.flex.space-x-2 [:img.align-center {:src "/img/doordash.png" :style {:width "16px" :height "16px"}}] [:div "Doordash"]]}
{:value "uber-eats"
:content [:div.flex.space-x-2 [:img.align-center {:src "/img/ubereats.png" :style {:width "16px" :height "16px"}}] [:div "Uber eats"]]}
{:value "grubhub"
:content [:div.flex.space-x-2 [:img.align-center {:src "/img/grubhub.png" :style {:width "16px" :height "16px"}}] [:div "Grubhub"]]}
{:value "koala"
:content [:div.flex.space-x-2 [:img.align-center {:src "/img/koala.png" :style {:width "16px" :height "16px"}}] [:div "Koala"]]}
{:value "ezcater"
:content [:div.flex.space-x-2 [:img.align-center {:src "/img/ezcater.png" :style {:width "16px" :height "16px"}}] [:div "EZCater"]]}
{:value "na"
:content "No Processor"}]})))
:name "processor"
:value (:processor (:query-params request))
:options [{:value ""
:content "All"}
{:value "square"
:content [:div.flex.space-x-2 [:img.align-center {:src "/img/square.png" :style {:width "16px" :height "16px"}}] [:div "Square"]]}
{:value "doordash"
:content [:div.flex.space-x-2 [:img.align-center {:src "/img/doordash.png" :style {:width "16px" :height "16px"}}] [:div "Doordash"]]}
{:value "uber-eats"
:content [:div.flex.space-x-2 [:img.align-center {:src "/img/ubereats.png" :style {:width "16px" :height "16px"}}] [:div "Uber eats"]]}
{:value "grubhub"
:content [:div.flex.space-x-2 [:img.align-center {:src "/img/grubhub.png" :style {:width "16px" :height "16px"}}] [:div "Grubhub"]]}
{:value "koala"
:content [:div.flex.space-x-2 [:img.align-center {:src "/img/koala.png" :style {:width "16px" :height "16px"}}] [:div "Koala"]]}
{:value "ezcater"
:content [:div.flex.space-x-2 [:img.align-center {:src "/img/ezcater.png" :style {:width "16px" :height "16px"}}] [:div "EZCater"]]}
{:value "na"
:content "No Processor"}]})))
(defn total-field* [request]
(com/field {:label "Total"}
@@ -40,7 +40,7 @@
:value (:total-gte (:query-params request))
:placeholder "0.01"
:size :small})
[:div.align-baseline
[:div.align-baseline
"to"]
(com/money-input {:name "total-lte"
:hx-preserve "true"
@@ -52,7 +52,7 @@
(defn exact-match-id-field* [request]
(when-let [exact-match-id (:exact-match-id (:query-params request))]
[:div
[:div
(com/field {:label "Exact match"}
(com/pill {:color :primary}
[:span.inline-flex.gap-2

View File

@@ -33,7 +33,6 @@
[:processor {:optional true} [:maybe (ref->enum-schema "ccp-processor")]]]
default-grid-fields-schema)]))
(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
@@ -42,7 +41,7 @@
"hx-indicator" "#expected-deposit-table"
#_#_:hx-disabled-elt "find fieldset"}
[:fieldset.space-y-6
[:fieldset.space-y-6
(date-range-field* request)
(exact-match-id-field* request)]])
@@ -70,26 +69,25 @@
(some-> (:start-date query-params) c/to-date)
(some-> (:end-date query-params) c/to-date)]]}
(:sort query-params) (add-sorter-fields {"client" ['[?e :expected-deposit/client ?c]
'[?c :client/name ?sort-client]]
"location" ['[?e :expected-deposit/location ?sort-location]]
"date" ['[?e :expected-deposit/date ?sort-date]]
"total" ['[?e :expected-deposit/total ?sort-total]]
"fee" ['[?e :expected-deposit/fee ?sort-fee]]}
query-params)
'[?c :client/name ?sort-client]]
"location" ['[?e :expected-deposit/location ?sort-location]]
"date" ['[?e :expected-deposit/date ?sort-date]]
"total" ['[?e :expected-deposit/total ?sort-total]]
"fee" ['[?e :expected-deposit/fee ?sort-fee]]}
query-params)
(:exact-match-id query-params)
(merge-query {:query {:in ['?e]
:where []}
:args [(:exact-match-id query-params)]})
(:total-gte query-params)
(:total-gte query-params)
(merge-query {:query {:in ['?total-gte]
:where ['[?e :expected-deposit/total ?a]
'[(>= ?a ?total-gte)]]}
:args [(:total-gte query-params)]})
(:total-lte query-params)
(:total-lte query-params)
(merge-query {:query {:in ['?total-lte]
:where ['[?e :expected-deposit/total ?a]
'[(<= ?a ?total-lte)]]}
@@ -104,7 +102,7 @@
true
(merge-query {:query {:find ['?sort-default '?e]
:where ['[?e :expected-deposit/date ?sort-default]]}}))]
(cond->> (query2 query)
true (apply-sort-3 query-params)
true (apply-pagination query-params))))
@@ -113,25 +111,25 @@
(let [results (->> (pull-many db default-read ids)
(group-by :db/id))
payments (->> ids
(map results)
(map first)
(map (fn get-totals [ed]
(assoc ed :totals
(->> (dc/q '[:find ?d4 (count ?c) (sum ?a)
:in $ ?ed
:where [?ed :expected-deposit/charges ?c]
[?c :charge/total ?a]
[?o :sales-order/charges ?c]
[?o :sales-order/date ?d]
[(clj-time.coerce/from-date ?d) ?d2]
[(auto-ap.time/localize ?d2) ?d3]
[(clj-time.coerce/to-local-date ?d3) ?d4]]
(dc/db conn)
(:db/id ed))
(map (fn [[date count amount]]
{:date (c/to-date-time date)
:count count
:amount amount})))))))]
(map results)
(map first)
(map (fn get-totals [ed]
(assoc ed :totals
(->> (dc/q '[:find ?d4 (count ?c) (sum ?a)
:in $ ?ed
:where [?ed :expected-deposit/charges ?c]
[?c :charge/total ?a]
[?o :sales-order/charges ?c]
[?o :sales-order/date ?d]
[(clj-time.coerce/from-date ?d) ?d2]
[(auto-ap.time/localize ?d2) ?d3]
[(clj-time.coerce/to-local-date ?d3) ?d4]]
(dc/db conn)
(:db/id ed))
(map (fn [[date count amount]]
{:date (c/to-date-time date)
:count count
:amount amount})))))))]
payments))
(defn fetch-page [args]
@@ -142,66 +140,64 @@
matching-count]))
(def grid-page
(helper/build
{:id "expected-deposit-table"
:nav com/main-aside-nav
:page-specific-nav filters
:fetch-page fetch-page
:oob-render
(fn [request]
[(assoc-in (date-range-field* request) [1 :hx-swap-oob] true)])
:breadcrumbs [[:a {:href (bidi/path-for ssr-routes/only-routes
:company)}
"POS"]
(helper/build
{:id "expected-deposit-table"
:nav com/main-aside-nav
:page-specific-nav filters
:fetch-page fetch-page
:oob-render
(fn [request]
[(assoc-in (date-range-field* request) [1 :hx-swap-oob] true)])
:breadcrumbs [[:a {:href (bidi/path-for ssr-routes/only-routes
:company)}
"POS"]
[:a {:href (bidi/path-for ssr-routes/only-routes
:pos-expected-deposits)}
"Expected deposits"]]
:title "Expected deposits"
:entity-name "Expected deposit"
:query-schema query-schema
:route :pos-expected-deposit-table
:row-buttons (fn [_ e]
[
(when (:expected-deposit/reference-link e)
(com/a-icon-button {:href (:expected-deposit/reference-link e)}
svg/external-link))
(when-let [transaction-id (-> e (:transaction/_expected-deposit) first :db/id)]
(com/a-button {:href (str (bidi/path-for ssr-routes/only-routes
::transaction-routes/all-page)
"?exact-match-id="
transaction-id)} "Transaction"))])
:headers [{:key "client"
:name "Client"
:sort-key "client"
:hide? (fn [args]
(= (count (:clients args)) 1))
:render #(-> % :expected-deposit/client :client/code)}
{:key "date"
:name "Date"
:sort-key "date"
:render #(atime/unparse-local (:expected-deposit/date %) atime/standard-time)}
{:key "sales-date"
:name "Sales Date"
:sort-key "sales-date"
:render #(atime/unparse-local (:expected-deposit/sales-date %) atime/standard-time)}
{:key "total"
:name "Total"
:sort-key "total"
:render #(some->> % :expected-deposit/total (format "$%.2f"))}
{:key "fee"
:name "Fee"
:sort-key "fee"
:render #(some->> % :expected-deposit/fee (format "$%.2f"))}]}))
[:a {:href (bidi/path-for ssr-routes/only-routes
:pos-expected-deposits)}
"Expected deposits"]]
:title "Expected deposits"
:entity-name "Expected deposit"
:query-schema query-schema
:route :pos-expected-deposit-table
:row-buttons (fn [_ e]
[(when (:expected-deposit/reference-link e)
(com/a-icon-button {:href (:expected-deposit/reference-link e)}
svg/external-link))
(when-let [transaction-id (-> e (:transaction/_expected-deposit) first :db/id)]
(com/a-button {:href (str (bidi/path-for ssr-routes/only-routes
::transaction-routes/all-page)
"?exact-match-id="
transaction-id)} "Transaction"))])
:headers [{:key "client"
:name "Client"
:sort-key "client"
:hide? (fn [args]
(= (count (:clients args)) 1))
:render #(-> % :expected-deposit/client :client/code)}
{:key "date"
:name "Date"
:sort-key "date"
:render #(atime/unparse-local (:expected-deposit/date %) atime/standard-time)}
{:key "sales-date"
:name "Sales Date"
:sort-key "sales-date"
:render #(atime/unparse-local (:expected-deposit/sales-date %) atime/standard-time)}
{:key "total"
:name "Total"
:sort-key "total"
:render #(some->> % :expected-deposit/total (format "$%.2f"))}
{:key "fee"
:name "Fee"
:sort-key "fee"
:render #(some->> % :expected-deposit/fee (format "$%.2f"))}]}))
(def row* (partial helper/row* grid-page))
(def table* (partial helper/table* grid-page))
(def key->handler
(apply-middleware-to-all-handlers
{:pos-expected-deposits (helper/page-route grid-page)
:pos-expected-deposit-table (helper/table-route grid-page)}
:pos-expected-deposit-table (helper/table-route grid-page)}
(fn [h]
(-> h
(wrap-copy-qp-pqp)

View File

@@ -36,7 +36,7 @@
"hx-indicator" "#refund-table"
#_#_:hx-disabled-elt "find fieldset"}
[:fieldset.space-y-6
[:fieldset.space-y-6
(date-range-field* request)
(total-field* request)]])
@@ -54,7 +54,7 @@
:where '[[(iol-ion.query/scan-sales-refunds $ ?clients ?start-date ?end-date) [[?e _ ?sort-default] ...]]]}
:args [db [(:trimmed-clients request)
(some-> query-params :start-date c/to-date)
(some-> query-params :end-date c/to-date )]]}
(some-> query-params :end-date c/to-date)]]}
(:sort query-params) (add-sorter-fields {"client" ['[?e :sales-refund/client ?c]
'[?c :client/name ?sort-client]]
"date" ['[?e :sales-refund/date ?sort-date]]
@@ -68,13 +68,13 @@
:where []}
:args [(:exact-match-id query-params)]})
(:total-gte query-params)
(:total-gte query-params)
(merge-query {:query {:in ['?total-gte]
:where ['[?e :sales-refund/total ?a]
'[(>= ?a ?total-gte)]]}
:args [(:total-gte query-params)]})
(:total-lte query-params)
(:total-lte query-params)
(merge-query {:query {:in ['?total-lte]
:where ['[?e :sales-refund/total ?a]
'[(<= ?a ?total-lte)]]}
@@ -83,7 +83,7 @@
true
(merge-query {:query {:find ['?sort-default '?e]
:where ['[?e :sales-refund/date ?sort-default]]}}))]
(cond->> (query2 query)
true (apply-sort-3 query-params)
true (apply-pagination query-params))))
@@ -149,13 +149,13 @@
(def table* (partial helper/table* grid-page))
(def key->handler
(apply-middleware-to-all-handlers
(apply-middleware-to-all-handlers
{:pos-refunds (helper/page-route grid-page)
:pos-refund-table (helper/table-route grid-page)}
(fn [h]
(-> h
(wrap-copy-qp-pqp)
(wrap-apply-sort grid-page)
(wrap-merge-prior-hx)
(wrap-schema-enforce :query-schema query-schema)
(wrap-schema-enforce :hx-schema query-schema)))))
(-> h
(wrap-copy-qp-pqp)
(wrap-apply-sort grid-page)
(wrap-merge-prior-hx)
(wrap-schema-enforce :query-schema query-schema)
(wrap-schema-enforce :hx-schema query-schema)))))

View File

@@ -36,29 +36,28 @@
(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
:pos-sales-table)
:pos-sales-table)
"hx-target" "#sales-table"
"hx-indicator" "#sales-table"
#_#_:hx-disabled-elt "find fieldset"}
[:fieldset.space-y-6
[:fieldset.space-y-6
(date-range-field* request)
(total-field* request)
[:div
(com/field {:label "Payment Method"}
(com/radio-card {:size :small
:name "payment-method"
:options [{:value ""
:content "All"}
{:value "CASH"
:content "Cash"}
{:value "CARD"
:content "Card"}
{:value "SQUARE_GIFT_CARD"
:content "Gift Card"}
{:value "OTHER"
:content "Other"}
]}))]
:name "payment-method"
:options [{:value ""
:content "All"}
{:value "CASH"
:content "Cash"}
{:value "CARD"
:content "Card"}
{:value "SQUARE_GIFT_CARD"
:content "Gift Card"}
{:value "OTHER"
:content "Other"}]}))]
[:div
(processor-field* request)]
@@ -87,8 +86,7 @@
:sales-order/source,
:sales-order/reference-link,
{:sales-order/client [:client/name :db/id :client/code]
:sales-order/charges [
:charge/type-name,
:sales-order/charges [:charge/type-name,
:charge/total,
:charge/tax,
:charge/tip,
@@ -125,13 +123,13 @@
:where []}
:args [(:exact-match-id query-params)]})
(:total-gte query-params)
(:total-gte query-params)
(merge-query {:query {:in ['?total-gte]
:where ['[?e :sales-order/total ?a]
'[(>= ?a ?total-gte)]]}
:args [(:total-gte query-params)]})
(:total-lte query-params)
(:total-lte query-params)
(merge-query {:query {:in ['?total-lte]
:where ['[?e :sales-order/total ?a]
'[(<= ?a ?total-lte)]]}
@@ -155,7 +153,6 @@
'[?chg :charge/processor ?processor]]}
:args [(:processor query-params)]})
true
(merge-query {:query {:find ['?sort-default '?e]}}))]
(clojure.pprint/pprint (update-in query [:args] #(drop 1 %)))
@@ -178,7 +175,6 @@
[(->> (hydrate-results ids-to-retrieve db request))
matching-count]))
(def grid-page
(helper/build
{:id "sales-table"
@@ -255,7 +251,6 @@
"OTHER" "other"
nil)))])}]}))
(def row* (partial helper/row* grid-page))
(def table* (partial helper/table* grid-page))

View File

@@ -158,13 +158,13 @@
[:span.text-sm account-name]
(com/pill {:color :red} "Missing acct"))
(com/a-icon-button {:class "p-1"
:hx-get (bidi/path-for ssr-routes/only-routes ::route/edit-item-account)
:hx-target "closest .account-cell"
:hx-swap "outerHTML"
:hx-vals (hx/json {:item-index (or (:item-index item) 0)
:client-id client-id
:current-account-id (or account-id "")})}
svg/pencil)]))
:hx-get (bidi/path-for ssr-routes/only-routes ::route/edit-item-account)
:hx-target "closest .account-cell"
:hx-swap "outerHTML"
:hx-vals (hx/json {:item-index (or (:item-index item) 0)
:client-id client-id
:current-account-id (or account-id "")})}
svg/pencil)]))
(defn account-edit-cell [{:keys [field-name-prefix client-id current-account-id]}]
(let [account-input-name (str field-name-prefix "[ledger-mapped/account]")]
@@ -172,23 +172,23 @@
(account-typeahead* {:name account-input-name
:value current-account-id
:client-id client-id})
[:div.flex.gap-1
(com/a-icon-button {:class "p-1"
:hx-put (bidi/path-for ssr-routes/only-routes ::route/save-item-account)
:hx-target "closest .account-cell"
:hx-swap "outerHTML"
:hx-include "closest .account-cell"
:hx-vals (hx/json {:field-name-prefix field-name-prefix
:client-id client-id})}
svg/check)
(com/a-icon-button {:class "p-1"
:hx-get (bidi/path-for ssr-routes/only-routes ::route/cancel-item-account)
:hx-target "closest .account-cell"
:hx-swap "outerHTML"
:hx-vals (hx/json {:field-name-prefix field-name-prefix
:client-id client-id
:current-account-id (or current-account-id "")})}
svg/x)]]))
[:div.flex.gap-1
(com/a-icon-button {:class "p-1"
:hx-put (bidi/path-for ssr-routes/only-routes ::route/save-item-account)
:hx-target "closest .account-cell"
:hx-swap "outerHTML"
:hx-include "closest .account-cell"
:hx-vals (hx/json {:field-name-prefix field-name-prefix
:client-id client-id})}
svg/check)
(com/a-icon-button {:class "p-1"
:hx-get (bidi/path-for ssr-routes/only-routes ::route/cancel-item-account)
:hx-target "closest .account-cell"
:hx-swap "outerHTML"
:hx-vals (hx/json {:field-name-prefix field-name-prefix
:client-id client-id
:current-account-id (or current-account-id "")})}
svg/x)]]))
(def grid-page
(helper/build {:id "entity-table"
@@ -576,8 +576,8 @@
[:span.text-gray-500 (truncate (:sales-summary-item/category item) 30)]
(account-display-cell {:item (assoc item :item-index actual-idx)
:field-name-prefix (str "step-params[sales-summary/items][" actual-idx "]")
:client-id client-id})
[:span.ml-auto.font-mono.tabular-nums.text-gray-900 (format "$%,.2f" (:ledger-mapped/amount item))]]))
:client-id client-id})
[:span.ml-auto.font-mono.tabular-nums.text-gray-900 (format "$%,.2f" (:ledger-mapped/amount item))]]))
[:div.h-6]))]
[:div.mt-2.border-t.pt-1
(summary-total-display request)
@@ -619,13 +619,13 @@
[:span.text-gray-500 (truncate (:sales-summary-item/category item) 30)]
(account-display-cell {:item (assoc item :item-index actual-idx)
:field-name-prefix (str "step-params[sales-summary/items][" actual-idx "]")
:client-id client-id})
[:span.ml-auto.font-mono.tabular-nums.text-gray-900 (format "$%,.2f" (:ledger-mapped/amount item))]]))
:client-id client-id})
[:span.ml-auto.font-mono.tabular-nums.text-gray-900 (format "$%,.2f" (:ledger-mapped/amount item))]]))
[:div.h-6]))]
[:div.mt-2.border-t.pt-1
(summary-total-display request)
(unbalanced-display request)]]]
[:div.mt-4.border-t.pt-2
[:div.mt-4.border-t.pt-2
(fc/with-field :sales-summary/items
(com/data-grid-new-row {:colspan 2
:hx-get (bidi/path-for ssr-routes/only-routes ::route/new-summary-item)
@@ -761,16 +761,16 @@
::route/edit-wizard-navigate (-> mm/next-handler
(mm/wrap-wizard edit-wizard)
(mm/wrap-decode-multi-form-state))
::route/new-summary-item (-> (add-new-entity-handler [:step-params :sales-summary/items]
(fn render [cursor request]
(sales-summary-item-row*
{:value cursor
:client-id (:client-id (:query-params request))}))
(fn build-new-row [base _]
(assoc base :sales-summary-item/manual? true)))
(wrap-schema-enforce :query-schema [:map
[:client-id {:optional true}
[:maybe entity-id]]]))
::route/new-summary-item (-> (add-new-entity-handler [:step-params :sales-summary/items]
(fn render [cursor request]
(sales-summary-item-row*
{:value cursor
:client-id (:client-id (:query-params request))}))
(fn build-new-row [base _]
(assoc base :sales-summary-item/manual? true)))
(wrap-schema-enforce :query-schema [:map
[:client-id {:optional true}
[:maybe entity-id]]]))
::route/edit-item-account (-> edit-item-account
(wrap-schema-enforce :query-schema [:map
[:item-index nat-int?]

View File

@@ -29,7 +29,7 @@
"hx-indicator" "#tender-table"
#_#_:hx-disabled-elt "find fieldset"}
[:fieldset.space-y-6
[:fieldset.space-y-6
(date-range-field* request)
(processor-field* request)
(total-field* request)]])
@@ -79,13 +79,13 @@
:where []}
:args [(:exact-match-id query-params)]})
(:total-gte query-params)
(:total-gte query-params)
(merge-query {:query {:in ['?total-gte]
:where ['[?e :charge/total ?a]
'[(>= ?a ?total-gte)]]}
:args [(:total-gte query-params)]})
(:total-lte query-params)
(:total-lte query-params)
(merge-query {:query {:in ['?total-lte]
:where ['[?e :charge/total ?a]
'[(<= ?a ?total-lte)]]}
@@ -96,10 +96,9 @@
:where ['[?e :charge/processor ?processor]]}
:args [(:processor query-params)]})
true
(merge-query {:query {:find ['?sort-default '?e]}}))]
(cond->> (query2 query)
true (apply-sort-3 query-params)
true (apply-pagination query-params))))
@@ -121,63 +120,62 @@
(def grid-page
(helper/build
{:id "tender-table"
:nav com/main-aside-nav
:page-specific-nav filters
:fetch-page fetch-page
:oob-render
(fn [request]
[(assoc-in (date-range-field* request) [1 :hx-swap-oob] true)])
:breadcrumbs [[:a {:href (bidi/path-for ssr-routes/only-routes
:company)}
"POS"]
[:a {:href (bidi/path-for ssr-routes/only-routes
:pos-tenders)}
"Tenders"]]
:title "Tenders"
:entity-name "Tender"
:query-schema query-schema
:route :pos-tender-table
:row-buttons (fn [request e]
(when (:charge/reference-link e)
[(com/a-icon-button {:href (:charge/reference-link e)}
svg/external-link)]))
:headers [{:key "client"
:name "Client"
:sort-key "client"
:hide? (fn [request]
(= (count (:clients request)) 1))
:render #(-> % :charge/client :client/code)}
{:key "date"
:name "Date"
:sort-key "date"
:render #(atime/unparse-local (:charge/date %) atime/standard-time)}
{:key "total"
:name "Total"
:sort-key "total"
:render #(some->> % :charge/total (format "$%.2f"))}
{:key "processor"
:name "Processor"
:sort-key "processor"
:render (fn [sales-order]
(when (:charge/processor sales-order)
(com/pill {:color :primary }
(name (:charge/processor sales-order)))))}
{:key "tip"
:name "Tip"
:sort-key "tip"
:render #(some->> % :charge/tip (format "$%.2f"))}
{:key "links"
:name "Links"
:render (fn [entity]
(when-let [expected-deposit-id (some->> entity :expected-deposit/_charges first :db/id)]
[:a {:href (str (bidi/path-for ssr-routes/only-routes
:pos-expected-deposits)
"?exact-match-id=" expected-deposit-id)
:hx-boost "true"}
(com/pill {:color :secondary} "expected deposit")]))}]}))
{:id "tender-table"
:nav com/main-aside-nav
:page-specific-nav filters
:fetch-page fetch-page
:oob-render
(fn [request]
[(assoc-in (date-range-field* request) [1 :hx-swap-oob] true)])
:breadcrumbs [[:a {:href (bidi/path-for ssr-routes/only-routes
:company)}
"POS"]
[:a {:href (bidi/path-for ssr-routes/only-routes
:pos-tenders)}
"Tenders"]]
:title "Tenders"
:entity-name "Tender"
:query-schema query-schema
:route :pos-tender-table
:row-buttons (fn [request e]
(when (:charge/reference-link e)
[(com/a-icon-button {:href (:charge/reference-link e)}
svg/external-link)]))
:headers [{:key "client"
:name "Client"
:sort-key "client"
:hide? (fn [request]
(= (count (:clients request)) 1))
:render #(-> % :charge/client :client/code)}
{:key "date"
:name "Date"
:sort-key "date"
:render #(atime/unparse-local (:charge/date %) atime/standard-time)}
{:key "total"
:name "Total"
:sort-key "total"
:render #(some->> % :charge/total (format "$%.2f"))}
{:key "processor"
:name "Processor"
:sort-key "processor"
:render (fn [sales-order]
(when (:charge/processor sales-order)
(com/pill {:color :primary}
(name (:charge/processor sales-order)))))}
{:key "tip"
:name "Tip"
:sort-key "tip"
:render #(some->> % :charge/tip (format "$%.2f"))}
{:key "links"
:name "Links"
:render (fn [entity]
(when-let [expected-deposit-id (some->> entity :expected-deposit/_charges first :db/id)]
[:a {:href (str (bidi/path-for ssr-routes/only-routes
:pos-expected-deposits)
"?exact-match-id=" expected-deposit-id)
:hx-boost "true"}
(com/pill {:color :secondary} "expected deposit")]))}]}))
(def row* (partial helper/row* grid-page))
(def table* (partial helper/table* grid-page))