From e3959b4cb0818cea4db4e1ebe8680b1719ada657 Mon Sep 17 00:00:00 2001 From: Bryce Covert Date: Mon, 22 Mar 2021 21:24:29 -0700 Subject: [PATCH] removed stupid bug. --- src/clj/auto_ap/graphql/checks.clj | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/clj/auto_ap/graphql/checks.clj b/src/clj/auto_ap/graphql/checks.clj index 5a26c902..414adb7f 100644 --- a/src/clj/auto_ap/graphql/checks.clj +++ b/src/clj/auto_ap/graphql/checks.clj @@ -321,9 +321,15 @@ (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})))) - _ (if (dollars-0? (reduce + 0.0 (filter - #(>= % 0.0) - (map :amount invoice-payments)))) + + _ (if (->> invoices-grouped-by-vendor + vals + (map (fn [payments] + (->> payments + (map (comp invoice-amounts :db/id)) + (reduce + 0.0)))) + (filter #(<= % 0.0)) + seq) (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))]