percentage-based splitting.
This commit is contained in:
@@ -39,6 +39,7 @@
|
||||
(forms/stop-form ::edit-transaction))
|
||||
|
||||
:dispatch (conj edit-completed edit-transaction)}))
|
||||
|
||||
(re-frame/reg-event-db
|
||||
::editing
|
||||
(fn [db [_ which]]
|
||||
@@ -46,14 +47,25 @@
|
||||
(-> db
|
||||
(forms/start-form ::edit-transaction {:id (:id which)
|
||||
:yodlee-merchant (:yodlee-merchant which)
|
||||
:amount (:amount which)
|
||||
:description-original (:description-original which)
|
||||
:location (:location which)
|
||||
:client-id (:id (:client which))
|
||||
:vendor-id (:id (:vendor which))
|
||||
:vendor-name (:name (:vendor which))
|
||||
:accounts (or (vec (:accounts which))
|
||||
[{:id (str "new-" (random-uuid))
|
||||
:amount (Math/abs (:amount which))}])}))))
|
||||
:accounts (if (seq (:accounts which))
|
||||
(vec (map
|
||||
(fn [a]
|
||||
(-> a
|
||||
(update :amount js/parseFloat)
|
||||
(assoc :amount-percentage (* 100 (/ (js/parseFloat (:amount a))
|
||||
(Math/abs (js/parseFloat (:amount which))))))
|
||||
(assoc :amount-mode "$")))
|
||||
(:accounts which)))
|
||||
[{:id (str "new-" (random-uuid))
|
||||
:amount-mode "$"
|
||||
:amount (Math/abs (:amount which))
|
||||
:amount-percentage 100}])}))))
|
||||
|
||||
|
||||
(re-frame/reg-event-fx
|
||||
@@ -111,6 +123,15 @@
|
||||
:disabled "disabled"
|
||||
:subscription data}]]]]
|
||||
|
||||
[:div.field
|
||||
[:p.help "Amount"]
|
||||
[:div.control
|
||||
[bind-field
|
||||
[:input.input {:type "text"
|
||||
:field [:amount]
|
||||
:disabled "disabled"
|
||||
:subscription data}]]]]
|
||||
|
||||
[:div.field
|
||||
[:p.help "Description"]
|
||||
[:div.control
|
||||
@@ -133,15 +154,16 @@
|
||||
:event change-event
|
||||
:subscription data}]]]]
|
||||
|
||||
[:div.field]
|
||||
[bind-field
|
||||
[expense-accounts-field
|
||||
{:type "expense-accounts"
|
||||
:field [:accounts]
|
||||
:descriptor "credit account"
|
||||
:locations locations
|
||||
:event change-event
|
||||
:subscription data}]]
|
||||
[:div.field
|
||||
[bind-field
|
||||
[expense-accounts-field
|
||||
{:type "expense-accounts"
|
||||
:field [:accounts]
|
||||
:max (Math/abs (js/parseFloat (:amount data)))
|
||||
:descriptor "credit account"
|
||||
:locations locations
|
||||
:event change-event
|
||||
:subscription data}]]]
|
||||
|
||||
(comment
|
||||
[:div.field
|
||||
@@ -151,18 +173,11 @@
|
||||
:field [:always-map]
|
||||
:subscription data}]
|
||||
" Always match Merchant '" (:merchant-name data) "' to '" (:vendor-name data) "'" ]]])
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
(when error
|
||||
^{:key error} [:div.notification.is-warning.animated.fadeInUp
|
||||
error])
|
||||
|
||||
[:button.button.is-medium.is-primary.is-fullwidth {:disabled (if @(re-frame/subscribe [::can-submit])
|
||||
""
|
||||
"disabled")
|
||||
:class (str @(re-frame/subscribe [::forms/loading-class ::edit-transaction])
|
||||
(when error " animated shake"))} "Save"]
|
||||
])])
|
||||
(when error " animated shake"))} "Save"]])])
|
||||
|
||||
Reference in New Issue
Block a user