adds links
This commit is contained in:
@@ -8,6 +8,9 @@
|
||||
[auto-ap.permissions :refer [wrap-must]]
|
||||
[auto-ap.query-params :refer [wrap-copy-qp-pqp]]
|
||||
[auto-ap.routes.transactions :as route]
|
||||
[auto-ap.routes.invoice :as invoice-routes]
|
||||
[auto-ap.routes.payments :as payment-routes]
|
||||
[auto-ap.routes.ledger :as ledger-routes]
|
||||
[auto-ap.routes.utils :refer [wrap-client-redirect-unauthenticated]]
|
||||
[auto-ap.ssr-routes :as ssr-routes]
|
||||
[auto-ap.ssr.components :as com]
|
||||
@@ -197,6 +200,7 @@
|
||||
[ :transaction/post-date :xform clj-time.coerce/from-date]
|
||||
:transaction/type
|
||||
:transaction/status
|
||||
:transaction/client-overrides
|
||||
:db/id
|
||||
{:transaction/vendor [:vendor/name :db/id]
|
||||
:transaction/client [:client/name :client/code :db/id]
|
||||
@@ -204,7 +208,8 @@
|
||||
:transaction/accounts [{:transaction-account/account [:account/name :db/id]}
|
||||
:transaction-account/location
|
||||
:transaction-account/amount]
|
||||
:transaction/matched-rule [:matched-rule/name]}])
|
||||
:transaction/matched-rule [:matched-rule/name]
|
||||
:transaction/payment [:db/id [:payment/date :xform clj-time.coerce/from-date]]}])
|
||||
|
||||
(defn hydrate-results [ids db _]
|
||||
(let [results (->> (pull-many db default-read ids)
|
||||
@@ -343,22 +348,60 @@
|
||||
:show-starting "lg"
|
||||
:class "w-8"
|
||||
:render (fn [i]
|
||||
(link-dropdown
|
||||
(cond-> []
|
||||
(:transaction/payment i)
|
||||
(conj
|
||||
{:link (hu/url (bidi/path-for ssr-routes/only-routes
|
||||
::route/payment-page)
|
||||
{:exact-match-id (:db/id (:transaction/payment i))})
|
||||
:color :primary
|
||||
:content (format "Payment '%s'" (-> i :transaction/payment :payment/invoice-number))})
|
||||
|
||||
(and (:transaction/client-overrides i) (seq (:transaction/client-overrides i)))
|
||||
{:link (hu/url (bidi/path-for client-routes/routes
|
||||
:transactions)
|
||||
{:exact-match-id (:db/id i)})
|
||||
:color :primary
|
||||
:content "Client Overrides"})))
|
||||
(let [db (dc/db conn)
|
||||
journal-entries (when (:db/id i)
|
||||
(dc/q '[:find (pull ?je [:db/id :journal-entry/id])
|
||||
:in $ ?t-id
|
||||
:where
|
||||
[?je :journal-entry/original-entity ?t-id]]
|
||||
db
|
||||
(:db/id i)))
|
||||
linked-invoices (when (and (:db/id i) (:transaction/payment i))
|
||||
(dc/q '[:find (pull ?inv [:db/id :invoice/invoice-number :invoice/total])
|
||||
:in $ ?payment-id
|
||||
:where
|
||||
[?ip :invoice-payment/payment ?payment-id]
|
||||
[?ip :invoice-payment/invoice ?inv]]
|
||||
db
|
||||
(:db/id (:transaction/payment i))))]
|
||||
(link-dropdown
|
||||
(cond-> []
|
||||
;; Payment link
|
||||
(:transaction/payment i)
|
||||
(conj
|
||||
{:link (hu/url (bidi/path-for ssr-routes/only-routes
|
||||
::route/payment-page)
|
||||
{:exact-match-id (:db/id (:transaction/payment i))})
|
||||
:color :primary
|
||||
:content (format "Payment '%s'" (-> i :transaction/payment :payment/date (atime/unparse-local atime/normal-date)))})
|
||||
|
||||
;; Journal entry links
|
||||
(seq journal-entries)
|
||||
(concat
|
||||
(for [[je] journal-entries]
|
||||
{:link (hu/url (bidi/path-for ssr-routes/only-routes ::ledger-routes/all-page)
|
||||
{:exact-match-id (:db/id je)})
|
||||
:color :yellow
|
||||
:content "Ledger entry"}))
|
||||
|
||||
;; Invoice links
|
||||
(seq linked-invoices)
|
||||
(concat
|
||||
(for [[inv] linked-invoices]
|
||||
{:link (hu/url (bidi/path-for ssr-routes/only-routes
|
||||
::invoice-routes/all-page)
|
||||
{:exact-match-id (:db/id inv)})
|
||||
:color :secondary
|
||||
:content (format "Invoice '%s'" (:invoice/invoice-number inv))}))
|
||||
|
||||
;; Client overrides
|
||||
(and (:transaction/client-overrides i) (seq (:transaction/client-overrides i)))
|
||||
(conj
|
||||
{:link (hu/url (bidi/path-for client-routes/routes
|
||||
:transactions)
|
||||
{:exact-match-id (:db/id i)})
|
||||
:color :primary
|
||||
:content "Client Overrides"})))))
|
||||
:render-for #{:html}}]}))
|
||||
|
||||
(def row* (partial helper/row* grid-page))
|
||||
@@ -388,4 +431,4 @@
|
||||
(wrap-schema-enforce :query-schema query-schema)
|
||||
(wrap-schema-enforce :hx-schema query-schema)
|
||||
(wrap-must {:activity :view :subject :transaction})
|
||||
(wrap-client-redirect-unauthenticated))))))
|
||||
(wrap-client-redirect-unauthenticated))))))
|
||||
|
||||
Reference in New Issue
Block a user