adds creator.
This commit is contained in:
@@ -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}]]}})
|
||||
|
||||
@@ -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))]
|
||||
|
||||
@@ -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]
|
||||
|
||||
@@ -36,6 +36,7 @@
|
||||
{:fields {:url {:type 'String}
|
||||
:name {:type 'String}
|
||||
:created {:type :iso_date}
|
||||
:creator {:type 'String}
|
||||
:id {:type :id}}}
|
||||
|
||||
:report_page
|
||||
|
||||
@@ -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))
|
||||
|
||||
Reference in New Issue
Block a user