unifying reports even more.
This commit is contained in:
@@ -1,9 +1,15 @@
|
||||
(ns auto-ap.ledger.reports
|
||||
(:require
|
||||
[auto-ap.utils :refer [dollars-0?]]
|
||||
#?(:cljs [auto-ap.views.utils :as au ]
|
||||
:clj [auto-ap.time :as atime])))
|
||||
|
||||
#?@
|
||||
(:clj
|
||||
[(:require
|
||||
[auto-ap.time :as atime]
|
||||
[auto-ap.utils :refer [dollars-0?]]
|
||||
[clojure.string :as str])]
|
||||
:cljs
|
||||
[(:require
|
||||
[auto-ap.utils :refer [dollars-0?]]
|
||||
[auto-ap.views.utils :as au]
|
||||
[clojure.string :as str])]))
|
||||
|
||||
(defn date->str [d]
|
||||
#?(:clj
|
||||
@@ -339,11 +345,26 @@
|
||||
{:header (headers pnl-data title)
|
||||
:rows (combine-tables pnl-data table percent-of-sales deltas)}))
|
||||
|
||||
(defn warning-message [pnl-data]
|
||||
(let [errors (->> pnl-data
|
||||
:data
|
||||
(filter (fn [{:keys [numeric-code]}]
|
||||
(nil? numeric-code))))
|
||||
error-count (count errors)]
|
||||
(when (> error-count 0)
|
||||
(str "This report does not include "
|
||||
(str/join ", "
|
||||
(map #(str (:count %) " unresolved ledger entries for " (if (str/blank? (:location %))
|
||||
" all locations"
|
||||
(:location %)))
|
||||
errors))))))
|
||||
|
||||
(defn summarize-pnl [pnl-data]
|
||||
{:summaries (for [[client-id location] (locations (:data pnl-data))]
|
||||
{:warning (warning-message pnl-data)
|
||||
:summaries (for [[client-id location] (locations (:data pnl-data))]
|
||||
(location-summary-table (-> pnl-data
|
||||
(filter-client client-id)
|
||||
(filter-location location))
|
||||
(filter-location location))
|
||||
(str (-> pnl-data :clients-by-id (get client-id)) " (" location ") Summary")))
|
||||
:details (for [[client-id location] (locations (:data pnl-data))]
|
||||
(location-detail-table (-> pnl-data
|
||||
|
||||
Reference in New Issue
Block a user