Voiding more forgiving

This commit is contained in:
Bryce
2024-03-20 19:59:38 -07:00
parent e914f8b994
commit ffde6efac3
2 changed files with 11 additions and 3 deletions

View File

@@ -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))