From 4e215c98aeaa552a7d815122fd5ea43fafb9781a Mon Sep 17 00:00:00 2001 From: Bryce Date: Tue, 15 Oct 2024 21:14:59 -0700 Subject: [PATCH] Adds warning --- iol_ion/src/iol_ion/query.clj | 39 ++++++++++++++++---- src/clj/auto_ap/ssr/ledger/balance_sheet.clj | 7 +++- 2 files changed, 37 insertions(+), 9 deletions(-) diff --git a/iol_ion/src/iol_ion/query.clj b/iol_ion/src/iol_ion/query.clj index 44a61b38..905985d5 100644 --- a/iol_ion/src/iol_ion/query.clj +++ b/iol_ion/src/iol_ion/query.clj @@ -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) diff --git a/src/clj/auto_ap/ssr/ledger/balance_sheet.clj b/src/clj/auto_ap/ssr/ledger/balance_sheet.clj index 29dd9e0c..a705e701 100644 --- a/src/clj/auto_ap/ssr/ledger/balance_sheet.clj +++ b/src/clj/auto_ap/ssr/ledger/balance_sheet.clj @@ -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) {})]