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))
|
||||
|
||||
Reference in New Issue
Block a user