From 8511d3071532e39ce8391c00aafca54da41cd9a6 Mon Sep 17 00:00:00 2001 From: Bryce Date: Sat, 3 Jan 2026 22:44:58 -0800 Subject: [PATCH] pnl changes --- .../auto_ap/ssr/ledger/profit_and_loss.clj | 42 ++++++++++++------- 1 file changed, 26 insertions(+), 16 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 ec0e292d..e52a5e10 100644 --- a/src/clj/auto_ap/ssr/ledger/profit_and_loss.clj +++ b/src/clj/auto_ap/ssr/ledger/profit_and_loss.clj @@ -221,27 +221,37 @@ "Profit and loss")) (defn make-profit-and-loss-pdf [request report] - (let [ output-stream (ByteArrayOutputStream.) + (let [output-stream (ByteArrayOutputStream.) date (:periods (:form-params request)) table (concat-tables (:details report))] (pdf/pdf - (-> [{:left-margin 10 :right-margin 10 :top-margin 15 :bottom-margin 15 - :size :letter - :font {:size 6 - :ttf-name "fonts/calibri-light.ttf"}} - [:heading (str "Balance Sheet - " (str/join ", " (map :client/name (seq (:client (:form-params request))))))]] + (-> [{:left-margin 10 :right-margin 10 :top-margin 15 :bottom-margin 15 + :size :letter + :font {:size 6 + :ttf-name "fonts/calibri-light.ttf"}} + [:heading (str "Profit and Loss - " (str/join ", " (map :client/name (seq (:client (:form-params request))))))]] - (conj [:paragraph {:color [128 0 0] :size 9} (:warning report) - ]) - (conj + (conj [:paragraph {:color [128 0 0] :size 9} (:warning report)]) + + (into + (for [table (concat (:summaries report) + (:details report))] (table->pdf table (into [20] (take (dec (cell-count table)) - (mapcat identity - (repeat - (if (-> (:form-params request) :include-deltas) - [13 6 13] - [13 6])))))))) - output-stream) + (mapcat identity + (repeat + (if (-> (:form-params request) :include-deltas) + [13 6 13] + [13 6])))))))) + #_(conj + (table->pdf table + (into [20] (take (dec (cell-count table)) + (mapcat identity + (repeat + (if (-> (:form-params request) :include-deltas) + [13 6 13] + [13 6])))))))) + output-stream) (.toByteArray output-stream))) (defn join-names [client-ids] @@ -252,7 +262,7 @@ (:date (:query-params request)) atime/iso-date) name (->> request :query-params :client (map :db/id) join-names)] - (format "Balance-sheet-%s-for-%s" date name))) + (format "Profit-and-loss-%s-for-%s" date name))) (defn print-profit-and-loss [request] (let [uuid (str (UUID/randomUUID))