You can update locations

This commit is contained in:
Bryce Covert
2018-06-15 17:21:45 -07:00
parent b06a6651ca
commit e749b3eb23
7 changed files with 31 additions and 7 deletions

View File

@@ -22,9 +22,9 @@
:company-id (:id @(re-frame/subscribe [::subs/company])))
[[:invoices [:id :total :outstanding-balance :invoice-number :date
[:vendor [:name :id]]
[:expense_accounts [:amount :id :expense_account_id
[:expense_accounts [:amount :id :expense_account_id :location
[:expense_account [:id :name [:parent [:id :name]]]]]]
[:company [:name :id]]
[:company [:name :id :locations]]
[:checks [:amount [:check [:amount :s3_url :check_number ]]]]
]]
:total

View File

@@ -250,13 +250,14 @@
{:invoice-id id
:expense-accounts (map (fn [ea] {:id (:id ea)
:amount (:amount ea)
:location (:location ea)
:expense-account-id (:expense-account-id ea)})
expense-accounts)}
[:id :total :outstanding-balance :invoice-number :date
[:vendor [:name :id]]
[:expense_accounts [:amount :id :expense_account_id
[:expense_accounts [:amount :id :location :expense_account_id
[:expense_account [:id :name [:parent [:id :name]]]]]]
[:company [:name :id]]
[:company [:name :id :locations]]
[:checks [:amount [:check [:amount :s3_url :check_number ]]]]
]]}]}
:on-success [::expense-accounts-updated]}})))
@@ -290,7 +291,8 @@
(drop (inc index) expense-accounts))))))
(defn change-expense-accounts-modal []
(let [{{:keys [expense-accounts total] :or {expense-accounts [] total 0}} :invoice :as data} @(re-frame/subscribe [::change-expense-accounts])
(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)
change-event [::events/change-form [::change-expense-accounts]]
expense-accounts-total (->> expense-accounts
(map :amount)
@@ -311,6 +313,8 @@
[:thead
[:tr
[:th {:style {:width "500px"}} "Expense Account"]
(when should-select-location?
[:th {:style {:width "500px"}} "Location"])
[:th {:style {:width "300px"}} "Amount"]
[:th {:style {:width "5em"}}]]]
[:tbody
@@ -325,6 +329,17 @@
:spec ::invoice/vendor-id
:subscription data}]]]]
(when should-select-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)]]]
])
[:td
[:div.control