From 705cab9435dc71b6e6aca10f6f3c0f7d2affce32 Mon Sep 17 00:00:00 2001 From: Bryce Date: Wed, 17 Apr 2024 22:38:01 -0700 Subject: [PATCH] Allows resetting expense accounts --- src/clj/auto_ap/graphql/transactions.clj | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/clj/auto_ap/graphql/transactions.clj b/src/clj/auto_ap/graphql/transactions.clj index e8398c27..ff92785c 100644 --- a/src/clj/auto_ap/graphql/transactions.clj +++ b/src/clj/auto_ap/graphql/transactions.clj @@ -374,8 +374,12 @@ set (conj "A") (conj "HQ"))))] - - (when-not (dollars= (Math/abs (:transaction/amount existing-transaction)) account-total) + + (when (and (not (dollars= (Math/abs (:transaction/amount existing-transaction)) account-total)) + (or + (and (= approval_status :unapproved) + (> (count accounts) 0)) + (not= approval_status :unapproved))) (let [error (str "Expense account total (" account-total ") does not equal transaction total (" (Math/abs (:transaction/amount existing-transaction)) ")")] (throw (ex-info error {:validation-error error})))) (when missing-locations