From ec4f88b7fcb8b6a399d8872a7f3ee44cdf38a517 Mon Sep 17 00:00:00 2001 From: Bryce Date: Wed, 17 Jun 2026 15:56:43 -0700 Subject: [PATCH] fix(ssr): hide P&L warning box when there is no warning The profit-and-loss report always passed :warning as a [:div ...] hiccup vector, which is truthy even when empty. The shared report table renders its red warning box with (when warning ...), so a clean report with no warning and no unresolved entries still showed an empty red error box. Only build the warning div when there is actual warning text or sample links, matching how the balance-sheet and cash-flows reports pass nil. Co-Authored-By: Claude Opus 4.8 --- .../auto_ap/ssr/ledger/profit_and_loss.clj | 26 +++++++++---------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/src/clj/auto_ap/ssr/ledger/profit_and_loss.clj b/src/clj/auto_ap/ssr/ledger/profit_and_loss.clj index bc65ddf4..e869355c 100644 --- a/src/clj/auto_ap/ssr/ledger/profit_and_loss.clj +++ b/src/clj/auto_ap/ssr/ledger/profit_and_loss.clj @@ -129,7 +129,17 @@ (let [{:keys [client warning]} (maybe-trim-clients request client) {:keys [data report]} (get-report (assoc-in request [:form-params :client] client)) client-count (count (set (map :client-id (:data data)))) - table-contents (concat-tables (concat (:summaries report) (:details report)))] + table-contents (concat-tables (concat (:summaries report) (:details report))) + warning-text (not-empty (str/join "\n " (filter not-empty [warning (:warning report)]))) + sample-links (when (can? (:identity request) + {:subject :history + :activity :view}) + (seq (for [n (:invalid-ids report)] + [:div + (com/link {:href (str (bidi/path-for ssr-routes/only-routes + :admin-history) + "/" n)} + "Sample")])))] (list [:div.text-2xl.font-bold.text-gray-600 (str "Profit and loss - " (str/join ", " (map :client/name client)))] (table {:widths (into [20] (take (dec (cell-count table-contents)) @@ -140,18 +150,8 @@ [13 6]))))) :investigate-url (bidi.bidi/path-for ssr-routes/only-routes ::route/investigate) :table table-contents - :warning [:div - (not-empty (str (str/join "\n " (filter not-empty [warning (:warning report)])))) - - (when (can? (:identity request) - {:subject :history - :activity :view}) - (for [n (:invalid-ids report)] - [:div - (com/link {:href (str (bidi/path-for ssr-routes/only-routes - :admin-history) - "/" n)} - "Sample")]))]}))))]) + :warning (when (or warning-text sample-links) + [:div warning-text sample-links])}))))]) (defn form* [request & children] (let [params (or (:query-params request) {})]