last refactoring before adding new accounts.
This commit is contained in:
@@ -9,23 +9,14 @@
|
|||||||
[auto-ap.views.components.sorter :refer [sorted-column]]
|
[auto-ap.views.components.sorter :refer [sorted-column]]
|
||||||
[auto-ap.views.pages.transactions.form :as edit]
|
[auto-ap.views.pages.transactions.form :as edit]
|
||||||
[auto-ap.views.pages.transactions.table :as table]
|
[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.utils :refer [replace-by]]
|
||||||
[auto-ap.views.pages.transactions.manual :as manual]
|
[auto-ap.views.pages.transactions.manual :as manual]
|
||||||
[auto-ap.views.utils :refer [bind-field date->str dispatch-event nf]]
|
[auto-ap.views.utils :refer [bind-field date->str dispatch-event nf]]
|
||||||
[goog.string :as gstring]
|
[goog.string :as gstring]
|
||||||
[re-frame.core :as re-frame]))
|
[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
|
(re-frame/reg-event-db
|
||||||
::edit-completed
|
::edit-completed
|
||||||
@@ -75,12 +66,6 @@
|
|||||||
(assoc ::transaction-page (first (:transaction-page data)))
|
(assoc ::transaction-page (first (:transaction-page data)))
|
||||||
(assoc-in [:status :loading] false))))
|
(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
|
(re-frame/reg-event-db
|
||||||
::change-selected-bank-account
|
::change-selected-bank-account
|
||||||
(fn [db [_ key value]]
|
(fn [db [_ key value]]
|
||||||
@@ -122,8 +107,9 @@
|
|||||||
[:li (:description-original transaction) "-" (:details error)])]])))
|
[:li (:description-original transaction) "-" (:details error)])]])))
|
||||||
[:div.is-pulled-right
|
[:div.is-pulled-right
|
||||||
[:div.buttons
|
[:div.buttons
|
||||||
|
(comment
|
||||||
[:button.button.is-danger {:on-click (dispatch-event [::manual/opening])}
|
[:button.button.is-danger {:on-click (dispatch-event [::manual/opening])}
|
||||||
"Manage Rules"]
|
"Manage Rules"])
|
||||||
[:button.button.is-danger {:on-click (dispatch-event [::manual/opening])}
|
[:button.button.is-danger {:on-click (dispatch-event [::manual/opening])}
|
||||||
"Manual Yodlee Import"]]]))
|
"Manual Yodlee Import"]]]))
|
||||||
[table/table {:id :transactions
|
[table/table {:id :transactions
|
||||||
|
|||||||
13
src/cljs/auto_ap/views/pages/transactions/common.cljs
Normal file
13
src/cljs/auto_ap/views/pages/transactions/common.cljs
Normal 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]]])
|
||||||
@@ -2,6 +2,7 @@
|
|||||||
(:require [auto-ap.forms :as forms]
|
(:require [auto-ap.forms :as forms]
|
||||||
[auto-ap.subs :as subs]
|
[auto-ap.subs :as subs]
|
||||||
[auto-ap.views.components.typeahead :refer [typeahead]]
|
[auto-ap.views.components.typeahead :refer [typeahead]]
|
||||||
|
[auto-ap.views.pages.transactions.common :refer [transaction-read]]
|
||||||
[auto-ap.views.utils :refer [bind-field]]
|
[auto-ap.views.utils :refer [bind-field]]
|
||||||
[re-frame.core :as re-frame]))
|
[re-frame.core :as re-frame]))
|
||||||
|
|
||||||
@@ -32,26 +33,14 @@
|
|||||||
(fn [{:keys [db]} [_ edit-completed]]
|
(fn [{:keys [db]} [_ edit-completed]]
|
||||||
(when @(re-frame/subscribe [::can-submit])
|
(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]} :data :as data} @(re-frame/subscribe [::forms/form ::edit-transaction])]
|
||||||
|
|
||||||
{:db (forms/loading db ::edit-transaction )
|
{:db (forms/loading db ::edit-transaction )
|
||||||
:graphql
|
:graphql
|
||||||
{:token (-> db :user)
|
{:token (-> db :user)
|
||||||
:query-obj {:venia/operation {:operation/type :mutation
|
:query-obj {:venia/operation {:operation/type :mutation
|
||||||
:operation/name "EditTransaction"}
|
:operation/name "EditTransaction"}
|
||||||
|
|
||||||
:venia/queries [{:query/data [:edit-transaction
|
:venia/queries [{:query/data [:edit-transaction
|
||||||
{:transaction {:id id :vendor-id vendor-id}}
|
{:transaction {:id id :vendor-id vendor-id}}
|
||||||
|
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]]]]}]}
|
|
||||||
:on-success [::edited edit-completed]
|
:on-success [::edited edit-completed]
|
||||||
:on-error [::forms/save-error ::edit-transaction]}}))))
|
:on-error [::forms/save-error ::edit-transaction]}}))))
|
||||||
|
|
||||||
@@ -70,8 +59,9 @@
|
|||||||
(re-frame/dispatch-sync [::saving edit-completed]))}
|
(re-frame/dispatch-sync [::saving edit-completed]))}
|
||||||
[:h1.title.is-2 "Edit Transaction"]
|
[:h1.title.is-2 "Edit Transaction"]
|
||||||
|
|
||||||
|
(comment
|
||||||
[:div.notification
|
[:div.notification
|
||||||
[:p "This transaction matches Invoice 'ABC' for 'DBI Beverages'. " [:a "Create payment and match"] "."]]
|
[:p "This transaction matches Invoice 'ABC' for 'DBI Beverages'. " [:a "Create payment and match"] "."]])
|
||||||
|
|
||||||
|
|
||||||
[:div.field
|
[:div.field
|
||||||
@@ -96,14 +86,14 @@
|
|||||||
:event change-event
|
:event change-event
|
||||||
:subscription data}]]]]
|
:subscription data}]]]]
|
||||||
|
|
||||||
|
(comment
|
||||||
[:div.field
|
[:div.field
|
||||||
|
|
||||||
[:p.control
|
[:p.control
|
||||||
[:label.checkbox
|
[:label.checkbox
|
||||||
[:input.checkbox {:type "checkbox"
|
[:input.checkbox {:type "checkbox"
|
||||||
:field [:always-map]
|
:field [:always-map]
|
||||||
:subscription data}]
|
:subscription data}]
|
||||||
" Always match Merchant '" (:merchant-name data) "' to '" (:vendor-name data) "'" ]]]
|
" Always match Merchant '" (:merchant-name data) "' to '" (:vendor-name data) "'" ]]])
|
||||||
|
|
||||||
[:div.field
|
[:div.field
|
||||||
[:p.help "Credit Account"]
|
[:p.help "Credit Account"]
|
||||||
|
|||||||
Reference in New Issue
Block a user