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