This commit is contained in:
Bryce Covert
2019-10-09 06:59:53 -07:00
parent 71e19ee66e
commit 03e391f24e

View File

@@ -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]}))))))