hopefully faster 1099 load.

This commit is contained in:
2023-01-15 05:06:38 -08:00
parent 6e23394373
commit 14b1847a90

View File

@@ -16,6 +16,13 @@
(:vendor/legal-entity-tin-type vendor)))) (:vendor/legal-entity-tin-type vendor))))
(defn get-1099-companies [user] (defn get-1099-companies [user]
(let [clients (->> (d/q '[:find ?c
:in $ ?user
:where [?c :client/code]
[(auto-ap.graphql.utils/can-see-client? ?user ?c)]]
(d/db conn) user)
(map first)
set)]
(->> (d/q '[:find (->> (d/q '[:find
(pull ?c [:client/code]) (pull ?c [:client/code])
(pull ?v [:db/id (pull ?v [:db/id
@@ -32,22 +39,22 @@
:vendor/legal-entity-last-name]) :vendor/legal-entity-last-name])
(sum ?a) (sum ?a)
:with ?p :with ?p
:in $ ?user :in $ [?c ...]
:where [?p :payment/date ?d ] :where
[?p :payment/client ?c]
[?p :payment/date ?d ]
[(>= ?d #inst "2018-01-01T08:00")] [(>= ?d #inst "2018-01-01T08:00")]
[(< ?d #inst "2023-01-01T08:00")] [(< ?d #inst "2023-01-01T08:00")]
[?p :payment/client ?c]
[(auto-ap.graphql.utils/can-see-client? ?user ?c)]
[?p :payment/amount ?a] [?p :payment/amount ?a]
[?p :payment/type :payment-type/check] [?p :payment/type :payment-type/check]
[?p :payment/vendor ?v]] [?p :payment/vendor ?v]]
(d/db conn) (d/db conn)
user) clients)
(filter (fn [[_ _ a]] (filter (fn [[_ _ a]]
(>= a 600.0))) (>= a 600.0)))
(sort-by (fn [[client _ amount]] (sort-by (fn [[client _ amount]]
[(:client/code client) amount]) ))) [(:client/code client) amount]) ))))
(defn dialog [header content footer] (defn dialog [header content footer]
[:div.modal.is-active [:div.modal.is-active