From 51c7bc9bdb5360128740db5a8ef097b13436a7e9 Mon Sep 17 00:00:00 2001 From: Bryce Covert Date: Sun, 11 Dec 2022 07:17:30 -0800 Subject: [PATCH] minor fixes. --- src/clj/auto_ap/graphql/ledger.clj | 8 +++----- src/cljc/auto_ap/ledger/reports.cljc | 10 ++++++++++ 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/src/clj/auto_ap/graphql/ledger.clj b/src/clj/auto_ap/graphql/ledger.clj index 11475a19..16217569 100644 --- a/src/clj/auto_ap/graphql/ledger.clj +++ b/src/clj/auto_ap/graphql/ledger.clj @@ -518,8 +518,8 @@ {:filters {:client_id client-id :location location :date_range (:date_range input) - :from_numeric_code (get-in l-reports/ranges [category 0]) - :to_numeric_code (get-in l-reports/ranges [category 1]) + :from_numeric_code (l-reports/min-numeric-code category ) + :to_numeric_code (l-reports/max-numeric-code category ) :per_page Integer/MAX_VALUE}} nil) :journal_entries @@ -528,9 +528,7 @@ (filter (fn [jel] (when-let [account (account-lookup (:id (:account jel)))] (and - (<= (get-in l-reports/ranges [category 0]) - (:numeric_code account) - (get-in l-reports/ranges [category 1])) + (l-reports/account-belongs-in-category? (:numeric-code account) category) (= location (:location jel))))) ) (map (fn [jel ] diff --git a/src/cljc/auto_ap/ledger/reports.cljc b/src/cljc/auto_ap/ledger/reports.cljc index 50c0e290..36233cd6 100644 --- a/src/cljc/auto_ap/ledger/reports.cljc +++ b/src/cljc/auto_ap/ledger/reports.cljc @@ -82,6 +82,16 @@ ["35000-40000 Other" 35000 39999]] :bottom-line [["11000-12000 Bottom Line" 11000 11999]]}) +(defn min-numeric-code [category] + (->> (groupings category) + (map second) + (apply min))) + +(defn max-numeric-code [category] + (->> (groupings category) + (map second) + (apply max))) + (def flat-categories (for [[category groups] groupings