last refactoring before adding new accounts.

This commit is contained in:
Bryce Covert
2019-04-11 08:41:08 -07:00
parent c3199fb4cb
commit f6d0870f32
3 changed files with 31 additions and 42 deletions

View File

@@ -9,23 +9,14 @@
[auto-ap.views.components.sorter :refer [sorted-column]]
[auto-ap.views.pages.transactions.form :as edit]
[auto-ap.views.pages.transactions.table :as table]
[auto-ap.views.pages.transactions.common :refer [transaction-read]]
[auto-ap.utils :refer [replace-by]]
[auto-ap.views.pages.transactions.manual :as manual]
[auto-ap.views.utils :refer [bind-field date->str dispatch-event nf]]
[goog.string :as gstring]
[re-frame.core :as re-frame]))
(def transaction-read
[:id
:amount
[:vendor [:name :id]]
:date
:post_date
:status
:description_original
[:payment [:check_number :s3_url]]
[:client [:name :id]]
[:bank-account [:name :yodlee-account-id]]])
(re-frame/reg-event-db
::edit-completed
@@ -75,12 +66,6 @@
(assoc ::transaction-page (first (:transaction-page data)))
(assoc-in [:status :loading] false))))
(re-frame/reg-event-fx
::invalidated
(fn [cofx [_ params]]
{:dispatch [::params-change @(re-frame/subscribe [::params])]}))
(re-frame/reg-event-db
::change-selected-bank-account
(fn [db [_ key value]]
@@ -122,8 +107,9 @@
[:li (:description-original transaction) "-" (:details error)])]])))
[:div.is-pulled-right
[:div.buttons
[:button.button.is-danger {:on-click (dispatch-event [::manual/opening])}
"Manage Rules"]
(comment
[:button.button.is-danger {:on-click (dispatch-event [::manual/opening])}
"Manage Rules"])
[:button.button.is-danger {:on-click (dispatch-event [::manual/opening])}
"Manual Yodlee Import"]]]))
[table/table {:id :transactions

View File

@@ -0,0 +1,13 @@
(ns auto-ap.views.pages.transactions.common)
(def transaction-read
[:id
:amount
[:vendor [:name :id]]
:date
:post_date
:status
:description_original
[:payment [:check_number :s3_url]]
[:client [:name :id]]
[:bank-account [:name :yodlee-account-id]]])

View File

@@ -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.pages.transactions.common :refer [transaction-read]]
[auto-ap.views.utils :refer [bind-field]]
[re-frame.core :as re-frame]))
@@ -32,26 +33,14 @@
(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])]
{: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}}
[:id
:amount
[:vendor [:name :id]]
:date
:post_date
:status
:description_original
[:payment [:check_number :s3_url]]
[:client [:name :id]]
[:bank-account [:name :yodlee-account-id]]]]}]}
transaction-read]}]}
:on-success [::edited edit-completed]
:on-error [::forms/save-error ::edit-transaction]}}))))
@@ -70,8 +59,9 @@
(re-frame/dispatch-sync [::saving edit-completed]))}
[:h1.title.is-2 "Edit Transaction"]
[:div.notification
[:p "This transaction matches Invoice 'ABC' for 'DBI Beverages'. " [:a "Create payment and match"] "."]]
(comment
[:div.notification
[:p "This transaction matches Invoice 'ABC' for 'DBI Beverages'. " [:a "Create payment and match"] "."]])
[:div.field
@@ -96,14 +86,14 @@
:event change-event
:subscription data}]]]]
[:div.field
[:p.control
[:label.checkbox
[:input.checkbox {:type "checkbox"
:field [:always-map]
:subscription data}]
" Always match Merchant '" (:merchant-name data) "' to '" (:vendor-name data) "'" ]]]
(comment
[:div.field
[:p.control
[:label.checkbox
[:input.checkbox {:type "checkbox"
:field [:always-map]
:subscription data}]
" Always match Merchant '" (:merchant-name data) "' to '" (:vendor-name data) "'" ]]])
[:div.field
[:p.help "Credit Account"]