diff --git a/src/clj/auto_ap/pdf/ledger.clj b/src/clj/auto_ap/pdf/ledger.clj index 599f16cf..77361e42 100644 --- a/src/clj/auto_ap/pdf/ledger.clj +++ b/src/clj/auto_ap/pdf/ledger.clj @@ -17,6 +17,8 @@ (java.text DecimalFormat) (java.util UUID))) +(def ^:dynamic *report-pedantic* false) + (defn cell->pdf [cell] (let [cell-contents (cond (and (= :dollar (:format cell)) @@ -28,7 +30,7 @@ (.format (DecimalFormat. "$###,##0.00") (:value cell)) (= :percent (:format cell)) - (.format (DecimalFormat. "0%") (:value cell)) + (.format (DecimalFormat. (if *report-pedantic* "0.00%" "0%")) (:value cell)) :else (str (:value cell)))] diff --git a/src/clj/auto_ap/ssr/admin/clients.clj b/src/clj/auto_ap/ssr/admin/clients.clj index 0ffc3565..f95a10a6 100644 --- a/src/clj/auto_ap/ssr/admin/clients.clj +++ b/src/clj/auto_ap/ssr/admin/clients.clj @@ -520,7 +520,8 @@ ["manually-pay-cintas" "Manually Pay Cintas"] ["include-in-ntg-corp-reports" "Include in NTG Corporate reports"] ["import-custom-amount" "Import Custom Amount Line Items from Square"] - ["code-sysco-items" "Code individual sysco line items"]]}))) + ["code-sysco-items" "Code individual sysco line items"] + ["report-pedantic" "Show two decimals in reports"]]}))) (com/data-grid-cell {:class "align-top"} (com/a-icon-button {"@click.prevent.stop" "$refs.p.remove()"} svg/x)))) 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 f357e181..2fc49ff0 100644 --- a/src/clj/auto_ap/ssr/ledger/profit_and_loss.clj +++ b/src/clj/auto_ap/ssr/ledger/profit_and_loss.clj @@ -7,7 +7,7 @@ [auto-ap.ledger :refer [build-account-lookup upsert-running-balance]] [auto-ap.ledger.reports :as l-reports] [auto-ap.logging :as alog] - [auto-ap.pdf.ledger :refer [table->pdf]] + [auto-ap.pdf.ledger :refer [table->pdf *report-pedantic*]] [auto-ap.permissions :refer [can? wrap-must]] [auto-ap.routes.ledger :as route] [auto-ap.routes.utils @@ -45,7 +45,7 @@ [:or [:enum :all] [:vector {:coerce? true :min 1} - [:entity-map {:pull [:db/id :client/name]}]]]] + [:entity-map {:pull [:db/id :client/name :client/feature-flags]}]]]] [:column-per-location {:default false} [:boolean {:decode/string {:enter #(if (= % "on") true @@ -106,7 +106,7 @@ :period {:start ( coerce/to-date (:start p)) :end (coerce/to-date (time/plus (:end p) (time/days 1)))}})) args (assoc (:form-params request) :periods (map (fn [d] {:start ( coerce/to-date (:start d)) :end ( coerce/to-date (:end d))}) periods)) - clients (pull-many (dc/db conn) [:client/code :client/name :db/id] client-ids) + clients (pull-many (dc/db conn) [:client/code :client/name :db/id :client/feature-flags] client-ids) pnl-data (l-reports/->PNLData args data (by :db/id :client/code clients)) report (l-reports/summarize-pnl pnl-data)] @@ -255,7 +255,8 @@ (let [uuid (str (UUID/randomUUID)) {:keys [client warning]} (maybe-trim-clients request (:client (:form-params request))) request (assoc-in request [:form-params :client] client) - pdf-data (make-profit-and-loss-pdf request (:report (get-report request))) + pdf-data (binding [*report-pedantic* (boolean ((set (:client/feature-flags (first client))) + "report-pedantic"))] (make-profit-and-loss-pdf request (:report (get-report request)))) name (profit-and-loss-args->name request) key (str "reports/profit-and-loss/" uuid "/" name ".pdf") url (str "https://" (:data-bucket env) "/" key)]