progress for sales
This commit is contained in:
@@ -11,11 +11,11 @@
|
||||
[bidi.bidi :as bidi]
|
||||
[clj-time.coerce :as coerce]))
|
||||
|
||||
;; TODO more filters
|
||||
;; TODO refunds
|
||||
;; TODO expected deposits
|
||||
;; TODO navigate between pages shouldnt copy sort if not applicable
|
||||
;; TODO remove sort button should work
|
||||
;; TODO loading screen
|
||||
;; TODO default date range
|
||||
;; always should be fast
|
||||
|
||||
(defn filters [params]
|
||||
[:form {"hx-trigger" "change delay:1000ms"
|
||||
@@ -33,11 +33,84 @@
|
||||
(com/date-input {:name "end-date"
|
||||
:value (:end-date (:parsed-query-params params))
|
||||
:placeholder "Date"}))]
|
||||
[:div
|
||||
[:div
|
||||
(com/field {:label "Total"}
|
||||
(com/money-input {:name "total-gte"
|
||||
:value (:total-gte (:parsed-query-params params))
|
||||
:placeholder "Total >="}))]]])
|
||||
[:div.flex.space-x-4.items-baseline
|
||||
(com/money-input {:name "total-gte"
|
||||
:value (:total-gte (:parsed-query-params params))
|
||||
:placeholder "0.01"})
|
||||
[:div.align-baseline
|
||||
"to"]
|
||||
(com/money-input {:name "total-lte"
|
||||
:value (:total-lte (:parsed-query-params params))
|
||||
:placeholder "9999.34"})])]
|
||||
[:div
|
||||
(com/field {:label "Payment Method"}
|
||||
(com/radio {:name "payment-method"
|
||||
:options [{:value "all"
|
||||
:content "All"}
|
||||
{:value "cash"
|
||||
:content "Cash"}
|
||||
{:value "card"
|
||||
:content "Card"}
|
||||
{:value "gift-card"
|
||||
:content "Gift Card"}
|
||||
{:value "other"
|
||||
:content "Other"}
|
||||
]}))]
|
||||
[:div
|
||||
|
||||
(com/field {:label "Processor"}
|
||||
(com/radio {:name "processor"
|
||||
: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"}
|
||||
]}))]
|
||||
|
||||
[:div
|
||||
(com/field {:label "Total"}
|
||||
(com/text-input {:name "category"
|
||||
:value (:category (:parsed-query-params params))
|
||||
:placeholder "Fries"}))]]])
|
||||
|
||||
(defn args->graphql-params [args]
|
||||
{:clients (:clients args)
|
||||
:start (:start (:parsed-query-params args))
|
||||
:sort (:sort (:parsed-query-params args))
|
||||
:per-page (:per-page (:parsed-query-params args))
|
||||
:category (not-empty (:category (:parsed-query-params args)))
|
||||
:date-range {:start (some-> args
|
||||
:raw-query-params
|
||||
(get "start-date")
|
||||
(atime/parse atime/iso-date))
|
||||
:end (some-> args
|
||||
:raw-query-params
|
||||
(get "end-date")
|
||||
(atime/parse atime/iso-date))}
|
||||
:total-gte (some-> args :raw-query-params (get "total-gte") not-empty (#(if (string? %) (Double/parseDouble %) (double %))))
|
||||
:total-lte (some-> args :raw-query-params (get "total-lte") not-empty (#(if (string? %) (Double/parseDouble %) (double %))))
|
||||
:type-name (condp = (:payment-method (:parsed-query-params args))
|
||||
"cash" "CASH"
|
||||
"" nil
|
||||
"all" nil
|
||||
"card" "CARD"
|
||||
"gift-card" "SQUARE_GIFT_CARD"
|
||||
"other" "OTHER"
|
||||
nil)
|
||||
:processor (some-> args :parsed-query-params :processor not-empty keyword)})
|
||||
|
||||
(def grid-page {:id "sales-table"
|
||||
:nav (com/main-aside-nav)
|
||||
@@ -45,31 +118,27 @@
|
||||
:id-fn :db/id
|
||||
:fetch-page (fn [user args]
|
||||
(d-sales/get-graphql
|
||||
{:clients (:clients args)
|
||||
:start (:start (:parsed-query-params args))
|
||||
:sort (:sort (:parsed-query-params args))
|
||||
:per-page (:per-page (:parsed-query-params args))
|
||||
:date-range {:start (some-> args
|
||||
:raw-query-params
|
||||
(get "start-date")
|
||||
(atime/parse atime/iso-date))
|
||||
:end (some-> args
|
||||
:raw-query-params
|
||||
(get "end-date")
|
||||
(atime/parse atime/iso-date))}
|
||||
:total-gte (some-> args :raw-query-params (get "total-gte") not-empty (#(if (string? %) (Double/parseDouble %) (double %)))) }))
|
||||
(args->graphql-params args)
|
||||
))
|
||||
:breadcrumbs [[:a {:href (bidi/path-for ssr-routes/only-routes
|
||||
:company)}
|
||||
"POS"]
|
||||
"POS"]
|
||||
|
||||
[:a {:href (bidi/path-for ssr-routes/only-routes
|
||||
:pos-sales)}
|
||||
"Sales"]]
|
||||
[:a {:href (bidi/path-for ssr-routes/only-routes
|
||||
:pos-sales)}
|
||||
"Sales"]]
|
||||
:title "Sales orders"
|
||||
:entity-name "Sales orders"
|
||||
:route :pos-sales-table
|
||||
:action-buttons (fn [user _]
|
||||
nil)
|
||||
:action-buttons (fn [user args]
|
||||
(let [{:keys [total tax]} (d-sales/summarize-graphql (args->graphql-params args))]
|
||||
[
|
||||
(com/pill {:color :primary}
|
||||
(format "Total $%.2f" total)
|
||||
)
|
||||
(com/pill {:color :secondary}
|
||||
(format "Tax $%.2f" tax )
|
||||
)]))
|
||||
:row-buttons (fn [user e]
|
||||
|
||||
(when (:sales-order/reference-link e)
|
||||
@@ -82,42 +151,42 @@
|
||||
:hx-target "closest tr"}
|
||||
svg/trash))]))
|
||||
:headers [
|
||||
{:key "client"
|
||||
:name "Client"
|
||||
:sort-key "client"
|
||||
:hide? (fn [args]
|
||||
(= (count (:clients args)) 1))
|
||||
:render #(-> % :sales-order/client :client/code)}
|
||||
{:key "date"
|
||||
:name "Date"
|
||||
:sort-key "date"
|
||||
:render #(atime/unparse-local (:sales-order/date %) atime/standard-time)}
|
||||
{:key "source"
|
||||
:name "Source"
|
||||
:sort-key "source"
|
||||
:render (fn [sales-order]
|
||||
(when (:sales-order/source sales-order)
|
||||
(com/pill {:color :primary }
|
||||
(:sales-order/source sales-order))))}
|
||||
{:key "total"
|
||||
:name "Total"
|
||||
:sort-key "total"
|
||||
:render #(some->> % :sales-order/total (format "$%.2f"))}
|
||||
{:key "tax"
|
||||
:name "Tax"
|
||||
:sort-key "tax"
|
||||
:render #(some->> % :sales-order/tax (format "$%.2f"))}
|
||||
{:key "tip"
|
||||
:name "Tip"
|
||||
:sort-key "tip"
|
||||
:render #(some->> % :sales-order/tip (format "$%.2f"))}
|
||||
{:key "Payment methods"
|
||||
:name "Payment Methods"
|
||||
:render (fn [sales-order]
|
||||
(println )
|
||||
(for [method (->> sales-order :sales-order/charges (map :charge/type-name) set)]
|
||||
(com/pill {:color :primary }
|
||||
method)))}]})
|
||||
{:key "client"
|
||||
:name "Client"
|
||||
:sort-key "client"
|
||||
:hide? (fn [args]
|
||||
(= (count (:clients args)) 1))
|
||||
:render #(-> % :sales-order/client :client/code)}
|
||||
{:key "date"
|
||||
:name "Date"
|
||||
:sort-key "date"
|
||||
:render #(atime/unparse-local (:sales-order/date %) atime/standard-time)}
|
||||
{:key "source"
|
||||
:name "Source"
|
||||
:sort-key "source"
|
||||
:render (fn [sales-order]
|
||||
(when (:sales-order/source sales-order)
|
||||
(com/pill {:color :primary }
|
||||
(:sales-order/source sales-order))))}
|
||||
{:key "total"
|
||||
:name "Total"
|
||||
:sort-key "total"
|
||||
:render #(some->> % :sales-order/total (format "$%.2f"))}
|
||||
{:key "tax"
|
||||
:name "Tax"
|
||||
:sort-key "tax"
|
||||
:render #(some->> % :sales-order/tax (format "$%.2f"))}
|
||||
{:key "tip"
|
||||
:name "Tip"
|
||||
:sort-key "tip"
|
||||
:render #(some->> % :sales-order/tip (format "$%.2f"))}
|
||||
{:key "Payment methods"
|
||||
:name "Payment Methods"
|
||||
:render (fn [sales-order]
|
||||
(println )
|
||||
(for [method (->> sales-order :sales-order/charges (map :charge/type-name) set)]
|
||||
(com/pill {:color :primary }
|
||||
method)))}]})
|
||||
|
||||
(def row* (partial helper/row* grid-page))
|
||||
(def table* (partial helper/table* grid-page))
|
||||
|
||||
Reference in New Issue
Block a user