undoing commit.
This commit is contained in:
@@ -3,9 +3,7 @@
|
||||
[auto-ap.forms :as forms]
|
||||
[auto-ap.ledger.reports :as l-reports]
|
||||
[auto-ap.status :as status]
|
||||
[clojure.string :as str]
|
||||
[auto-ap.subs :as subs]
|
||||
[auto-ap.views.components.modal :as modal]
|
||||
[auto-ap.views.components.layouts
|
||||
:refer [appearing-side-bar side-bar-layout]]
|
||||
[auto-ap.views.components.switch-field :refer [switch-field]]
|
||||
@@ -24,7 +22,6 @@
|
||||
[re-frame.core :as re-frame]
|
||||
[reagent.core :as reagent]
|
||||
[vimsical.re-frame.fx.track :as track]
|
||||
[vimsical.re-frame.cofx.inject :as inject]
|
||||
[auto-ap.views.pages.ledger.report-table :as rtable]))
|
||||
|
||||
(defn data-params->query-params [params]
|
||||
@@ -72,68 +69,25 @@
|
||||
|
||||
(re-frame/reg-event-fx
|
||||
::report-requested
|
||||
[with-user (forms/in-form ::form) (re-frame/inject-cofx ::inject/sub [::subs/client])]
|
||||
(fn [{:keys [db user ::subs/client]} [_]]
|
||||
[with-user (forms/in-form ::form)]
|
||||
(fn [{:keys [db user]} [_]]
|
||||
{:db (dissoc db :report)
|
||||
:graphql {:token user
|
||||
:query-obj {:venia/queries [[:balance-sheet
|
||||
(-> (:data db)
|
||||
(assoc :client-id (:id client))
|
||||
(update :date (fnil #(date->str % standard) nil))
|
||||
(update :comparison-date (fnil #(date->str % standard) nil)))
|
||||
(assoc (:data db)
|
||||
:client-id (:id @(re-frame/subscribe [::subs/client])))
|
||||
[[:balance-sheet-accounts [:name :amount :account-type :id :numeric-code]]
|
||||
[:comparable-balance-sheet-accounts [:name :amount :account-type :id :numeric-code]]]]]}
|
||||
|
||||
:owns-state {:single ::page}
|
||||
:on-success [::received]}}))
|
||||
|
||||
(defn email-body [report-url]
|
||||
(js/encodeURIComponent
|
||||
(str
|
||||
"Hello,
|
||||
Click here (" report-url ") to download your financial reports. We have not finished reviewing and reconciling these numbers with you. Please review and let us know if anything seems missing or in need of correction.
|
||||
Click here (http://app.integreatconsult.com/) to login to the Financials app to review the details here.
|
||||
Click here (https://share.vidyard.com/watch/MHTo5PyXPxXUpVH93RWFM9?) for a video on how to run a P&L on your own.
|
||||
To see a history of past financial reports, click here: https://app.integreatconsult.com/reports/
|
||||
|
||||
NOTE: Please review the transactions we may have question for you here: https://app.integreatconsult.com/transactions/requires-feedback. You can either edit the transaction to what expense account it should be or email back what it should be.")))
|
||||
|
||||
(re-frame/reg-event-fx
|
||||
::received-pdf
|
||||
[(re-frame/inject-cofx ::inject/sub [::subs/client])]
|
||||
(fn [{:keys [::subs/client]} [_ result]]
|
||||
{:dispatch [::modal/modal-requested {:title "Your report is ready"
|
||||
:body [:div
|
||||
[:div "Click "
|
||||
[:a {:href (-> result :balance-sheet-pdf :url) :target "_new"} "here"] " to view it."]
|
||||
(when (seq (:emails client))
|
||||
[:div "Once you've confirmed you're happy with it, click "
|
||||
[:a {:href (str "mailto:" (str/join ";" (map :email (:emails client))) "?body=" (email-body (-> result :balance-sheet-pdf :url))
|
||||
"&subject=" (-> result :balance-sheet-pdf :name) " is ready")}
|
||||
"here"] " to open your email client and to send it to " (str/join "," (map (fn [e]
|
||||
(str (:email e) " (" (:description e) ")"))
|
||||
(:emails client))) "."])]}]}))
|
||||
|
||||
(re-frame/reg-event-fx
|
||||
::export-pdf
|
||||
[with-user (forms/in-form ::form) (re-frame/inject-cofx ::inject/sub [::subs/client])]
|
||||
(fn [{:keys [db user ::subs/client]} [_]]
|
||||
{:db (dissoc db :report)
|
||||
:graphql {:token user
|
||||
:query-obj {:venia/queries [[:balance-sheet-pdf
|
||||
(-> (:data db)
|
||||
(assoc :client-id (:id client))
|
||||
(update :date (fnil #(date->str % standard) nil))
|
||||
(update :comparison-date (fnil #(date->str % standard) nil)))
|
||||
[:url :name]]]}
|
||||
|
||||
:owns-state {:single ::page}
|
||||
:on-success [::received-pdf]}}))
|
||||
|
||||
|
||||
(re-frame/reg-event-fx
|
||||
::investigate-clicked
|
||||
(fn [{:keys [db]} [_ {:keys [from-numeric-code to-numeric-code date-range]}]]
|
||||
(fn [{:keys [db]} [_ {:keys [from-numeric-code to-numeric-code date-range] :as g}]]
|
||||
(println g)
|
||||
|
||||
{:db (-> db (assoc ::ledger-list-active? true))
|
||||
:dispatch [::data-page/additional-params-changed ::ledger {:client-id (:id @(re-frame/subscribe [::subs/client]))
|
||||
:from-numeric-code from-numeric-code
|
||||
@@ -172,17 +126,15 @@ NOTE: Please review the transactions we may have question for you here: https://
|
||||
|
||||
(re-frame/reg-event-fx
|
||||
::unmounted-balance-sheet
|
||||
(fn [{:keys [db]} _]
|
||||
{
|
||||
:db (dissoc db ::ledger-list-active?)
|
||||
:dispatch [::data-page/dispose ::ledger]
|
||||
(fn [_ _]
|
||||
{:dispatch [::data-page/dispose ::ledger]
|
||||
::track/dispose {:id ::ledger-params}}))
|
||||
|
||||
(re-frame/reg-event-fx
|
||||
::mounted-balance-sheet
|
||||
(fn [{:keys [db]} _]
|
||||
{:db (forms/start-form db ::form {:date (local-now)
|
||||
:comparison-date (t/minus (local-now) (t/years 1))
|
||||
{:db (forms/start-form db ::form {:date (date->str (local-now) standard)
|
||||
:comparison-date (date->str (t/minus (local-now) (t/years 1)) standard)
|
||||
:include-comparison true})
|
||||
::track/register {:id ::ledger-params
|
||||
:subscription [::data-page/params ::ledger]
|
||||
@@ -199,6 +151,7 @@ NOTE: Please review the transactions we may have question for you here: https://
|
||||
{:keys [data]} @(re-frame/subscribe [::forms/form ::form])]
|
||||
(form-inline {}
|
||||
[:div
|
||||
[status/status-notification {:statuses [[::status/single ::page]]}]
|
||||
[:div.report-controls
|
||||
[:div.level
|
||||
[:div.level-left
|
||||
@@ -206,8 +159,7 @@ NOTE: Please review the transactions we may have question for you here: https://
|
||||
[:div.control
|
||||
[:p.help "Date"]
|
||||
(raw-field
|
||||
[date-picker-friendly {:cljs-date? true
|
||||
:type "date"
|
||||
[date-picker-friendly {:type "date"
|
||||
:field [:date]}])]]
|
||||
[:div.level-item
|
||||
[:div.control
|
||||
@@ -224,9 +176,8 @@ NOTE: Please review the transactions we may have question for you here: https://
|
||||
[:div.control
|
||||
[:p.help "Comparison Date"]
|
||||
(raw-field
|
||||
[date-picker-friendly {:cljs-date? true
|
||||
:type "date"
|
||||
:field [:comparison-date]}])])]]
|
||||
[date-picker-friendly {:type "date"
|
||||
:field [:comparison-date]}])])]]
|
||||
[:div.level-right
|
||||
[:div.buttons
|
||||
|
||||
@@ -245,14 +196,18 @@ NOTE: Please review the transactions we may have question for you here: https://
|
||||
(assoc b
|
||||
:period (:comparison-date args)
|
||||
:amount (js/parseFloat (:amount b)))))))
|
||||
|
||||
client-names (->> @(re-frame/subscribe [::subs/clients-by-id])
|
||||
(map (fn [[k v]]
|
||||
[k (:name v)]))
|
||||
(into {}))
|
||||
pnl-data (l-reports/->PNLData args pnl-data client-names)
|
||||
report (l-reports/summarize-balance-sheet pnl-data)]
|
||||
[rtable/table {:widths (cond-> [30 13]
|
||||
(:include-comparison args) (into [13 13]))
|
||||
[rtable/table {:widths (into [30 13
|
||||
(when (:include-comparison args)
|
||||
13)
|
||||
(when (:include-comparison args)
|
||||
13)])
|
||||
:click-event ::investigate-clicked
|
||||
:table report}]))
|
||||
|
||||
@@ -265,6 +220,7 @@ NOTE: Please review the transactions we may have question for you here: https://
|
||||
[status/status-notification {:statuses [[::status/single ::page]]}]
|
||||
[report-form]
|
||||
|
||||
|
||||
[status/big-loader status]
|
||||
(when (and (not= :loading (:state status))
|
||||
report)
|
||||
|
||||
Reference in New Issue
Block a user