a much better general ledger profit and loss.
This commit is contained in:
@@ -106,12 +106,15 @@
|
||||
vals
|
||||
(mapcat (fn [a]
|
||||
(map (fn [o]
|
||||
[[[(:db/id a) (:db/id (:account-client-override/client o))]]
|
||||
#_(println "override" (:db/id a) (:db/id (:account-client-override/client o)))
|
||||
#_(print [[(:db/id a) (:db/id (:account-client-override/client o))]])
|
||||
[[(:db/id a) (:db/id (:account-client-override/client o))]
|
||||
(:account-client-override/name o)])
|
||||
(:account/client-overrides a))
|
||||
) )
|
||||
(into {} ))]
|
||||
(fn [a]
|
||||
#_(println a client-id (keys overrides-by-client))
|
||||
{:name (or (:bank-account/name (bank-accounts a))
|
||||
(overrides-by-client [a client-id])
|
||||
(:account/name (accounts a)))
|
||||
@@ -155,16 +158,16 @@
|
||||
(defn get-profit-and-loss [context args value]
|
||||
(let [client-id (:client_id args)
|
||||
_ (assert-can-see-client (:id context) client-id)
|
||||
start-date (coerce/to-date (:start (:date_range args)))
|
||||
end-date (coerce/to-date (:end (:date_range args)))
|
||||
comparable-start-date (coerce/to-date (time/minus (:start (:date_range args)) (time/years 1)))
|
||||
comparable-end-date (coerce/to-date (time/minus (:end (:date_range args)) (time/years 1)))
|
||||
_ (println args)
|
||||
all-ledger-entries (full-ledger-for-client client-id)
|
||||
lookup-account (build-account-lookup client-id)]
|
||||
|
||||
(->graphql
|
||||
{:balance-sheet-accounts (roll-up-until lookup-account all-ledger-entries end-date start-date )
|
||||
:comparable-balance-sheet-accounts (roll-up-until lookup-account all-ledger-entries comparable-end-date comparable-start-date )})))
|
||||
{:periods (reduce (fn [acc {:keys [start end]}]
|
||||
(conj acc
|
||||
{:accounts (roll-up-until lookup-account all-ledger-entries (coerce/to-date end) (coerce/to-date start) )}))
|
||||
[]
|
||||
(:periods args))})))
|
||||
|
||||
|
||||
(defn assoc-error [f]
|
||||
|
||||
Reference in New Issue
Block a user