You can now type accounts.

This commit is contained in:
Bryce Covert
2019-04-11 13:59:20 -07:00
parent a9975c8a10
commit 0eedc8908d
10 changed files with 54 additions and 12 deletions

View File

@@ -20,6 +20,11 @@
(fn [db]
(:accounts db)))
(re-frame/reg-sub
::accounts-for-client
(fn [db client]
(:accounts db)))
(re-frame/reg-sub
::bank-accounts
:<- [::clients]

View File

@@ -4,6 +4,7 @@
[:id
:amount
[:vendor [:name :id]]
[:account [:id :name]]
:date
:post_date
:status

View File

@@ -11,6 +11,8 @@
(fn [db [_ which]]
(-> db
(forms/start-form ::edit-transaction {:id (:id which)
:account-id (:id (:account which))
:account-name (:name (:account which))
:vendor-id (:id (:vendor which))
:vendor-name (:name (:vendor which))}))))
@@ -32,14 +34,17 @@
::saving
(fn [{:keys [db]} [_ edit-completed]]
(when @(re-frame/subscribe [::can-submit])
(let [{{:keys [id vendor-id]} :data :as data} @(re-frame/subscribe [::forms/form ::edit-transaction])]
(let [{{:keys [id vendor-id account-id]} :data :as data} @(re-frame/subscribe [::forms/form ::edit-transaction])]
(println "DATA" data)
{:db (forms/loading db ::edit-transaction )
:graphql
{:token (-> db :user)
:query-obj {:venia/operation {:operation/type :mutation
:operation/name "EditTransaction"}
:venia/queries [{:query/data [:edit-transaction
{:transaction {:id id :vendor-id vendor-id}}
{:transaction {:id id
:vendor-id vendor-id
:account-id account-id}}
transaction-read]}]}
:on-success [::edited edit-completed]
:on-error [::forms/save-error ::edit-transaction]}}))))
@@ -99,10 +104,11 @@
[:p.help "Credit Account"]
[:div.control
[bind-field
[typeahead {:matches (map (fn [x] [(:id x) (str (:id x) " - " (:name x))]) @(re-frame/subscribe [::subs/chooseable-expense-accounts]))
[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 [:expense-account-id]
:event [::change id]
:field [:account-id]
:text-field [:account-name]
:event change-event
:subscription data}]]]]
(when error

View File

@@ -61,6 +61,14 @@
:asc asc}
"Amount"]
[sorted-column {:on-sort opc
:style {:width "8em" :cursor "pointer"}
:sort-key "account"
:class "has-text-right"
:sort-by sort-by
:asc asc}
"Account"]
[sorted-column {:on-sort opc
:style {:width "8em" :cursor "pointer"}
:sort-key "status"
@@ -74,7 +82,7 @@
[:tr
[:td {:col-span 5}
[:i.fa.fa-spin.fa-spinner]]]
(for [{:keys [client vendor check status bank-account description-original date amount id ] :as i} (:transactions @transaction-page)]
(for [{:keys [client account vendor check status bank-account description-original date amount id ] :as i} (:transactions @transaction-page)]
^{:key id}
[:tr {:class (:class i)}
(when-not selected-client
@@ -85,6 +93,7 @@
[:td description-original]
[:td (date->str date) ]
[:td.has-text-right (nf amount )]
[:td (:name account)]
[:td status]
[:td (:name bank-account )]
[:td