This commit is contained in:
2022-04-26 17:05:58 -07:00
parent cae28589d2
commit 96a796522c
7 changed files with 48 additions and 71 deletions

View File

@@ -140,7 +140,7 @@
(defn get-by-id [id]
(->> (d/q '[:find (pull ?e [*
{:default-account [:account/name :db/id :account/location]
{:vendor/default-account [:account/name :db/id :account/location]
:vendor/legal-entity-tin-type [:db/ident :db/id]
:vendor/legal-entity-1099-type [:db/ident :db/id]
:vendor/account-overrides [* {:vendor-account-override/client [:client/name :db/id]

View File

@@ -366,7 +366,12 @@
(let [type (keyword "payment-type" (name type))
invoices (d-invoices/get-multi (map :invoice-id invoice-payments))
client (d-clients/get-by-id client-id)
vendors (by :db/id (d-vendors/get-graphql {}))
vendors (->> (d/q '[:find [?e ...]
:in $
:where [?e :vendor/name]]
(d/db conn))
(d/pull-many (d/db conn) d-vendors/default-read)
(by :db/id))
invoice-amounts (by :invoice-id :amount invoice-payments)
invoices-grouped-by-vendor (group-by (comp :db/id :invoice/vendor) invoices)
bank-account (d-bank-accounts/get-by-id bank-account-id)

View File

@@ -307,6 +307,7 @@
(assert (:invoice/client invoice))
(assert-can-see-client (:id context) (:db/id (:invoice/client invoice)))
(assert-not-locked (:db/id (:invoice/client invoice)) (:invoice/date invoice))
(assert (not (seq (:invoice-payment/_invoice invoice))))
(audit-transact [[:db/add id :invoice/status :invoice-status/unpaid]
[:db/add id :invoice/outstanding-balance (:invoice/total invoice)]
[:db/retract id :invoice/scheduled-payment (:invoice/scheduled-payment invoice)]]

View File

@@ -147,14 +147,22 @@
(d-vendors/get-graphql-by-id (assoc args :id (:id context))
(:id args))))
(defn search [_ args _]
(->> (d/q '[:find ?n ?i ?s
:in $ ?q
:where [(fulltext $ :vendor/search-terms ?q) [[?i ?n _ ?s]]]
(not [?i :vendor/hidden true])]
(d/db conn)
(:query args))
(sort-by last)
(map (fn [[n i]]
{:name n
:id i}))))
(defn search [context args _]
(let [data (if (is-admin? (:id context))
(d/q '[:find ?n ?i ?s
:in $ ?q
:where [(fulltext $ :vendor/search-terms ?q) [[?i ?n _ ?s]]]]
(d/db conn)
(:query args))
(d/q '[:find ?n ?i ?s
:in $ ?q
:where [(fulltext $ :vendor/search-terms ?q) [[?i ?n _ ?s]]]
(not [?i :vendor/hidden true])]
(d/db conn)
(:query args)))]
(->> data
(sort-by last)
(map (fn [[n i]]
{:name n
:id i})))))