long shot attempt to get report looking better

This commit is contained in:
Bryce Covert
2022-10-22 20:45:22 -07:00
parent d49d823e23
commit d8030e98a1
3 changed files with 47 additions and 35 deletions

View File

@@ -520,25 +520,39 @@
:per_page Integer/MAX_VALUE}} :per_page Integer/MAX_VALUE}}
nil) nil)
:journal_entries :journal_entries
(map (fn [je] (mapcat (fn [je]
(update je :line_items (->> (je :line_items)
(fn [jels] (filter (fn [jel]
(into [] (when-let [account (account-lookup (:id (:account jel)))]
(filter (fn [jel] (and
(when-let [account (account-lookup (:id (:account jel)))] (<= (get-in l-reports/ranges [category 0])
(and (:numeric_code account)
(<= (get-in l-reports/ranges [category 0]) (get-in l-reports/ranges [category 1]))
(:numeric_code account) (= location (:location jel)))))
(get-in l-reports/ranges [category 1])) )
(= location (:location jel))))) (map (fn [jel ]
jels )))))) {:date (:date je)
(group-by #(account-lookup (get-in % [:line_items 0 :account :id]))))] :debit (:debit jel)
:credit (:credit jel)
:description (or (:name (:vendor je))
(:alternate_description je))
:account (:account jel)
:location (:location jel)})))))
(group-by #(account-lookup (get-in % [:account :id]))))]
[account journal-entries] journal-entries] [account journal-entries] 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 (reduce
(fn [[acc last-je] je]
(let [next-je (assoc je :running_balance
(- (+ (:running_balance last-je 0.0)
(Double/parseDouble (:debit je 0.0)))
(Double/parseDouble (:credit je 0.0))))]
[(conj acc next-je) next-je]))
[]
journal-entries)})})
@@ -596,6 +610,16 @@
:date {:type 'String} :date {:type 'String}
:line_items {:type '(list :journal_entry_line)}}} :line_items {:type '(list :journal_entry_line)}}}
:journal_detail_report_row
{:fields {:client {:type :client}
:description {:type 'String}
:date {:type 'String}
:account {:type :account}
:location {:type 'String}
:debit {:type 'String}
:credit {:type 'String}
:running_balance {:type :money}}}
:ledger_page :ledger_page
{:fields {:journal_entries {:type '(list :journal_entry)} {:fields {:journal_entries {:type '(list :journal_entry)}
:count {:type 'Int} :count {:type 'Int}
@@ -619,7 +643,7 @@
:account {:type :account} :account {:type :account}
:client_id {:type :id} :client_id {:type :id}
:location {:type 'String} :location {:type 'String}
:journal_entries {:type '(list :journal_entry)}}} :journal_entries {:type '(list :journal_detail_report_row)}}}
:journal_detail_report :journal_detail_report
{:fields {:categories {:type '(list :journal_detail_report_category)}}}}) {:fields {:categories {:type '(list :journal_detail_report_category)}}}})

View File

@@ -575,14 +575,12 @@
(map (map
(fn [je] (fn [je]
[{:value (user-friendly-date (:date je))} [{:value (user-friendly-date (:date je))}
{:value (or (:description je) {:value (:description je "")}
(:name (:vendor je)) {:value (get je :debit)
"")}
{:value (get-in je [:line-items 0 :debit])
:format :dollar} :format :dollar}
{:value (get-in je [:line-items 0 :credit]) {:value (get je :credit)
:format :dollar} :format :dollar}
{:value (get-in je [:line-items 0 :running-balance]) {:value (get je :running-balance)
:format :dollar}]) :format :dollar}])
(:journal-entries category)))) (:journal-entries category))))

View File

@@ -49,20 +49,10 @@
:categories [:sales :categories [:sales
:cogs :cogs
:payroll]} :payroll]}
[[:categories [[:journal-entries [:id [[:categories [[:journal-entries [:description
:source :date
:original-entity :debit :credit :location :running-balance
:note [:account [:id :name]]]]
:amount
:alternate-description
[:vendor
[:name :id]]
[:client
[:name :id]]
[:line-items
[:id :debit :credit :location :running-balance
[:account [:id :name]]]]
:date]]
:category :category
:client-id :client-id
:location :location