more support for negative invoices.
This commit is contained in:
@@ -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")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user