pnl detail
This commit is contained in:
@@ -539,21 +539,24 @@
|
|||||||
: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
|
||||||
|
:let [journal-entries (first (reduce
|
||||||
|
(fn [[acc last-je] je]
|
||||||
|
(let [next-je (assoc je :running_balance
|
||||||
|
(- (+ (or (:running_balance last-je 0.0) 0.0)
|
||||||
|
(or (:debit je 0.0) 0.0))
|
||||||
|
(or (:credit je 0.0) 0.0)))]
|
||||||
|
[(conj acc next-je) next-je]))
|
||||||
|
[]
|
||||||
|
(sort-by :date journal-entries)))]]
|
||||||
{:category category
|
{:category category
|
||||||
:client_id client-id
|
:client_id client-id
|
||||||
:location location
|
:location location
|
||||||
:account account
|
:account account
|
||||||
:journal_entries
|
:journal_entries journal-entries
|
||||||
(first (reduce
|
:total (- (reduce + 0.0 (map (fnil :debit 0.0) journal-entries))
|
||||||
(fn [[acc last-je] je]
|
(reduce + 0.0 (map (fnil :credit 0.0) journal-entries)))
|
||||||
(let [next-je (assoc je :running_balance
|
})})
|
||||||
(- (+ (or (:running_balance last-je 0.0) 0.0)
|
|
||||||
(or (:debit je 0.0) 0.0))
|
|
||||||
(or (:credit je 0.0) 0.0)))]
|
|
||||||
[(conj acc next-je) next-je]))
|
|
||||||
[]
|
|
||||||
journal-entries))})})
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user