customized transactions.
This commit is contained in:
@@ -106,15 +106,18 @@
|
||||
(re-frame/reg-event-db
|
||||
::adding
|
||||
(fn [db [_ new]]
|
||||
(let [locations @(re-frame/subscribe [::subs/locations-for-client (:client new)])]
|
||||
(let [locations @(re-frame/subscribe [::subs/locations-for-client (:client new)])
|
||||
accounts-by-id @(re-frame/subscribe [::subs/accounts-by-id (:client new)])]
|
||||
(-> db (forms/start-form ::form (assoc new :expense-accounts
|
||||
(expense-accounts-field/from-graphql (:expense-accounts new)
|
||||
accounts-by-id
|
||||
0.0
|
||||
locations)))))))
|
||||
(re-frame/reg-event-db
|
||||
::editing
|
||||
(fn [db [_ which]]
|
||||
(let [edit-invoice (update which :date #(date->str % standard))
|
||||
(let [accounts-by-id @(re-frame/subscribe [::subs/accounts-by-id (:client which)])
|
||||
edit-invoice (update which :date #(date->str % standard))
|
||||
edit-invoice (update edit-invoice :due #(date->str % standard))
|
||||
edit-invoice (assoc edit-invoice :original edit-invoice)
|
||||
locations @(re-frame/subscribe [::subs/locations-for-client (:id (:client which))])]
|
||||
@@ -129,6 +132,7 @@
|
||||
:vendor (:vendor edit-invoice)
|
||||
:client (:client edit-invoice)
|
||||
:expense-accounts (expense-accounts-field/from-graphql (:expense-accounts which)
|
||||
accounts-by-id
|
||||
(:amount which)
|
||||
locations)})))))
|
||||
|
||||
@@ -212,9 +216,7 @@
|
||||
can-change-amount? (#{:unpaid ":unpaid"} (:status data))
|
||||
min-total (if (= (:total (:original data)) (:outstanding-balance (:original data)))
|
||||
nil
|
||||
(- (:total (:original data)) (:outstanding-balance (:original data))))
|
||||
chooseable-expense-accounts @(re-frame/subscribe [::subs/chooseable-expense-accounts])
|
||||
accounts-by-id @(re-frame/subscribe [::subs/accounts-for-client-by-id])]
|
||||
(- (:total (:original data)) (:outstanding-balance (:original data))))]
|
||||
^{:key id}
|
||||
[form (assoc params :title "New Invoice")
|
||||
(when-not @(re-frame/subscribe [::subs/client])
|
||||
@@ -278,6 +280,7 @@
|
||||
:descriptor "expense account"
|
||||
:locations (:locations (:client data))
|
||||
:max (:total data)
|
||||
:client (or (:client data) @(re-frame/subscribe [::subs/client]))
|
||||
:field [:expense-accounts]}]]
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user