diff --git a/src/clj/auto_ap/graphql.clj b/src/clj/auto_ap/graphql.clj index 9dc59c99..9bc5a676 100644 --- a/src/clj/auto_ap/graphql.clj +++ b/src/clj/auto_ap/graphql.clj @@ -108,6 +108,7 @@ {:fields {:id {:type 'String} :amount {:type 'String} :location {:type 'String} + :count {:type 'Int} :numeric_code {:type 'Int} :account_type {:type :account_type} :name {:type 'String}}} diff --git a/src/clj/auto_ap/graphql/ledger.clj b/src/clj/auto_ap/graphql/ledger.clj index a56d5546..58b6c8d7 100644 --- a/src/clj/auto_ap/graphql/ledger.clj +++ b/src/clj/auto_ap/graphql/ledger.clj @@ -80,6 +80,7 @@ (conj acc (merge {:id (str account-id "-" location) :location (or location "") + :count count :amount (if account-type (if (#{:account-type/asset :account-type/dividend :account-type/expense} account-type) diff --git a/src/clj/auto_ap/handler.clj b/src/clj/auto_ap/handler.clj index 93612192..62021f61 100644 --- a/src/clj/auto_ap/handler.clj +++ b/src/clj/auto_ap/handler.clj @@ -87,4 +87,4 @@ (wrap-params) (mp/wrap-multipart-params) (wrap-edn-params) - (wrap-gzip))) + #_(wrap-gzip))) 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 ce9540f9..907b2864 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 @@ -13,7 +13,8 @@ [auto-ap.views.pages.data-page :as data-page] [vimsical.re-frame.fx.track :as track] [reagent.core :as reagent] - [clojure.set :as set])) + [clojure.set :as set] + [clojure.string :as str])) (def ranges {:sales [40000 49999] :cogs [50000 59999] @@ -75,6 +76,16 @@ (<= (get-in ranges [type 0]) numeric-code (get-in ranges [type 1]))))) (sort-by :numeric-code)))) +(re-frame/reg-sub + ::uncategorized-accounts + (fn [db [_ ]] + + (->> (get-in db [::report :periods ]) + (mapcat :accounts) + (map #(update % :amount js/parseFloat)) + (filter (fn [{:keys [account-type location numeric-code]}] + (nil? numeric-code)))))) + (defn parse-amounts [period] (update period :accounts (fn [a] (map #(update % :amount js/parseFloat) a)))) @@ -173,7 +184,7 @@ {:client-id (:id c) :periods (mapv (fn [[start end] ] {:start (date->str start standard) :end (date->str end standard)} ) (:periods params))} - [[:periods [[:accounts [:name :amount :account-type :id :numeric-code :location]]]]]]]} + [[:periods [[:accounts [:name :amount :account-type :id :count :numeric-code :location]]]]]]]} :on-success [::received]})))))) @@ -482,7 +493,8 @@ status @(re-frame/subscribe [::status/single ::page]) params @(re-frame/subscribe [::params]) period-inputs @(re-frame/subscribe [::period-inputs]) - periods @(re-frame/subscribe [::periods])] + periods @(re-frame/subscribe [::periods]) + unresolved-accounts @(re-frame/subscribe [::uncategorized-accounts]) ] (if-not current-client [:div @@ -690,6 +702,13 @@ [status/big-loader status] (when (not= :loading (:state status)) [:div + (when (seq unresolved-accounts) + [:div.notification.is-warning.is-light + "This report does not include " (str/join ", " + (map #(str (:count %) " unresolved ledger entries for " (if (str/blank? (:location %)) + " all locations" + (:location %))) + unresolved-accounts))]) [:<> (for [location @(re-frame/subscribe [::locations])] ^{:key (str location "-summary")}