Sample ledger show
This commit is contained in:
@@ -241,7 +241,7 @@
|
|||||||
([db client-id ^java.util.Date end ^java.util.Date start]
|
([db client-id ^java.util.Date end ^java.util.Date start]
|
||||||
|
|
||||||
(for [running-balance-set (account-sets db client-id)
|
(for [running-balance-set (account-sets db client-id)
|
||||||
:let [{:keys [account-id client-id location current-balance debits credits count]}
|
:let [{:keys [account-id client-id location current-balance debits credits count sample]}
|
||||||
(->> running-balance-set
|
(->> running-balance-set
|
||||||
(filter (fn until-end [^Line l]
|
(filter (fn until-end [^Line l]
|
||||||
(let [^java.util.Date d (.-date l)]
|
(let [^java.util.Date d (.-date l)]
|
||||||
@@ -259,13 +259,15 @@
|
|||||||
:current-balance (.-running-balance l)
|
:current-balance (.-running-balance l)
|
||||||
:account-id (.-account-id l)
|
:account-id (.-account-id l)
|
||||||
:client-id (.-client-id l)
|
:client-id (.-client-id l)
|
||||||
:location (.-location l)))
|
:location (.-location l)
|
||||||
|
:sample (.-id l)))
|
||||||
(transient {:count 0
|
(transient {:count 0
|
||||||
:debits 0.0
|
:debits 0.0
|
||||||
:credits 0.0
|
:credits 0.0
|
||||||
:current-balance 0.0})))]
|
:current-balance 0.0})))]
|
||||||
:when client-id]
|
:when client-id]
|
||||||
[client-id account-id location debits credits current-balance count])))
|
(do
|
||||||
|
[client-id account-id location debits credits current-balance count sample]))))
|
||||||
|
|
||||||
|
|
||||||
(comment
|
(comment
|
||||||
|
|||||||
@@ -8,7 +8,7 @@
|
|||||||
[auto-ap.ledger.reports :as l-reports]
|
[auto-ap.ledger.reports :as l-reports]
|
||||||
[auto-ap.logging :as alog]
|
[auto-ap.logging :as alog]
|
||||||
[auto-ap.pdf.ledger :refer [table->pdf]]
|
[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.ledger :as route]
|
||||||
[auto-ap.routes.utils
|
[auto-ap.routes.utils
|
||||||
:refer [wrap-client-redirect-unauthenticated]]
|
:refer [wrap-client-redirect-unauthenticated]]
|
||||||
@@ -86,7 +86,7 @@
|
|||||||
data (into []
|
data (into []
|
||||||
(for [client-id client-ids
|
(for [client-id client-ids
|
||||||
p periods
|
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)]]
|
:let [account ((or (lookup-account client-id) {}) account-id)]]
|
||||||
{:client-id client-id
|
{:client-id client-id
|
||||||
:account-id account-id
|
:account-id account-id
|
||||||
@@ -102,6 +102,7 @@
|
|||||||
:account-type (:account_type account)
|
:account-type (:account_type account)
|
||||||
:numeric-code (:numeric_code account)
|
:numeric-code (:numeric_code account)
|
||||||
:name (:name account)
|
:name (:name account)
|
||||||
|
:sample sample
|
||||||
:period {:start ( coerce/to-date (:start p)) :end (coerce/to-date (time/plus (:end p) (time/days 1)))}}))
|
:period {:start ( coerce/to-date (:start p)) :end (coerce/to-date (time/plus (:end p) (time/days 1)))}}))
|
||||||
args (assoc (:form-params request)
|
args (assoc (:form-params request)
|
||||||
:periods (map (fn [d] {:start ( coerce/to-date (:start d)) :end ( coerce/to-date (:end d))}) periods))
|
:periods (map (fn [d] {:start ( coerce/to-date (:start d)) :end ( coerce/to-date (:end d))}) periods))
|
||||||
@@ -130,14 +131,26 @@
|
|||||||
(list
|
(list
|
||||||
[:div.text-2xl.font-bold.text-gray-600 (str "Profit and loss - " (str/join ", " (map :client/name client)))]
|
[: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))
|
(table {:widths (into [20] (take (dec (cell-count table-contents))
|
||||||
(mapcat identity
|
(mapcat identity
|
||||||
(repeat
|
(repeat
|
||||||
(if (-> data :args :include-deltas)
|
(if (-> data :args :include-deltas)
|
||||||
[13 6 13]
|
[13 6 13]
|
||||||
[13 6])))))
|
[13 6])))))
|
||||||
:investigate-url (bidi.bidi/path-for ssr-routes/only-routes ::route/investigate)
|
:investigate-url (bidi.bidi/path-for ssr-routes/only-routes ::route/investigate)
|
||||||
:table table-contents
|
: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"}}
|
:ttf-name "fonts/calibri-light.ttf"}}
|
||||||
[:heading (str "Balance Sheet - " (str/join ", " (map :client/name (seq (:client (:form-params request))))))]]
|
[: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
|
(conj
|
||||||
(table->pdf table
|
(table->pdf table
|
||||||
(into [20] (take (dec (cell-count table))
|
(into [20] (take (dec (cell-count table))
|
||||||
|
|||||||
@@ -715,8 +715,17 @@
|
|||||||
(:location %)))
|
(:location %)))
|
||||||
errors))))))
|
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]
|
(defn summarize-pnl [pnl-data]
|
||||||
{:warning (warning-message pnl-data)
|
{:warning (warning-message pnl-data)
|
||||||
|
:invalid-ids (invalid-ids pnl-data)
|
||||||
:summaries
|
:summaries
|
||||||
(if (-> pnl-data :args :column-per-location)
|
(if (-> pnl-data :args :column-per-location)
|
||||||
[(location-summary-table (mapcat identity (for [[period i] (map vector (-> pnl-data :args :periods ) (range))]
|
[(location-summary-table (mapcat identity (for [[period i] (map vector (-> pnl-data :args :periods ) (range))]
|
||||||
|
|||||||
Reference in New Issue
Block a user