Revert "Revert "Prep to select more than 1 client""

This reverts commit 574023fea0.
This commit is contained in:
Bryce Covert
2021-10-18 06:34:13 -07:00
parent 52d7eff1bd
commit d81096b8bc
4 changed files with 312 additions and 323 deletions

View File

@@ -554,6 +554,7 @@
:profit_and_loss {:type :profit_and_loss_report
:args {:client_id {:type :id}
:client_ids {:type '(list :id)}
:periods {:type '(list :date_range)}}
:resolve :get-profit-and-loss}

View File

@@ -183,9 +183,14 @@
(defn get-profit-and-loss [context args value]
(let [client-id (:client_id args)
_ (assert-can-see-client (:id context) client-id)
all-ledger-entries (full-ledger-for-client client-id)
lookup-account (build-account-lookup client-id)]
client-ids (or (some-> client-id vector)
(:client_ids args))
_ (when (not (seq client-ids))
(throw (ex-info "Please select a client." {:validation-error "Please select a client."})))
_ (doseq [client-id client-ids]
(assert-can-see-client (:id context) client-id))
all-ledger-entries (full-ledger-for-client (first client-ids))
lookup-account (build-account-lookup (first client-ids))]
(->graphql
{:periods (reduce (fn [acc {:keys [start end]}]
(conj acc