Voiding more forgiving
This commit is contained in:
@@ -479,7 +479,7 @@
|
||||
(:payment/status p))))
|
||||
(mapcat (fn [p]
|
||||
(cond-> [{:link (hu/url (bidi/path-for ssr-routes/only-routes
|
||||
::payment-route/page)
|
||||
::payment-route/all-page)
|
||||
{:exact-match-id (:db/id p)})
|
||||
:content (str (format "$%,.2f" (:payment/amount p))
|
||||
(some-> (:payment/date p) coerce/to-date-time (atime/unparse-local atime/normal-date) (#(str " payment on " %))))}]
|
||||
@@ -502,6 +502,13 @@
|
||||
#(when-not (= :invoice-status/unpaid (:invoice/status invoice))
|
||||
(throw (ex-info "Cannot void an invoice if it is paid. First void the payment." {}))))
|
||||
|
||||
(when (->> invoice :invoice/payments
|
||||
(filter (fn [p]
|
||||
(not= :payment-status/voided
|
||||
(:payment/status p))))
|
||||
seq)
|
||||
(throw (ex-info "This invoice has linked payments. Void the payments first." {:type :notification})))
|
||||
|
||||
(exception->notification
|
||||
#(assert-can-see-client identity (:db/id (:invoice/client invoice))))
|
||||
(notify-if-locked (:db/id (:invoice/client invoice))
|
||||
|
||||
@@ -126,7 +126,7 @@
|
||||
{:payment/vendor [:vendor/name {:vendor/default-account
|
||||
[:account/name :account/numeric-code :db/id]} :db/id {:vendor/primary-contact [*]} {:vendor/address [*]}]}
|
||||
{[:payment/status :xform iol-ion.query/ident] [:db/ident]}
|
||||
{:payment/type [:db/ident]}
|
||||
{[:payment/type :xform iol-ion.query/ident] [:db/ident]}
|
||||
{:transaction/_payment [:db/id :transaction/date]}])
|
||||
|
||||
(defn fetch-ids [db {:keys [query-params route-params] :as request}]
|
||||
@@ -307,7 +307,7 @@
|
||||
"Payments"]]
|
||||
:title (fn [r]
|
||||
(str
|
||||
(some-> r :route-params :status name str/capitalize (str " "))
|
||||
(some-> r :rout-params :status name str/capitalize (str " "))
|
||||
"Payments"))
|
||||
:entity-name "payments"
|
||||
:route ::route/table
|
||||
@@ -392,6 +392,7 @@
|
||||
(mc/decode query-schema {"start-date" #inst "2023-12-21T08:00:00.000-00:00"} (mt/transformer main-transformer mt/strip-extra-keys-transformer)))
|
||||
|
||||
(defn delete [{check :entity :as request identity :identity}]
|
||||
(alog/peek ::check-type check)
|
||||
(exception->notification
|
||||
#(when-not (or (= :payment-status/pending (:payment/status check))
|
||||
(#{:payment-type/cash :payment-type/debit :payment-type/balance-credit} (:payment/type check)))
|
||||
|
||||
Reference in New Issue
Block a user