Makes print checks basically work.
This commit is contained in:
@@ -11,7 +11,7 @@
|
||||
:aws-access-key-id "AKIAINHACMVQJ6NYD26A"
|
||||
:aws-secret-access-key "FwdL4TbIC/5H/4mwhQy4iSI/eSewyPgfS1EEt6tL"
|
||||
:aws-region "us-east-1"
|
||||
:datomic-url "datomic:dev://localhost:4334/dev2"
|
||||
:datomic-url "datomic:dev://localhost:4334/prod-migration2"
|
||||
:invoice-import-queue-url "https://sqs.us-east-1.amazonaws.com/679918342773/integreat-mail-staging"
|
||||
:background-task-definition "integreat_background-worker_prod"
|
||||
:requests-queue-url "https://sqs.us-east-1.amazonaws.com/679918342773/integreat-background-request-prod"
|
||||
|
||||
3246
package-lock.json
generated
3246
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@@ -135,6 +135,14 @@
|
||||
display: inherit;
|
||||
}
|
||||
|
||||
.htmx-request .htmx-indicator-invisible {
|
||||
visibility: hidden !important;
|
||||
}
|
||||
|
||||
.htmx-indicator-invisible {
|
||||
display: inherit;
|
||||
}
|
||||
|
||||
.htmx-swapping .fade-out {
|
||||
opacity: 0.0 !important;
|
||||
}
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -570,7 +570,6 @@
|
||||
|
||||
(defn get-all-payments [context args _]
|
||||
(assert-admin (:id context))
|
||||
(println "HERE")
|
||||
(map
|
||||
->graphql
|
||||
(first (d-checks/get-graphql (assoc (<-graphql (assoc args :clients (:clients context))) :count Integer/MAX_VALUE)))))
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
[auto-ap.logging :as alog]
|
||||
[auto-ap.time :as atime]
|
||||
[buddy.auth :refer [throw-unauthorized]]
|
||||
[cheshire.core :as cheshire]
|
||||
[clj-time.coerce :as coerce]
|
||||
[clojure.set :as set]
|
||||
[clojure.string :as str]
|
||||
@@ -11,8 +10,8 @@
|
||||
[com.brunobonacci.mulog :as mu]
|
||||
[com.walmartlabs.lacinia.util :refer [attach-resolvers]]
|
||||
[datomic.api :as dc]
|
||||
[hiccup2.core :as hiccup]
|
||||
[iol-ion.query :refer [entid]]))
|
||||
[iol-ion.query :refer [entid]]
|
||||
[slingshot.slingshot :refer [throw+]]))
|
||||
|
||||
|
||||
(defn snake->kebab [s]
|
||||
@@ -196,12 +195,22 @@
|
||||
user-client-ids)))
|
||||
|
||||
(defn exception->notification [f]
|
||||
(try
|
||||
(f)
|
||||
(catch Throwable e
|
||||
(throw (ex-info (.getMessage e)
|
||||
{:type :notification}
|
||||
e)))))
|
||||
|
||||
(defn exception->4xx [f]
|
||||
(try
|
||||
(f)
|
||||
(catch Throwable e
|
||||
(throw (ex-info (.getMessage e)
|
||||
{:type :notification}
|
||||
e)))))
|
||||
(throw+ (ex-info (.getMessage e) {:type :form-validation
|
||||
:form-validation-errors [(.getMessage e)]}))
|
||||
#_(throw (ex-info (.getMessage e)
|
||||
{:type :notification}
|
||||
e)))))
|
||||
|
||||
(defn notify-if-locked [client-id date]
|
||||
(try
|
||||
|
||||
@@ -88,7 +88,7 @@
|
||||
|
||||
[:button (update params
|
||||
:class #(cond-> %
|
||||
true (str " focus:ring-4 font-bold rounded-lg text-xs p-3 text-center mr-2 inline-flex items-center justify-center"
|
||||
true (str " focus:ring-4 font-bold rounded-lg text-xs p-3 text-center mr-2 inline-flex items-center relative justify-center"
|
||||
(bg-colors (:color params) (:disabled params)))
|
||||
|
||||
(not (:disabled params))
|
||||
@@ -102,11 +102,11 @@
|
||||
|
||||
(nil? (:color params))
|
||||
(str " bg-white dark:bg-gray-600 border-gray-300 dark:border-gray-700 text-gray-500 hover:text-gray-800 dark:text-gray-400 dark:hover:text-gray-100 font-medium border border-gray-300 dark:border-gray-700")))
|
||||
[:div.htmx-indicator.flex.items-center
|
||||
[:div.htmx-indicator.flex.items-center.absolute.inset-0.justify-center
|
||||
(svg/spinner {:class "inline w-4 h-4 text-white"})
|
||||
(when (not (:minimal-loading? params))
|
||||
[:div.ml-3 "Loading..."])]
|
||||
(into [:div.htmx-indicator-hidden.inline-flex.gap-2.items-center.justify-center] children)])
|
||||
(into [:div.htmx-indicator-invisible.inline-flex.gap-2.items-center.justify-center] children)])
|
||||
|
||||
(defn a-button- [params & children]
|
||||
[:a (-> params
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
[:div (-> params
|
||||
(assoc "@click.outside" "open=false")
|
||||
(dissoc :handle-unexpected-error?)
|
||||
(update :class (fnil hh/add-class "") "w-full h-full modal-stack"))
|
||||
(update :class (fnil hh/add-class "") ""))
|
||||
children])
|
||||
|
||||
(defn modal-card- [params header content footer]
|
||||
@@ -47,11 +47,11 @@
|
||||
children])
|
||||
|
||||
(defn modal-body- [params & children]
|
||||
[:div {:class "px-6 py-2 space-y-6 overflow-y-scroll w-full shrink"}
|
||||
[:div {:class "px-6 py-2 space-y-6 overflow-y-scroll w-full shrink grow"}
|
||||
children])
|
||||
|
||||
(defn modal-footer- [params & children]
|
||||
[:div {:class "p-4"}
|
||||
[:div {:class "p-4 border-t"}
|
||||
[:span.items-center.bg-red-100.text-red-800.text-xs.font-medium.mb-2.p-1.rounded-full.inline-flex
|
||||
(hx/alpine-appear {:x-show "unexpectedError" :class "dark:bg-red-900 dark:text-red-300"})
|
||||
[:span {:class "w-2 h-2 bg-red-500 rounded-full"}]
|
||||
@@ -61,5 +61,5 @@
|
||||
|
||||
(defn modal-card-advanced- [params & children]
|
||||
[:div (merge params
|
||||
{:class (hh/add-class "bg-white rounded-lg shadow dark:bg-gray-700 dark:text-white modal-content flex flex-col h-full" (:class params "")) })
|
||||
{:class (hh/add-class "bg-white rounded-lg shadow dark:bg-gray-700 dark:text-white modal-content flex flex-col max-h-screen max-w-screen" (:class params "")) })
|
||||
children])
|
||||
|
||||
@@ -30,8 +30,7 @@
|
||||
:hx-target-400 "#form-errors .error-content"
|
||||
:hx-trigger "submit"
|
||||
:hx-target "this"
|
||||
"x-trap" "true"
|
||||
:class "h-full w-full"})
|
||||
"x-trap" "true" })
|
||||
|
||||
(defprotocol ModalWizardStep
|
||||
(step-key [this])
|
||||
@@ -114,12 +113,13 @@
|
||||
:to (encode-step-key (step-key (get-step linear-wizard n)))})}
|
||||
(step-name (get-step linear-wizard n))])))))
|
||||
(defn back-button [linear-wizard step validation-route]
|
||||
[:a.cursor-pointer.whitespace-nowrap {:hx-put (hu/url (bidi/path-for ssr-routes/only-routes validation-route)
|
||||
[:a.cursor-pointer.whitespace-nowrap.font-medium.text-blue-600 {:hx-put (hu/url (bidi/path-for ssr-routes/only-routes validation-route)
|
||||
{:from (encode-step-key (step-key step))
|
||||
:to (encode-step-key (->> (partition-all 2 1 (steps linear-wizard))
|
||||
(filter (fn [[from to]]
|
||||
(= to (step-key step))))
|
||||
ffirst))})}
|
||||
ffirst))})
|
||||
:class "dark:text-blue-500"}
|
||||
"Back"])
|
||||
|
||||
(defn default-next-button [linear-wizard step validation-route]
|
||||
@@ -146,7 +146,7 @@
|
||||
[:div.w-5.h-5 svg/arrow-right]))))
|
||||
|
||||
(defn default-step-body [params & children]
|
||||
[:div.space-y-1 {:class "w-[600px] h-[700px]"}
|
||||
[:div.space-y-1 {}
|
||||
children])
|
||||
|
||||
(defn default-step-footer [linear-wizard step & {:keys [validation-route
|
||||
@@ -174,11 +174,31 @@
|
||||
(let [is-last? (= (step-key step) (last (steps linear-wizard)))]
|
||||
(com/modal-card-advanced
|
||||
{"@keydown.enter.prevent.stop" "$refs.next.click()"
|
||||
:class (str (when is-last? "last-modal-step")
|
||||
" transition duration-300 ease-in-out
|
||||
:class (str
|
||||
"w-[750px] h-[600px]
|
||||
group-[.forward]/transition:htmx-swapping:opacity-0
|
||||
group-[.forward]/transition:htmx-swapping:-translate-x-1/4
|
||||
group-[.forward]/transition:htmx-swapping:scale-75
|
||||
group-[.forward]/transition:htmx-swapping:ease-in
|
||||
group-[.forward]/transition:htmx-added:opacity-0
|
||||
group-[.forward]/transition:htmx-added:scale-75
|
||||
group-[.forward]/transition:htmx-added:translate-x-1/4
|
||||
group-[.forward]/transition:htmx-added:ease-out
|
||||
|
||||
group-[.backward]/transition:htmx-swapping:opacity-0
|
||||
group-[.backward]/transition:htmx-swapping:translate-x-1/4
|
||||
group-[.backward]/transition:htmx-swapping:scale-75
|
||||
group-[.backward]/transition:htmx-swapping:ease-in
|
||||
group-[.backward]/transition:htmx-added:opacity-0
|
||||
group-[.backward]/transition:htmx-added:scale-75
|
||||
group-[.backward]/transition:htmx-added:-translate-x-1/4
|
||||
group-[.backward]/transition:htmx-added:ease-out
|
||||
opacity-100 translate-x-0 scale-100"
|
||||
(when is-last? "last-modal-step")
|
||||
" transition duration-150
|
||||
")
|
||||
":class" (hiccup/raw "{
|
||||
\"htmx-swapping:-translate-x-2/3 htmx-swapping:opacity-0 htmx-swapping:scale-0 htmx-added:translate-x-2/3 htmx-added:opacity-0 htmx-added:scale-0 scale-100 translate-x-0 opacity-100\": $data.transitionType=='forward',
|
||||
#_#_":class" (hiccup/raw "{
|
||||
\"htmx-added:opacity-0 opacity-100\": $data.transitionType=='forward',
|
||||
\"htmx-swapping:translate-x-2/3 htmx-swapping:opacity-0 htmx-swapping:scale-0 htmx-added:-translate-x-2/3 htmx-added:opacity-0 htmx-added:scale-0 scale-100 translate-x-0 opacity-100\": $data.transitionType=='backward'
|
||||
}
|
||||
")
|
||||
@@ -186,7 +206,7 @@
|
||||
(com/modal-header {}
|
||||
head)
|
||||
#_(com/modal-header-attachment {})
|
||||
[:div.flex.shrink
|
||||
[:div.flex.shrink.overflow-auto.grow
|
||||
[:div.grow-0.pr-6.pt-2.bg-gray-100.self-stretch #_{:style "margin-left:-20px"} (render-timeline linear-wizard step validation-route)]
|
||||
(com/modal-body {}
|
||||
body)]
|
||||
@@ -197,15 +217,9 @@
|
||||
(defn wrap-ensure-step [handler]
|
||||
(->
|
||||
(fn [{:keys [wizard multi-form-state] :as request}]
|
||||
|
||||
(println "ENSURE STEP")
|
||||
(clojure.pprint/pprint (:step-params (:multi-form-state request)))
|
||||
|
||||
(assert-schema (step-schema (get-current-step wizard)) (:step-params multi-form-state))
|
||||
(handler request))
|
||||
(wrap-form-4xx-2 (fn [{:keys [wizard] :as request}] ;; THIS MAY BE BETTER TO JUST MAKE THE LINEAR WIZARD POPULATE FROM THE REQUEST
|
||||
(println "FINAL")
|
||||
(clojure.pprint/pprint (:step-params (:multi-form-state request)))
|
||||
(html-response
|
||||
(render-wizard wizard request)
|
||||
:headers {"x-transition-type" "none"
|
||||
@@ -242,7 +256,7 @@
|
||||
(select-state
|
||||
(edit-path new-step request)
|
||||
(init-step-params- new-step request))))))
|
||||
:headers {"HX-reswap" (when transition-type "outerHTML swap:0.15s")
|
||||
:headers {"HX-reswap" (when transition-type "outerHTML swap:0.16s")
|
||||
"x-transition-type" (or transition-type "none")})))
|
||||
(wrap-ensure-step)
|
||||
(wrap-schema-enforce :query-schema
|
||||
@@ -260,7 +274,7 @@
|
||||
(render-wizard wizard
|
||||
(-> request
|
||||
(assoc :multi-form-state (discard-changes current-step multi-form-state))))
|
||||
:headers {"HX-reswap" (when transition-type "outerHTML swap:0.15s")
|
||||
:headers {"HX-reswap" (when transition-type "outerHTML swap:0.16s")
|
||||
"x-transition-type" (or transition-type "none")})))
|
||||
(wrap-schema-enforce :query-schema
|
||||
[:map
|
||||
@@ -319,8 +333,19 @@
|
||||
|
||||
(defn open-wizard-handler [{:keys [wizard current-step] :as request}]
|
||||
(modal-response
|
||||
[:div {:x-data (hx/json {"transitionType" "none"})
|
||||
"@htmx:after-request" "if(event.detail.xhr.getResponseHeader('x-transition-type')) { $data.transitionType = event.detail.xhr.getResponseHeader('x-transition-type');}"}
|
||||
[:div#transitioner.flex-1 {:x-data (hx/json {"transitionType" "none"})
|
||||
:x-ref "transitioner"
|
||||
:class ""
|
||||
"@htmx:after-request" "if(event.detail.xhr.getResponseHeader('x-transition-type')) {
|
||||
$refs.transitioner.classList.remove('forward')
|
||||
$refs.transitioner.classList.remove('backward');
|
||||
$refs.transitioner.classList.add('group/transition')
|
||||
$refs.transitioner.classList.add(event.detail.xhr.getResponseHeader('x-transition-type'));
|
||||
} else {
|
||||
|
||||
$refs.transitioner.classList.remove('group/transition')
|
||||
}
|
||||
"}
|
||||
(render-wizard wizard request)]))
|
||||
|
||||
|
||||
@@ -335,24 +360,6 @@
|
||||
(wrap-init-multi-form-state
|
||||
handler
|
||||
(fn parse-multi-form-state [request]
|
||||
(println "HERE WE ARE FULL")
|
||||
(clojure.pprint/pprint (:step-params (:form-params request)))
|
||||
(println "OK NOW")
|
||||
(clojure.pprint/pprint (:step-params (map->MultiStepFormState (mc/decode [:map
|
||||
[:snapshot {:optional true
|
||||
:decode/arbitrary
|
||||
#(clojure.edn/read-string {:readers clj-time.coerce/data-readers
|
||||
:eof nil}
|
||||
%)}
|
||||
[:maybe :any]]
|
||||
[:edit-path {:optional true :decode/arbitrary (fn [z]
|
||||
(clojure.edn/read-string z))} [:maybe [:sequential {:min 0} any?]]]
|
||||
[:step-params {:optional true}
|
||||
[:maybe
|
||||
:any]]]
|
||||
(:form-params request)
|
||||
main-transformer))))
|
||||
|
||||
(map->MultiStepFormState (mc/decode [:map
|
||||
[:snapshot {:optional true
|
||||
:decode/arbitrary
|
||||
@@ -368,7 +375,7 @@
|
||||
(:form-params request)
|
||||
main-transformer)))))
|
||||
|
||||
(comment
|
||||
#_(comment
|
||||
(def f {"snapshot"
|
||||
"{:invoices [{:invoice_id 17592297837035, :amount 23.0, :invoice {:db/id 17592297837035, :invoice/vendor {:db/id 17592186045722, :vendor/name \"Sysco\"}, :invoice/client {:db/id 17592232555238}, :invoice/outstanding-balance 23.0, :invoice/invoice-number \"702,34\"}} {:invoice_id 17592297837049, :amount 23.0, :invoice {:db/id 17592297837049, :invoice/vendor {:db/id 17592186045722, :vendor/name \"Sysco\"}, :invoice/client {:db/id 17592232555238}, :invoice/outstanding-balance 23.0, :invoice/invoice-number \"80[234234\"}}], :client 17592232555238}",
|
||||
"edit-path" "[]",
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
pull-many]]
|
||||
[auto-ap.graphql.checks :as gq-checks :refer [print-checks-internal]]
|
||||
[auto-ap.graphql.utils :refer [assert-can-see-client
|
||||
exception->4xx
|
||||
exception->notification
|
||||
extract-client-ids notify-if-locked]]
|
||||
[auto-ap.logging :as alog]
|
||||
@@ -593,15 +594,37 @@
|
||||
updated-count
|
||||
(count ids))})})))
|
||||
|
||||
(defn does-amount-exceed-outstanding? [amount outstanding-balance]
|
||||
(or (and (> outstanding-balance 0)
|
||||
(> amount outstanding-balance))
|
||||
(and (> outstanding-balance 0)
|
||||
(<= amount 0))
|
||||
(and (< outstanding-balance 0)
|
||||
(< amount outstanding-balance))
|
||||
(and (< outstanding-balance 0)
|
||||
(>= amount 0))))
|
||||
|
||||
(def payment-form-schema
|
||||
(mc/schema [:map
|
||||
[:client entity-id]
|
||||
[:invoices [:vector {:coerce? true}
|
||||
[:map
|
||||
[:invoice-id entity-id]
|
||||
[:amount money]]]]
|
||||
[:invoices [:and
|
||||
[:vector {:coerce? true}
|
||||
[:map
|
||||
[:invoice-id entity-id]
|
||||
[:amount money]]]
|
||||
[:fn {:error/message "All payments must not exceed their outstanding balance."}
|
||||
(fn [invoices]
|
||||
(let [outstanding-balances (->> (dc/q '[:find ?i ?ob
|
||||
:in $ [?i ...]
|
||||
:where [?i :invoice/outstanding-balance ?ob]]
|
||||
(dc/db conn)
|
||||
(map :invoice-id invoices))
|
||||
(into {}))]
|
||||
(every? #(not (does-amount-exceed-outstanding? (:amount %) (outstanding-balances (:invoice-id %))))
|
||||
invoices)))]]]
|
||||
[:bank-account entity-id]
|
||||
[:method :string]]))
|
||||
[:mode [:enum :simple :advanced]]
|
||||
[:method [:enum :debit :print-check :cash :handwrite-check]]]))
|
||||
|
||||
(defn bank-account-card-base [{:keys [bg-color text-color icon bank-account]}]
|
||||
[:div {:class "w-[30em] cursor-move"}
|
||||
@@ -631,20 +654,45 @@
|
||||
:data-key "vis"
|
||||
:class "bg-gray-100 dark:bg-gray-600 rounded-lg shadow-2xl w-max z-50 p-4"
|
||||
"@click.outside" "chosen=false"})
|
||||
(com/button {:color :primary
|
||||
:x-show "chosen"
|
||||
"@click.prevent.capture" "chosen=true"
|
||||
:hx-vals (hx/json {"step-params[bank-account]" (:db/id bank-account)})
|
||||
:hx-put (hu/url (bidi/path-for ssr-routes/only-routes ::route/pay-wizard-navigate)
|
||||
{:from (mm/encode-step-key :choose-method)
|
||||
:to (mm/encode-step-key :payment-details)})}
|
||||
"Print check")
|
||||
(com/button {:x-show "chosen"
|
||||
"@click.prevent.capture" "chosen=true"}
|
||||
"Debit")
|
||||
(com/button {:x-show "chosen"
|
||||
"@click.prevent.capture" "chosen=true"}
|
||||
"Handwrite check")]]])])
|
||||
(when (= :bank-account-type/check
|
||||
(:bank-account/type bank-account))
|
||||
(com/button {:color :primary
|
||||
:minimal-loading? true
|
||||
:hx-vals (hx/json {"step-params[bank-account]" (:db/id bank-account)
|
||||
"step-params[method]" "print-check"})
|
||||
:hx-put (hu/url (bidi/path-for ssr-routes/only-routes ::route/pay-wizard-navigate)
|
||||
{:from (mm/encode-step-key :choose-method)
|
||||
:to (mm/encode-step-key :payment-details)})}
|
||||
"Print check"))
|
||||
(when (= :bank-account-type/cash
|
||||
(:bank-account/type bank-account))
|
||||
(com/button {:minimal-loading? true
|
||||
:hx-vals (hx/json {"step-params[bank-account]" (:db/id bank-account)
|
||||
"step-params[method]" "cash"})
|
||||
:hx-put (hu/url (bidi/path-for ssr-routes/only-routes ::route/pay-wizard-navigate)
|
||||
{:from (mm/encode-step-key :choose-method)
|
||||
:to (mm/encode-step-key :payment-details)})}
|
||||
"With cash"))
|
||||
(when (not= :bank-account-type/cash
|
||||
(:bank-account/type bank-account))
|
||||
(com/button {:color (when (= :bank-account-type/credit
|
||||
(:bank-account/type bank-account))
|
||||
:primary)
|
||||
:minimal-loading? true
|
||||
:hx-vals (hx/json {"step-params[bank-account]" (:db/id bank-account)
|
||||
"step-params[method]" "debit"})
|
||||
:hx-put (hu/url (bidi/path-for ssr-routes/only-routes ::route/pay-wizard-navigate)
|
||||
{:from (mm/encode-step-key :choose-method)
|
||||
:to (mm/encode-step-key :payment-details)})}
|
||||
"Debit"))
|
||||
(when (= :bank-account-type/check (:bank-account/type bank-account))
|
||||
(com/button {:minimal-loading? true
|
||||
:hx-vals (hx/json {"step-params[bank-account]" (:db/id bank-account)
|
||||
"step-params[method]" "handwrite-check"})
|
||||
:hx-put (hu/url (bidi/path-for ssr-routes/only-routes ::route/pay-wizard-navigate)
|
||||
{:from (mm/encode-step-key :choose-method)
|
||||
:to (mm/encode-step-key :payment-details)})}
|
||||
"Handwrite check"))]]])])
|
||||
|
||||
|
||||
(defmulti bank-account-card (comp :bank-account/type))
|
||||
@@ -682,12 +730,12 @@
|
||||
[])
|
||||
|
||||
(step-schema [_]
|
||||
(mut/select-keys (mm/form-schema linear-wizard) #{:bank-account}))
|
||||
(mut/select-keys (mm/form-schema linear-wizard) #{:bank-account :method}))
|
||||
|
||||
(render-step [this request]
|
||||
(mm/default-render-step
|
||||
linear-wizard this
|
||||
:head [:div "Pay " (count (:invoices (:snapshot (:multi-form-state request))))]
|
||||
:head [:div.p-2 "Pay " (count (:invoices (:snapshot (:multi-form-state request)))) " invoices"]
|
||||
:body (mm/default-step-body
|
||||
{}
|
||||
(let [bank-accounts (->> (dc/q '[:find (pull ?ba [:bank-account/name :bank-account/sort-order :bank-account/visible
|
||||
@@ -704,8 +752,9 @@
|
||||
(for [ba bank-accounts]
|
||||
(bank-account-card ba))]))
|
||||
:footer
|
||||
(mm/default-step-footer linear-wizard this :validation-route ::route/navigate)
|
||||
:validation-route ::route/navigate)))
|
||||
nil
|
||||
#_(mm/default-step-footer linear-wizard this :validation-route ::route/navigate)
|
||||
:validation-route ::route/pay-wizard-navigate)))
|
||||
|
||||
(defrecord PaymentDetailsStep [linear-wizard]
|
||||
mm/ModalWizardStep
|
||||
@@ -723,51 +772,52 @@
|
||||
(render-step [this request]
|
||||
(mm/default-render-step
|
||||
linear-wizard this
|
||||
:head [:div "HI"]
|
||||
:head [:div.p-2 "Pay " (count (:invoices (:snapshot (:multi-form-state request)))) " invoices"]
|
||||
:body (mm/default-step-body
|
||||
{}
|
||||
[:div {}
|
||||
(com/radio-list {:x-model "mode"
|
||||
:name "mode"
|
||||
:name "step-params[mode]"
|
||||
:options [{:value "simple"
|
||||
:content "Pay in full"}
|
||||
{:value "advanced"
|
||||
:content "Customize payments"}]})
|
||||
[:div.space-y-4 (hx/alpine-appear {:x-show "mode==\"advanced\""})
|
||||
(fc/with-field :invoices
|
||||
(com/data-grid
|
||||
{:headers [(com/data-grid-header {} "Vendor")
|
||||
(com/data-grid-header {} "Invoice Number")
|
||||
(com/data-grid-header {:class "text-right"} "Total")
|
||||
(com/data-grid-header {:class "text-right"} "Pay")]}
|
||||
(fc/cursor-map
|
||||
(fn [i]
|
||||
(println fc/*current*)
|
||||
(com/data-grid-row
|
||||
{}
|
||||
(com/data-grid-cell
|
||||
(com/validated-field
|
||||
{:errors (fc/field-errors)}
|
||||
(com/data-grid
|
||||
{:headers [(com/data-grid-header {} "Vendor")
|
||||
(com/data-grid-header {} "Invoice Number")
|
||||
(com/data-grid-header {:class "text-right"} "Total")
|
||||
(com/data-grid-header {:class "text-right"} "Pay")]}
|
||||
(fc/cursor-map
|
||||
(fn [i]
|
||||
(com/data-grid-row
|
||||
{}
|
||||
(com/data-grid-cell
|
||||
{}
|
||||
|
||||
(-> (fc/field-value) :invoice :invoice/vendor :vendor/name))
|
||||
(com/data-grid-cell
|
||||
{}
|
||||
(fc/with-field :invoice-id
|
||||
(com/hidden {:name (fc/field-name)
|
||||
:value (fc/field-value)}))
|
||||
(-> (fc/field-value) :invoice :invoice/invoice-number))
|
||||
(com/data-grid-cell
|
||||
{:class "text-right"}
|
||||
(format "$%,.2f" (-> (fc/field-value) :invoice :invoice/outstanding-balance)))
|
||||
(com/data-grid-cell
|
||||
{:class "w-20"}
|
||||
(fc/with-field :amount
|
||||
(com/validated-field {:errors (fc/field-errors)}
|
||||
(com/money-input {:value (format "%.2f" (fc/field-value)) :class "w-20"
|
||||
:name (fc/field-name)
|
||||
:error? (fc/error?)})))))))))]])
|
||||
(-> (fc/field-value) :invoice :invoice/vendor :vendor/name))
|
||||
(com/data-grid-cell
|
||||
{}
|
||||
(fc/with-field :invoice-id
|
||||
(com/hidden {:name (fc/field-name)
|
||||
:value (fc/field-value)}))
|
||||
(-> (fc/field-value) :invoice :invoice/invoice-number))
|
||||
(com/data-grid-cell
|
||||
{:class "text-right"}
|
||||
(format "$%,.2f" (-> (fc/field-value) :invoice :invoice/outstanding-balance)))
|
||||
(com/data-grid-cell
|
||||
{:class "w-20"}
|
||||
(fc/with-field :amount
|
||||
(com/validated-field {:errors (fc/field-errors)}
|
||||
(com/money-input {:value (format "%.2f" (fc/field-value)) :class "w-20"
|
||||
:name (fc/field-name)
|
||||
:error? (fc/error?)}))))))))))]])
|
||||
:footer
|
||||
(mm/default-step-footer linear-wizard this :validation-route ::route/pay-wizard-navigate)
|
||||
:validation-route ::route/navigate)))
|
||||
:validation-route ::route/pay-wizard-navigate)))
|
||||
|
||||
|
||||
|
||||
@@ -786,29 +836,32 @@
|
||||
(render-wizard [this {:keys [multi-form-state] :as request}]
|
||||
|
||||
;; TODO should this be customized based off the selections they make?
|
||||
(let [invoices (->> (dc/q '[:find (pull ?i [{:invoice/vendor [:vendor/name :db/id]
|
||||
:invoice/client [:db/id]}
|
||||
:invoice/outstanding-balance
|
||||
:invoice/invoice-number
|
||||
:db/id])
|
||||
:in $ [?i ...]]
|
||||
(dc/db conn)
|
||||
(map :invoice-id (get-in request [:multi-form-state :step-params :invoices])))
|
||||
(map first)
|
||||
(sort-by (juxt (comp :invoice/vendor :vendor/name)
|
||||
:invoice/invoice-number)))
|
||||
request (update-in request [:multi-form-state :step-params :invoices]
|
||||
(fn [form-invoices]
|
||||
(mapv (fn [form-invoice i]
|
||||
(assoc form-invoice :invoice i)) form-invoices invoices)))]
|
||||
(clojure.pprint/pprint (:step-params (:multi-form-state request)))
|
||||
(mm/default-render-wizard
|
||||
this request
|
||||
:form-params
|
||||
(-> mm/default-form-props
|
||||
(assoc :hx-post
|
||||
(str (bidi/path-for ssr-routes/only-routes ::route/pay-submit)))
|
||||
(assoc :x-data (hx/json {:mode "simple"}))))))
|
||||
(let [invoices (->> (dc/q '[:find (pull ?i [{:invoice/vendor [:vendor/name :db/id]
|
||||
:invoice/client [:db/id]}
|
||||
:invoice/outstanding-balance
|
||||
:invoice/invoice-number
|
||||
:db/id])
|
||||
:in $ [?i ...]]
|
||||
(dc/db conn)
|
||||
(map :invoice-id (get-in request [:multi-form-state :step-params :invoices])))
|
||||
(map first)
|
||||
(sort-by (juxt (comp :invoice/vendor :vendor/name)
|
||||
:invoice/invoice-number)))
|
||||
request (update-in request [:multi-form-state :step-params :invoices]
|
||||
(fn [form-invoices]
|
||||
(mapv (fn [form-invoice i]
|
||||
(assoc form-invoice :invoice i)) form-invoices invoices)))]
|
||||
(mm/default-render-wizard
|
||||
this request
|
||||
:form-params
|
||||
(-> mm/default-form-props
|
||||
(assoc :hx-post
|
||||
(str (bidi/path-for ssr-routes/only-routes ::route/pay-submit)))
|
||||
(assoc :x-data (hx/json {:mode (some-> multi-form-state
|
||||
:step-params
|
||||
:mode
|
||||
name)}))))))
|
||||
|
||||
(steps [_]
|
||||
[:choose-method
|
||||
:payment-details])
|
||||
@@ -829,15 +882,21 @@
|
||||
payment-form-schema
|
||||
(:snapshot multi-form-state)
|
||||
mt/strip-extra-keys-transformer)
|
||||
result (print-checks-internal (map (fn [i] {:invoice-id (:invoice-id i)
|
||||
:amount (:amount i)})
|
||||
(:invoices snapshot))
|
||||
(:client snapshot)
|
||||
(:bank-account snapshot)
|
||||
:payment-type/check
|
||||
identity)]
|
||||
result (exception->4xx
|
||||
#(print-checks-internal (map (fn [i] {:invoice-id (:invoice-id i)
|
||||
:amount (:amount i)})
|
||||
(:invoices snapshot))
|
||||
(:client snapshot)
|
||||
(:bank-account snapshot)
|
||||
(cond (= :print-check (:method snapshot))
|
||||
:payment-type/check
|
||||
(= :debit (:method snapshot))
|
||||
:payment-type/debit
|
||||
(= :cash (:method snapshot))
|
||||
:payment-type/cash
|
||||
:else :payment-type/debit)
|
||||
identity))]
|
||||
(alog/info ::printed :result result)
|
||||
|
||||
(modal-response
|
||||
(com/modal {}
|
||||
(com/modal-card-advanced
|
||||
@@ -846,16 +905,10 @@
|
||||
(com/modal-body {}
|
||||
[:div.flex.flex-col.mt-4.space-y-4.items-center
|
||||
[:div.w-24.h-24.bg-green-50.rounded-full.p-4.text-green-300.animate-gg
|
||||
|
||||
svg/thumbs-up]
|
||||
[:div "Your checks are ready. Click "
|
||||
(com/link {:href (:pdf-url result)} "here")
|
||||
" to download."]]))))
|
||||
#_(html-response
|
||||
[:div]
|
||||
|
||||
:headers {"hx-trigger" (hx/json {:notification (str "Printed!")})}))))
|
||||
|
||||
" to download."]])))))))
|
||||
|
||||
(def pay-wizard
|
||||
(->PayWizard nil nil nil))
|
||||
@@ -892,14 +945,14 @@
|
||||
(sort-by (juxt (comp :invoice/vendor :vendor/name)
|
||||
:invoice/invoice-number)))]
|
||||
(mm/->MultiStepFormState {:invoices (mapv (fn [i] {:invoice-id (:db/id i)
|
||||
:amount (:invoice/outstanding-balance i) })
|
||||
:amount (:invoice/outstanding-balance i)})
|
||||
invoices)
|
||||
:mode :simple
|
||||
:client (-> invoices first :invoice/client :db/id)}
|
||||
[]
|
||||
{}))))
|
||||
#_(wrap-entity [:route-params :db/id] default-read)
|
||||
#_(wrap-schema-enforce :route-schema [:map [:db/id entity-id]]))
|
||||
{:mode :simple})))))
|
||||
::route/pay-submit (-> mm/submit-handler
|
||||
|
||||
(mm/wrap-wizard pay-wizard)
|
||||
(mm/wrap-decode-multi-form-state))
|
||||
::route/pay-wizard-navigate
|
||||
@@ -914,7 +967,4 @@
|
||||
(wrap-merge-prior-hx)
|
||||
(wrap-schema-enforce :query-schema query-schema)
|
||||
(wrap-schema-enforce :hx-schema query-schema)
|
||||
(wrap-client-redirect-unauthenticated)))))
|
||||
|
||||
|
||||
|
||||
(wrap-client-redirect-unauthenticated)))))
|
||||
@@ -109,7 +109,5 @@ input[type=number] {
|
||||
"x-transition:leave-start" "!opacity-100 !translate-y-0"
|
||||
"x-transition:leave-end" "!opacity-0 !translate-y-32"}
|
||||
|
||||
[:div.flex.items-center.justify-center.max-w-6xl {:class "min-w-[700px] max-h-full "}
|
||||
|
||||
[:div#modal-content.flex.flex-col.self-stretch {:class "min-w-[700px] md:p-12"} ;;.overflow-scroll
|
||||
]]]]]]]))
|
||||
[:div#modal-content.flex.items-center.justify-center {:class "md:p-12"}
|
||||
]]]]]]))
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#!/bin/bash
|
||||
#sudo docker run --rm -ti -v ~/dev/integreat/data/solr:/var/solr --network=bridge -p 8983:8983 solr
|
||||
sudo podman container run --user 1000 --privileged --volume /home/notid/dev/integreat/data/solr:/var/solr -p 8983:8983 solr
|
||||
sudo podman container run --user 1000 --privileged --volume /home/notid/dev/integreat/data/solr:/var/solr -p 8983:8983 docker.io/solr
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user