diff --git a/src/clj/auto_ap/graphql/checks.clj b/src/clj/auto_ap/graphql/checks.clj index 49c5f0f9..5a26c902 100644 --- a/src/clj/auto_ap/graphql/checks.clj +++ b/src/clj/auto_ap/graphql/checks.clj @@ -321,17 +321,9 @@ (let [message (str "The bank account " (:bank-account/name bank-account) " does not have a starting check number. Please ask the integreat staff to initialize it.")] (throw (ex-info message {:validation-error message})))) - - _ (throw (ex-info "The selected invoices do not have an outstanding balance." - {:validation-error "The selected invoices do not have an outstanding balance."})) - _ (if (->> invoices-grouped-by-vendor - vals - (map (fn [payments] - (->> payments - (map (comp invoice-amounts :db/id)) - (reduce + 0.0)))) - (filter #(<= % 0.0)) - seq) + _ (if (dollars-0? (reduce + 0.0 (filter + #(>= % 0.0) + (map :amount invoice-payments)))) (throw (ex-info "The selected invoices do not have an outstanding balance." {:validation-error "The selected invoices do not have an outstanding balance."}))) checks (->> (for [[[vendor-id invoices] index] (map vector invoices-grouped-by-vendor (range))]