Prevents errors from multiple dialogs open
This commit is contained in:
@@ -41,8 +41,9 @@
|
|||||||
[:input (merge {:id "checkbox-all", :type "checkbox", :class inputs/default-checkbox-classes :name (:name params) :value (:value params)} params)]
|
[:input (merge {:id "checkbox-all", :type "checkbox", :class inputs/default-checkbox-classes :name (:name params) :value (:value params)} params)]
|
||||||
[:label {:for "checkbox-all", :class "sr-only"} "checkbox"]]])
|
[:label {:for "checkbox-all", :class "sr-only"} "checkbox"]]])
|
||||||
|
|
||||||
(defn data-grid- [{:keys [headers thead-params id]} & rest]
|
(defn data-grid- [{:keys [headers thead-params id] :as params} & rest]
|
||||||
[:table {:class "w-full text-sm text-left text-gray-500 dark:text-gray-400" :id id}
|
[:table (merge {:class "w-full text-sm text-left text-gray-500 dark:text-gray-400"}
|
||||||
|
(dissoc params :headers :thead-params))
|
||||||
[:thead (assoc thead-params :class "text-xs text-gray-800 uppercase bg-gray-50 dark:bg-gray-700 dark:text-gray-400")
|
[:thead (assoc thead-params :class "text-xs text-gray-800 uppercase bg-gray-50 dark:bg-gray-700 dark:text-gray-400")
|
||||||
(into
|
(into
|
||||||
[:tr]
|
[:tr]
|
||||||
|
|||||||
@@ -596,8 +596,6 @@
|
|||||||
})
|
})
|
||||||
[:headers "hx-trigger"] "invalidated")))))
|
[:headers "hx-trigger"] "invalidated")))))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
(def new-wizard (->NewWizard2 nil nil))
|
(def new-wizard (->NewWizard2 nil nil))
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -39,7 +39,7 @@
|
|||||||
dissoc-nil-transformer entity-id html-response
|
dissoc-nil-transformer entity-id html-response
|
||||||
main-transformer modal-response money ref->enum-schema
|
main-transformer modal-response money ref->enum-schema
|
||||||
round-money strip wrap-entity wrap-implied-route-param
|
round-money strip wrap-entity wrap-implied-route-param
|
||||||
wrap-merge-prior-hx wrap-schema-enforce]]
|
wrap-merge-prior-hx wrap-schema-enforce form-validation-error assert-schema]]
|
||||||
[auto-ap.time :as atime]
|
[auto-ap.time :as atime]
|
||||||
[auto-ap.utils :refer [by dollars=]]
|
[auto-ap.utils :refer [by dollars=]]
|
||||||
[bidi.bidi :as bidi]
|
[bidi.bidi :as bidi]
|
||||||
@@ -642,8 +642,9 @@
|
|||||||
(and (< outstanding-balance 0)
|
(and (< outstanding-balance 0)
|
||||||
(< amount outstanding-balance))
|
(< amount outstanding-balance))
|
||||||
(and (< outstanding-balance 0)
|
(and (< outstanding-balance 0)
|
||||||
(>= amount 0)))))
|
(>= amount 0))
|
||||||
|
(and (= outstanding-balance 0.0)
|
||||||
|
(not= amount 0.0)))))
|
||||||
|
|
||||||
(def payment-form-schema
|
(def payment-form-schema
|
||||||
(mc/schema
|
(mc/schema
|
||||||
@@ -663,6 +664,7 @@
|
|||||||
(map :invoice-id invoices))
|
(map :invoice-id invoices))
|
||||||
(into {}))]
|
(into {}))]
|
||||||
(every? (fn [%]
|
(every? (fn [%]
|
||||||
|
(println "TEST" (:amount %) (outstanding-balances (:invoice-id %)))
|
||||||
(not (does-amount-exceed-outstanding? (:amount %) (outstanding-balances (:invoice-id %)))))
|
(not (does-amount-exceed-outstanding? (:amount %) (outstanding-balances (:invoice-id %)))))
|
||||||
invoices)))]]]
|
invoices)))]]]
|
||||||
[:has-warning? :boolean]
|
[:has-warning? :boolean]
|
||||||
@@ -838,7 +840,7 @@
|
|||||||
[])
|
[])
|
||||||
|
|
||||||
(step-schema [_]
|
(step-schema [_]
|
||||||
(mut/select-keys (mm/form-schema linear-wizard) #{:invoices :check-number :handwritten-date}))
|
(mut/select-keys (mm/form-schema linear-wizard) #{:invoices :check-number :handwritten-date :mode}))
|
||||||
|
|
||||||
(render-step [this request]
|
(render-step [this request]
|
||||||
(mm/default-render-step
|
(mm/default-render-step
|
||||||
@@ -877,15 +879,16 @@
|
|||||||
(format "Pay in full ($%,.2f)" total)))}
|
(format "Pay in full ($%,.2f)" total)))}
|
||||||
{:value "advanced"
|
{:value "advanced"
|
||||||
:content "Customize payments"}]})
|
:content "Customize payments"}]})
|
||||||
[:div.space-y-4 (hx/alpine-appear {:x-show "mode==\"advanced\""})
|
[:div.space-y-4
|
||||||
(fc/with-field :invoices
|
(fc/with-field :invoices
|
||||||
(com/validated-field
|
(com/validated-field
|
||||||
{:errors (fc/field-errors)}
|
{:errors (fc/field-errors)}
|
||||||
(com/data-grid
|
(com/data-grid
|
||||||
{:headers [(com/data-grid-header {} "Vendor")
|
(hx/alpine-appear {:headers [(com/data-grid-header {} "Vendor")
|
||||||
(com/data-grid-header {} "Invoice Number")
|
(com/data-grid-header {} "Invoice Number")
|
||||||
(com/data-grid-header {:class "text-right"} "Total")
|
(com/data-grid-header {:class "text-right"} "Total")
|
||||||
(com/data-grid-header {:class "text-right"} "Pay")]}
|
(com/data-grid-header {:class "text-right"} "Pay")]
|
||||||
|
:x-show "mode==\"advanced\""})
|
||||||
(fc/cursor-map
|
(fc/cursor-map
|
||||||
(fn [i]
|
(fn [i]
|
||||||
(com/data-grid-row
|
(com/data-grid-row
|
||||||
@@ -945,16 +948,6 @@
|
|||||||
(doseq [[_ i] (:tempids result)]
|
(doseq [[_ i] (:tempids result)]
|
||||||
(solr/touch-with-ledger i)))))
|
(solr/touch-with-ledger i)))))
|
||||||
|
|
||||||
;; TODO Payment validations
|
|
||||||
;; 1. ensure that filtering for selected ids happens again
|
|
||||||
;; at the end of the modal to prevent race conditions
|
|
||||||
;; add validation to prevent overpaying
|
|
||||||
;; Paying a completed invoice is allowed presently
|
|
||||||
;; Thought is to put it into the pay function itself
|
|
||||||
;; balance should only go to negative if total was negative
|
|
||||||
;; balance should stay positive if total was positive
|
|
||||||
;; NOTE: payable-ids function could be used.
|
|
||||||
|
|
||||||
;; TODO support crediting from balance
|
;; TODO support crediting from balance
|
||||||
(defrecord PayWizard [form-params current-step invoice-by-id]
|
(defrecord PayWizard [form-params current-step invoice-by-id]
|
||||||
mm/LinearModalWizard
|
mm/LinearModalWizard
|
||||||
@@ -1029,14 +1022,16 @@
|
|||||||
payment-form-schema
|
payment-form-schema
|
||||||
(:snapshot multi-form-state)
|
(:snapshot multi-form-state)
|
||||||
mt/strip-extra-keys-transformer)
|
mt/strip-extra-keys-transformer)
|
||||||
|
|
||||||
|
|
||||||
|
_ (assert-schema payment-form-schema snapshot)
|
||||||
|
|
||||||
_ (exception->4xx
|
_ (exception->4xx
|
||||||
#(if (= :handwrite-check (:method snapshot))
|
#(if (= :handwrite-check (:method snapshot))
|
||||||
(when (or (not (some? (:check-number snapshot)))
|
(when (or (not (some? (:check-number snapshot)))
|
||||||
(= "" (:check-number snapshot)))
|
(= "" (:check-number snapshot)))
|
||||||
(throw (Exception. "Check number is required")))
|
(throw (Exception. "Check number is required")))
|
||||||
true))
|
true))
|
||||||
;; TODO just confirm that the outstanding balances haven't been surpassed
|
|
||||||
;; and that the invoices are still pending
|
|
||||||
result (exception->4xx
|
result (exception->4xx
|
||||||
#(if (= :handwrite-check (:method snapshot))
|
#(if (= :handwrite-check (:method snapshot))
|
||||||
(add-handwritten-check request this snapshot)
|
(add-handwritten-check request this snapshot)
|
||||||
@@ -1131,7 +1126,7 @@
|
|||||||
|
|
||||||
(def key->handler
|
(def key->handler
|
||||||
(apply-middleware-to-all-handlers
|
(apply-middleware-to-all-handlers
|
||||||
(->
|
(->
|
||||||
{::route/all-page (-> (helper/page-route grid-page)
|
{::route/all-page (-> (helper/page-route grid-page)
|
||||||
(wrap-implied-route-param :status nil))
|
(wrap-implied-route-param :status nil))
|
||||||
::route/paid-page (-> (helper/page-route grid-page)
|
::route/paid-page (-> (helper/page-route grid-page)
|
||||||
@@ -1154,7 +1149,7 @@
|
|||||||
|
|
||||||
(mm/wrap-wizard pay-wizard)
|
(mm/wrap-wizard pay-wizard)
|
||||||
(mm/wrap-init-multi-form-state initial-pay-wizard-state))
|
(mm/wrap-init-multi-form-state initial-pay-wizard-state))
|
||||||
|
|
||||||
::route/pay-submit (-> mm/submit-handler
|
::route/pay-submit (-> mm/submit-handler
|
||||||
|
|
||||||
(mm/wrap-wizard pay-wizard)
|
(mm/wrap-wizard pay-wizard)
|
||||||
@@ -1165,7 +1160,7 @@
|
|||||||
(mm/wrap-decode-multi-form-state))
|
(mm/wrap-decode-multi-form-state))
|
||||||
|
|
||||||
::route/table (helper/table-route grid-page)}
|
::route/table (helper/table-route grid-page)}
|
||||||
(merge new-invoice-wizard/key->handler))
|
(merge new-invoice-wizard/key->handler))
|
||||||
(fn [h]
|
(fn [h]
|
||||||
(-> h
|
(-> h
|
||||||
(wrap-status-from-source)
|
(wrap-status-from-source)
|
||||||
|
|||||||
Reference in New Issue
Block a user