Adds ability to link across entities more.

This commit is contained in:
Bryce Covert
2021-01-24 13:25:41 -08:00
parent e2cdb3c719
commit 611ecc438d
5 changed files with 69 additions and 21 deletions

View File

@@ -231,6 +231,7 @@
{:fields {:id {:type :id}
:source {:type 'String}
:external_id {:type 'String}
:original_entity {:type :id}
:amount {:type 'String}
:note {:type 'String}
:cleared_against {:type 'String}

View File

@@ -22,21 +22,21 @@
(defn get-ledger-page [context args value]
(let [args (assoc args :id (:id context))
[journal-entries journal-entries-count] (l/get-graphql (assoc (<-graphql (:filters args)
)
[journal-entries journal-entries-count] (l/get-graphql (assoc (<-graphql (:filters args))
:id (:id context)))
journal-entries (mapv
(fn [je]
(update je :journal-entry/line-items
(fn [jels]
(mapv
(fn [jel]
(assoc jel :running-balance (get-in @running-balance-cache [(:db/id (:journal-entry/client je))
(:db/id jel)])))
(-> je
(update :journal-entry/original-entity :db/id)
(update :journal-entry/line-items
(fn [jels]
(mapv
(fn [jel]
(assoc jel :running-balance (get-in @running-balance-cache [(:db/id (:journal-entry/client je))
(:db/id jel)])))
jels)
))
)
jels)))))
journal-entries)]
(result->page journal-entries journal-entries-count :journal_entries (:filters args))))