progress on new report
This commit is contained in:
@@ -32,7 +32,7 @@
|
||||
::received
|
||||
[(forms/in-form ::form)]
|
||||
(fn [db [_ data]]
|
||||
(-> db (assoc :report (:profit-and-loss data)))))
|
||||
(-> db (assoc :report (:journal-detail-report data)))))
|
||||
|
||||
;; EVENTS
|
||||
|
||||
@@ -63,7 +63,10 @@
|
||||
[:id :debit :credit :location :running-balance
|
||||
[:account [:id :name]]]]
|
||||
:date]]
|
||||
:category]]]]]}
|
||||
:category
|
||||
:client-id
|
||||
:location
|
||||
[:account [:numeric-code :name]]]]]]]}
|
||||
:on-success [::received]}
|
||||
:set-uri-params {:date-range (:date-range (:data db))
|
||||
:clients (mapv #(select-keys (:client %) [:name :id]) (:clients (:data db))) }
|
||||
@@ -128,10 +131,6 @@ NOTE: Please review the transactions we may have question for you here: https://
|
||||
(fn [{:keys [db]} [_ & event]]
|
||||
{:db (dissoc db :report)}))
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
(defn report-control-detail [{:keys [active box which]} children]
|
||||
(when (and @box
|
||||
(= which @active))
|
||||
@@ -189,36 +188,19 @@ NOTE: Please review the transactions we may have question for you here: https://
|
||||
(when (not= @!box el)
|
||||
(reset! !box el)))}]]]))))
|
||||
|
||||
(defn pnl-report [{:keys [args report-data]}]
|
||||
(let [pnl-data (->> report-data
|
||||
:periods
|
||||
(mapcat (fn [p1 p2]
|
||||
(map
|
||||
(fn [a]
|
||||
(assoc a :period p1
|
||||
:amount (js/parseFloat (:amount a)))
|
||||
)
|
||||
(:accounts p2)))
|
||||
(:periods args)))
|
||||
client-codes (->> @(re-frame/subscribe [::subs/clients-by-id])
|
||||
(defn pnl-detail-report [{:keys [args report-data]}]
|
||||
(let [client-codes (->> @(re-frame/subscribe [::subs/clients-by-id])
|
||||
(map (fn [[k v]]
|
||||
[k (:code v)]))
|
||||
(into {}))
|
||||
pnl-data (l-reports/->PNLData args pnl-data client-codes)
|
||||
report (l-reports/summarize-pnl pnl-data)
|
||||
table (rtable/concat-tables (concat (:summaries report) (:details report)))]
|
||||
report (l-reports/journal-detail-report args report-data client-codes)]
|
||||
[:div
|
||||
[:h1.title "Profit and Loss - " (str/join ", " (map (comp :name :client) (:clients args)))]
|
||||
[:h1.title "Profit and Loss Detail - " (str/join ", " (map (comp :name :client) (:clients args)))]
|
||||
(when (:warning report)
|
||||
[:div.notification.is-warning.is-light
|
||||
(:warning report)])
|
||||
[rtable/table {:widths (into [20] (take (dec (rtable/cell-count table))
|
||||
(mapcat identity
|
||||
(repeat
|
||||
(if (-> pnl-data :args :include-deltas)
|
||||
[13 6 13]
|
||||
[13 6])))))
|
||||
:table table}]]))
|
||||
[rtable/table {:widths [20 20 60 20 20]
|
||||
:table report}]]))
|
||||
|
||||
|
||||
;; TODO Break out one category per location
|
||||
@@ -234,8 +216,8 @@ NOTE: Please review the transactions we may have question for you here: https://
|
||||
[status/big-loader status]
|
||||
(when (and (not= :loading (:state status))
|
||||
report)
|
||||
[pnl-report {:report-data report
|
||||
:args data}])]))
|
||||
[pnl-detail-report {:report-data report
|
||||
:args data}])]))
|
||||
|
||||
|
||||
(re-frame/reg-event-fx
|
||||
|
||||
@@ -30,12 +30,13 @@
|
||||
|
||||
[:span {:class "icon icon-performance-increase-1" :style {:font-size "25px"}}]
|
||||
[:span {:class "name"} "Profit & Loss"]]]
|
||||
[:li.menu-item
|
||||
[:a.item {:href (bidi/path-for routes/routes :profit-and-loss-detail)
|
||||
:class [(active-when ap = :profit-and-loss-detail)]}
|
||||
(when (= "admin" (:user/role user))
|
||||
[:li.menu-item
|
||||
[:a.item {:href (bidi/path-for routes/routes :profit-and-loss-detail)
|
||||
:class [(active-when ap = :profit-and-loss-detail)]}
|
||||
|
||||
[:span {:class "icon icon-performance-increase-1" :style {:font-size "25px"}}]
|
||||
[:span {:class "name"} "Profit & Loss Detail"]]]
|
||||
[:span {:class "icon icon-performance-increase-1" :style {:font-size "25px"}}]
|
||||
[:span {:class "name"} "Profit & Loss Detail"]]])
|
||||
[:li.menu-item
|
||||
[:a.item {:href (bidi/path-for routes/routes :balance-sheet)
|
||||
:class [(active-when ap = :balance-sheet)]}
|
||||
|
||||
Reference in New Issue
Block a user