adding and removing transaction rules works.
This commit is contained in:
@@ -52,7 +52,7 @@
|
||||
|
||||
(defn expense-account->entity [{:keys [id account_id amount location]}]
|
||||
(remove-nils #:invoice-expense-account {:amount (Double/parseDouble amount)
|
||||
:db/id id
|
||||
:db/id id
|
||||
:account account_id
|
||||
:location location}))
|
||||
|
||||
|
||||
@@ -27,22 +27,35 @@
|
||||
(fn [db]
|
||||
(-> db (::params {}))))
|
||||
|
||||
;; EVENTS
|
||||
|
||||
(defn ungraphql-transaction-rule [x]
|
||||
(-> x
|
||||
(update :amount-lte #(some-> % js/parseFloat))
|
||||
(update :amount-gte #(some-> % js/parseFloat))))
|
||||
|
||||
(re-frame/reg-event-db
|
||||
::edit-completed
|
||||
(fn [db [_ edit-transaction-rule]]
|
||||
(println edit-transaction-rule)
|
||||
(-> db
|
||||
(update-in [::page :transaction-rules]
|
||||
replace-by :id (assoc edit-transaction-rule :class "live-added")))))
|
||||
replace-by :id
|
||||
(-> edit-transaction-rule
|
||||
ungraphql-transaction-rule
|
||||
(assoc :class "live-added"))))))
|
||||
|
||||
;; EVENTS
|
||||
|
||||
(re-frame/reg-event-db
|
||||
::received
|
||||
(fn [db [_ data]]
|
||||
(println data)
|
||||
(-> db
|
||||
(update ::page merge (:transaction-rule-page data))
|
||||
|
||||
(update ::page merge
|
||||
(-> data
|
||||
:transaction-rule-page
|
||||
(update :transaction-rules (fn [rules]
|
||||
(mapv ungraphql-transaction-rule rules)))))
|
||||
(assoc-in [:status :loading] false))))
|
||||
|
||||
(re-frame/reg-event-fx
|
||||
|
||||
@@ -47,12 +47,25 @@
|
||||
::adding
|
||||
(fn [db [_ new]]
|
||||
(-> db (forms/start-form ::form (assoc new
|
||||
:description nil)))))
|
||||
:description nil
|
||||
:client nil
|
||||
:bank-account nil
|
||||
:note nil
|
||||
:amount-lte nil
|
||||
:amount-gte nil
|
||||
)))))
|
||||
|
||||
(re-frame/reg-event-db
|
||||
::editing
|
||||
(fn [db [_ which]]
|
||||
(-> db (forms/start-form ::form {}))))
|
||||
(-> db (forms/start-form ::form (select-keys which
|
||||
[:description
|
||||
:id
|
||||
:client
|
||||
:bank-account
|
||||
:note
|
||||
:amount-lte
|
||||
:amount-gte])))))
|
||||
|
||||
|
||||
(re-frame/reg-event-db
|
||||
@@ -95,7 +108,7 @@
|
||||
chooseable-expense-accounts @(re-frame/subscribe [::subs/chooseable-expense-accounts])
|
||||
accounts-by-id @(re-frame/subscribe [::subs/accounts-for-client-by-id])]
|
||||
^{:key id}
|
||||
[form (assoc params :title "New Invoice")
|
||||
[form (assoc params :title "New Transaction Rule")
|
||||
(when-not @(re-frame/subscribe [::subs/client])
|
||||
[field "Client"
|
||||
[typeahead-entity {:matches @(re-frame/subscribe [::subs/clients])
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
(ns auto-ap.views.pages.admin.rules.table
|
||||
(:require [auto-ap.subs :as subs]
|
||||
[auto-ap.views.utils :refer [dispatch-event ->$]]
|
||||
[auto-ap.views.pages.admin.rules.form :as form]
|
||||
[auto-ap.views.components.paginator :refer [paginator]]
|
||||
[auto-ap.views.components.sorter :refer [sorted-column]]
|
||||
[re-frame.core :as re-frame]))
|
||||
@@ -59,18 +61,22 @@
|
||||
:sort-key "note"
|
||||
:sort-by sort-by
|
||||
:asc asc}
|
||||
"Note"]]]
|
||||
"Note"]
|
||||
[:th {:style {:width "6em"}}
|
||||
]]]
|
||||
[:tbody
|
||||
(if (:loading @status)
|
||||
[:tr
|
||||
[:td {:col-span 5}
|
||||
[:i.fa.fa-spin.fa-spinner]]]
|
||||
(for [{:keys [client bank-account description amount-lte amount-gte note] :as r} transaction-rules]
|
||||
(for [{:keys [client bank-account description amount-lte amount-gte note id] :as r} transaction-rules]
|
||||
^{:key id}
|
||||
[:tr {:class (:class r)}
|
||||
[:td (:name client)]
|
||||
[:td (:name bank-account)]
|
||||
[:td description]
|
||||
[:td.has-text-right amount-gte ]
|
||||
[:td.has-text-right amount-lte]
|
||||
[:td note]]))]]]))))
|
||||
[:td.has-text-right (some-> amount-gte ->$) ]
|
||||
[:td.has-text-right (some-> amount-lte ->$)]
|
||||
[:td note]
|
||||
[:td
|
||||
[:a.button {:on-click (dispatch-event [::form/editing r])} [:span.icon [:i.fa.fa-pencil]]]]]))]]]))))
|
||||
|
||||
Reference in New Issue
Block a user