diff --git a/src/clj/auto_ap/ssr/company/company_1099.clj b/src/clj/auto_ap/ssr/company/company_1099.clj index 854e7b6a..4f6bc525 100644 --- a/src/clj/auto_ap/ssr/company/company_1099.clj +++ b/src/clj/auto_ap/ssr/company/company_1099.clj @@ -15,7 +15,7 @@ (:vendor/legal-entity-tin vendor) (:vendor/legal-entity-tin-type vendor)))) -(defn get-1099-companies-2 [user] +(defn get-1099-companies [user] (let [clients (->> (d/q '[:find ?c :in $ ?user :where [?c :client/code] @@ -27,66 +27,25 @@ ?c ?v (sum ?a) - :with ?p - :in $ [?c ...] + :with ?d + :in $ :where - [?p :payment/client ?c] - [?p :payment/type :payment-type/check] [?p :payment/date ?d ] [(>= ?d #inst "2022-01-01T08:00")] [(< ?d #inst "2023-01-01T08:00")] + [?p :payment/client ?c] [?p :payment/amount ?a] [?p :payment/vendor ?v]] (d/db conn) - clients) + ) (filter (fn [[_ _ a]] - (>= a 600.0))) + (>= (or a 0.0) 600.0))) + (filter (comp clients first)) (take 200) - (sort-by (fn [[client _ amount]] + (sort-by (fn [[client _ amount]] [client amount]) )))) -(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 - (pull ?c [:client/code]) - (pull ?v [:db/id - :vendor/name - {:vendor/legal-entity-1099-type [:db/ident]} - {:vendor/legal-entity-tin-type [:db/ident]} - {:vendor/address [:address/street1 - :address/city - :address/state - :address/zip]} - :vendor/legal-entity-first-ein - :vendor/legal-entity-first-name - :vendor/legal-entity-middle-name - :vendor/legal-entity-last-name]) - (sum ?a) - :with ?p - :in $ [?c ...] - :where - [?p :payment/client ?c] - [?p :payment/type :payment-type/check] - [?p :payment/date ?d ] - [(>= ?d #inst "2022-01-01T08:00")] - [(< ?d #inst "2023-01-01T08:00")] - [?p :payment/amount ?a] - [?p :payment/vendor ?v]] - (d/db conn) - clients) - (filter (fn [[_ _ a]] - (>= a 600.0))) - (take 200) - - (sort-by (fn [[client _ amount]] - [(:client/code client) amount]) )))) (defn dialog [header content footer] [:div.modal.is-active