more standardization
This commit is contained in:
@@ -15,7 +15,8 @@
|
||||
[cljs-time.core :as t]
|
||||
[clojure.string :as str]
|
||||
[goog.string :as gstring]
|
||||
[re-frame.core :as re-frame]))
|
||||
[re-frame.core :as re-frame]
|
||||
[auto-ap.views.components.expense-accounts-dialog :as expense-accounts-dialog]))
|
||||
|
||||
(defn query [params]
|
||||
{:venia/queries [[:invoice_page
|
||||
@@ -84,15 +85,14 @@
|
||||
{:invoice-id id}
|
||||
invoice-read]}]}
|
||||
:on-success (fn [result]
|
||||
[::invoice-updated (assoc (:unvoid-invoice result)
|
||||
:class "live-added")])}}))
|
||||
[::invoice-updated (:unvoid-invoice result)])}}))
|
||||
|
||||
(re-frame/reg-event-fx
|
||||
::invoice-updated
|
||||
(fn [{:keys [db]} [_ invoice]]
|
||||
{:db db}))
|
||||
|
||||
(defn row [{:keys [invoice check-boxes checked selected-client overrides expense-event ]}]
|
||||
(defn row [{:keys [invoice check-boxes checked selected-client overrides expense-event actions]}]
|
||||
(let [{:keys [client payments expense-accounts invoice-number date due total outstanding-balance id vendor checkable?] :as i} invoice
|
||||
accounts-by-id @(re-frame/subscribe [::subs/accounts-by-id client])
|
||||
account->name #(:name (accounts-by-id (:id %)))]
|
||||
@@ -134,10 +134,12 @@
|
||||
^{:key (:id e)}
|
||||
[:span.dropdown-item (account->name (:account e)) " " (gstring/format "$%.2f" (:amount e) ) ])
|
||||
|
||||
[:hr.dropdown-divider]
|
||||
(when (get actions :expense-accounts)
|
||||
[:<>
|
||||
|
||||
(when expense-event
|
||||
[:a.dropdown-item.is-primary {:on-click (dispatch-event (conj expense-event i))} "Change"])]]])
|
||||
[:hr.dropdown-divider]
|
||||
|
||||
[:a.dropdown-item.is-primary {:on-click (dispatch-event [::expense-accounts-dialog/show i])} "Change"]])]]])
|
||||
[:span {:style {:margin-left "1em"}}]
|
||||
(when (seq payments)
|
||||
[:<>
|
||||
@@ -165,17 +167,20 @@
|
||||
(when (= :cleared (:status (:payment payment)))
|
||||
(str " - " (:post-date (:transaction (:payment payment))))))]))]]
|
||||
[:span {:style {:margin-right "1em"}}]])
|
||||
(when (not= ":voided" (:status i))
|
||||
(when (and (get actions :edit)
|
||||
(not= ":voided" (:status i)))
|
||||
[buttons/fa-icon {:icon "fa-pencil"
|
||||
:event [::form/editing i]}])
|
||||
(when (and (= (:outstanding-balance i) (:total i)) (not= ":voided" (:status i)))
|
||||
(when (and (get actions :void)
|
||||
(= (:outstanding-balance i) (:total i)) (not= ":voided" (:status i)))
|
||||
[buttons/sl-icon {:icon "icon-bin-2"
|
||||
:event [::void-invoice i]}])
|
||||
(when (= ":voided" (:status i))
|
||||
(when (and (get actions :void)
|
||||
(= ":voided" (:status i)))
|
||||
[buttons/fa-icon {:icon "fa-undo"
|
||||
:event [::unvoid-invoice i]}])]]]))
|
||||
|
||||
(defn invoice-table [{:keys [id data checked status vendors check-boxes on-check-changed expense-event overrides]}]
|
||||
(defn invoice-table [{:keys [id data checked status check-boxes on-check-changed overrides actions]}]
|
||||
(let [selected-client @(re-frame/subscribe [::subs/client])
|
||||
{:keys [sort]} @(re-frame/subscribe [::table-params])
|
||||
selected-client @(re-frame/subscribe [::subs/client])
|
||||
@@ -204,7 +209,7 @@
|
||||
:checked checked
|
||||
:status status
|
||||
:check-boxes? check-boxes
|
||||
:column-count (if selected-client 7 8)}
|
||||
:column-count (if selected-client 8 9)}
|
||||
[grid/controls data
|
||||
[:div.level-item
|
||||
"Outstanding " (nf (:outstanding data))]]
|
||||
@@ -235,5 +240,5 @@
|
||||
^{:key id}
|
||||
[row {:invoice i
|
||||
:selected-client selected-client
|
||||
:overrides overrides
|
||||
:expense-event expense-event}])]])]))
|
||||
:actions actions
|
||||
:overrides overrides}])]])]))
|
||||
|
||||
Reference in New Issue
Block a user