started adjusting the transaction form to support splits.
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
(:require [auto-ap.forms :as forms]
|
||||
[auto-ap.subs :as subs]
|
||||
[auto-ap.views.components.typeahead :refer [typeahead]]
|
||||
[auto-ap.views.components.expense-accounts-field :refer [expense-accounts-field]]
|
||||
[auto-ap.views.pages.transactions.common :refer [transaction-read]]
|
||||
[auto-ap.views.utils :refer [bind-field]]
|
||||
[re-frame.core :as re-frame]))
|
||||
@@ -9,7 +10,6 @@
|
||||
(re-frame/reg-event-db
|
||||
::editing
|
||||
(fn [db [_ which]]
|
||||
(println which)
|
||||
(-> db
|
||||
(forms/start-form ::edit-transaction {:id (:id which)
|
||||
:yodlee-merchant (:yodlee-merchant which)
|
||||
@@ -19,7 +19,10 @@
|
||||
:account-id (:id (:account which))
|
||||
:account-name (:name (:account which))
|
||||
:vendor-id (:id (:vendor which))
|
||||
:vendor-name (:name (:vendor which))}))))
|
||||
:vendor-name (:name (:vendor which))
|
||||
:expense-accounts (or (:expense-accounts which)
|
||||
[{:id (str "new-" (random-uuid))
|
||||
:amount (Math/abs (:amount which))}])}))))
|
||||
(re-frame/reg-sub
|
||||
::request
|
||||
:<- [::forms/form ::edit-transaction]
|
||||
@@ -80,7 +83,6 @@
|
||||
(.stopPropagation e)
|
||||
(.preventDefault e))
|
||||
(re-frame/dispatch-sync [::saving edit-completed]))}
|
||||
(println data)
|
||||
[:h1.title.is-2 "Edit Transaction"]
|
||||
|
||||
(comment
|
||||
@@ -119,6 +121,15 @@
|
||||
:event change-event
|
||||
:subscription data}]]]]
|
||||
|
||||
[bind-field
|
||||
[expense-accounts-field
|
||||
{:type "expense-accounts"
|
||||
:field [:expense-accounts]
|
||||
:descriptor "credit account"
|
||||
:locations locations
|
||||
:event change-event
|
||||
:subscription data}]]
|
||||
|
||||
(comment
|
||||
[:div.field
|
||||
[:p.control
|
||||
@@ -128,32 +139,8 @@
|
||||
:subscription data}]
|
||||
" Always match Merchant '" (:merchant-name data) "' to '" (:vendor-name data) "'" ]]])
|
||||
|
||||
[:div.field
|
||||
[:p.help "Credit Account"]
|
||||
[:div.control
|
||||
[bind-field
|
||||
[typeahead {:matches (map (fn [x] [(:id x) (str (:numeric-code x) " - " (:name x))]) @(re-frame/subscribe [::subs/accounts-for-client (:id (:client data))]))
|
||||
:type "typeahead"
|
||||
:field [:account-id]
|
||||
:text-field [:account-name]
|
||||
:event [::change-account]
|
||||
:subscription data}]]]]
|
||||
|
||||
[:div.field
|
||||
[:p.help "Location"]
|
||||
[:div.control
|
||||
(if-let [forced-location (:location @(re-frame/subscribe [::subs/account (-> data :account-id )]))]
|
||||
[:div.select
|
||||
[:select {:disabled "disabled" :value forced-location} [:option {:value forced-location} forced-location]]]
|
||||
[:div.select
|
||||
[bind-field
|
||||
[:select {:type "select"
|
||||
:allow-nil? true
|
||||
:field [:location]
|
||||
:spec (set locations)
|
||||
:event change-event
|
||||
:subscription data}
|
||||
(map (fn [l] ^{:key l} [:option {:value l} l]) locations)]]])]]
|
||||
|
||||
|
||||
|
||||
(when error
|
||||
|
||||
Reference in New Issue
Block a user