diff --git a/src/cljs/auto_ap/views/pages/unpaid_invoices.cljs b/src/cljs/auto_ap/views/pages/unpaid_invoices.cljs index 75211376..1287384d 100644 --- a/src/cljs/auto_ap/views/pages/unpaid_invoices.cljs +++ b/src/cljs/auto_ap/views/pages/unpaid_invoices.cljs @@ -641,7 +641,10 @@ (let [data @(re-frame/subscribe [::edit-invoice]) change-event [::events/change-form [::edit-invoice]] locations (get-in @(re-frame/subscribe [::subs/clients-by-id]) [(:client-id data) :locations]) - min-total (- (:total (:original data)) (:outstanding-balance (:original data))) + min-total (if (= (:total (:original data)) (:outstanding-balance (:original data))) + nil + + (- (:total (:original data)) (:outstanding-balance (:original data)))) should-select-location? (and locations (> (count locations) 1))] @@ -650,7 +653,7 @@ :action-text "Save" :save-event [::edit-invoice-save] :can-submit? (and #_(s/valid? ::invoice/invoice data) - (>= (:total data) min-total))} + (or (not min-total) (>= (:total data) min-total)))} [horizontal-field [:label.label "Date"] @@ -741,7 +744,14 @@ [:div.dropdown-trigger [:button.button.is-success {:aria-haspopup true :on-click (dispatch-event [::print-checks-clicked ]) - :disabled (if (seq checked-invoices) + :disabled (if (and (seq checked-invoices) + (->> checked-invoices + vals + (group-by #(get-in % [:vendor :id])) + (reduce-kv (fn [negative? _ invoices] + (or negative? (< (reduce + 0 (map (fn [x] (-> x :outstanding-balance js/parseFloat)) invoices) ) 0))) + false) + not)) "" "disabled")