report updates for nick the greek.

This commit is contained in:
2022-05-12 16:34:07 -07:00
parent e8f1a0d734
commit 11722415fc
6 changed files with 29 additions and 20 deletions

View File

@@ -34,6 +34,7 @@
(defn process-sqs [] (defn process-sqs []
(lc/with-context {:source "import-uploaded-invoices"} (lc/with-context {:source "import-uploaded-invoices"}
(try (try
(log/info "Fetching messages from sqs...") (log/info "Fetching messages from sqs...")
(doseq [message (:messages (sqs/receive-message {:queue-url (:invoice-import-queue-url env) (doseq [message (:messages (sqs/receive-message {:queue-url (:invoice-import-queue-url env)

View File

@@ -150,7 +150,7 @@
args (assoc args args (assoc args
:periods (filter identity (cond-> [(:date args)] :periods (filter identity (cond-> [(:date args)]
(:include-comparison args) (conj (:comparison-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) data (concat (->> (:balance-sheet-accounts data)
(map (fn [b] (map (fn [b]
(assoc b (assoc b
@@ -159,7 +159,7 @@
(map (fn [b] (map (fn [b]
(assoc b (assoc b
:period (:comparison-date args)))))) :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) report (l-reports/summarize-balance-sheet pnl-data)
output-stream (ByteArrayOutputStream.)] output-stream (ByteArrayOutputStream.)]
(log/info report) (log/info report)
@@ -181,7 +181,7 @@
(let [data (<-graphql data) (let [data (<-graphql data)
args (<-graphql args) 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 data (->> data
:periods :periods
(mapcat (fn [p1 p2] (mapcat (fn [p1 p2]
@@ -192,7 +192,7 @@
(:accounts p2)) (:accounts p2))
) )
(:periods args))) (: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) report (l-reports/summarize-pnl pnl-data)
output-stream (ByteArrayOutputStream.)] output-stream (ByteArrayOutputStream.)]
(pdf/pdf (pdf/pdf

View File

@@ -1,7 +1,7 @@
(ns auto-ap.square.core (ns auto-ap.square.core
(:require [auto-ap.datomic :refer [conn remove-nils]] (:require [auto-ap.datomic :refer [conn remove-nils]]
[auto-ap.time :as atime] [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.coerce :as coerce]
[clj-time.core :as time] [clj-time.core :as time]
[clj-time.periodic :as periodic] [clj-time.periodic :as periodic]
@@ -12,7 +12,6 @@
[datomic.api :as d] [datomic.api :as d]
[mount.core :as mount] [mount.core :as mount]
[unilog.context :as lc] [unilog.context :as lc]
#_{:clj-kondo/ignore [:unused-namespace]}
[yang.scheduler :as scheduler] [yang.scheduler :as scheduler]
[clojure.core.async :as async])) [clojure.core.async :as async]))

View File

@@ -304,8 +304,9 @@
(if (-> pnl-data :args :column-per-location) (if (-> pnl-data :args :column-per-location)
(mapcat (mapcat
(fn [p] (fn [p]
(cond-> [(merge {:value (or ( (cond-> [(merge {:value (or (when (-> p :filters :location)
-> p :filters :location) "Total") (str ((-> p :client-codes) (-> p :filters :client-id)) "-" (-> p :filters :location)))
"Total")
:align :right} :align :right}
(:cell-args p)) (:cell-args p))
(merge {:value "%" (merge {:value "%"
@@ -470,8 +471,9 @@
(if (-> pnl-data :args :column-per-location) (if (-> pnl-data :args :column-per-location)
[(location-summary-table (mapcat identity (for [[period i] (map vector (-> pnl-data :args :periods ) (range))] [(location-summary-table (mapcat identity (for [[period i] (map vector (-> pnl-data :args :periods ) (range))]
(concat (concat
(for [location (set (map second (client-locations pnl-data)))] (for [[client-id location] (client-locations pnl-data)]
(-> pnl-data (-> pnl-data
(filter-client client-id)
(filter-location location) (filter-location location)
(filter-period period) (filter-period period)
(zebra i))) (zebra i)))
@@ -488,9 +490,10 @@
:details :details
(doall (if (-> pnl-data :args :column-per-location) (doall (if (-> pnl-data :args :column-per-location)
[(location-detail-table (mapcat identity (for [[period i] (map vector (-> pnl-data :args :periods ) (range))] [(location-detail-table (mapcat identity (for [[period i] (map vector (-> pnl-data :args :periods ) (range))]
(concat (concat
(for [location (set (map second (client-locations pnl-data)))] (for [[client-id location] (client-locations pnl-data)]
(-> pnl-data (-> pnl-data
(filter-client client-id)
(filter-location location) (filter-location location)
(filter-period period) (filter-period period)
(zebra i))) (zebra i)))
@@ -557,4 +560,4 @@
:rows table})) :rows table}))
(defrecord PNLData [args data client-names]) (defrecord PNLData [args data client-codes])

View File

@@ -82,7 +82,9 @@
encode-period encode-period
(:periods (:data db))) (:periods (:data db)))
:clients (mapv #(select-keys % [:name :id]) (:clients (: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] (defn email-body [report-url]
(js/encodeURIComponent (js/encodeURIComponent
@@ -440,11 +442,11 @@ NOTE: Please review the transactions we may have question for you here: https://
) )
(:accounts p2))) (:accounts p2)))
(:periods args))) (:periods args)))
client-names (->> @(re-frame/subscribe [::subs/clients-by-id]) client-codes (->> @(re-frame/subscribe [::subs/clients-by-id])
(map (fn [[k v]] (map (fn [[k v]]
[k (:name v)])) [k (:code v)]))
(into {})) (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) report (l-reports/summarize-pnl pnl-data)
table (rtable/concat-tables (concat (:summaries report) (:details report)))] table (rtable/concat-tables (concat (:summaries report) (:details report)))]
[:div [:div

View File

@@ -144,7 +144,8 @@
(for [[i override] (map vector (range) value) (for [[i override] (map vector (range) value)
:let [is-disabled? (if (= false allow-change?) :let [is-disabled? (if (= false allow-change?)
(not (boolean (:new? override))) (not (boolean (:new? override)))
nil)]] nil)]
]
^{:key (:key override)} ^{:key (:key override)}
[:div.level [:div.level
[:div.level-left [:div.level-left
@@ -174,9 +175,12 @@
(filter (fn [r] (filter (fn [r]
(not= [:key :new?] (keys r))) (not= [:key :new?] (keys r)))
(assoc-in value (into [i] (get-in template [1 :field])) (assoc-in value (into [i] (get-in template [1 :field]))
(if (and e (.. e -target)) (update
(.. e -target -value ) (if (and e (.. e -target))
e) )))) (.. e -target -value )
e)
:key
(fnil identity (random-uuid))) ))))
(on-change (mapv (on-change (mapv
(fn [v] (fn [v]
(dissoc v :new? :key)) (dissoc v :new? :key))