adds creator.

This commit is contained in:
2022-03-31 07:35:06 -07:00
parent a538cffe6d
commit 7199b9192e
8 changed files with 18 additions and 40 deletions

View File

@@ -24,4 +24,8 @@
{:db/ident :report/url
:db/doc "Where to download the report"
:db/valueType :db.type/string
:db/cardinality :db.cardinality/one}]]}})
:db/cardinality :db.cardinality/one}]]}
::add-creator {:txes [[{:db/ident :report/creator
:db/doc "Creator of the report's name"
:db/valueType :db.type/string
:db/cardinality :db.cardinality/one}]]}})

View File

@@ -25,6 +25,7 @@
(:sort args) (add-sorter-fields {"client" ['[?e :report/client ?c]
'[?c :client/name ?sort-client]]
"created" ['[?e :report/created ?sort-created]]
"creator" ['[?e :report/creator ?sort-creator]]
"name" ['[?e :report/name ?sort-name]
]}
args)
@@ -37,7 +38,7 @@
(apply-pagination args))))
(defn graphql-results [ids db args]
(let [results (->> (d/pull-many db '[:db/id :report/client :report/created :report/url :report/name]
(let [results (->> (d/pull-many db '[:db/id :report/client :report/created :report/url :report/name :report/creator]
ids)
(map #(update % :report/created c/from-date))
(group-by :db/id))]

View File

@@ -210,31 +210,9 @@
(defn profit-and-loss-pdf [context args value]
(let [data (get-profit-and-loss context args value)
result (print-pnl args data)]
result (print-pnl (:id context) args data)]
(->graphql {:report_url result}))
#_(let [client-id (:client_id args)
client-ids (or (some-> client-id vector)
(filter identity (:client_ids args)))
_ (when (not (seq client-ids))
(throw (ex-info "Please select a client." {:validation-error "Please select a client."})))
_ (doseq [client-id client-ids]
(assert-can-see-client (:id context) client-id))
all-ledger-entries (->> client-ids
(map (fn [client-id]
[client-id (full-ledger-for-client client-id)]))
(into {}))
lookup-account (->> client-ids
(map (fn [client-id]
[client-id (build-account-lookup client-id)]))
(into {}))]
(->graphql
{:periods
(->> (:periods args)
(mapv (fn [{:keys [start end]}]
{:accounts (mapcat
#(roll-up-until (lookup-account %) (all-ledger-entries %) (coerce/to-date end) (coerce/to-date start) )
client-ids)})))})))
(->graphql {:report_url result})))
(defn assoc-error [f]

View File

@@ -36,6 +36,7 @@
{:fields {:url {:type 'String}
:name {:type 'String}
:created {:type :iso_date}
:creator {:type 'String}
:id {:type :id}}}
:report_page

View File

@@ -29,14 +29,7 @@
(.format (DecimalFormat. "0%") (:value cell))
:else
(str (:value cell)))
cell-contents (if (:filters cell)
(do
(println (:filters cell))
cell-contents)
cell-contents)]
(str (:value cell)))]
[:pdf-cell
(cond-> {}
@@ -205,7 +198,7 @@
names (str/replace (->> args :client_ids (d/pull-many (d/db conn) [:client/name]) (map :client/name) (str/join "-")) #" " "_" )]
(format "Profit-and-loss-%s-to-%s-for-%s" min-date max-date names)))
(defn print-pnl [args data]
(defn print-pnl [user args data]
(let [uuid (str (UUID/randomUUID))
pdf-data (make-pnl args data)
name (args->name args)
@@ -221,5 +214,6 @@
:report/client (:client_ids args)
:report/key key
:report/url url
:report/creator (:user user)
:report/created (java.util.Date.)}])
url))

View File

@@ -540,10 +540,7 @@ Please download it by clicking this link: " report-url)))
(fn [table]
(-> (:header table)
(into (:rows table))
(conj []))
#_(println "table 1" table)
#_[(:header table)
(:rows table)])
(conj [])))
rest))}))
(defn pnl-report [{:keys [args report-data]}]

View File

@@ -31,6 +31,7 @@
[[:reports [:id
:name
:created
:creator
:url]]
:total
:start

View File

@@ -23,10 +23,11 @@
[::data-page/updated-entity data-page {:name "deleted"}]
#_[::invoice-updated ()(:void-invoice result)])}}))
(defn row [{{:keys [name created url id] :as i} :row is-admin? :is-admin? data-page :data-page}]
(defn row [{{:keys [name creator created url id] :as i} :row is-admin? :is-admin? data-page :data-page}]
[:<>
[grid/row {:class (:class i) :id id}
[grid/cell {} name]
[grid/cell {} creator]
[grid/cell {} (date->str created) ]
[grid/button-cell {}
[:div.buttons
@@ -51,6 +52,7 @@
[grid/header
[grid/row {}
[grid/sortable-header-cell {:sort-key "name" :sort-name "Name"} "Name"]
[grid/sortable-header-cell {:sort-key "creator" :sort-name "Created by"} "Created by"]
[grid/sortable-header-cell {:sort-key "created" :sort-name "Created" :style {:width "8em"}} "Created"]
[grid/header-cell {:style {:width (action-cell-width (if
is-admin?