Started added direct linkage

This commit is contained in:
Bryce Covert
2021-01-23 10:24:55 -08:00
parent cb33e1e54a
commit b00e2c5b60
8 changed files with 63 additions and 30 deletions

View File

@@ -22,6 +22,7 @@
(defn query [params]
{:venia/queries [[:invoice_page
{
:exact-match-id (some-> params :exact-match-id str)
:start (:start params 0)
:sort (:sort params)
:per-page (:per-page params)
@@ -96,7 +97,7 @@
{:db db}))
(defn row [{:keys [invoice check-boxes selected-client overrides checkable? expense-event actions]}]
(let [{:keys [client payments expense-accounts invoice-number date due total outstanding-balance id vendor] :as i} invoice
(let [{:keys [client status payments expense-accounts invoice-number date due total outstanding-balance id vendor] :as i} invoice
accounts-by-id @(re-frame/subscribe [::subs/accounts-by-id client])
account->name #(:name (accounts-by-id (:id %)))]
[grid/row {:class (:class i) :id id :checkable? checkable? :entity invoice}
@@ -110,11 +111,13 @@
[grid/cell {} (date->str date) ]
[grid/cell {}
(when due
(let [due-in (days-until due)]
(if (> due-in 0)
[:span.has-text-success due-in " days"]
[:span.has-text-danger due-in " days"])
))]
(if (#{":paid" :paid ":voided" :voided} status)
nil
(let [due-in (days-until due)]
(if (> due-in 0)
[:span.has-text-success due-in " days"]
[:span.has-text-danger due-in " days"])
)))]
[grid/cell {} (str/join ", " (set (map :location expense-accounts)))]
[grid/cell {:class "has-text-right"} (nf total )]
@@ -153,18 +156,24 @@
^{:key (:id payment)}
[:a.dropdown-item {:href (str (bidi/path-for routes/routes :payments )
"?"
(url/map->query {:check-number-like (:check-number (:payment payment))}))
(url/map->query {:exact-match-id (:id (:payment payment))}))
:target "_new"}
[:i.fa.fa-money-check]
[:span.icon [:i.fa.fa-money]]
(str " " (:check-number (:payment payment)) " (" (gstring/format "$%.2f" (:amount payment) ) ")")]
[:span.icon {:class [(when (= :cleared (:status (:payment payment)))
"has-text-success")]}
[:i.fa.fa-money]]
^{:key (:id payment)}
[:span.dropdown-item [:span.icon {:class [(when (= :cleared (:status (:payment payment)))
"has-text-success")]}
[:i.fa.fa-money]] (str " " (:check-number (:payment payment)) " (" (gstring/format "$%.2f" (:amount payment) ) ") "
(when (= :cleared (:status (:payment payment)))
(str " - " (:post-date (:transaction (:payment payment))))))]))]]
(if (:check-number (:payment payment))
(str "Check " (:check-number (:payment payment))
" (" (gstring/format "$%.2f" (:amount payment) ) ")"
(when (= :cleared (:status (:payment payment)))
(str " - " (:post-date (:transaction (:payment payment))))))
(str "Debit (" (gstring/format "$%.2f" (:amount payment) ) ") "
(when (= :cleared (:status (:payment payment)))
(str " - " (:post-date (:transaction (:payment payment)))))
(when (= :cleared (:status (:payment payment)))
(str " - " (:post-date (:transaction (:payment payment))))))) ]))]]
[:span {:style {:margin-right "1em"}}]])
(when (and (get actions :edit)
(not= ":voided" (:status i)))

View File

@@ -6,7 +6,7 @@
[auto-ap.views.components.switch-field :refer [switch-field]]
[auto-ap.views.components.typeahead :refer [typeahead-entity]]
[auto-ap.views.pages.data-page :as data-page]
[auto-ap.views.utils :refer [active-when dispatch-value-change]]
[auto-ap.views.utils :refer [active-when dispatch-event dispatch-value-change]]
[bidi.bidi :as bidi]
[re-frame.core :as re-frame]))
@@ -106,6 +106,13 @@
[:div
[invoice-number-filter params]]
(when-let [exact-match-id @(re-frame/subscribe [::data-page/filter data-page :exact-match-id])]
[:div
[:p.menu-label "Specific Invoice"]
[:span.tag.is-medium exact-match-id " "
[:button.delete.is-small {:on-click
(dispatch-event [::data-page/filter-changed data-page :exact-match-id nil])}]]])
(when (= "admin" (:user/role user))
[:<>
[:p.menu-label "Admin only"]