From 03e391f24e6021d7596d4258099091701f4bd4f2 Mon Sep 17 00:00:00 2001 From: Bryce Covert Date: Wed, 9 Oct 2019 06:59:53 -0700 Subject: [PATCH] fix. --- .../views/pages/ledger/profit_and_loss.cljs | 26 ++++++++++--------- 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/src/cljs/auto_ap/views/pages/ledger/profit_and_loss.cljs b/src/cljs/auto_ap/views/pages/ledger/profit_and_loss.cljs index 37f953c1..b84d0581 100644 --- a/src/cljs/auto_ap/views/pages/ledger/profit_and_loss.cljs +++ b/src/cljs/auto_ap/views/pages/ledger/profit_and_loss.cljs @@ -147,18 +147,20 @@ (re-frame/reg-event-fx ::params-change (fn [cofx [_ params]] - {:db (-> (:db cofx) - (assoc-in [::loading] true) - (assoc-in [::params] params)) - :graphql {:token (-> cofx :db :user) - :query-obj {:venia/queries [[:profit-and-loss - {:client-id (:id @(re-frame/subscribe [::subs/client])) - :from-date (:from-date params) - :to-date (:to-date params)} - [[:balance-sheet-accounts [:name :amount :account-type :id :numeric-code :location]] - [:comparable-balance-sheet-accounts [:name :amount :account-type :id :numeric-code :location]]]]]} - :on-success [::received] - :on-error [::error]}})) + (let [c @(re-frame/subscribe [::subs/client])] + (cond-> {:db (-> (:db cofx) + (assoc-in [::loading] true) + (assoc-in [::params] params))} + c (assoc :graphql (when @(re-frame/subscribe [::subs/client]) + {:token (-> cofx :db :user) + :query-obj {:venia/queries [[:profit-and-loss + {:client-id (:id c) + :from-date (:from-date params) + :to-date (:to-date params)} + [[:balance-sheet-accounts [:name :amount :account-type :id :numeric-code :location]] + [:comparable-balance-sheet-accounts [:name :amount :account-type :id :numeric-code :location]]]]]} + :on-success [::received] + :on-error [::error]}))))))