Adds warning

This commit is contained in:
2024-10-15 21:14:59 -07:00
parent 9d22de1338
commit 4e215c98ae
2 changed files with 37 additions and 9 deletions

View File

@@ -2,7 +2,8 @@
(:require [clj-time.core :as time]
[clj-time.coerce :as coerce]
[clj-time.format :as f]
[datomic.api :as dc]))
[datomic.api :as dc]
[auto-ap.time :as atime]))
;; TODO WILL NOT WORK IN DATOMIC CLOUD
(defn entid [db i]
@@ -164,7 +165,18 @@
(defn ident [x]
(:db/ident x))
(deftype Line [^Long id ^Long client-id ^Long account-id ^String location ^java.util.Date date ^Double debit ^Double credit ^Double running-balance])
(deftype Line [^Long id ^Long client-id ^Long account-id ^String location ^java.util.Date date ^Double debit ^Double credit ^Double running-balance]
)
(defmethod print-method Line [entity writer]
(.write writer (format "Line %d: client:%d account:%d location:%s date:%s"
(.-id entity)
(.-client-id entity)
(.-account-id entity)
(.-location entity)
(iso-date (.-date entity)))))
(defn ->line [{[current-client current-account current-location current-date debit credit running-balance]
:v
@@ -204,7 +216,6 @@
(for [running-balance-set (account-sets db client-id)
:let [{:keys [account-id client-id location current-balance debits credits count]}
(->> running-balance-set
(take-while (fn until-date [^Line l]
(let [^java.util.Date d (.-date l)]
(<= (.compareTo ^java.util.Date d end) 0))))
@@ -227,16 +238,30 @@
(comment
(detailed-account-snapshot (dc/db auto-ap.datomic/conn)
(auto-ap.datomic/pull-id (dc/db auto-ap.datomic/conn)
[:client/code "NGOP"])
#inst "2020-01-01")
(->>
(detailed-account-snapshot (dc/db auto-ap.datomic/conn)
(auto-ap.datomic/pull-id (dc/db auto-ap.datomic/conn)
[:client/code "NGOP"])
#inst "2024-05-01")
(map #(nth % 2))
(into #{})
seq)
(account-snapshot (dc/db auto-ap.datomic/conn)
(auto-ap.datomic/pull-id (dc/db auto-ap.datomic/conn)
[:client/code "NGOP"])
#inst "2022-01-01")
(def orig (->> [:client/code "NGOP"]
(auto-ap.datomic/pull-id (dc/db auto-ap.datomic/conn))
(account-sets (dc/db auto-ap.datomic/conn))
(mapcat (fn [ls]
ls))
(filter (fn [l] (nil? (.-location l))))
(into #{})))
(.-location orig)
(def orig (into [] (take 5000 (mapcat (fn [ls]
(map #(.-id %) ls)) (account-sets (dc/db auto-ap.datomic/conn)
(auto-ap.datomic/pull-id (dc/db auto-ap.datomic/conn)

View File

@@ -148,10 +148,12 @@
(apply max counts)
0)))
(defn table [{:keys [table widths investigate-url]}]
(defn table [{:keys [table widths investigate-url warning]}]
(let [cell-count (cell-count table)]
(com/content-card {:class "inline-block overflow-hidden"}
[:div { :class "overflow-y-auto h-[70vh] m-4 inline-block"}
(when warning [:div.rounded.bg-red-50.text-red-800.p-4.m-2
warning])
(-> [:table {:class "text-sm text-left text-gray-500 dark:text-gray-400"}
[:thead {:class "text-xs text-gray-800 uppercase bg-gray-50 dark:bg-gray-700 dark:text-gray-400 font-bold"}
(map
@@ -289,7 +291,8 @@
(table {:widths (cond-> (into [30 ] (repeat 13 client-count))
(:include-comparison (:args data)) (into (repeat 13 (* 2 client-count))))
:investigate-url (bidi.bidi/path-for ssr-routes/only-routes ::route/investigate)
:table report} ))))])
:table report
:warning (:warning report)} ))))])
(defn form* [request]
(let [params (merge (:query-params request) (:form-params request) {})]