From 9378c8159d2b07676e05ac25ebdc8cd1fce8fad6 Mon Sep 17 00:00:00 2001 From: Bryce Covert Date: Sun, 23 Oct 2022 20:50:54 -0700 Subject: [PATCH] fixes. --- src/clj/auto_ap/graphql/ledger.clj | 5 ++--- src/cljc/auto_ap/ledger/reports.cljc | 22 +++++++++++++------ .../pages/ledger/profit_and_loss_detail.cljs | 1 + 3 files changed, 18 insertions(+), 10 deletions(-) diff --git a/src/clj/auto_ap/graphql/ledger.clj b/src/clj/auto_ap/graphql/ledger.clj index 8aa276eb..197cb8a1 100644 --- a/src/clj/auto_ap/graphql/ledger.clj +++ b/src/clj/auto_ap/graphql/ledger.clj @@ -553,10 +553,9 @@ :client_id client-id :location location :account account - :journal_entries journal-entries + :journal_entries (sort-by :date journal-entries) :total (- (or (reduce + 0.0 (map #(or (:debit %) 0.0) journal-entries)) 0.0) - (or (reduce + 0.0 (map #(or (:credit %) 0.0) journal-entries)) 0.0)) - })}) + (or (reduce + 0.0 (map #(or (:credit %) 0.0) journal-entries)) 0.0))})}) diff --git a/src/cljc/auto_ap/ledger/reports.cljc b/src/cljc/auto_ap/ledger/reports.cljc index 1b13779b..be8368f1 100644 --- a/src/cljc/auto_ap/ledger/reports.cljc +++ b/src/cljc/auto_ap/ledger/reports.cljc @@ -565,13 +565,13 @@ (fn [rows category] (into rows ;; TODO colspan ? - (cons [{:value (str (client-codes (:client-id category)) " - " (:location category) " - " (name (:category category)) " - " (:name (:account category)) ) + (concat [[{:value (str (client-codes (:client-id category)) " - " (:location category) " - " (name (:category category)) " - " (:name (:account category)) ) - } - {:value ""} - {:value ""} - {:value ""} - {:value ""}] + } + {:value ""} + {:value ""} + {:value ""} + {:value ""}]] (map (fn [je] [{:value (user-friendly-date (:date je))} @@ -582,7 +582,15 @@ :format :dollar} {:value (get je :running-balance) :format :dollar}]) - (:journal-entries category)))) + (:journal-entries category)) + [[{:value (str (client-codes (:client-id category)) " - " (:location category) " - " (name (:category category)) " - " (:name (:account category)) ) + + } + {:value "Total"} + {:value ""} + {:value ""} + {:value (:total category) + :format :dollar}]])) ) [] diff --git a/src/cljs/auto_ap/views/pages/ledger/profit_and_loss_detail.cljs b/src/cljs/auto_ap/views/pages/ledger/profit_and_loss_detail.cljs index 473cd951..7975176b 100644 --- a/src/cljs/auto_ap/views/pages/ledger/profit_and_loss_detail.cljs +++ b/src/cljs/auto_ap/views/pages/ledger/profit_and_loss_detail.cljs @@ -52,6 +52,7 @@ [[:categories [[:journal-entries [:description :date :debit :credit :location :running-balance + :total [:account [:id :name]]]] :category :client-id