More grouping.
This commit is contained in:
@@ -44,14 +44,16 @@
|
|||||||
(defn roll-up [results]
|
(defn roll-up [results]
|
||||||
(->> results
|
(->> results
|
||||||
(mapcat :journal-entry/line-items)
|
(mapcat :journal-entry/line-items)
|
||||||
(group-by :journal-entry-line/account)
|
(group-by (juxt :journal-entry-line/account :journal-entry-line/location))
|
||||||
(reduce-kv (fn [result account line-items]
|
(reduce-kv (fn [result [account location] line-items]
|
||||||
;; TODO fix
|
;; TODO fix
|
||||||
(when-not (or (:bank-account/name account) (:account/name account))
|
(when-not (or (:bank-account/name account) (:account/name account))
|
||||||
(println "WARNING " account line-items))
|
(println "WARNING " account line-items))
|
||||||
(conj result
|
(conj result
|
||||||
{:name (or (:bank-account/name account) (:account/name account))
|
{:name (str (or (:bank-account/name account) (:account/name account)) (when-not (#{"A" } location)
|
||||||
:id (:db/id account)
|
(str
|
||||||
|
"-" location)))
|
||||||
|
:id (str (:db/id account) "-" location)
|
||||||
:numeric-code (or (:account/numeric-code account)
|
:numeric-code (or (:account/numeric-code account)
|
||||||
(and (:bank-account/type account)
|
(and (:bank-account/type account)
|
||||||
1100))
|
1100))
|
||||||
|
|||||||
@@ -46,34 +46,31 @@
|
|||||||
(= type account-type)))
|
(= type account-type)))
|
||||||
(by :id))))
|
(by :id))))
|
||||||
|
|
||||||
|
(re-frame/reg-sub
|
||||||
|
::loading
|
||||||
|
(fn [db]
|
||||||
|
(-> db ::loading)))
|
||||||
|
|
||||||
(def groupings
|
(def groupings
|
||||||
{:asset
|
{:asset [["1100 Cash and Bank Accounts" 1100 1199]
|
||||||
[["1100 Cash and Bank Accounts" 1100 1199]
|
["1200 Accounts Receivable" 1200 1299]
|
||||||
["1200 Accounts Receivable" 1200 1299]
|
["1300 Inventory" 1300 1399]
|
||||||
["1300 Inventory" 1300 1399]
|
["1400 Prepaid Expenses" 1400 1499]
|
||||||
["1400 Prepaid Expenses" 1400 1499]
|
["1500 Property and Equipment" 1500 1599]
|
||||||
["1500 Property and Equipment" 1500 1599]
|
["1600 Intangible Assets" 1600 1699]]
|
||||||
["1600 Intangible Assets" 1600 1699]]
|
:liability [["2100 Accounts Payable" 2100 2399]
|
||||||
:liability
|
["2400 Accrued Expenses" 2400 2499]
|
||||||
[["2100 Accounts Payable" 2100 2399]
|
["2500 Other Liabilities" 2500 2599]
|
||||||
["2400 Accrued Expenses" 2400 2499]
|
["2600 Split Accounts" 2600 2699]
|
||||||
["2500 Other Liabilities" 2500 2599]
|
["2700 Current Portion of Long-Term Debt" 2700 2799]
|
||||||
["2600 Split Accounts" 2600 2699]
|
["2800 Notes Payable" 2800 3000]]})
|
||||||
["2700 Current Portion of Long-Term Debt" 2700 2799]
|
|
||||||
["2800 Notes Payable" 2800 3000]]})
|
|
||||||
|
|
||||||
#_(re-frame/reg-sub
|
|
||||||
::liabilities
|
|
||||||
(fn [db]
|
|
||||||
(->> db ::report :balance-sheet-accounts (filter (fn [{:keys [account-type]}] :liability)))))
|
|
||||||
|
|
||||||
(re-frame/reg-event-db
|
(re-frame/reg-event-db
|
||||||
::received
|
::received
|
||||||
(fn [db [_ data]]
|
(fn [db [_ data]]
|
||||||
(-> db
|
(-> db
|
||||||
(assoc ::report (:balance-sheet data))
|
(assoc ::report (:balance-sheet data))
|
||||||
(assoc-in [:status :loading] false))))
|
(assoc-in [::loading] false))))
|
||||||
|
|
||||||
(re-frame/reg-sub
|
(re-frame/reg-sub
|
||||||
::params
|
::params
|
||||||
@@ -84,7 +81,7 @@
|
|||||||
::params-change
|
::params-change
|
||||||
(fn [cofx [_ params]]
|
(fn [cofx [_ params]]
|
||||||
{:db (-> (:db cofx)
|
{:db (-> (:db cofx)
|
||||||
(assoc-in [:status :loading] true)
|
(assoc-in [::loading] true)
|
||||||
(assoc-in [::params] params))
|
(assoc-in [::params] params))
|
||||||
:graphql {:token (-> cofx :db :user)
|
:graphql {:token (-> cofx :db :user)
|
||||||
:query-obj {:venia/queries [[:balance-sheet
|
:query-obj {:venia/queries [[:balance-sheet
|
||||||
@@ -169,17 +166,20 @@
|
|||||||
:event [::date-picked]
|
:event [::date-picked]
|
||||||
:popper-props (clj->js {:placement "right"})
|
:popper-props (clj->js {:placement "right"})
|
||||||
:subscription params}]]
|
:subscription params}]]
|
||||||
[:table.table.compact.balance-sheet
|
(if @(re-frame/subscribe [::loading])
|
||||||
[:tr
|
[:div [:i.icon.fa.fa-spin.fa-spinner]]
|
||||||
[:td.has-text-right "Period ending"]
|
[:table.table.compact.balance-sheet
|
||||||
[:td.has-text-right (date->str (str->date (:date params) standard))]
|
[:tr
|
||||||
[:td.has-text-right (when (:date params)
|
[:td.has-text-right "Period ending"]
|
||||||
(date->str (t/minus (str->date (:date params) standard) (t/years 1))))]
|
[:td.has-text-right (date->str (str->date (:date params) standard))]
|
||||||
[:td]]
|
[:td.has-text-right (when (:date params)
|
||||||
(list
|
(date->str (t/minus (str->date (:date params) standard) (t/years 1))))]
|
||||||
(overall-grouping :asset "Assets")
|
[:td]]
|
||||||
(overall-grouping :liability "Liabilities" )
|
(list
|
||||||
(overall-grouping :equity "Owner's Equity" ))]
|
(overall-grouping :asset "Assets")
|
||||||
|
(overall-grouping :liability "Liabilities" )
|
||||||
|
(overall-grouping :equity "Owner's Equity" ))])
|
||||||
|
|
||||||
|
|
||||||
]))
|
]))
|
||||||
{:component-will-mount #(re-frame/dispatch-sync [::params-change {:date (date->str (local-now) standard)}]) }))
|
{:component-will-mount #(re-frame/dispatch-sync [::params-change {:date (date->str (local-now) standard)}]) }))
|
||||||
|
|||||||
Reference in New Issue
Block a user