progress on new report
This commit is contained in:
@@ -505,16 +505,40 @@
|
||||
|
||||
|
||||
(defn get-journal-detail-report [context input _]
|
||||
(clojure.pprint/pprint
|
||||
(for [category (:categories input)]
|
||||
{:category category
|
||||
:journal_entries (:journal_entries (get-ledger-page context {:filters (doto {:client_ids (:client_ids input)
|
||||
:date_range (:date_range input)
|
||||
:from_numeric_code (get-in l-reports/ranges [category 0])
|
||||
:to_numeric_code (get-in l-reports/ranges [category 1])
|
||||
:per_page Integer/MAX_VALUE}
|
||||
clojure.pprint/pprint)}
|
||||
nil))})))
|
||||
{:categories
|
||||
(for [client-id (:client_ids input)
|
||||
:let [account-lookup (build-account-lookup client-id)
|
||||
c (d/pull (d/db conn) '[:client/locations] client-id) ]
|
||||
location (:client/locations c)
|
||||
category (:categories input)
|
||||
:let [journal-entries (->> (get-ledger-page context
|
||||
{:filters {:client_id client-id
|
||||
:location location
|
||||
:date_range (:date_range input)
|
||||
:from_numeric_code (get-in l-reports/ranges [category 0])
|
||||
:to_numeric_code (get-in l-reports/ranges [category 1])
|
||||
:per_page Integer/MAX_VALUE}}
|
||||
nil)
|
||||
:journal_entries
|
||||
(map (fn [je]
|
||||
(update je :line_items
|
||||
(fn [jels]
|
||||
(into []
|
||||
(filter (fn [jel]
|
||||
(when-let [account (account-lookup (:id (:account jel)))]
|
||||
(and
|
||||
(<= (get-in l-reports/ranges [category 0])
|
||||
(:numeric_code account)
|
||||
(get-in l-reports/ranges [category 1]))
|
||||
(= location (:location jel)))))
|
||||
jels ))))))
|
||||
(group-by #(account-lookup (get-in % [:line_items 0 :account :id]))))]
|
||||
[account journal-entries] journal-entries]
|
||||
{:category category
|
||||
:client_id client-id
|
||||
:location location
|
||||
:account account
|
||||
:journal_entries journal-entries})})
|
||||
|
||||
|
||||
(def objects
|
||||
@@ -584,6 +608,9 @@
|
||||
|
||||
:journal_detail_report_category
|
||||
{:fields {:category {:type :ledger_category}
|
||||
:account {:type :account}
|
||||
:client_id {:type :id}
|
||||
:location {:type 'String}
|
||||
:journal_entries {:type '(list :journal_entry)}}}
|
||||
:journal_detail_report
|
||||
{:fields {:categories {:type '(list :journal_detail_report_category)}}}})
|
||||
|
||||
Reference in New Issue
Block a user