can unapprove, but there are bugs. UI doesnt refresh, filters are lost.
This commit is contained in:
@@ -17,7 +17,9 @@
|
|||||||
(keyword "transaction" sort-by)))
|
(keyword "transaction" sort-by)))
|
||||||
|
|
||||||
|
|
||||||
(defn raw-graphql-ids [db args]
|
(defn raw-graphql-ids
|
||||||
|
([args] (raw-graphql-ids (d/db (d/connect uri)) args))
|
||||||
|
([db args]
|
||||||
(let [query (cond-> {:query {:find []
|
(let [query (cond-> {:query {:find []
|
||||||
:in ['$ ]
|
:in ['$ ]
|
||||||
:where []}
|
:where []}
|
||||||
@@ -114,7 +116,7 @@
|
|||||||
(cond->> query
|
(cond->> query
|
||||||
true (d/query)
|
true (d/query)
|
||||||
true (apply-sort-2 args [:desc :asc])
|
true (apply-sort-2 args [:desc :asc])
|
||||||
true (apply-pagination args))))
|
true (apply-pagination args)))))
|
||||||
|
|
||||||
(defn graphql-results [ids db args]
|
(defn graphql-results [ids db args]
|
||||||
(let [results (->> (d/pull-many db '[* {:transaction/client [:client/name :db/id :client/code]
|
(let [results (->> (d/pull-many db '[* {:transaction/client [:client/name :db/id :client/code]
|
||||||
@@ -160,3 +162,12 @@
|
|||||||
(update :transaction/date c/from-date)
|
(update :transaction/date c/from-date)
|
||||||
(update :transaction/post-date c/from-date)
|
(update :transaction/post-date c/from-date)
|
||||||
(dissoc :transaction/id)))
|
(dissoc :transaction/id)))
|
||||||
|
|
||||||
|
(defn unapprove [ids]
|
||||||
|
(doseq [x (partition-all 1000 ids)]
|
||||||
|
@(d/transact (d/connect uri)
|
||||||
|
(doto (mapv (fn [i]
|
||||||
|
{:db/id i
|
||||||
|
:transaction/approval-status :transaction-approval-status/unapproved})
|
||||||
|
x)
|
||||||
|
println))))
|
||||||
|
|||||||
@@ -611,6 +611,21 @@
|
|||||||
:args {:invoices {:type '(list :id)}}
|
:args {:invoices {:type '(list :id)}}
|
||||||
:resolve :mutation/approve-invoices}
|
:resolve :mutation/approve-invoices}
|
||||||
|
|
||||||
|
:unapprove_transactions {:type '(list :transaction_page)
|
||||||
|
:args {:client_id {:type :id}
|
||||||
|
:vendor_id {:type :id}
|
||||||
|
:bank_account_id {:type :id}
|
||||||
|
:date_range {:type :date_range}
|
||||||
|
:amount_lte {:type :money}
|
||||||
|
:amount_gte {:type :money}
|
||||||
|
:description {:type 'String}
|
||||||
|
:start {:type 'Int}
|
||||||
|
:sort_by {:type 'String}
|
||||||
|
:asc {:type 'Boolean}
|
||||||
|
:approval_status {:type :transaction_approval_status}}
|
||||||
|
|
||||||
|
:resolve :mutation/unapprove-transactions}
|
||||||
|
|
||||||
:merge_vendors {:type :id
|
:merge_vendors {:type :id
|
||||||
:args {:from {:type :id}
|
:args {:from {:type :id}
|
||||||
:to {:type :id}}
|
:to {:type :id}}
|
||||||
@@ -844,6 +859,7 @@
|
|||||||
:mutation/add-and-print-invoice gq-invoices/add-and-print-invoice
|
:mutation/add-and-print-invoice gq-invoices/add-and-print-invoice
|
||||||
:mutation/edit-invoice gq-invoices/edit-invoice
|
:mutation/edit-invoice gq-invoices/edit-invoice
|
||||||
:mutation/edit-transaction gq-transactions/edit-transaction
|
:mutation/edit-transaction gq-transactions/edit-transaction
|
||||||
|
:mutation/unapprove-transactions gq-transactions/unapprove-transactions
|
||||||
:mutation/upsert-transaction-rule gq-transaction-rules/upsert-transaction-rule
|
:mutation/upsert-transaction-rule gq-transaction-rules/upsert-transaction-rule
|
||||||
:test-transaction-rule gq-transaction-rules/test-transaction-rule
|
:test-transaction-rule gq-transaction-rules/test-transaction-rule
|
||||||
:run-transaction-rule gq-transaction-rules/run-transaction-rule
|
:run-transaction-rule gq-transaction-rules/run-transaction-rule
|
||||||
|
|||||||
@@ -39,6 +39,16 @@
|
|||||||
:start (:start args 0)
|
:start (:start args 0)
|
||||||
:end (+ (:start args 0) (count transactions))}]))
|
:end (+ (:start args 0) (count transactions))}]))
|
||||||
|
|
||||||
|
(defn unapprove-transactions [context args value]
|
||||||
|
(let [args (assoc args :id (:id context))
|
||||||
|
ids (:ids (d-transactions/raw-graphql-ids (update (<-graphql args) :approval-status
|
||||||
|
#(some->> %
|
||||||
|
name
|
||||||
|
snake->kebab
|
||||||
|
(keyword "transaction-approval-status")))))]
|
||||||
|
(d-transactions/unapprove ids)
|
||||||
|
(get-transaction-page context args value)))
|
||||||
|
|
||||||
(defn transaction-account->entity [{:keys [id account_id amount location]}]
|
(defn transaction-account->entity [{:keys [id account_id amount location]}]
|
||||||
(remove-nils #:transaction-account {:amount (Double/parseDouble amount)
|
(remove-nils #:transaction-account {:amount (Double/parseDouble amount)
|
||||||
:db/id id
|
:db/id id
|
||||||
|
|||||||
@@ -65,6 +65,27 @@
|
|||||||
:end]]]}
|
:end]]]}
|
||||||
:on-success [::received]}}))
|
:on-success [::received]}}))
|
||||||
|
|
||||||
|
(re-frame/reg-event-fx
|
||||||
|
::unapprove-all
|
||||||
|
(fn [cofx [_ params]]
|
||||||
|
|
||||||
|
{:db (-> (:db cofx)
|
||||||
|
(assoc-in [:status :loading] true)
|
||||||
|
(assoc-in [::params] params))
|
||||||
|
:graphql {:token (-> cofx :db :user)
|
||||||
|
:query-obj
|
||||||
|
{:venia/operation {:operation/type :mutation
|
||||||
|
:operation/name "UnapproveTransactions"}
|
||||||
|
:venia/queries [{:query/data
|
||||||
|
[:unapprove-transactions
|
||||||
|
(assoc (::params (:db cofx)) :client-id (:id @(re-frame/subscribe [::subs/client])))
|
||||||
|
[[:transactions transaction-read]
|
||||||
|
:total
|
||||||
|
:start
|
||||||
|
:end]]}]}
|
||||||
|
|
||||||
|
:on-success [::received]}}))
|
||||||
|
|
||||||
(re-frame/reg-event-db
|
(re-frame/reg-event-db
|
||||||
::received
|
::received
|
||||||
(fn [db [_ data]]
|
(fn [db [_ data]]
|
||||||
@@ -161,7 +182,9 @@
|
|||||||
[:div.is-pulled-right
|
[:div.is-pulled-right
|
||||||
[:div.buttons
|
[:div.buttons
|
||||||
[:button.button.is-outlined.is-primary {:on-click (dispatch-event [::manual/opening])}
|
[:button.button.is-outlined.is-primary {:on-click (dispatch-event [::manual/opening])}
|
||||||
"Manual Yodlee Import"]]]])
|
"Manual Yodlee Import"]
|
||||||
|
[:button.button.is-outlined.is-danger {:on-click (dispatch-event [::unapprove-all])}
|
||||||
|
"Unapprove all"]]]])
|
||||||
[table/table {:id :transactions
|
[table/table {:id :transactions
|
||||||
:params (re-frame/subscribe [::params])
|
:params (re-frame/subscribe [::params])
|
||||||
:transaction-page (re-frame/subscribe [::transaction-page])
|
:transaction-page (re-frame/subscribe [::transaction-page])
|
||||||
|
|||||||
Reference in New Issue
Block a user