adds creator.
This commit is contained in:
@@ -24,4 +24,8 @@
|
|||||||
{:db/ident :report/url
|
{:db/ident :report/url
|
||||||
:db/doc "Where to download the report"
|
:db/doc "Where to download the report"
|
||||||
:db/valueType :db.type/string
|
:db/valueType :db.type/string
|
||||||
|
: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}]]}})
|
:db/cardinality :db.cardinality/one}]]}})
|
||||||
|
|||||||
@@ -25,6 +25,7 @@
|
|||||||
(:sort args) (add-sorter-fields {"client" ['[?e :report/client ?c]
|
(:sort args) (add-sorter-fields {"client" ['[?e :report/client ?c]
|
||||||
'[?c :client/name ?sort-client]]
|
'[?c :client/name ?sort-client]]
|
||||||
"created" ['[?e :report/created ?sort-created]]
|
"created" ['[?e :report/created ?sort-created]]
|
||||||
|
"creator" ['[?e :report/creator ?sort-creator]]
|
||||||
"name" ['[?e :report/name ?sort-name]
|
"name" ['[?e :report/name ?sort-name]
|
||||||
]}
|
]}
|
||||||
args)
|
args)
|
||||||
@@ -37,7 +38,7 @@
|
|||||||
(apply-pagination args))))
|
(apply-pagination args))))
|
||||||
|
|
||||||
(defn graphql-results [ids db 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)
|
ids)
|
||||||
(map #(update % :report/created c/from-date))
|
(map #(update % :report/created c/from-date))
|
||||||
(group-by :db/id))]
|
(group-by :db/id))]
|
||||||
|
|||||||
@@ -210,31 +210,9 @@
|
|||||||
|
|
||||||
(defn profit-and-loss-pdf [context args value]
|
(defn profit-and-loss-pdf [context args value]
|
||||||
(let [data (get-profit-and-loss 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}))
|
(->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)})))})))
|
|
||||||
|
|
||||||
|
|
||||||
(defn assoc-error [f]
|
(defn assoc-error [f]
|
||||||
|
|||||||
@@ -36,6 +36,7 @@
|
|||||||
{:fields {:url {:type 'String}
|
{:fields {:url {:type 'String}
|
||||||
:name {:type 'String}
|
:name {:type 'String}
|
||||||
:created {:type :iso_date}
|
:created {:type :iso_date}
|
||||||
|
:creator {:type 'String}
|
||||||
:id {:type :id}}}
|
:id {:type :id}}}
|
||||||
|
|
||||||
:report_page
|
:report_page
|
||||||
|
|||||||
@@ -29,14 +29,7 @@
|
|||||||
(.format (DecimalFormat. "0%") (:value cell))
|
(.format (DecimalFormat. "0%") (:value cell))
|
||||||
|
|
||||||
:else
|
:else
|
||||||
(str (:value cell)))
|
(str (:value cell)))]
|
||||||
cell-contents (if (:filters cell)
|
|
||||||
(do
|
|
||||||
(println (:filters cell))
|
|
||||||
cell-contents)
|
|
||||||
|
|
||||||
|
|
||||||
cell-contents)]
|
|
||||||
[:pdf-cell
|
[:pdf-cell
|
||||||
(cond-> {}
|
(cond-> {}
|
||||||
|
|
||||||
@@ -205,7 +198,7 @@
|
|||||||
names (str/replace (->> args :client_ids (d/pull-many (d/db conn) [:client/name]) (map :client/name) (str/join "-")) #" " "_" )]
|
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)))
|
(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))
|
(let [uuid (str (UUID/randomUUID))
|
||||||
pdf-data (make-pnl args data)
|
pdf-data (make-pnl args data)
|
||||||
name (args->name args)
|
name (args->name args)
|
||||||
@@ -221,5 +214,6 @@
|
|||||||
:report/client (:client_ids args)
|
:report/client (:client_ids args)
|
||||||
:report/key key
|
:report/key key
|
||||||
:report/url url
|
:report/url url
|
||||||
|
:report/creator (:user user)
|
||||||
:report/created (java.util.Date.)}])
|
:report/created (java.util.Date.)}])
|
||||||
url))
|
url))
|
||||||
|
|||||||
@@ -540,10 +540,7 @@ Please download it by clicking this link: " report-url)))
|
|||||||
(fn [table]
|
(fn [table]
|
||||||
(-> (:header table)
|
(-> (:header table)
|
||||||
(into (:rows table))
|
(into (:rows table))
|
||||||
(conj []))
|
(conj [])))
|
||||||
#_(println "table 1" table)
|
|
||||||
#_[(:header table)
|
|
||||||
(:rows table)])
|
|
||||||
rest))}))
|
rest))}))
|
||||||
|
|
||||||
(defn pnl-report [{:keys [args report-data]}]
|
(defn pnl-report [{:keys [args report-data]}]
|
||||||
|
|||||||
@@ -31,6 +31,7 @@
|
|||||||
[[:reports [:id
|
[[:reports [:id
|
||||||
:name
|
:name
|
||||||
:created
|
:created
|
||||||
|
:creator
|
||||||
:url]]
|
:url]]
|
||||||
:total
|
:total
|
||||||
:start
|
:start
|
||||||
|
|||||||
@@ -23,10 +23,11 @@
|
|||||||
[::data-page/updated-entity data-page {:name "deleted"}]
|
[::data-page/updated-entity data-page {:name "deleted"}]
|
||||||
#_[::invoice-updated ()(:void-invoice result)])}}))
|
#_[::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/row {:class (:class i) :id id}
|
||||||
[grid/cell {} name]
|
[grid/cell {} name]
|
||||||
|
[grid/cell {} creator]
|
||||||
[grid/cell {} (date->str created) ]
|
[grid/cell {} (date->str created) ]
|
||||||
[grid/button-cell {}
|
[grid/button-cell {}
|
||||||
[:div.buttons
|
[:div.buttons
|
||||||
@@ -51,6 +52,7 @@
|
|||||||
[grid/header
|
[grid/header
|
||||||
[grid/row {}
|
[grid/row {}
|
||||||
[grid/sortable-header-cell {:sort-key "name" :sort-name "Name"} "Name"]
|
[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/sortable-header-cell {:sort-key "created" :sort-name "Created" :style {:width "8em"}} "Created"]
|
||||||
[grid/header-cell {:style {:width (action-cell-width (if
|
[grid/header-cell {:style {:width (action-cell-width (if
|
||||||
is-admin?
|
is-admin?
|
||||||
|
|||||||
Reference in New Issue
Block a user