diff --git a/src/cljs/auto_ap/views/pages/admin/clients/form.cljs b/src/cljs/auto_ap/views/pages/admin/clients/form.cljs index fa2b9935..cdc6df97 100644 --- a/src/cljs/auto_ap/views/pages/admin/clients/form.cljs +++ b/src/cljs/auto_ap/views/pages/admin/clients/form.cljs @@ -132,7 +132,7 @@ :name name :check-number (when-not (str/blank? check-number) (js/parseInt check-number)) - :numeric-code (when-not (str/blank? check-number) + :numeric-code (when-not (str/blank? numeric-code) (js/parseInt numeric-code)) :include-in-reports include-in-reports :start-date (cond (not start-date) 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 d64e2890..e079f4a2 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 @@ -11,7 +11,7 @@ [auto-ap.views.components.buttons :as buttons] [auto-ap.views.components.switch-field :refer [switch-field]] [auto-ap.views.components.modal :as modal] - [auto-ap.views.utils :refer [date->str date-picker date-picker-friendly bind-field standard pretty dispatch-event local-today ->% ->$ str->date with-user dispatch-value-change query-params]] + [auto-ap.views.utils :refer [date->str date-picker date-picker-friendly bind-field standard pretty dispatch-event local-today ->% ->$ str->date with-user dispatch-value-change query-params multi-field]] [cljs-time.core :as t] [re-frame.core :as re-frame] [react-dom :as react-dom] @@ -172,8 +172,7 @@ (cond-> {:graphql {:token user :owns-state {:single ::page} :query-obj {:venia/queries [[:profit-and-loss - {:client-ids (some-> (:id (:client (:data db))) - vector) + {:client-ids (map :id (:clients (:data db))) :periods (mapv (fn [[start end] ] {:start (date->str start standard) :end (date->str end standard)} ) (:periods (:data db)))} [[:periods [[:accounts [:name :amount :client_id :account-type :id :count :numeric-code :location]]]]]]]} @@ -639,11 +638,13 @@ [report-control-detail {:active active :box !box :which :clients} [:div {:style {:width "20em"}} [:h4.subtitle "Companies"] - (raw-field - [typeahead-v3 {:entities @(re-frame/subscribe [::subs/clients]) - :entity->text :name - :type "typeahead-v3" - :field [:client]}])]]] + [raw-field + [multi-field {:type "multi-field" + :field [:clients] + :template [[typeahead-v3 {:entities @(re-frame/subscribe [::subs/clients]) + :entity->text :name + :type "typeahead-v3"}]]}]] + ]]] [:div.level-item [buttons/dropdown {:on-click (fn [] (reset! active :range))} [:span (str "Range" @@ -829,6 +830,7 @@ (when-not @!box (reset! !box el)))}]])))) + (defn profit-and-loss-content [] (let [user @(re-frame/subscribe [::subs/user]) status @(re-frame/subscribe [::status/single ::page]) @@ -847,7 +849,7 @@ [:div - [:h1.title "Profit and Loss - " (:name (:client data))] + [:h1.title "Profit and Loss - " (str/join ", " (map :name (:clients data)))] (when (seq unresolved-accounts) [:div.notification.is-warning.is-light "This report does not include " (str/join ", " @@ -890,6 +892,8 @@ period)))) :client (or (:client qp) (some-> @(re-frame/subscribe [::subs/client]) (select-keys [:name :id]))) + :clients [(or (:client qp) + (some-> @(re-frame/subscribe [::subs/client]) (select-keys [:name :id])))] :include-deltas true}) ::track/register {:id ::ledger-params :subscription [::data-page/params ::ledger] diff --git a/src/cljs/auto_ap/views/utils.cljs b/src/cljs/auto_ap/views/utils.cljs index 744d950e..b9ce56df 100644 --- a/src/cljs/auto_ap/views/utils.cljs +++ b/src/cljs/auto_ap/views/utils.cljs @@ -155,7 +155,13 @@ [:div.level-item (update template 1 assoc - :value (get-in override (get-in template [1 :field])) + :value (let [value (get-in override (get-in template [1 :field])) ;; TODO this is really ugly to support maps or strings + value (if (map? value) + (dissoc value :key :new?) + value)] + (if (= value {}) + nil + value)) :disabled is-disabled? :on-change (fn [e] (reset! value-repr