diff --git a/src/clj/auto_ap/background/mail.clj b/src/clj/auto_ap/background/mail.clj index 4648af56..7764b7e5 100644 --- a/src/clj/auto_ap/background/mail.clj +++ b/src/clj/auto_ap/background/mail.clj @@ -34,6 +34,7 @@ (defn process-sqs [] (lc/with-context {:source "import-uploaded-invoices"} + (try (log/info "Fetching messages from sqs...") (doseq [message (:messages (sqs/receive-message {:queue-url (:invoice-import-queue-url env) diff --git a/src/clj/auto_ap/pdf/ledger.clj b/src/clj/auto_ap/pdf/ledger.clj index 49ef168a..3a8649e9 100644 --- a/src/clj/auto_ap/pdf/ledger.clj +++ b/src/clj/auto_ap/pdf/ledger.clj @@ -150,7 +150,7 @@ args (assoc args :periods (filter identity (cond-> [(:date args)] (:include-comparison args) (conj (:comparison-date args))))) - clients (d/pull-many (d/db conn) '[:client/name :db/id] [(:client-id args)]) + clients (d/pull-many (d/db conn) '[:client/code :client/name :db/id] [(:client-id args)]) data (concat (->> (:balance-sheet-accounts data) (map (fn [b] (assoc b @@ -159,7 +159,7 @@ (map (fn [b] (assoc b :period (:comparison-date args)))))) - pnl-data (l-reports/->PNLData args data (by :db/id clients)) + pnl-data (l-reports/->PNLData args data (by :db/id :client/code clients)) report (l-reports/summarize-balance-sheet pnl-data) output-stream (ByteArrayOutputStream.)] (log/info report) @@ -181,7 +181,7 @@ (let [data (<-graphql data) args (<-graphql args) - clients (d/pull-many (d/db conn) '[:client/name :db/id] (:client-ids args)) + clients (d/pull-many (d/db conn) '[:client/code :client/name :db/id] (:client-ids args)) data (->> data :periods (mapcat (fn [p1 p2] @@ -192,7 +192,7 @@ (:accounts p2)) ) (:periods args))) - pnl-data (l-reports/->PNLData args data (by :db/id clients)) + pnl-data (l-reports/->PNLData args data (by :db/id :client/code clients)) report (l-reports/summarize-pnl pnl-data) output-stream (ByteArrayOutputStream.)] (pdf/pdf diff --git a/src/clj/auto_ap/square/core.clj b/src/clj/auto_ap/square/core.clj index da747f57..e572e55a 100644 --- a/src/clj/auto_ap/square/core.clj +++ b/src/clj/auto_ap/square/core.clj @@ -1,7 +1,7 @@ (ns auto-ap.square.core (:require [auto-ap.datomic :refer [conn remove-nils]] [auto-ap.time :as atime] - [c(daily-results )lj-http.client :as client] + [clj-http.client :as client] [clj-time.coerce :as coerce] [clj-time.core :as time] [clj-time.periodic :as periodic] @@ -12,7 +12,6 @@ [datomic.api :as d] [mount.core :as mount] [unilog.context :as lc] - #_{:clj-kondo/ignore [:unused-namespace]} [yang.scheduler :as scheduler] [clojure.core.async :as async])) diff --git a/src/cljc/auto_ap/ledger/reports.cljc b/src/cljc/auto_ap/ledger/reports.cljc index 47e11b0c..4a59fb35 100644 --- a/src/cljc/auto_ap/ledger/reports.cljc +++ b/src/cljc/auto_ap/ledger/reports.cljc @@ -304,8 +304,9 @@ (if (-> pnl-data :args :column-per-location) (mapcat (fn [p] - (cond-> [(merge {:value (or ( --> p :filters :location) "Total") + (cond-> [(merge {:value (or (when (-> p :filters :location) + (str ((-> p :client-codes) (-> p :filters :client-id)) "-" (-> p :filters :location))) + "Total") :align :right} (:cell-args p)) (merge {:value "%" @@ -470,8 +471,9 @@ (if (-> pnl-data :args :column-per-location) [(location-summary-table (mapcat identity (for [[period i] (map vector (-> pnl-data :args :periods ) (range))] (concat - (for [location (set (map second (client-locations pnl-data)))] + (for [[client-id location] (client-locations pnl-data)] (-> pnl-data + (filter-client client-id) (filter-location location) (filter-period period) (zebra i))) @@ -488,9 +490,10 @@ :details (doall (if (-> pnl-data :args :column-per-location) [(location-detail-table (mapcat identity (for [[period i] (map vector (-> pnl-data :args :periods ) (range))] - (concat - (for [location (set (map second (client-locations pnl-data)))] + (concat + (for [[client-id location] (client-locations pnl-data)] (-> pnl-data + (filter-client client-id) (filter-location location) (filter-period period) (zebra i))) @@ -557,4 +560,4 @@ :rows table})) -(defrecord PNLData [args data client-names]) +(defrecord PNLData [args data client-codes]) 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 ef1e786c..ec0fc73e 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 @@ -82,7 +82,9 @@ encode-period (:periods (:data db))) :clients (mapv #(select-keys % [:name :id]) (:clients (:data db))) } - :db (dissoc db :report)}))) + :db (-> db + (dissoc :report) + (update-in [:data :clients] #(into [] (filter seq %))))}))) (defn email-body [report-url] (js/encodeURIComponent @@ -440,11 +442,11 @@ NOTE: Please review the transactions we may have question for you here: https:// ) (:accounts p2))) (:periods args))) - client-names (->> @(re-frame/subscribe [::subs/clients-by-id]) + client-codes (->> @(re-frame/subscribe [::subs/clients-by-id]) (map (fn [[k v]] - [k (:name v)])) + [k (:code v)])) (into {})) - pnl-data (l-reports/->PNLData args pnl-data client-names) + pnl-data (l-reports/->PNLData args pnl-data client-codes) report (l-reports/summarize-pnl pnl-data) table (rtable/concat-tables (concat (:summaries report) (:details report)))] [:div diff --git a/src/cljs/auto_ap/views/utils.cljs b/src/cljs/auto_ap/views/utils.cljs index 051135a3..baee1b7d 100644 --- a/src/cljs/auto_ap/views/utils.cljs +++ b/src/cljs/auto_ap/views/utils.cljs @@ -144,7 +144,8 @@ (for [[i override] (map vector (range) value) :let [is-disabled? (if (= false allow-change?) (not (boolean (:new? override))) - nil)]] + nil)] + ] ^{:key (:key override)} [:div.level [:div.level-left @@ -174,9 +175,12 @@ (filter (fn [r] (not= [:key :new?] (keys r))) (assoc-in value (into [i] (get-in template [1 :field])) - (if (and e (.. e -target)) - (.. e -target -value ) - e) )))) + (update + (if (and e (.. e -target)) + (.. e -target -value ) + e) + :key + (fnil identity (random-uuid))) )))) (on-change (mapv (fn [v] (dissoc v :new? :key))