Adding transaction approval status to transaction page

This commit is contained in:
Bryce Covert
2019-05-17 07:14:16 -07:00
parent d0b5772d94
commit a87d22c320
9 changed files with 71 additions and 26 deletions

View File

@@ -0,0 +1,12 @@
(ns auto-ap.views.components.button-radio)
(defn button-radio [{:keys [options on-change value]}]
[:div.control
[:div.field.has-addons
(for [[k v] options]
^{:key k}
[:p.control
[:a.button {:class (if (= value k)
"is-primary"
"")
:on-click (fn [] (on-change k))} v]])]])

View File

@@ -4,6 +4,7 @@
[auto-ap.forms :as forms]
[auto-ap.subs :as subs]
[auto-ap.views.components.modal :refer [modal]]
[auto-ap.views.components.button-radio :refer [button-radio]]
[auto-ap.utils :refer [dollars=]]
[auto-ap.views.components.dropdown :refer [drop-down]]
[auto-ap.views.components.expense-accounts-field :as expense-accounts-field :refer [expense-accounts-field recalculate-amounts]]
@@ -178,16 +179,7 @@
:submit-event [::saving ]
:id ::form}))
(defn button-radio [{:keys [options on-change value]}]
[:div.control
[:div.field.has-addons
(for [[k v] options]
^{:key k}
[:p.control
[:a.button {:class (if (= value k)
"is-primary"
"")
:on-click (fn [] (on-change k))} v]])]])
(defn form [{:keys [can-change-amount?] :as params}]
[layouts/side-bar {:on-close (dispatch-event [::forms/form-closing ::form ])}
@@ -296,8 +288,7 @@
:field [:transaction-approval-status]
:options [[:unapproved "Unapproved"]
[:requires-feedback "Client Review"]
[:approved "Approved"]
]}]]
[:approved "Approved"]]}]]
[:div.is-divider]

View File

@@ -5,6 +5,7 @@
:amount
:location
:exclude-from-ledger
:approval-status
[:matched-rule [:note :id]]
[:vendor [:name :id]]
[:accounts [:id :amount :location [:account [:name :id :location :numeric-code]]]]

View File

@@ -3,6 +3,7 @@
[auto-ap.subs :as subs]
[auto-ap.views.components.layouts :as layouts]
[auto-ap.views.components.typeahead :refer [typeahead typeahead-entity]]
[auto-ap.views.components.button-radio :refer [button-radio]]
[auto-ap.views.components.expense-accounts-field :refer [expense-accounts-field] :as expense-accounts-field]
[auto-ap.views.pages.transactions.common :refer [transaction-read]]
[auto-ap.views.utils :refer [bind-field dispatch-event with-user]]
@@ -14,7 +15,7 @@
(re-frame/reg-sub
::submit-query
:<- [::forms/form ::form]
(fn [{{:keys [id vendor accounts exclude-from-ledger]} :data}]
(fn [{{:keys [id vendor accounts exclude-from-ledger approval-status]} :data}]
{:venia/operation {:operation/type :mutation
:operation/name "EditTransaction"}
:venia/queries [{:query/data
@@ -22,6 +23,7 @@
{:transaction {:id id
:vendor-id (:id vendor)
:exclude-from-ledger exclude-from-ledger
:approval-status approval-status
:accounts (map
(fn [{:keys [id account amount location]}]
{:id (when-not (str/starts-with? id "new-")
@@ -49,7 +51,7 @@
(-> which
(select-keys [:vendor :amount :payment :client :description-original
:yodlee-merchant :id :potential-payment-matches
:exclude-from-ledger :location :accounts :transaction-approval-status
:exclude-from-ledger :location :accounts :approval-status
:matched-rule])
(assoc :potential-payment-matches (if (:matched-rule which)
nil
@@ -249,6 +251,22 @@
:field [:exclude-from-ledger]}]]
" Exclude from ledger"]]
[field "Include in ledger"
[button-radio
{:type "button-radio"
:field [:exclude-from-ledger]
:options [[true "Exclude from Ledger"]
[false "Include in Ledger"]
]}]]
[field "Approval Status"
[button-radio
{:type "button-radio"
:field [:approval-status]
:options [[:unapproved "Unapproved"]
[:requires-feedback "Client Review"]
[:approved "Approved"]]}]]
[:hr]
[error-notification]