progress on a shared pnl with pdf.

This commit is contained in:
2022-03-18 23:00:57 -07:00
parent 6e41ada061
commit f536d1ac5e
6 changed files with 1646 additions and 172 deletions

View File

@@ -212,8 +212,31 @@
:clients (mapv #(select-keys % [:name :id]) (:clients (:data db))) }
:db (dissoc db :report)})))
(re-frame/reg-event-fx
::received-pdf
(fn [_ [_ result]]
(println result)
{:dispatch [::modal/modal-requested {:title "Your report is ready"
:body [:div
[:div "Click " [:a {:href (-> result :profit-and-loss-pdf :report-url) :target "_new"} "here"] " to view it."]]}]}))
(re-frame/reg-event-fx
::export-pdf
[with-user (forms/in-form ::form)]
(fn [{:keys [db user] :as cofx}]
(cond-> {:graphql {:token user
:owns-state {:single ::page}
:query-obj {:venia/queries [[:profit-and-loss-pdf
{:client-ids (map :id (:clients (:data db)))
:periods (mapv (fn [[start end] ] {:start (date->str start standard) :end (date->str end standard)} )
(:periods (:data db)))}
[:report_url]]]}
:on-success [::received-pdf]}
:set-uri-params {:periods (mapv (fn [[start end title]]
[(date->str start standard)
(date->str end standard)])
(:periods (:data db)))
:clients (mapv #(select-keys % [:name :id]) (:clients (:data db))) }
:db (dissoc db :report)})))
(re-frame/reg-event-db
@@ -876,7 +899,11 @@
:label "Include deltas"
:type "checkbox"}]]]]
[:div.level-right
[:button.button.is-primary "Run"]]]
[:div.buttons
[:button.button.is-secondary {:on-click (dispatch-event [::export-pdf])} "Export"]
[:button.button.is-primary "Run"]]
]]
[:div.report-control-detail {:ref (fn [el]
(when-not @!box
(reset! !box el)))}]]))))