huge number of changes to start making all usages of expense accounts dynamic.
This commit is contained in:
@@ -25,8 +25,8 @@
|
||||
(re-frame/reg-sub
|
||||
::expense-account
|
||||
:<- [::change-expense-accounts]
|
||||
(fn [{{:keys [expense-accounts] :or {expense-accounts [] }} :invoice} [_ expense-account-id]]
|
||||
(first (filter #(= expense-account-id (:id %)) expense-accounts))))
|
||||
(fn [{{:keys [expense-accounts] :or {expense-accounts [] }} :invoice} [_ invoice-expense-account-id]]
|
||||
(first (filter #(= invoice-expense-account-id (:id %)) expense-accounts))))
|
||||
|
||||
(re-frame/reg-event-fx
|
||||
::change-expense-accounts
|
||||
@@ -89,12 +89,12 @@
|
||||
)
|
||||
:amount (:new-amount ea)
|
||||
:location (:location ea)
|
||||
:expense-account-id (:expense-account-id ea)})
|
||||
:account-id (:id (:account ea))})
|
||||
expense-accounts)}
|
||||
[:id :total :outstanding-balance :invoice-number :date :status
|
||||
[:vendor [:name :id]]
|
||||
[:expense_accounts [:amount :id :location :expense_account_id
|
||||
[:expense_account [:id :name [:parent [:id :name]]]]]]
|
||||
[:account [:id :name :numeric-code :location]]]]
|
||||
[:client [:name :id :locations]]
|
||||
[:payments [:amount :id [:payment [:amount :s3_url :check_number ]]]]]]}]}
|
||||
:on-success on-success}})))
|
||||
@@ -104,7 +104,7 @@
|
||||
(fn [db _]
|
||||
(let [{{{:keys [locations]} :client} :invoice} @(re-frame/subscribe [::change-expense-accounts])]
|
||||
(update-in db [::change-expense-accounts :invoice :expense-accounts]
|
||||
conj {:amount "0.0" :id (str "new-" (random-uuid)) :expense-account-id {} :location (first locations)}))))
|
||||
conj {:amount "0.0" :id (str "new-" (random-uuid)) :account {} :location (first locations)}))))
|
||||
|
||||
(re-frame/reg-event-db
|
||||
::remove-expense-account-split
|
||||
@@ -148,21 +148,22 @@
|
||||
[:th {:style {:width "5em"}}]]]
|
||||
[:tbody
|
||||
(doall (for [{:keys [id] :as expense-account} expense-accounts
|
||||
:let [sub @(re-frame/subscribe [::expense-account (:id expense-account)])]]
|
||||
:let [sub @(re-frame/subscribe [::expense-account (:id expense-account)])
|
||||
_ (println "SUBB" sub)]]
|
||||
^{:key id}
|
||||
[:tr
|
||||
[:td.expandable [:div.control
|
||||
[bind-field
|
||||
[typeahead {:matches (map (fn [x] [(:id x) (str (:id x) " - " (:name x))]) chooseable-expense-accounts)
|
||||
[typeahead {:matches (map (fn [x] [(:id x) (str (:numeric-code x) " - " (:name x))]) chooseable-expense-accounts)
|
||||
:type "typeahead"
|
||||
:field [:expense-account-id]
|
||||
:field [:account :id]
|
||||
:event [::change id]
|
||||
:spec ::invoices-expense-accounts/expense-account-id
|
||||
:spec ::invoices-expense-accounts/account-id
|
||||
:subscription sub}]]]]
|
||||
|
||||
(when multi-location?
|
||||
[:td
|
||||
(if-let [forced-location (-> expense-account :expense-account-id expense-accounts/expense-accounts :location)]
|
||||
(if-let [forced-location (:location @(re-frame/subscribe [::subs/account (-> sub :account :id )]))]
|
||||
[:div.select
|
||||
[:select {:disabled "disabled" :value forced-location} [:option {:value forced-location} forced-location]]]
|
||||
[:div.select
|
||||
|
||||
@@ -49,8 +49,8 @@
|
||||
:client-id (:id @(re-frame/subscribe [::subs/client])))
|
||||
[[:invoices [:id :total :outstanding-balance :invoice-number :date :status
|
||||
[:vendor [:name :id]]
|
||||
[:expense_accounts [:amount :id :expense_account_id :location
|
||||
[:expense_account [:id :name :location [:parent [:id :name]]]]]]
|
||||
[:expense_accounts [:amount :id :location
|
||||
[:account [:id :name :numeric-code :location ]]]]
|
||||
[:client [:name :id :locations]]
|
||||
[:payments [:amount :id [:payment [:id :status :amount :s3_url :check_number
|
||||
[:transaction [:post_date]]]]]]]]
|
||||
@@ -182,7 +182,7 @@
|
||||
[:div
|
||||
(for [e expense-accounts]
|
||||
^{:key (:id e)}
|
||||
[:span.dropdown-item (:name (:expense-account e)) " " (gstring/format "$%.2f" (:amount e) ) ])
|
||||
[:span.dropdown-item (:name (:account e)) " " (gstring/format "$%.2f" (:amount e) ) ])
|
||||
|
||||
[:hr.dropdown-divider]
|
||||
|
||||
|
||||
@@ -12,8 +12,8 @@
|
||||
[auto-ap.subs :as subs]))
|
||||
|
||||
(defn vendor-dialog [{:keys [vendor save-event change-event id] {:keys [name]} :vendor}]
|
||||
(println (s/explain ::entity/vendor vendor) )
|
||||
(let [clients-by-id @(re-frame/subscribe [::subs/clients-by-id])]
|
||||
(let [clients-by-id @(re-frame/subscribe [::subs/clients-by-id])
|
||||
chooseable-expense-accounts @(re-frame/subscribe [::subs/chooseable-expense-accounts]) ]
|
||||
[action-modal {:id id
|
||||
:title [:span (if (:id vendor)
|
||||
(str "Edit " (or name "<vendor>"))
|
||||
@@ -51,23 +51,12 @@
|
||||
[horizontal-field
|
||||
[:label.label "Default"]
|
||||
[bind-field
|
||||
[typeahead {:matches (map (fn [[k v]] [k (:name v)]) chooseable-expense-accounts)
|
||||
[typeahead {:matches (map (fn [x] [(:id x) (str (:numeric-code x) " - " (:name x))]) chooseable-expense-accounts)
|
||||
:type "typeahead"
|
||||
:field [:default-expense-account]
|
||||
:spec ::entity/default-expense-account
|
||||
:field [:default-account-id]
|
||||
:event change-event
|
||||
:subscription vendor}]]]
|
||||
#_[horizontal-field
|
||||
[:label.label "Code"]
|
||||
[:div.control
|
||||
|
||||
[bind-field
|
||||
[:input.input.is-expanded {:type "text"
|
||||
:field :code
|
||||
:spec ::entity/code
|
||||
:event change-event
|
||||
:subscription vendor}]]
|
||||
[:p.help "The vendor code is used for invoice parsing. Only one vendor at a time can use a code"]]]
|
||||
|
||||
|
||||
[:h2.subtitle "Address"]
|
||||
[address-field {:field [:address]
|
||||
@@ -163,11 +152,4 @@
|
||||
:event change-event
|
||||
:subscription vendor}]]
|
||||
" Never"]]]
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
(when (:saving? vendor) [:div.is-overlay {:style {"backgroundColor" "rgba(150,150,150, 0.5)"}}])]))
|
||||
|
||||
Reference in New Issue
Block a user