progress on reports.
This commit is contained in:
@@ -472,6 +472,7 @@
|
||||
|
||||
(mark-all-clients-dirty)
|
||||
|
||||
|
||||
(clients-needing-refresh (dc/db conn))
|
||||
|
||||
(upsert-running-balance)
|
||||
|
||||
@@ -341,6 +341,7 @@
|
||||
(update :class (fnil hh/add-class "") default-input-classes)
|
||||
(assoc :x-modelable "value")
|
||||
(assoc :type "text")
|
||||
(assoc "autocomplete" "off")
|
||||
(assoc :x-data (hx/json {:dp nil}) )
|
||||
(assoc :x-init " dp = initDatepicker($el);")
|
||||
(assoc "@htmx:before-history-save" "destroyDatepicker(dp)" )
|
||||
|
||||
@@ -33,7 +33,8 @@
|
||||
[config.core :refer [env] :as env]
|
||||
[datomic.api :as dc]
|
||||
[iol-ion.utils :refer [by]]
|
||||
[malli.core :as mc])
|
||||
[malli.core :as mc]
|
||||
[medley.core :refer [map-vals]])
|
||||
(:import
|
||||
[java.util UUID]
|
||||
[org.apache.commons.io.output ByteArrayOutputStream]))
|
||||
@@ -84,7 +85,7 @@
|
||||
data (into []
|
||||
(for [client-id client-ids
|
||||
p periods
|
||||
[client-id account-id location debits credits balance count] (iol-ion.query/detailed-account-snapshot (dc/db conn) client-id (coerce/to-date (:end p)))
|
||||
[client-id account-id location debits credits balance count] (iol-ion.query/detailed-account-snapshot (dc/db conn) client-id (coerce/to-date (:end p)) (coerce/to-date (:start p)))
|
||||
:let [account ((or (lookup-account client-id) {}) account-id)]]
|
||||
{:client-id client-id
|
||||
:account-id account-id
|
||||
@@ -92,7 +93,11 @@
|
||||
:debits debits
|
||||
:credits credits
|
||||
:count count
|
||||
:amount balance
|
||||
:amount (if (#{:account-type/asset
|
||||
:account-type/dividend
|
||||
:account-type/expense} (:account_type account))
|
||||
(- (or debits 0.0) (or credits 0.0))
|
||||
(- (or credits 0.0) (or debits 0.0)))
|
||||
:account-type (:account_type account)
|
||||
:numeric-code (:numeric_code account)
|
||||
:name (:name account)
|
||||
@@ -120,7 +125,7 @@
|
||||
(let [{:keys [client warning]} (maybe-trim-clients request client)
|
||||
{:keys [data report]} (get-report (assoc-in request [:form-params :client] client))
|
||||
client-count (count (set (map :client-id (:data data))))
|
||||
table-contents (concat-tables (:details report))]
|
||||
table-contents (concat-tables (concat (:summaries report) (:details report)))]
|
||||
(list
|
||||
[:div.text-2xl.font-bold.text-gray-600 (str "Profit and loss - " (str/join ", " (map :client/name client)))]
|
||||
(table {:widths (into [20] (take (dec (cell-count table-contents))
|
||||
|
||||
@@ -166,7 +166,7 @@
|
||||
(filter (comp in-range? :numeric-code))
|
||||
(filter #(not= "A" (:location %)))
|
||||
(group-by (juxt :client-id :location))
|
||||
(filter (fn [[_ as]]
|
||||
(filter (fn [[_ as]]
|
||||
(not (dollars-0? (reduce + 0 (map (comp or-0 :amount) as))))))
|
||||
(mapcat second)
|
||||
(map (fn [a]
|
||||
@@ -185,11 +185,11 @@
|
||||
(:location x))]))))
|
||||
|
||||
(defn aggregate-accounts [pnl-data]
|
||||
(reduce (fnil + 0.0) 0.0 (map :amount (:data pnl-data))))
|
||||
(reduce (fnil + 0.0) 0.0 (map (comp or-0 :amount) (:data pnl-data))))
|
||||
|
||||
(defn aggregate-cashflow-accounts [pnl-data]
|
||||
(reduce (fnil + 0.0) 0.0 (map (fn [d]
|
||||
(cashflow-account->amount (:numeric-code d) (:amount d)))
|
||||
(reduce (fnil + 0.0) 0.0 (map (comp or-0 (fn [d]
|
||||
(cashflow-account->amount (:numeric-code d) (:amount d))))
|
||||
(:data pnl-data))))
|
||||
|
||||
(defn aggregate-credits [pnl-data]
|
||||
@@ -260,6 +260,8 @@
|
||||
(defn filter-period [pnl-data period]
|
||||
(-> pnl-data
|
||||
(update :data (fn [data]
|
||||
#_(println "THE PERIOD IS" period
|
||||
(take 3 ((group-by :period data) period)))
|
||||
((group-by :period data) period)))
|
||||
(update :filters (fn [f]
|
||||
(assoc f :date-range period)))))
|
||||
@@ -498,6 +500,10 @@
|
||||
this-name-exists? (->> (:data p)
|
||||
(filter (comp #{name} :name))
|
||||
seq)]
|
||||
(if ( = 40000 numeric-code)
|
||||
(do (println "TEST HERE" numeric-code)
|
||||
(clojure.pprint/pprint pnl-data))
|
||||
)
|
||||
(merge
|
||||
(if this-name-exists?
|
||||
{:format :dollar
|
||||
|
||||
Reference in New Issue
Block a user