forces expense account A or HQ.
This commit is contained in:
@@ -8,6 +8,7 @@
|
||||
[auto-ap.entities.companies :as company]
|
||||
[auto-ap.entities.invoice :as invoice]
|
||||
[auto-ap.entities.vendors :as vendor]
|
||||
[auto-ap.expense-accounts :as expense-accounts]
|
||||
[auto-ap.entities.invoices-expense-accounts :as invoices-expense-accounts]
|
||||
[auto-ap.views.utils :refer [dispatch-event bind-field horizontal-field date->str str->date pretty standard]]
|
||||
[auto-ap.utils :refer [by replace-if]]
|
||||
@@ -412,8 +413,9 @@
|
||||
(re-frame/reg-event-db
|
||||
::add-expense-account-split
|
||||
(fn [db _]
|
||||
(update-in db [::change-expense-accounts :invoice :expense-accounts]
|
||||
conj {:amount 0 :expense-account-id nil})))
|
||||
(let [{{{:keys [locations]} :company} :invoice} @(re-frame/subscribe [::change-expense-accounts])]
|
||||
(update-in db [::change-expense-accounts :invoice :expense-accounts]
|
||||
conj {:amount 0 :expense-account-id nil :location (first locations)}))))
|
||||
|
||||
(re-frame/reg-event-db
|
||||
::remove-expense-account-split
|
||||
@@ -425,7 +427,7 @@
|
||||
|
||||
(defn change-expense-accounts-modal []
|
||||
(let [{{:keys [expense-accounts total ] :or {expense-accounts [] total 0} {:keys [locations]} :company} :invoice :as data} @(re-frame/subscribe [::change-expense-accounts])
|
||||
should-select-location? (> (count locations) 1)
|
||||
multi-location? (> (count locations) 1)
|
||||
change-event [::events/change-form [::change-expense-accounts]]
|
||||
expense-accounts-total (->> expense-accounts
|
||||
(map :amount)
|
||||
@@ -446,7 +448,7 @@
|
||||
[:thead
|
||||
[:tr
|
||||
[:th {:style {:width "500px"}} "Expense Account"]
|
||||
(when should-select-location?
|
||||
(when multi-location?
|
||||
[:th {:style {:width "500px"}} "Location"])
|
||||
[:th {:style {:width "300px"}} "Amount"]
|
||||
[:th {:style {:width "5em"}}]]]
|
||||
@@ -462,17 +464,19 @@
|
||||
:spec ::invoice/vendor-id
|
||||
:subscription data}]]]]
|
||||
|
||||
(when should-select-location?
|
||||
(when multi-location?
|
||||
[:td
|
||||
[:div.select
|
||||
[bind-field
|
||||
[:select {:type "select"
|
||||
:field [:invoice :expense-accounts index :location]
|
||||
:spec (set locations)
|
||||
:event change-event
|
||||
:subscription data}
|
||||
(map (fn [l] [:option {:value l} l]) locations)]]]
|
||||
])
|
||||
(if-let [forced-location (-> expense-account :expense-account-id expense-accounts/expense-accounts :location)]
|
||||
[:div.select
|
||||
[:select {:disabled "disabled" :value forced-location} [:option {:value forced-location} forced-location]]]
|
||||
[:div.select
|
||||
[bind-field
|
||||
[:select {:type "select"
|
||||
:field [:invoice :expense-accounts index :location]
|
||||
:spec (set locations)
|
||||
:event change-event
|
||||
:subscription data}
|
||||
(map (fn [l] [:option {:value l} l]) locations)]]])])
|
||||
|
||||
[:td
|
||||
[:div.control
|
||||
|
||||
Reference in New Issue
Block a user