pnl detail

This commit is contained in:
Bryce Covert
2022-10-23 07:24:55 -07:00
parent 824a12f4b0
commit a35c2699df

View File

@@ -539,13 +539,8 @@
:account (:account jel) :account (:account jel)
:location (:location jel)}))))) :location (:location jel)})))))
(group-by #(account-lookup (get-in % [:account :id]))))] (group-by #(account-lookup (get-in % [:account :id]))))]
[account journal-entries] journal-entries] [account journal-entries] journal-entries
{:category category :let [journal-entries (first (reduce
:client_id client-id
:location location
:account account
:journal_entries
(first (reduce
(fn [[acc last-je] je] (fn [[acc last-je] je]
(let [next-je (assoc je :running_balance (let [next-je (assoc je :running_balance
(- (+ (or (:running_balance last-je 0.0) 0.0) (- (+ (or (:running_balance last-je 0.0) 0.0)
@@ -553,7 +548,15 @@
(or (:credit je 0.0) 0.0)))] (or (:credit je 0.0) 0.0)))]
[(conj acc next-je) next-je])) [(conj acc next-je) next-je]))
[] []
journal-entries))})}) (sort-by :date journal-entries)))]]
{:category category
:client_id client-id
:location location
:account account
:journal_entries journal-entries
:total (- (reduce + 0.0 (map (fnil :debit 0.0) journal-entries))
(reduce + 0.0 (map (fnil :credit 0.0) journal-entries)))
})})