Sample ledger show
This commit is contained in:
@@ -8,7 +8,7 @@
|
||||
[auto-ap.ledger.reports :as l-reports]
|
||||
[auto-ap.logging :as alog]
|
||||
[auto-ap.pdf.ledger :refer [table->pdf]]
|
||||
[auto-ap.permissions :refer [wrap-must]]
|
||||
[auto-ap.permissions :refer [can? wrap-must]]
|
||||
[auto-ap.routes.ledger :as route]
|
||||
[auto-ap.routes.utils
|
||||
:refer [wrap-client-redirect-unauthenticated]]
|
||||
@@ -86,7 +86,7 @@
|
||||
data (into []
|
||||
(for [client-id client-ids
|
||||
p periods
|
||||
[client-id account-id location debits credits balance count] (iol-ion.query/detailed-account-snapshot (dc/db conn) client-id (coerce/to-date (:end p)) (coerce/to-date (:start p)))
|
||||
[client-id account-id location debits credits balance count sample] (iol-ion.query/detailed-account-snapshot (dc/db conn) client-id (coerce/to-date (:end p)) (coerce/to-date (:start p)))
|
||||
:let [account ((or (lookup-account client-id) {}) account-id)]]
|
||||
{:client-id client-id
|
||||
:account-id account-id
|
||||
@@ -102,6 +102,7 @@
|
||||
:account-type (:account_type account)
|
||||
:numeric-code (:numeric_code account)
|
||||
:name (:name account)
|
||||
:sample sample
|
||||
: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))
|
||||
@@ -130,14 +131,26 @@
|
||||
(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))
|
||||
(mapcat identity
|
||||
(repeat
|
||||
(if (-> data :args :include-deltas)
|
||||
[13 6 13]
|
||||
[13 6])))))
|
||||
(mapcat identity
|
||||
(repeat
|
||||
(if (-> data :args :include-deltas)
|
||||
[13 6 13]
|
||||
[13 6])))))
|
||||
:investigate-url (bidi.bidi/path-for ssr-routes/only-routes ::route/investigate)
|
||||
:table table-contents
|
||||
:warning (not-empty (str/join "\n " (filter not-empty [warning (:warning report)])))}))))])
|
||||
: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")]))]
|
||||
}))))])
|
||||
|
||||
|
||||
|
||||
@@ -215,7 +228,8 @@
|
||||
:ttf-name "fonts/calibri-light.ttf"}}
|
||||
[:heading (str "Balance Sheet - " (str/join ", " (map :client/name (seq (:client (:form-params request))))))]]
|
||||
|
||||
(conj [:paragraph {:color [128 0 0] :size 9} (:warning report)])
|
||||
(conj [:paragraph {:color [128 0 0] :size 9} (:warning report)
|
||||
])
|
||||
(conj
|
||||
(table->pdf table
|
||||
(into [20] (take (dec (cell-count table))
|
||||
|
||||
@@ -715,8 +715,17 @@
|
||||
(:location %)))
|
||||
errors))))))
|
||||
|
||||
(defn invalid-ids [pnl-data]
|
||||
(let [errors (->> pnl-data
|
||||
:data
|
||||
(filter (fn [{:keys [numeric-code]}]
|
||||
(nil? numeric-code)))
|
||||
(map :sample)) ]
|
||||
errors))
|
||||
|
||||
(defn summarize-pnl [pnl-data]
|
||||
{:warning (warning-message pnl-data)
|
||||
:invalid-ids (invalid-ids pnl-data)
|
||||
:summaries
|
||||
(if (-> pnl-data :args :column-per-location)
|
||||
[(location-summary-table (mapcat identity (for [[period i] (map vector (-> pnl-data :args :periods ) (range))]
|
||||
|
||||
Reference in New Issue
Block a user