balance sheet fixes

This commit is contained in:
2023-09-06 07:35:47 -07:00
parent 4fe048f9c7
commit c417c4ac14
3 changed files with 26 additions and 7 deletions

View File

@@ -133,6 +133,7 @@
(do (do
(println "INVOICES")
(auto-ap.datomic/audit-transact-batch (->> (dc/q '[:find ?e ?c (auto-ap.datomic/audit-transact-batch (->> (dc/q '[:find ?e ?c
:in $ :in $
:where [?e :invoice/client ?c]] :where [?e :invoice/client ?c]]
@@ -143,6 +144,7 @@
:invoice/client c}))) :invoice/client c})))
{:user/name "hydrate-tuples"}) {:user/name "hydrate-tuples"})
(println "TRANSACTIONS")
(auto-ap.datomic/audit-transact-batch (->> (dc/q '[:find ?e ?c (auto-ap.datomic/audit-transact-batch (->> (dc/q '[:find ?e ?c
:in $ :in $
:where [?e :transaction/client ?c]] :where [?e :transaction/client ?c]]
@@ -154,6 +156,7 @@
{:user/name "hydrate-tuples"}) {:user/name "hydrate-tuples"})
(println "JOURNALS")
(auto-ap.datomic/audit-transact-batch (->> (dc/q '[:find ?e ?c (auto-ap.datomic/audit-transact-batch (->> (dc/q '[:find ?e ?c
:in $ :in $
:where [?e :journal-entry/client ?c]] :where [?e :journal-entry/client ?c]]
@@ -165,4 +168,16 @@
{:user/name "hydrate-tuples"}) {:user/name "hydrate-tuples"})
(println "PAYMENTS")
(auto-ap.datomic/audit-transact-batch (->> (dc/q '[:find ?e ?c
:in $
:where [?e :payment/client ?c]]
(dc/db conn)
)
(map (fn [[i c]]
{:db/id i
:payment/client c})))
{:user/name "hydrate-tuples"})
) )

View File

@@ -127,13 +127,15 @@
:request-method (:request-method request) :request-method (:request-method request)
:user (:identity request) :user (:identity request)
:user-role (:user/role (:identity request)) :user-role (:user/role (:identity request))
:user-name (:user/name (:identity request))} :user-name (:user/name (:identity request))
:query-params (:query-params request)}
(mu/trace ::http-request-trace (mu/trace ::http-request-trace
[] []
(lc/with-context {:uri (:uri request) (lc/with-context {:uri (:uri request)
:source "request" :source "request"
:user-role (:user/role (:identity request)) :user-role (:user/role (:identity request))
:user-name (:user/name (:identity request))} :user-name (:user/name (:identity request))
:query-params (:query-params request)}
(when-not (str/includes? (:uri request) "health-check") (when-not (str/includes? (:uri request) "health-check")

View File

@@ -56,6 +56,7 @@
(defn table->pdf [table widths] (defn table->pdf [table widths]
(let [cell-count (cell-count table)] (let [cell-count (cell-count table)]
(-> [:pdf-table {:header (mapv (-> [:pdf-table {:header (mapv
(fn [header] (fn [header]
(map cell->pdf header)) (map cell->pdf header))
@@ -162,6 +163,8 @@
(assoc b (assoc b
:period (:comparison-date args)))))) :period (:comparison-date args))))))
pnl-data (l-reports/->PNLData args data (by :db/id :client/code clients)) pnl-data (l-reports/->PNLData args data (by :db/id :client/code clients))
client-count (count (set (map :client-id (:data pnl-data))))
report (l-reports/summarize-balance-sheet pnl-data) report (l-reports/summarize-balance-sheet pnl-data)
output-stream (ByteArrayOutputStream.)] output-stream (ByteArrayOutputStream.)]
(log/info report) (log/info report)
@@ -174,8 +177,8 @@
(conj [:paragraph {:color [128 0 0] :size 9} (:warning report)]) (conj [:paragraph {:color [128 0 0] :size 9} (:warning report)])
(conj (conj
(table->pdf report (table->pdf report
(cond-> [30 13] (cond-> (into [30 ] (repeat client-count 13))
(:include-comparison args) (into [13 13]))))) (:include-comparison args) (into (repeat (* 2 client-count) 13))))))
output-stream) output-stream)
(.toByteArray output-stream))) (.toByteArray output-stream)))
@@ -312,7 +315,6 @@
(format "Cash-flows-%s-to-%s-for-%s" min-date max-date names))) (format "Cash-flows-%s-to-%s-for-%s" min-date max-date names)))
(defn journal-detail-args->name [args] (defn journal-detail-args->name [args]
(println args)
(let [min-date (atime/unparse-local (let [min-date (atime/unparse-local
(->> args :date_range :start) (->> args :date_range :start)
atime/iso-date) atime/iso-date)
@@ -326,7 +328,7 @@
(let [date (atime/unparse-local (let [date (atime/unparse-local
(:date args) (:date args)
atime/iso-date) atime/iso-date)
name (str/replace (->> args :client_id (pull-attr (dc/db conn) :client/name)) #" " "_" )] name (str/replace (->> args :client_ids (pull-many (dc/db conn) [:client/name]) (map :client/name) (str/join "-")) #" " "_" )]
(format "Balance-sheet-%s-for-%s" date name))) (format "Balance-sheet-%s-for-%s" date name)))
(defn print-pnl [user args data] (defn print-pnl [user args data]
@@ -384,7 +386,7 @@
:content-type "application/pdf"}) :content-type "application/pdf"})
@(dc/transact conn @(dc/transact conn
[{:report/name name [{:report/name name
:report/client [(:client_id args)] :report/client (:client_ids args)
:report/key key :report/key key
:report/url url :report/url url
:report/creator (:user user) :report/creator (:user user)