ui fixes for client screen.

This commit is contained in:
2024-02-19 21:49:12 -08:00
parent 2a6f02b5a9
commit 8bca115443
2 changed files with 88 additions and 28 deletions

View File

@@ -4,6 +4,7 @@
audit-transact conn merge-query pull-attr pull-id
pull-many query2]]
[auto-ap.graphql.utils :refer [extract-client-ids]]
[auto-ap.logging :as alog]
[auto-ap.routes.admin.clients :as route]
[auto-ap.routes.queries :as q]
[auto-ap.routes.utils
@@ -279,9 +280,9 @@
[:client/locations [:vector {:decode/arbitrary (fn [m] (if (map? m)
(vals m)
m))} :string]]
[:client/groups [:vector {:decode/arbitrary (fn [m] (if (map? m)
(vals m)
m))} :string]]
[:client/groups {:optional true :default []} [:maybe [:vector {:decode/arbitrary (fn [m] (if (map? m)
(vals m)
m))} :string]]]
[:client/emails {:optional true} [:maybe (many-entity {}
[:db/id [:or entity-id temp-id]]
[:email-contact/description :string]
@@ -332,10 +333,10 @@
(clj-time.coerce/to-date (auto-ap.time/parse m atime/normal-date))
m))}
inst?]])]]
[:client/matches [:vector {:decode/arbitrary (fn [m] (if (map? m)
(vals m)
m))}
:string]]
[:client/matches {:optional true :default []} [:vector {:decode/arbitrary (fn [m] (if (map? m)
(vals m)
m))}
:string]]
[:client/address {:optional true}
[:maybe
[:map
@@ -786,7 +787,12 @@
:value (some-> (fc/field-value)
(clj-time.coerce/to-date-time)
(atime/unparse-local atime/normal-date))})]))])
(atime/unparse-local atime/normal-date))})]))
(fc/with-field :bank-account/include-in-reports
(com/checkbox {:name (fc/field-name)
:value (boolean (fc/field-value))
:checked (fc/field-value)}
"Include in reports"))])
@@ -1434,6 +1440,7 @@
(-> bank-account
(update :bank-account/start-date #(when % (clj-time.coerce/to-date %)))))
bank-accounts))))
_ (alog/info ::peeker :entity (:client/bank-accounts entity))
_ (when (and (:client/code entity) (pull-id (dc/db conn) [:client/code (:client/code entity)]))
(form-validation-error (format "The code '%s' is already in use" (:client/code entity))
:code (:client/code entity)))

View File

@@ -6,7 +6,7 @@
(auto-ap.routes.queries/put-query
my-id
(str '[:find ?an ?cn ?a ?fmt-date ?action ?payee
(str '[:find ?an ?cn ?a2 ?fmt-date ?action ?payee
:where [(ground ["SCSJ-USB9606" "SCCB-USB9598" "SCMH-USB4250" "SCM8-UB3082" "PWL-PWL2370"]) [?bac ...]]
[(iol-ion.query/recent-date 5) ?sd]
[(ground (clj-time.format/with-zone (clj-time.format/formatter "MMddyyyy") (clj-time.core/time-zone-for-id "America/Los_Angeles"))) ?fmt]
@@ -17,6 +17,7 @@
[(>= ?pd ?sd)]
[?p :payment/type :payment-type/check]
[?p :payment/amount ?a]
[(format "%.2f" ?a) ?a2]
[?p :payment/check-number ?cn]
[(clj-time.coerce/from-date ?pd) ?pd2]
[(clj-time.format/unparse ?fmt ?pd2) ?fmt-date]
@@ -24,6 +25,7 @@
[?p :payment/vendor ?v]
[(get-some $ ?v :vendor/print-as :vendor/name) [_ ?payee]]])
"One-off for randy"))
(setup-randy-queries)
(dc/q
@@ -127,26 +129,77 @@
(dc/db conn)
(dc/since (dc/db conn) #inst "2024-02-04")
(dc/history (dc/db conn)))
(dc/transact conn (->> (dc/q '[:find ?v
:in $
:where [?v :vendor/plaid-merchant]
(not [?v :vendor/name])
[?t :transaction/vendor ?v]
[?t :transaction/date ?d]]
(dc/db conn))
(mapv (fn [[i]]
[:db/retractEntity i]))))
(dc/transact conn (->> (dc/q '[:find ?v
:in $
:where [?v :vendor/plaid-merchant]
(not [?v :vendor/name])
[?t :transaction/vendor ?v]
[?t :transaction/date ?d]]
(dc/db conn))
(mapv (fn [[i]]
[:db/retractEntity i]))))
@(dc/transact conn (->> (dc/q '[:find ?c
:where [?c :client/name ?n]
[(clojure.string/upper-case ?n) ?n2]
[(clojure.string/includes? ?n2 "NICK")]]
(dc/db conn))
(map (fn [[c]]
{:db/id c :client/groups ["NTG"]}))))
@(dc/transact conn (->> (dc/q '[:find ?c
:where [?c :client/name ?n]
[(clojure.string/upper-case ?n) ?n2]
[(clojure.string/includes? ?n2 "NICK")]]
(dc/db conn))
(map (fn [[c]]
{:db/id c :client/groups ["NTG"]}))))
(dc/q '[:find (count ?je)
:in $$
:where [$$ ?je :journal-entry/client 17592238607837]]
(dc/before
(dc/since (dc/db conn) #inst "2024-02-13T15:20:00-08:00")
#inst "2024-02-13T17:00:00-08:00"))
(user/init-repl)
(let [start #inst "2024-02-13T11:20:00-08:00"
end #inst "2024-02-13T18:00:00-08:00"]
(->>
(dc/tx-range (dc/log conn) start end)
seq
(mapcat :data)
(filter (fn [{:keys [a] :as z}]
(= "journal-entry" (str (namespace (auto-ap.datomic/pull-attr (dc/db conn) :db/ident a))))))
(map :e)
(into #{})
(map (fn [m]
[(try (dc/pull (dc/as-of (dc/db conn) start) '[{:journal-entry/client [:client/code]} :db/id *] m) (catch Exception e nil))
(try (dc/pull (dc/as-of (dc/db conn) end) '[{:journal-entry/client [:client/code]} :db/id *] m) (catch Exception e nil))]))
(filter (fn [[l r]]
(not= l r)))
(filter (fn [[l r]]
(or (= "NGRI" (-> l :journal-entry/client :client/code))
(= "NGRI" (-> r :journal-entry/client :client/code)))))
count))
(auto-ap.routes.queries/get-query {:identity {:user/role "admin"}
:params {:query-id "a4345849-00a7-424e-b393-06257d3c1820"}})
(auto-ap.datomic/pull-id (dc/db conn) [:client/code "NGRV"])
(->> (dc/q '[:find (pull ?ba [:bank-account/name :bank-account/code {:client/_bank-accounts [:client/code]}])
:in $ $$
:where
[$$ ?ba :bank-account/include-in-reports false ?tx true]
[(get-else $ ?ba :bank-account/include-in-reports false) ?include]
[(= ?include false)]
[?tx :db/txInstant ?d]
[(>= ?d #inst "2024-02-01")]]
(dc/db conn)
(dc/history (dc/db conn)))
(map (fn [[ba]]
(println ba)
[(-> ba :client/_bank-accounts :client/code) (:bank-account/code ba) (:bank-account/name ba)]))
( #(clojure.data.csv/write-csv *out* % :separator \tab)))
)