undoing commit.
This commit is contained in:
@@ -9,7 +9,7 @@
|
|||||||
:refer [->graphql <-graphql assert-admin assert-can-see-client result->page]]
|
:refer [->graphql <-graphql assert-admin assert-can-see-client result->page]]
|
||||||
[auto-ap.parse.util :as parse]
|
[auto-ap.parse.util :as parse]
|
||||||
[auto-ap.utils :refer [by dollars=]]
|
[auto-ap.utils :refer [by dollars=]]
|
||||||
[auto-ap.pdf.ledger :refer [print-pnl print-balance-sheet]]
|
[auto-ap.pdf.ledger :refer [print-pnl]]
|
||||||
[clj-time.coerce :as coerce]
|
[clj-time.coerce :as coerce]
|
||||||
[clojure.tools.logging :as log]
|
[clojure.tools.logging :as log]
|
||||||
[com.walmartlabs.lacinia.util :refer [attach-resolvers]]
|
[com.walmartlabs.lacinia.util :refer [attach-resolvers]]
|
||||||
@@ -214,12 +214,6 @@
|
|||||||
|
|
||||||
(->graphql result)))
|
(->graphql result)))
|
||||||
|
|
||||||
(defn balance-sheet-pdf [context args value]
|
|
||||||
(let [data (get-balance-sheet context args value)
|
|
||||||
result (print-balance-sheet (:id context) args data)]
|
|
||||||
|
|
||||||
(->graphql result)))
|
|
||||||
|
|
||||||
|
|
||||||
(defn assoc-error [f]
|
(defn assoc-error [f]
|
||||||
(fn [entry]
|
(fn [entry]
|
||||||
@@ -518,7 +512,7 @@
|
|||||||
:account_type {:type :account_type}
|
:account_type {:type :account_type}
|
||||||
:name {:type 'String}}}
|
:name {:type 'String}}}
|
||||||
|
|
||||||
:report_pdf
|
:profit_and_loss_pdf
|
||||||
{:fields {:url {:type 'String}
|
{:fields {:url {:type 'String}
|
||||||
:name {:type 'String}}}
|
:name {:type 'String}}}
|
||||||
|
|
||||||
@@ -587,20 +581,13 @@
|
|||||||
:include_deltas {:type 'Boolean}}
|
:include_deltas {:type 'Boolean}}
|
||||||
:resolve :get-profit-and-loss}
|
:resolve :get-profit-and-loss}
|
||||||
|
|
||||||
:profit_and_loss_pdf {:type :report_pdf
|
:profit_and_loss_pdf {:type :profit_and_loss_pdf
|
||||||
:args {:client_id {:type :id}
|
:args {:client_id {:type :id}
|
||||||
:client_ids {:type '(list :id)}
|
:client_ids {:type '(list :id)}
|
||||||
:periods {:type '(list :date_range)}
|
:periods {:type '(list :date_range)}
|
||||||
:include_deltas {:type 'Boolean}}
|
:include_deltas {:type 'Boolean}}
|
||||||
:resolve :profit-and-loss-pdf}
|
:resolve :profit-and-loss-pdf}
|
||||||
|
|
||||||
:balance_sheet_pdf {:type :report_pdf
|
|
||||||
:args {:client_id {:type :id}
|
|
||||||
:include_comparison {:type 'Boolean}
|
|
||||||
:date {:type :iso_date}
|
|
||||||
:comparison_date {:type :iso_date}}
|
|
||||||
:resolve :balance-sheet-pdf}
|
|
||||||
|
|
||||||
:ledger_page {:type :ledger_page
|
:ledger_page {:type :ledger_page
|
||||||
:args {:filters {:type :ledger_filters}}
|
:args {:filters {:type :ledger_filters}}
|
||||||
:resolve :get-ledger-page}})
|
:resolve :get-ledger-page}})
|
||||||
@@ -669,7 +656,6 @@
|
|||||||
:get-balance-sheet get-balance-sheet
|
:get-balance-sheet get-balance-sheet
|
||||||
:get-profit-and-loss get-profit-and-loss
|
:get-profit-and-loss get-profit-and-loss
|
||||||
:profit-and-loss-pdf profit-and-loss-pdf
|
:profit-and-loss-pdf profit-and-loss-pdf
|
||||||
:balance-sheet-pdf balance-sheet-pdf
|
|
||||||
:mutation/delete-external-ledger delete-external-ledger
|
:mutation/delete-external-ledger delete-external-ledger
|
||||||
:mutation/import-ledger import-ledger})
|
:mutation/import-ledger import-ledger})
|
||||||
|
|
||||||
|
|||||||
@@ -10,8 +10,7 @@
|
|||||||
[clojure.java.io :as io]
|
[clojure.java.io :as io]
|
||||||
[clojure.string :as str]
|
[clojure.string :as str]
|
||||||
[config.core :refer [env]]
|
[config.core :refer [env]]
|
||||||
[datomic.api :as d]
|
[datomic.api :as d])
|
||||||
[clojure.tools.logging :as log])
|
|
||||||
(:import
|
(:import
|
||||||
(java.io ByteArrayOutputStream)
|
(java.io ByteArrayOutputStream)
|
||||||
(java.text DecimalFormat)
|
(java.text DecimalFormat)
|
||||||
@@ -142,40 +141,6 @@
|
|||||||
9))]
|
9))]
|
||||||
table))
|
table))
|
||||||
|
|
||||||
(defn make-balance-sheet [args data]
|
|
||||||
|
|
||||||
(let [data (<-graphql data)
|
|
||||||
args (<-graphql args)
|
|
||||||
args (assoc args
|
|
||||||
:periods (filter identity (cond-> [(:date args)]
|
|
||||||
(:include-comparison args) (conj (:comparison-date args)))))
|
|
||||||
clients (d/pull-many (d/db conn) '[:client/name :db/id] [(:client-id args)])
|
|
||||||
data (concat (->> (:balance-sheet-accounts data)
|
|
||||||
(map (fn [b]
|
|
||||||
(assoc b
|
|
||||||
:period (:date args)))))
|
|
||||||
(->> (:comparable-balance-sheet-accounts data)
|
|
||||||
(map (fn [b]
|
|
||||||
(assoc b
|
|
||||||
:period (:comparison-date args))))))
|
|
||||||
pnl-data (l-reports/->PNLData args data (by :db/id clients))
|
|
||||||
report (l-reports/summarize-balance-sheet pnl-data)
|
|
||||||
output-stream (ByteArrayOutputStream.)]
|
|
||||||
(log/info report)
|
|
||||||
(pdf/pdf
|
|
||||||
(-> [{:left-margin 10 :right-margin 10 :top-margin 15 :bottom-margin 15
|
|
||||||
:size :letter
|
|
||||||
:font {:size 6
|
|
||||||
:ttf-name "fonts/calibri-light.ttf"}}
|
|
||||||
[:heading (str "Balance Sheet - " (str/join ", " (map :client/name clients)))]]
|
|
||||||
(conj [:paragraph {:color [128 0 0] :size 9} (:warning report)])
|
|
||||||
(conj
|
|
||||||
(table->pdf report
|
|
||||||
(cond-> [30 13]
|
|
||||||
(:include-comparison args) (into [13 13])))))
|
|
||||||
output-stream)
|
|
||||||
(.toByteArray output-stream)))
|
|
||||||
|
|
||||||
(defn make-pnl [args data]
|
(defn make-pnl [args data]
|
||||||
|
|
||||||
(let [data (<-graphql data)
|
(let [data (<-graphql data)
|
||||||
@@ -223,7 +188,7 @@
|
|||||||
output-stream)
|
output-stream)
|
||||||
(.toByteArray output-stream)))
|
(.toByteArray output-stream)))
|
||||||
|
|
||||||
(defn pnl-args->name [args]
|
(defn args->name [args]
|
||||||
(let [min-date (atime/unparse-local
|
(let [min-date (atime/unparse-local
|
||||||
(->> args :periods (map :start) first)
|
(->> args :periods (map :start) first)
|
||||||
atime/iso-date)
|
atime/iso-date)
|
||||||
@@ -233,17 +198,10 @@
|
|||||||
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 balance-sheet-args->name [args]
|
|
||||||
(let [date (atime/unparse-local
|
|
||||||
(:date args)
|
|
||||||
atime/iso-date)
|
|
||||||
name (str/replace (->> args :client_id (d/pull (d/db conn) [:client/name]) :client/name ) #" " "_" )]
|
|
||||||
(format "Balance-sheet-%s-for-%s" date name)))
|
|
||||||
|
|
||||||
(defn print-pnl [user 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 (pnl-args->name args)
|
name (args->name args)
|
||||||
key (str "reports/pnl/" uuid "/" name ".pdf")
|
key (str "reports/pnl/" uuid "/" name ".pdf")
|
||||||
url (str "http://" (:data-bucket env) ".s3-website-us-east-1.amazonaws.com/" key)]
|
url (str "http://" (:data-bucket env) ".s3-website-us-east-1.amazonaws.com/" key)]
|
||||||
(s3/put-object :bucket-name (:data-bucket env)
|
(s3/put-object :bucket-name (:data-bucket env)
|
||||||
@@ -260,24 +218,3 @@
|
|||||||
:report/created (java.util.Date.)}])
|
:report/created (java.util.Date.)}])
|
||||||
{:report/name name
|
{:report/name name
|
||||||
:report/url url }))
|
:report/url url }))
|
||||||
|
|
||||||
(defn print-balance-sheet [user args data]
|
|
||||||
(let [uuid (str (UUID/randomUUID))
|
|
||||||
pdf-data (make-balance-sheet args data)
|
|
||||||
name (balance-sheet-args->name args)
|
|
||||||
key (str "reports/balance-sheet/" uuid "/" name ".pdf")
|
|
||||||
url (str "http://" (:data-bucket env) ".s3-website-us-east-1.amazonaws.com/" key)]
|
|
||||||
(s3/put-object :bucket-name (:data-bucket env)
|
|
||||||
:key key
|
|
||||||
:input-stream (io/make-input-stream pdf-data {})
|
|
||||||
:metadata {:content-length (count pdf-data)
|
|
||||||
:content-type "application/pdf"})
|
|
||||||
@(d/transact conn
|
|
||||||
[{:report/name name
|
|
||||||
:report/client [(:client_id args)]
|
|
||||||
:report/key key
|
|
||||||
:report/url url
|
|
||||||
:report/creator (:user user)
|
|
||||||
:report/created (java.util.Date.)}])
|
|
||||||
{:report/name name
|
|
||||||
:report/url url }))
|
|
||||||
|
|||||||
@@ -14,7 +14,7 @@
|
|||||||
(defn date->str [d]
|
(defn date->str [d]
|
||||||
#?(:clj
|
#?(:clj
|
||||||
(atime/unparse-local d atime/normal-date)
|
(atime/unparse-local d atime/normal-date)
|
||||||
:cljs (au/date->str d au/pretty)))
|
:cljs (au/date->str d au/standard)))
|
||||||
|
|
||||||
|
|
||||||
(def ranges
|
(def ranges
|
||||||
@@ -407,8 +407,8 @@
|
|||||||
|
|
||||||
(defn balance-sheet-headers [pnl-data]
|
(defn balance-sheet-headers [pnl-data]
|
||||||
[(cond-> [{:value "Period Ending"}
|
[(cond-> [{:value "Period Ending"}
|
||||||
{:value (date->str (:date (:args pnl-data)))}]
|
{:value (:date (:args pnl-data))}]
|
||||||
(:include-comparison (:args pnl-data)) (into [{:value (date->str (:comparison-date (:args pnl-data)))} {:value "+/-"}]))])
|
(:include-comparison (:args pnl-data)) (into [{:value (:comparison-date (:args pnl-data))} {:value "+/-"}]))])
|
||||||
|
|
||||||
(defn append-deltas [table]
|
(defn append-deltas [table]
|
||||||
(->> table
|
(->> table
|
||||||
@@ -420,6 +420,7 @@
|
|||||||
(:value b))})]))))
|
(:value b))})]))))
|
||||||
|
|
||||||
(defn summarize-balance-sheet [pnl-data]
|
(defn summarize-balance-sheet [pnl-data]
|
||||||
|
(println (:periods (:args pnl-data)))
|
||||||
(let [table (-> []
|
(let [table (-> []
|
||||||
(into (detail-rows pnl-data
|
(into (detail-rows pnl-data
|
||||||
:assets
|
:assets
|
||||||
|
|||||||
@@ -3,9 +3,7 @@
|
|||||||
[auto-ap.forms :as forms]
|
[auto-ap.forms :as forms]
|
||||||
[auto-ap.ledger.reports :as l-reports]
|
[auto-ap.ledger.reports :as l-reports]
|
||||||
[auto-ap.status :as status]
|
[auto-ap.status :as status]
|
||||||
[clojure.string :as str]
|
|
||||||
[auto-ap.subs :as subs]
|
[auto-ap.subs :as subs]
|
||||||
[auto-ap.views.components.modal :as modal]
|
|
||||||
[auto-ap.views.components.layouts
|
[auto-ap.views.components.layouts
|
||||||
:refer [appearing-side-bar side-bar-layout]]
|
:refer [appearing-side-bar side-bar-layout]]
|
||||||
[auto-ap.views.components.switch-field :refer [switch-field]]
|
[auto-ap.views.components.switch-field :refer [switch-field]]
|
||||||
@@ -24,7 +22,6 @@
|
|||||||
[re-frame.core :as re-frame]
|
[re-frame.core :as re-frame]
|
||||||
[reagent.core :as reagent]
|
[reagent.core :as reagent]
|
||||||
[vimsical.re-frame.fx.track :as track]
|
[vimsical.re-frame.fx.track :as track]
|
||||||
[vimsical.re-frame.cofx.inject :as inject]
|
|
||||||
[auto-ap.views.pages.ledger.report-table :as rtable]))
|
[auto-ap.views.pages.ledger.report-table :as rtable]))
|
||||||
|
|
||||||
(defn data-params->query-params [params]
|
(defn data-params->query-params [params]
|
||||||
@@ -72,68 +69,25 @@
|
|||||||
|
|
||||||
(re-frame/reg-event-fx
|
(re-frame/reg-event-fx
|
||||||
::report-requested
|
::report-requested
|
||||||
[with-user (forms/in-form ::form) (re-frame/inject-cofx ::inject/sub [::subs/client])]
|
[with-user (forms/in-form ::form)]
|
||||||
(fn [{:keys [db user ::subs/client]} [_]]
|
(fn [{:keys [db user]} [_]]
|
||||||
{:db (dissoc db :report)
|
{:db (dissoc db :report)
|
||||||
:graphql {:token user
|
:graphql {:token user
|
||||||
:query-obj {:venia/queries [[:balance-sheet
|
:query-obj {:venia/queries [[:balance-sheet
|
||||||
(-> (:data db)
|
(assoc (:data db)
|
||||||
(assoc :client-id (:id client))
|
:client-id (:id @(re-frame/subscribe [::subs/client])))
|
||||||
(update :date (fnil #(date->str % standard) nil))
|
|
||||||
(update :comparison-date (fnil #(date->str % standard) nil)))
|
|
||||||
[[:balance-sheet-accounts [:name :amount :account-type :id :numeric-code]]
|
[[:balance-sheet-accounts [:name :amount :account-type :id :numeric-code]]
|
||||||
[:comparable-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}
|
:owns-state {:single ::page}
|
||||||
:on-success [::received]}}))
|
: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
|
(re-frame/reg-event-fx
|
||||||
::investigate-clicked
|
::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))
|
{:db (-> db (assoc ::ledger-list-active? true))
|
||||||
:dispatch [::data-page/additional-params-changed ::ledger {:client-id (:id @(re-frame/subscribe [::subs/client]))
|
:dispatch [::data-page/additional-params-changed ::ledger {:client-id (:id @(re-frame/subscribe [::subs/client]))
|
||||||
:from-numeric-code from-numeric-code
|
: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
|
(re-frame/reg-event-fx
|
||||||
::unmounted-balance-sheet
|
::unmounted-balance-sheet
|
||||||
(fn [{:keys [db]} _]
|
(fn [_ _]
|
||||||
{
|
{:dispatch [::data-page/dispose ::ledger]
|
||||||
:db (dissoc db ::ledger-list-active?)
|
|
||||||
:dispatch [::data-page/dispose ::ledger]
|
|
||||||
::track/dispose {:id ::ledger-params}}))
|
::track/dispose {:id ::ledger-params}}))
|
||||||
|
|
||||||
(re-frame/reg-event-fx
|
(re-frame/reg-event-fx
|
||||||
::mounted-balance-sheet
|
::mounted-balance-sheet
|
||||||
(fn [{:keys [db]} _]
|
(fn [{:keys [db]} _]
|
||||||
{:db (forms/start-form db ::form {:date (local-now)
|
{:db (forms/start-form db ::form {:date (date->str (local-now) standard)
|
||||||
:comparison-date (t/minus (local-now) (t/years 1))
|
:comparison-date (date->str (t/minus (local-now) (t/years 1)) standard)
|
||||||
:include-comparison true})
|
:include-comparison true})
|
||||||
::track/register {:id ::ledger-params
|
::track/register {:id ::ledger-params
|
||||||
:subscription [::data-page/params ::ledger]
|
: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])]
|
{:keys [data]} @(re-frame/subscribe [::forms/form ::form])]
|
||||||
(form-inline {}
|
(form-inline {}
|
||||||
[:div
|
[:div
|
||||||
|
[status/status-notification {:statuses [[::status/single ::page]]}]
|
||||||
[:div.report-controls
|
[:div.report-controls
|
||||||
[:div.level
|
[:div.level
|
||||||
[:div.level-left
|
[:div.level-left
|
||||||
@@ -206,8 +159,7 @@ NOTE: Please review the transactions we may have question for you here: https://
|
|||||||
[:div.control
|
[:div.control
|
||||||
[:p.help "Date"]
|
[:p.help "Date"]
|
||||||
(raw-field
|
(raw-field
|
||||||
[date-picker-friendly {:cljs-date? true
|
[date-picker-friendly {:type "date"
|
||||||
:type "date"
|
|
||||||
:field [:date]}])]]
|
:field [:date]}])]]
|
||||||
[:div.level-item
|
[:div.level-item
|
||||||
[:div.control
|
[:div.control
|
||||||
@@ -224,9 +176,8 @@ NOTE: Please review the transactions we may have question for you here: https://
|
|||||||
[:div.control
|
[:div.control
|
||||||
[:p.help "Comparison Date"]
|
[:p.help "Comparison Date"]
|
||||||
(raw-field
|
(raw-field
|
||||||
[date-picker-friendly {:cljs-date? true
|
[date-picker-friendly {:type "date"
|
||||||
:type "date"
|
:field [:comparison-date]}])])]]
|
||||||
:field [:comparison-date]}])])]]
|
|
||||||
[:div.level-right
|
[:div.level-right
|
||||||
[:div.buttons
|
[:div.buttons
|
||||||
|
|
||||||
@@ -245,14 +196,18 @@ NOTE: Please review the transactions we may have question for you here: https://
|
|||||||
(assoc b
|
(assoc b
|
||||||
:period (:comparison-date args)
|
:period (:comparison-date args)
|
||||||
:amount (js/parseFloat (:amount b)))))))
|
:amount (js/parseFloat (:amount b)))))))
|
||||||
|
|
||||||
client-names (->> @(re-frame/subscribe [::subs/clients-by-id])
|
client-names (->> @(re-frame/subscribe [::subs/clients-by-id])
|
||||||
(map (fn [[k v]]
|
(map (fn [[k v]]
|
||||||
[k (:name v)]))
|
[k (:name v)]))
|
||||||
(into {}))
|
(into {}))
|
||||||
pnl-data (l-reports/->PNLData args pnl-data client-names)
|
pnl-data (l-reports/->PNLData args pnl-data client-names)
|
||||||
report (l-reports/summarize-balance-sheet pnl-data)]
|
report (l-reports/summarize-balance-sheet pnl-data)]
|
||||||
[rtable/table {:widths (cond-> [30 13]
|
[rtable/table {:widths (into [30 13
|
||||||
(:include-comparison args) (into [13 13]))
|
(when (:include-comparison args)
|
||||||
|
13)
|
||||||
|
(when (:include-comparison args)
|
||||||
|
13)])
|
||||||
:click-event ::investigate-clicked
|
:click-event ::investigate-clicked
|
||||||
:table report}]))
|
: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]]}]
|
[status/status-notification {:statuses [[::status/single ::page]]}]
|
||||||
[report-form]
|
[report-form]
|
||||||
|
|
||||||
|
|
||||||
[status/big-loader status]
|
[status/big-loader status]
|
||||||
(when (and (not= :loading (:state status))
|
(when (and (not= :loading (:state status))
|
||||||
report)
|
report)
|
||||||
|
|||||||
@@ -5,6 +5,7 @@
|
|||||||
[auto-ap.status :as status]
|
[auto-ap.status :as status]
|
||||||
[auto-ap.subs :as subs]
|
[auto-ap.subs :as subs]
|
||||||
[auto-ap.views.pages.ledger.report-table :as rtable]
|
[auto-ap.views.pages.ledger.report-table :as rtable]
|
||||||
|
[auto-ap.utils :refer [dollars-0?]]
|
||||||
[auto-ap.views.components.buttons :as buttons]
|
[auto-ap.views.components.buttons :as buttons]
|
||||||
[auto-ap.views.components.layouts
|
[auto-ap.views.components.layouts
|
||||||
:refer [appearing-side-bar side-bar-layout]]
|
:refer [appearing-side-bar side-bar-layout]]
|
||||||
@@ -17,6 +18,8 @@
|
|||||||
[auto-ap.views.utils
|
[auto-ap.views.utils
|
||||||
:refer [date->str
|
:refer [date->str
|
||||||
date-picker-friendly
|
date-picker-friendly
|
||||||
|
->$
|
||||||
|
->%
|
||||||
dispatch-event
|
dispatch-event
|
||||||
local-today
|
local-today
|
||||||
multi-field
|
multi-field
|
||||||
@@ -68,7 +71,7 @@
|
|||||||
(re-frame/reg-event-fx
|
(re-frame/reg-event-fx
|
||||||
::report-requested
|
::report-requested
|
||||||
[with-user (forms/in-form ::form)]
|
[with-user (forms/in-form ::form)]
|
||||||
(fn [{:keys [db user]}]
|
(fn [{:keys [db user] :as cofx}]
|
||||||
(cond-> {:graphql {:token user
|
(cond-> {:graphql {:token user
|
||||||
:owns-state {:single ::page}
|
:owns-state {:single ::page}
|
||||||
:query-obj {:venia/queries [[:profit-and-loss
|
:query-obj {:venia/queries [[:profit-and-loss
|
||||||
@@ -135,7 +138,7 @@ NOTE: Please review the transactions we may have question for you here: https://
|
|||||||
(re-frame/reg-event-db
|
(re-frame/reg-event-db
|
||||||
::change-internal
|
::change-internal
|
||||||
(forms/change-handler ::form
|
(forms/change-handler ::form
|
||||||
(fn [_ field value]
|
(fn [data field value]
|
||||||
(cond
|
(cond
|
||||||
(= [:periods] field)
|
(= [:periods] field)
|
||||||
[field value]
|
[field value]
|
||||||
@@ -203,7 +206,8 @@ NOTE: Please review the transactions we may have question for you here: https://
|
|||||||
(re-frame/reg-event-fx
|
(re-frame/reg-event-fx
|
||||||
::investigate-clicked
|
::investigate-clicked
|
||||||
(fn [{:keys [db]} [_ {:keys [location from-numeric-code to-numeric-code client-id]
|
(fn [{:keys [db]} [_ {:keys [location from-numeric-code to-numeric-code client-id]
|
||||||
{:keys [start end]} :date-range}]]
|
{:keys [start end]} :date-range
|
||||||
|
:as g}]]
|
||||||
{:db (-> db (assoc ::ledger-list-active? true))
|
{:db (-> db (assoc ::ledger-list-active? true))
|
||||||
:dispatch [::data-page/additional-params-changed ::ledger {:client-id client-id
|
:dispatch [::data-page/additional-params-changed ::ledger {:client-id client-id
|
||||||
:from-numeric-code from-numeric-code
|
:from-numeric-code from-numeric-code
|
||||||
@@ -215,7 +219,7 @@ NOTE: Please review the transactions we may have question for you here: https://
|
|||||||
|
|
||||||
(re-frame/reg-sub
|
(re-frame/reg-sub
|
||||||
::can-submit
|
::can-submit
|
||||||
(fn [_]
|
(fn [db]
|
||||||
true))
|
true))
|
||||||
|
|
||||||
(def pnl-form (forms/vertical-form {:can-submit [::can-submit]
|
(def pnl-form (forms/vertical-form {:can-submit [::can-submit]
|
||||||
@@ -233,12 +237,12 @@ NOTE: Please review the transactions we may have question for you here: https://
|
|||||||
])
|
])
|
||||||
@box)))
|
@box)))
|
||||||
|
|
||||||
(defn report-controls [_]
|
(defn report-controls [pnl-form]
|
||||||
(let [!box (reagent/atom nil)
|
(let [!box (reagent/atom nil)
|
||||||
active (reagent/atom nil)]
|
active (reagent/atom nil)]
|
||||||
(fn [pnl-form]
|
(fn [pnl-form]
|
||||||
(let [{:keys [raw-field]} pnl-form
|
(let [{:keys [form-inline field raw-field error-notification submit-button ]} pnl-form
|
||||||
{:keys [data]} @(re-frame/subscribe [::forms/form ::form])
|
{:keys [data report active? error id]} @(re-frame/subscribe [::forms/form ::form])
|
||||||
{:keys [periods selected-period include-deltas]} data]
|
{:keys [periods selected-period include-deltas]} data]
|
||||||
[:div.report-controls
|
[:div.report-controls
|
||||||
[:div.level.mb-2
|
[:div.level.mb-2
|
||||||
|
|||||||
@@ -100,13 +100,6 @@
|
|||||||
e
|
e
|
||||||
(date->str (time/from-default-time-zone (c/from-date e)) standard))))))
|
(date->str (time/from-default-time-zone (c/from-date e)) standard))))))
|
||||||
|
|
||||||
(defn dispatch-cljs-date-change [event]
|
|
||||||
(fn [e g]
|
|
||||||
(re-frame/dispatch (conj event
|
|
||||||
(if (str/blank? e)
|
|
||||||
e
|
|
||||||
(time/from-default-time-zone (c/from-date e)))))))
|
|
||||||
|
|
||||||
;; TODO inline on-changes causes each field to be rerendered each time. When we fix this
|
;; TODO inline on-changes causes each field to be rerendered each time. When we fix this
|
||||||
;; let's make sure that we find away not to trigger a re-render for every component any time any form field
|
;; let's make sure that we find away not to trigger a re-render for every component any time any form field
|
||||||
;; changes
|
;; changes
|
||||||
@@ -312,10 +305,10 @@
|
|||||||
(let [field (if (keyword? field) [field] field)
|
(let [field (if (keyword? field) [field] field)
|
||||||
event (if (keyword? event) [event] event)
|
event (if (keyword? event) [event] event)
|
||||||
selected (get-in subscription field)
|
selected (get-in subscription field)
|
||||||
|
|
||||||
selected (cond (string? selected)
|
selected (cond (string? selected)
|
||||||
(c/to-date (time/to-default-time-zone (time/from-default-time-zone (str->date selected standard))))
|
(c/to-date (time/to-default-time-zone (time/from-default-time-zone (str->date selected standard))))
|
||||||
|
|
||||||
|
|
||||||
(instance? goog.date.DateTime selected)
|
(instance? goog.date.DateTime selected)
|
||||||
(c/to-date (time/to-default-time-zone (time/from-default-time-zone selected)))
|
(c/to-date (time/to-default-time-zone (time/from-default-time-zone selected)))
|
||||||
|
|
||||||
@@ -324,10 +317,9 @@
|
|||||||
|
|
||||||
:else
|
:else
|
||||||
selected )
|
selected )
|
||||||
|
|
||||||
keys (assoc keys
|
keys (assoc keys
|
||||||
:on-change (when (:cljs-date? keys)
|
:on-change (dispatch-date-change (conj event field))
|
||||||
(dispatch-date-change (conj event field))
|
|
||||||
(dispatch-cljs-date-change (conj event field)))
|
|
||||||
:selected selected
|
:selected selected
|
||||||
:class (str class
|
:class (str class
|
||||||
(when (and spec (not (s/valid? spec (get-in subscription field))))
|
(when (and spec (not (s/valid? spec (get-in subscription field))))
|
||||||
@@ -459,6 +451,8 @@
|
|||||||
:next-month-label ""
|
:next-month-label ""
|
||||||
:type "date")])
|
:type "date")])
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
(defn local-now []
|
(defn local-now []
|
||||||
(t/to-default-time-zone (t/now)))
|
(t/to-default-time-zone (t/now)))
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user