Should make reloading AND aot work again

This commit is contained in:
2024-02-08 15:20:58 -08:00
parent 5b32518562
commit a5e6b0549d
20 changed files with 280 additions and 351 deletions

View File

@@ -1,129 +1,152 @@
(defn setup-randy-queries []
(import '[java.util UUID])
(def my-id "a4345849-00a7-424e-b393-06257d3c1820")
(auto-ap.routes.queries/put-query
my-id
(str '[:find ?an ?cn ?a ?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]
[?ba :bank-account/code ?bac]
[?ba :bank-account/number ?an]
[?p :payment/bank-account ?ba]
[?p :payment/date ?pd]
[(>= ?pd ?sd)]
[?p :payment/type :payment-type/check]
[?p :payment/amount ?a]
[?p :payment/check-number ?cn]
[(clj-time.coerce/from-date ?pd) ?pd2]
[(clj-time.format/unparse ?fmt ?pd2) ?fmt-date]
[(ground "IS") ?action]
[?p :payment/vendor ?v]
[(get-some $ ?v :vendor/print-as :vendor/name) [_ ?payee]]])
"One-off for randy"))
(dc/q
'[:find ?cd ?bal (count ?l)
:where [?b :bank-account/locations ?bal]
[?c :client/bank-accounts ?b]
[?c :client/code ?cd]
[?c :client/locations ?l]]
(dc/db conn))
(init-repl)
(comment
(defn setup-randy-queries []
(import '[java.util UUID])
(def my-id "a4345849-00a7-424e-b393-06257d3c1820")
(seq (dc/q
'[:find ?a ?n ?n2
:where [?a :account/name ?n]
[?a :account/numeric-code ?n2]
(not [?a :account/code])]
(dc/db conn)))
(dc/q
'[:find (pull ?a [* {:account/applicability [:db/ident] :account/default-allowance [*]}])
:where [?a :account/numeric-code 34090]]
(dc/db conn))
(auto-ap.routes.queries/put-query
my-id
(str '[:find ?an ?cn ?a ?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]
[?ba :bank-account/code ?bac]
[?ba :bank-account/number ?an]
[?p :payment/bank-account ?ba]
[?p :payment/date ?pd]
[(>= ?pd ?sd)]
[?p :payment/type :payment-type/check]
[?p :payment/amount ?a]
[?p :payment/check-number ?cn]
[(clj-time.coerce/from-date ?pd) ?pd2]
[(clj-time.format/unparse ?fmt ?pd2) ?fmt-date]
[(ground "IS") ?action]
[?p :payment/vendor ?v]
[(get-some $ ?v :vendor/print-as :vendor/name) [_ ?payee]]])
"One-off for randy"))
(dc/q
'[:find ?a
:where [?a :account/numeric-code ?nc]
(not [?a :account/default-allowance])]
(dc/since (dc/db conn) #inst "2023-02-01"))
@(dc/transact conn
(->>
(dc/q
'[:find ?a
:where [?a :account/numeric-code ?nc]
(not [?a :account/default-allowance])]
(dc/since (dc/db conn) #inst "2023-02-01"))
(map (fn [[a]]
{:db/id a
:account/default-allowance :allowance/allowed}))))
(dc/q
'[:find ?cd ?bal (count ?l)
:where [?b :bank-account/locations ?bal]
[?c :client/bank-accounts ?b]
[?c :client/code ?cd]
[?c :client/locations ?l]]
(dc/db conn))
(dc/q '[:find (pull ?l [*])
:in $ ?a
:where [?a :invoice/client]
[?l :journal-entry/original-entity ?a]]
(dc/db conn)
17592316421929)
(init-repl)
(dc/pull (dc/db conn) '[*] 17592316421929)
(seq (dc/q
'[:find ?a ?n ?n2
:where [?a :account/name ?n]
[?a :account/numeric-code ?n2]
(not [?a :account/code])]
(dc/db conn)))
(entity-history 17592316421929)
(dc/q
'[:find (pull ?a [* {:account/applicability [:db/ident] :account/default-allowance [*]}])
:where [?a :account/numeric-code 34090]]
(dc/db conn))
(dc/q '[:find (pull ?l [*])
:in $ ?a
:where [?a :invoice/client]
[?l :journal-entry/original-entity ?a]]
(dc/db conn)
17592316421929)
(dc/q
'[:find ?a
:where [?a :account/numeric-code ?nc]
(not [?a :account/default-allowance])]
(dc/since (dc/db conn) #inst "2023-02-01"))
@(dc/transact conn
(->>
(dc/q
'[:find ?a
:where [?a :account/numeric-code ?nc]
(not [?a :account/default-allowance])]
(dc/since (dc/db conn) #inst "2023-02-01"))
(map (fn [[a]]
{:db/id a
:account/default-allowance :allowance/allowed}))))
(dc/q '[:find (pull ?l [*])
:in $ ?a
:where [?a :invoice/client]
[?l :journal-entry/original-entity ?a]]
(dc/db conn)
17592316421929)
(dc/pull (dc/db conn) '[*] 17592316421929)
(entity-history 17592316421929)
(dc/q '[:find (pull ?l [*])
:in $ ?a
:where [?a :invoice/client]
[?l :journal-entry/original-entity ?a]]
(dc/db conn)
17592316421929)
;; Find journal entries that have been divorced from the original entity
@(dc/transact auto-ap.datomic/conn
(->>
(dc/q '[:find ?l
:in $ $$ $$$
:where [$$ ?l :journal-entry/amount]
(not [$ ?l :journal-entry/external-id])
[$ ?l :journal-entry/source "invoice"]
(not [$ ?l :journal-entry/original-entity])
[$ ?l :journal-entry/client ?c]
[$ ?c :client/code ?cd]
[$$$ ?l :journal-entry/original-entity _ ?tx false]]
(dc/db conn)
(dc/since (dc/db conn) #inst "2024-02-04")
(dc/history (dc/db conn)))
(map (fn [[jl]]
[:db/retractEntity jl]))
seq)
)
@(dc/transact auto-ap.datomic/conn
(->>
(dc/q '[:find ?l
:in $ $$ $$$
:where [$$ ?l :journal-entry/amount]
(not [$ ?l :journal-entry/external-id])
[$ ?l :journal-entry/source "invoice"]
(not [$ ?l :journal-entry/original-entity])
[$ ?l :journal-entry/client ?c]
[$ ?c :client/code ?cd]
[$$$ ?l :journal-entry/original-entity _ ?tx false]]
(dc/db conn)
(dc/since (dc/db conn) #inst "2024-02-04")
(dc/history (dc/db conn)))
(map (fn [[jl]]
[:db/retractEntity jl]))
seq))
(entity-history 13194269907490)
(entity-history 13194269907490)
(user/tx-detail 13194269907766)
(user/tx-detail 13194269907766)
(dc/tx-range (dc/log conn)
13194269907490
13194269907490)
(dc/q '[:find ?l
:in $ $$ $$$
:where [$$ ?l :journal-entry/amount]
(not [$ ?l :journal-entry/external-id])
[$ ?l :journal-entry/source "invoice"]
(not [$ ?l :journal-entry/original-entity])
[$ ?l :journal-entry/client ?c]
[$ ?c :client/code ?cd]
[$$$ ?l :journal-entry/original-entity _ ?tx false]]
(dc/db conn)
(dc/since (dc/db conn) #inst "2024-02-04")
(dc/history (dc/db conn)))
(dc/tx-range (dc/log conn)
13194269907490
13194269907490)
(dc/q '[:find ?l
:in $ $$ $$$
:where [$$ ?l :journal-entry/amount]
(not [$ ?l :journal-entry/external-id])
[$ ?l :journal-entry/source "invoice"]
(not [$ ?l :journal-entry/original-entity])
[$ ?l :journal-entry/client ?c]
[$ ?c :client/code ?cd]
[$$$ ?l :journal-entry/original-entity _ ?tx false]]
(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 ?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"]}))))
)