supports filtering down to just duplicates.
This commit is contained in:
@@ -18,15 +18,40 @@
|
|||||||
:else
|
:else
|
||||||
(keyword "transaction" sort-by)))
|
(keyword "transaction" sort-by)))
|
||||||
|
|
||||||
|
(defn potential-duplicate-ids [db args]
|
||||||
|
(if (and (:potential-duplicates args)
|
||||||
|
(:bank-account-id args))
|
||||||
|
(->> (d/q '[:find ?tx ?amount ?date
|
||||||
|
:in $ ?ba
|
||||||
|
:where
|
||||||
|
[?tx :transaction/bank-account ?ba]
|
||||||
|
[?tx :transaction/amount ?amount]
|
||||||
|
[?tx :transaction/date ?date]]
|
||||||
|
db
|
||||||
|
(:bank-account-id args))
|
||||||
|
(group-by (fn [[tx amount date]]
|
||||||
|
[amount date]))
|
||||||
|
(filter (fn [[g txes]]
|
||||||
|
(> (count txes) 1)))
|
||||||
|
|
||||||
|
(vals)
|
||||||
|
(mapcat identity)
|
||||||
|
(map first)
|
||||||
|
set)))
|
||||||
|
|
||||||
|
|
||||||
(defn raw-graphql-ids
|
(defn raw-graphql-ids
|
||||||
([args] (raw-graphql-ids (d/db (d/connect uri)) args))
|
([args] (raw-graphql-ids (d/db conn) args))
|
||||||
([db args]
|
([db args]
|
||||||
(let [query (cond-> {:query {:find []
|
(let [potential-duplicates (potential-duplicate-ids db args)
|
||||||
|
query (cond-> {:query {:find []
|
||||||
:in ['$ ]
|
:in ['$ ]
|
||||||
:where []}
|
:where []}
|
||||||
:args [db]}
|
:args [db]}
|
||||||
|
|
||||||
|
(:potential-duplicates args)
|
||||||
|
(merge-query {:query {:in '[[?e ...]]}
|
||||||
|
:args [potential-duplicates]})
|
||||||
|
|
||||||
(:exact-match-id args)
|
(:exact-match-id args)
|
||||||
(merge-query {:query {:in ['?e]
|
(merge-query {:query {:in ['?e]
|
||||||
|
|||||||
@@ -343,24 +343,7 @@
|
|||||||
|
|
||||||
:forecast_match {:fields {:id {:type :id}
|
:forecast_match {:fields {:id {:type :id}
|
||||||
:identifier {:type 'String}}}
|
:identifier {:type 'String}}}
|
||||||
:transaction {:fields {:id {:type :id}
|
|
||||||
:amount {:type 'String}
|
|
||||||
:description_original {:type 'String}
|
|
||||||
:description_simple {:type 'String}
|
|
||||||
:location {:type 'String}
|
|
||||||
:forecast_match {:type :forecast_match}
|
|
||||||
:status {:type 'String}
|
|
||||||
:yodlee_merchant {:type :yodlee_merchant}
|
|
||||||
:client {:type :client}
|
|
||||||
:accounts {:type '(list :invoices_expense_accounts)}
|
|
||||||
:payment {:type :payment}
|
|
||||||
:expected_deposit {:type :expected_deposit}
|
|
||||||
:vendor {:type :vendor}
|
|
||||||
:bank_account {:type :bank_account}
|
|
||||||
:date {:type 'String}
|
|
||||||
:post_date {:type 'String}
|
|
||||||
:approval_status {:type :transaction_approval_status}
|
|
||||||
:matched_rule {:type :transaction_rule}}}
|
|
||||||
|
|
||||||
:transaction_rule {:fields {:id {:type :id}
|
:transaction_rule {:fields {:id {:type :id}
|
||||||
:note {:type 'String}
|
:note {:type 'String}
|
||||||
@@ -455,11 +438,7 @@
|
|||||||
:start {:type 'Int}
|
:start {:type 'Int}
|
||||||
:end {:type 'Int}}}
|
:end {:type 'Int}}}
|
||||||
|
|
||||||
:transaction_page {:fields {:data {:type '(list :transaction)}
|
|
||||||
:count {:type 'Int}
|
|
||||||
:total {:type 'Int}
|
|
||||||
:start {:type 'Int}
|
|
||||||
:end {:type 'Int}}}
|
|
||||||
|
|
||||||
:transaction_rule_page {:fields {:transaction_rules {:type '(list :transaction_rule)}
|
:transaction_rule_page {:fields {:transaction_rules {:type '(list :transaction_rule)}
|
||||||
:count {:type 'Int}
|
:count {:type 'Int}
|
||||||
@@ -531,6 +510,12 @@
|
|||||||
{:expense_account_stats {:type '(list :expense_account_stat)
|
{:expense_account_stats {:type '(list :expense_account_stat)
|
||||||
:args {:client_id {:type :id}}
|
:args {:client_id {:type :id}}
|
||||||
:resolve :get-expense-account-stats}
|
:resolve :get-expense-account-stats}
|
||||||
|
:potential_transaction_rule_matches {:type '(list :transaction_rule)
|
||||||
|
:args {:transaction_id {:type :id}}
|
||||||
|
:resolve :get-transaction-rule-matches}
|
||||||
|
:potential_payment_matches {:type '(list :payment)
|
||||||
|
:args {:transaction_id {:type :id}}
|
||||||
|
:resolve :get-potential-payments}
|
||||||
|
|
||||||
:test_transaction_rule {:type '(list :transaction)
|
:test_transaction_rule {:type '(list :transaction)
|
||||||
:args {:transaction_rule {:type :edit_transaction_rule}}
|
:args {:transaction_rule {:type :edit_transaction_rule}}
|
||||||
@@ -547,21 +532,6 @@
|
|||||||
:cash_flow {:type :cash_flow_result
|
:cash_flow {:type :cash_flow_result
|
||||||
:args {:client_id {:type :id}}
|
:args {:client_id {:type :id}}
|
||||||
:resolve :get-cash-flow}
|
:resolve :get-cash-flow}
|
||||||
|
|
||||||
:potential_payment_matches {:type '(list :payment)
|
|
||||||
:args {:transaction_id {:type :id}}
|
|
||||||
:resolve :get-potential-payments}
|
|
||||||
|
|
||||||
:potential_autopay_invoices_matches {:type '(list (list :invoice))
|
|
||||||
:args {:transaction_id {:type :id}}
|
|
||||||
:resolve :get-potential-autopay-invoices-matches}
|
|
||||||
:potential_unpaid_invoices_matches {:type '(list (list :invoice))
|
|
||||||
:args {:transaction_id {:type :id}}
|
|
||||||
:resolve :get-potential-unpaid-invoices-matches}
|
|
||||||
|
|
||||||
:potential_transaction_rule_matches {:type '(list :transaction_rule)
|
|
||||||
:args {:transaction_id {:type :id}}
|
|
||||||
:resolve :get-transaction-rule-matches}
|
|
||||||
:balance_sheet {:type :balance_sheet
|
:balance_sheet {:type :balance_sheet
|
||||||
:args {:client_id {:type :id}
|
:args {:client_id {:type :id}
|
||||||
:include_comparison {:type 'Boolean}
|
:include_comparison {:type 'Boolean}
|
||||||
@@ -637,10 +607,7 @@
|
|||||||
:args {}
|
:args {}
|
||||||
:resolve :get-intuit-bank-accounts}
|
:resolve :get-intuit-bank-accounts}
|
||||||
|
|
||||||
:transaction_page {:type :transaction_page
|
|
||||||
:args {:filters {:type :transaction_filters}}
|
|
||||||
|
|
||||||
:resolve :get-transaction-page}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -715,23 +682,7 @@
|
|||||||
:sort_name {:type 'String}
|
:sort_name {:type 'String}
|
||||||
:asc {:type 'Boolean}}}
|
:asc {:type 'Boolean}}}
|
||||||
|
|
||||||
:transaction_filters {:fields {:client_id {:type :id}
|
|
||||||
:exact_match_id {:type :id}
|
|
||||||
:import_batch_id {:type :id}
|
|
||||||
|
|
||||||
:vendor_id {:type :id}
|
|
||||||
:bank_account_id {:type :id}
|
|
||||||
:account_id {:type :id}
|
|
||||||
:date_range {:type :date_range}
|
|
||||||
:location {:type 'String}
|
|
||||||
:amount_lte {:type :money}
|
|
||||||
:amount_gte {:type :money}
|
|
||||||
:description {:type 'String}
|
|
||||||
:start {:type 'Int}
|
|
||||||
:per_page {:type 'Int}
|
|
||||||
:sort {:type '(list :sort_item)}
|
|
||||||
:approval_status {:type :transaction_approval_status}
|
|
||||||
:unresolved {:type 'Boolean}}}
|
|
||||||
|
|
||||||
|
|
||||||
:ledger_filters {:fields {:client_id {:type :id}
|
:ledger_filters {:fields {:client_id {:type :id}
|
||||||
@@ -902,12 +853,7 @@
|
|||||||
:scheduled_payment {:type :iso_date}
|
:scheduled_payment {:type :iso_date}
|
||||||
:due {:type :iso_date}
|
:due {:type :iso_date}
|
||||||
:total {:type :money}}}
|
:total {:type :money}}}
|
||||||
:edit_transaction
|
|
||||||
{:fields {:id {:type :id}
|
|
||||||
:vendor_id {:type :id}
|
|
||||||
:forecast_match {:type :id}
|
|
||||||
:approval_status {:type :transaction_approval_status}
|
|
||||||
:accounts {:type '(list :edit_expense_account)}}}
|
|
||||||
|
|
||||||
:edit_percentage_account
|
:edit_percentage_account
|
||||||
{:fields {:id {:type :id}
|
{:fields {:id {:type :id}
|
||||||
@@ -976,11 +922,7 @@
|
|||||||
{:enum-value :liability}
|
{:enum-value :liability}
|
||||||
{:enum-value :equity}
|
{:enum-value :equity}
|
||||||
{:enum-value :revenue}]}
|
{:enum-value :revenue}]}
|
||||||
:transaction_approval_status {:values [{:enum-value :approved}
|
}
|
||||||
{:enum-value :unapproved}
|
|
||||||
{:enum-value :suppressed}
|
|
||||||
{:enum-value :requires_feedback}
|
|
||||||
{:enum-value :excluded}]}}
|
|
||||||
:mutations
|
:mutations
|
||||||
{:request_import {:type 'String
|
{:request_import {:type 'String
|
||||||
:args {:which {:type 'String}}
|
:args {:which {:type 'String}}
|
||||||
@@ -994,20 +936,13 @@
|
|||||||
:args {:invoices {:type '(list :id)}}
|
:args {:invoices {:type '(list :id)}}
|
||||||
:resolve :mutation/approve-invoices}
|
:resolve :mutation/approve-invoices}
|
||||||
|
|
||||||
:bulk_change_transaction_status {:type :message
|
|
||||||
:args {:filters {:type :transaction_filters}
|
|
||||||
:status {:type :transaction_approval_status}
|
|
||||||
:ids {:type '(list :id)}}
|
|
||||||
:resolve :mutation/bulk-change-transaction-status}
|
|
||||||
|
|
||||||
:delete_external_ledger {:type :message
|
:delete_external_ledger {:type :message
|
||||||
:args {:filters {:type :ledger_filters}
|
:args {:filters {:type :ledger_filters}
|
||||||
:ids {:type '(list :id)}}
|
:ids {:type '(list :id)}}
|
||||||
:resolve :mutation/delete-external-ledger}
|
:resolve :mutation/delete-external-ledger}
|
||||||
:delete_transactions {:type :message
|
|
||||||
:args {:filters {:type :transaction_filters}
|
|
||||||
:ids {:type '(list :id)}}
|
|
||||||
:resolve :mutation/delete-transactions}
|
|
||||||
:delete_transaction_rule {:type :id
|
:delete_transaction_rule {:type :id
|
||||||
:args {:transaction_rule_id {:type :id}}
|
:args {:transaction_rule_id {:type :id}}
|
||||||
:resolve :mutation/delete-transaction-rule}
|
:resolve :mutation/delete-transaction-rule}
|
||||||
@@ -1063,34 +998,7 @@
|
|||||||
:upsert_account {:type :account
|
:upsert_account {:type :account
|
||||||
:args {:account {:type :edit_account}}
|
:args {:account {:type :edit_account}}
|
||||||
:resolve :mutation/upsert-account}
|
:resolve :mutation/upsert-account}
|
||||||
:edit_transaction {:type :transaction
|
|
||||||
:args {:transaction {:type :edit_transaction}}
|
|
||||||
:resolve :mutation/edit-transaction}
|
|
||||||
|
|
||||||
:match_transaction {:type :transaction
|
|
||||||
:args {:transaction_id {:type :id}
|
|
||||||
:payment_id {:type :id}}
|
|
||||||
:resolve :mutation/match-transaction}
|
|
||||||
|
|
||||||
:match_transaction_autopay_invoices {:type :transaction
|
|
||||||
:args {:transaction_id {:type :id}
|
|
||||||
:autopay_invoice_ids {:type '(list :id)}}
|
|
||||||
:resolve :mutation/match-transaction-autopay-invoices}
|
|
||||||
|
|
||||||
:match_transaction_unpaid_invoices {:type :transaction
|
|
||||||
:args {:transaction_id {:type :id}
|
|
||||||
:unpaid_invoice_ids {:type '(list :id)}}
|
|
||||||
:resolve :mutation/match-transaction-unpaid-invoices}
|
|
||||||
|
|
||||||
:match_transaction_rules {:type '(list :transaction)
|
|
||||||
:args {:transaction_ids {:type '(list :id)}
|
|
||||||
:all {:type 'Boolean}
|
|
||||||
:transaction_rule_id {:type :id}}
|
|
||||||
:resolve :mutation/match-transaction-rules}
|
|
||||||
|
|
||||||
:unlink_transaction {:type :transaction
|
|
||||||
:args {:transaction_id {:type :id}}
|
|
||||||
:resolve :mutation/unlink-transaction}
|
|
||||||
:void_invoice {:type :invoice
|
:void_invoice {:type :invoice
|
||||||
:args {:invoice_id {:type :id}}
|
:args {:invoice_id {:type :id}}
|
||||||
:resolve :mutation/void-invoice}
|
:resolve :mutation/void-invoice}
|
||||||
@@ -1346,10 +1254,7 @@
|
|||||||
:get-all-sales-orders get-all-sales-orders
|
:get-all-sales-orders get-all-sales-orders
|
||||||
:get-payment-page gq-checks/get-payment-page
|
:get-payment-page gq-checks/get-payment-page
|
||||||
:get-potential-payments gq-checks/get-potential-payments
|
:get-potential-payments gq-checks/get-potential-payments
|
||||||
:get-potential-autopay-invoices-matches gq-transactions/get-potential-autopay-invoices-matches
|
|
||||||
:get-potential-unpaid-invoices-matches gq-transactions/get-potential-unpaid-invoices-matches
|
|
||||||
:get-accounts gq-accounts/get-accounts
|
:get-accounts gq-accounts/get-accounts
|
||||||
:get-transaction-page gq-transactions/get-transaction-page
|
|
||||||
:get-ledger-page gq-ledger/get-ledger-page
|
:get-ledger-page gq-ledger/get-ledger-page
|
||||||
:get-sales-order-page gq-sales-orders/get-sales-orders-page
|
:get-sales-order-page gq-sales-orders/get-sales-orders-page
|
||||||
:get-balance-sheet gq-ledger/get-balance-sheet
|
:get-balance-sheet gq-ledger/get-balance-sheet
|
||||||
@@ -1372,18 +1277,10 @@
|
|||||||
:mutation/add-invoice gq-invoices/add-invoice
|
:mutation/add-invoice gq-invoices/add-invoice
|
||||||
: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/unlink-transaction gq-transactions/unlink-transaction
|
|
||||||
:mutation/bulk-change-transaction-status gq-transactions/bulk-change-status
|
|
||||||
:mutation/delete-external-ledger gq-ledger/delete-external-ledger
|
:mutation/delete-external-ledger gq-ledger/delete-external-ledger
|
||||||
:mutation/delete-transactions gq-transactions/delete-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
|
||||||
:mutation/match-transaction gq-transactions/match-transaction
|
|
||||||
:mutation/match-transaction-autopay-invoices gq-transactions/match-transaction-autopay-invoices
|
|
||||||
:mutation/match-transaction-unpaid-invoices gq-transactions/match-transaction-unpaid-invoices
|
|
||||||
:mutation/match-transaction-rules gq-transactions/match-transaction-rules
|
|
||||||
:mutation/edit-client gq-clients/edit-client
|
:mutation/edit-client gq-clients/edit-client
|
||||||
:mutation/upsert-vendor gq-vendors/upsert-vendor
|
:mutation/upsert-vendor gq-vendors/upsert-vendor
|
||||||
:mutation/upsert-account gq-accounts/upsert-account
|
:mutation/upsert-account gq-accounts/upsert-account
|
||||||
@@ -1398,6 +1295,7 @@
|
|||||||
:get-vendor gq-vendors/get-graphql})
|
:get-vendor gq-vendors/get-graphql})
|
||||||
gq-plaid/attach
|
gq-plaid/attach
|
||||||
gq-import-batches/attach
|
gq-import-batches/attach
|
||||||
|
gq-transactions/attach
|
||||||
schema/compile))
|
schema/compile))
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -4,33 +4,54 @@
|
|||||||
[audit-transact audit-transact-batch conn remove-nils]]
|
[audit-transact audit-transact-batch conn remove-nils]]
|
||||||
[auto-ap.datomic.accounts :as a]
|
[auto-ap.datomic.accounts :as a]
|
||||||
[auto-ap.datomic.checks :as d-checks]
|
[auto-ap.datomic.checks :as d-checks]
|
||||||
|
[auto-ap.datomic.invoices :as d-invoices]
|
||||||
[auto-ap.datomic.transaction-rules :as tr]
|
[auto-ap.datomic.transaction-rules :as tr]
|
||||||
[auto-ap.datomic.transactions :as d-transactions]
|
[auto-ap.datomic.transactions :as d-transactions]
|
||||||
[auto-ap.graphql.transaction-rules :as g-tr]
|
[auto-ap.graphql.transaction-rules :as g-tr]
|
||||||
[auto-ap.import.transactions :as i-transactions]
|
|
||||||
[auto-ap.graphql.utils
|
[auto-ap.graphql.utils
|
||||||
:refer
|
:refer
|
||||||
[->graphql
|
[->graphql
|
||||||
<-graphql
|
<-graphql
|
||||||
assert-admin
|
assert-admin
|
||||||
assert-power-user
|
|
||||||
assert-can-see-client
|
assert-can-see-client
|
||||||
|
assert-power-user
|
||||||
enum->keyword
|
enum->keyword
|
||||||
ident->enum-f
|
ident->enum-f
|
||||||
snake->kebab]]
|
snake->kebab]]
|
||||||
|
[auto-ap.import.transactions :as i-transactions]
|
||||||
[auto-ap.rule-matching :as rm]
|
[auto-ap.rule-matching :as rm]
|
||||||
[auto-ap.utils :refer [dollars=]]
|
[auto-ap.utils :refer [dollars=]]
|
||||||
[clj-time.coerce :as coerce]
|
[clj-time.coerce :as coerce]
|
||||||
[clojure.set :as set]
|
[clojure.set :as set]
|
||||||
[clojure.string :as str]
|
[clojure.string :as str]
|
||||||
[clojure.tools.logging :as log]
|
[clojure.tools.logging :as log]
|
||||||
[datomic.api :as d]
|
[com.walmartlabs.lacinia.util :refer [attach-resolvers]]
|
||||||
[auto-ap.datomic.invoices :as d-invoices]))
|
[datomic.api :as d]))
|
||||||
|
|
||||||
(def approval-status->graphql (ident->enum-f :transaction/approval-status))
|
(def approval-status->graphql (ident->enum-f :transaction/approval-status))
|
||||||
|
|
||||||
|
(defn assert-filtered-enough [filters]
|
||||||
|
(when (:potential_duplicates filters)
|
||||||
|
(assert-admin (:id filters))
|
||||||
|
(when-not (:bank_account_id filters)
|
||||||
|
(throw (ex-info "In order to select potential duplicates, you must choose a bank account."
|
||||||
|
{:validation-error "In order to select potential duplicates, you must choose a bank account."})))
|
||||||
|
(when-not (seq (->> filters
|
||||||
|
(filter (fn [[k v]]
|
||||||
|
(not (nil? v))))
|
||||||
|
(filter (comp (complement #{:id :start :sort :client_id :bank_account_id :potential_duplicates :per_page})
|
||||||
|
first))
|
||||||
|
(filter (fn [[k v]]
|
||||||
|
(if (= :date_range k)
|
||||||
|
(and (some? (:start v))
|
||||||
|
(some? (:end v)))
|
||||||
|
true)))))
|
||||||
|
(throw (ex-info "In order to select potential duplicates, you must filter your view more."
|
||||||
|
{:validation-error "In order to select potential duplicates, you must filter your view more."})))))
|
||||||
|
|
||||||
(defn get-transaction-page [context args value]
|
(defn get-transaction-page [context args value]
|
||||||
(let [args (assoc (:filters args) :id (:id context))
|
(let [args (assoc (:filters args) :id (:id context))
|
||||||
|
_ (assert-filtered-enough args)
|
||||||
[transactions transactions-count] (d-transactions/get-graphql (update (<-graphql args) :approval-status enum->keyword "transaction-approval-status"))
|
[transactions transactions-count] (d-transactions/get-graphql (update (<-graphql args) :approval-status enum->keyword "transaction-approval-status"))
|
||||||
transactions (map ->graphql (map approval-status->graphql transactions))]
|
transactions (map ->graphql (map approval-status->graphql transactions))]
|
||||||
{:data transactions
|
{:data transactions
|
||||||
@@ -81,13 +102,16 @@
|
|||||||
(mapcat (fn [i]
|
(mapcat (fn [i]
|
||||||
(let [transaction (d/entity db i)
|
(let [transaction (d/entity db i)
|
||||||
payment-id (-> transaction :transaction/payment :db/id)
|
payment-id (-> transaction :transaction/payment :db/id)
|
||||||
expected-deposit-id (-> transaction :transaction/expected-deposit :db/id)]
|
expected-deposit-id (-> transaction :transaction/expected-deposit :db/id)
|
||||||
(cond->> [{:db/id i
|
transaction-tx (if (:suppress args)
|
||||||
:transaction/approval-status :transaction-approval-status/suppressed}
|
{:db/id i
|
||||||
|
:transaction/approval-status :transaction-approval-status/suppressed}
|
||||||
|
[:db/retractEntity i])]
|
||||||
|
(cond->> [transaction-tx
|
||||||
[:db/retractEntity [:journal-entry/original-entity i]]]
|
[:db/retractEntity [:journal-entry/original-entity i]]]
|
||||||
payment-id (into [{:db/id payment-id
|
payment-id (into [{:db/id payment-id
|
||||||
:payment/status :payment-status/pending}
|
:payment/status :payment-status/pending}
|
||||||
[:db/retract (:db/id transaction) :transaction/payment payment-id]])
|
[:db/retract (:db/id transaction) :transaction/payment payment-id]])
|
||||||
expected-deposit-id (into [{:db/id expected-deposit-id
|
expected-deposit-id (into [{:db/id expected-deposit-id
|
||||||
:expected-deposit/status :expected-deposit-status/pending}
|
:expected-deposit/status :expected-deposit-status/pending}
|
||||||
[:db/retract (:db/id transaction) :transaction/expected-deposit expected-deposit-id]]))))
|
[:db/retract (:db/id transaction) :transaction/expected-deposit expected-deposit-id]]))))
|
||||||
@@ -440,3 +464,135 @@
|
|||||||
conj
|
conj
|
||||||
[]
|
[]
|
||||||
transaction_ids ))
|
transaction_ids ))
|
||||||
|
|
||||||
|
(def objects
|
||||||
|
{:transaction {:fields {:id {:type :id}
|
||||||
|
:amount {:type 'String}
|
||||||
|
:description_original {:type 'String}
|
||||||
|
:description_simple {:type 'String}
|
||||||
|
:location {:type 'String}
|
||||||
|
:forecast_match {:type :forecast_match}
|
||||||
|
:status {:type 'String}
|
||||||
|
:yodlee_merchant {:type :yodlee_merchant}
|
||||||
|
:client {:type :client}
|
||||||
|
:accounts {:type '(list :invoices_expense_accounts)}
|
||||||
|
:payment {:type :payment}
|
||||||
|
:expected_deposit {:type :expected_deposit}
|
||||||
|
:vendor {:type :vendor}
|
||||||
|
:bank_account {:type :bank_account}
|
||||||
|
:date {:type 'String}
|
||||||
|
:post_date {:type 'String}
|
||||||
|
:approval_status {:type :transaction_approval_status}
|
||||||
|
:matched_rule {:type :transaction_rule}}}
|
||||||
|
:transaction_page {:fields {:data {:type '(list :transaction)}
|
||||||
|
:count {:type 'Int}
|
||||||
|
:total {:type 'Int}
|
||||||
|
:start {:type 'Int}
|
||||||
|
:end {:type 'Int}}}})
|
||||||
|
|
||||||
|
(def queries
|
||||||
|
{:potential_autopay_invoices_matches {:type '(list (list :invoice))
|
||||||
|
:args {:transaction_id {:type :id}}
|
||||||
|
:resolve :get-potential-autopay-invoices-matches}
|
||||||
|
:potential_unpaid_invoices_matches {:type '(list (list :invoice))
|
||||||
|
:args {:transaction_id {:type :id}}
|
||||||
|
:resolve :get-potential-unpaid-invoices-matches}
|
||||||
|
:transaction_page {:type :transaction_page
|
||||||
|
:args {:filters {:type :transaction_filters}}
|
||||||
|
:resolve :get-transaction-page}})
|
||||||
|
|
||||||
|
(def mutations
|
||||||
|
{:bulk_change_transaction_status {:type :message
|
||||||
|
:args {:filters {:type :transaction_filters}
|
||||||
|
:status {:type :transaction_approval_status}
|
||||||
|
:ids {:type '(list :id)}}
|
||||||
|
:resolve :mutation/bulk-change-transaction-status}
|
||||||
|
:delete_transactions {:type :message
|
||||||
|
:args {:filters {:type :transaction_filters}
|
||||||
|
:ids {:type '(list :id)}
|
||||||
|
:suppress {:type 'Boolean}}
|
||||||
|
:resolve :mutation/delete-transactions}
|
||||||
|
:edit_transaction {:type :transaction
|
||||||
|
:args {:transaction {:type :edit_transaction}}
|
||||||
|
:resolve :mutation/edit-transaction}
|
||||||
|
|
||||||
|
:match_transaction {:type :transaction
|
||||||
|
:args {:transaction_id {:type :id}
|
||||||
|
:payment_id {:type :id}}
|
||||||
|
:resolve :mutation/match-transaction}
|
||||||
|
|
||||||
|
:match_transaction_autopay_invoices {:type :transaction
|
||||||
|
:args {:transaction_id {:type :id}
|
||||||
|
:autopay_invoice_ids {:type '(list :id)}}
|
||||||
|
:resolve :mutation/match-transaction-autopay-invoices}
|
||||||
|
|
||||||
|
:match_transaction_unpaid_invoices {:type :transaction
|
||||||
|
:args {:transaction_id {:type :id}
|
||||||
|
:unpaid_invoice_ids {:type '(list :id)}}
|
||||||
|
:resolve :mutation/match-transaction-unpaid-invoices}
|
||||||
|
|
||||||
|
:unlink_transaction {:type :transaction
|
||||||
|
:args {:transaction_id {:type :id}}
|
||||||
|
:resolve :mutation/unlink-transaction}
|
||||||
|
|
||||||
|
:match_transaction_rules {:type '(list :transaction)
|
||||||
|
:args {:transaction_ids {:type '(list :id)}
|
||||||
|
:all {:type 'Boolean}
|
||||||
|
:transaction_rule_id {:type :id}}
|
||||||
|
:resolve :mutation/match-transaction-rules}})
|
||||||
|
|
||||||
|
(def input-objects
|
||||||
|
{:transaction_filters {:fields {:client_id {:type :id}
|
||||||
|
:exact_match_id {:type :id}
|
||||||
|
:import_batch_id {:type :id}
|
||||||
|
:potential_duplicates {:type 'Boolean}
|
||||||
|
:vendor_id {:type :id}
|
||||||
|
:bank_account_id {:type :id}
|
||||||
|
:account_id {:type :id}
|
||||||
|
:date_range {:type :date_range}
|
||||||
|
:location {:type 'String}
|
||||||
|
:amount_lte {:type :money}
|
||||||
|
:amount_gte {:type :money}
|
||||||
|
:description {:type 'String}
|
||||||
|
:start {:type 'Int}
|
||||||
|
:per_page {:type 'Int}
|
||||||
|
:sort {:type '(list :sort_item)}
|
||||||
|
:approval_status {:type :transaction_approval_status}
|
||||||
|
:unresolved {:type 'Boolean}}}
|
||||||
|
:edit_transaction
|
||||||
|
{:fields {:id {:type :id}
|
||||||
|
:vendor_id {:type :id}
|
||||||
|
:forecast_match {:type :id}
|
||||||
|
:approval_status {:type :transaction_approval_status}
|
||||||
|
:accounts {:type '(list :edit_expense_account)}}}})
|
||||||
|
|
||||||
|
(def enums
|
||||||
|
{:transaction_approval_status {:values [{:enum-value :approved}
|
||||||
|
{:enum-value :unapproved}
|
||||||
|
{:enum-value :suppressed}
|
||||||
|
{:enum-value :requires_feedback}
|
||||||
|
{:enum-value :excluded}]}})
|
||||||
|
|
||||||
|
(def resolvers
|
||||||
|
{:get-transaction-page get-transaction-page
|
||||||
|
:get-potential-autopay-invoices-matches get-potential-autopay-invoices-matches
|
||||||
|
:get-potential-unpaid-invoices-matches get-potential-unpaid-invoices-matches
|
||||||
|
:mutation/edit-transaction edit-transaction
|
||||||
|
:mutation/unlink-transaction unlink-transaction
|
||||||
|
:mutation/bulk-change-transaction-status bulk-change-status
|
||||||
|
:mutation/delete-transactions delete-transactions
|
||||||
|
:mutation/match-transaction match-transaction
|
||||||
|
:mutation/match-transaction-autopay-invoices match-transaction-autopay-invoices
|
||||||
|
:mutation/match-transaction-unpaid-invoices match-transaction-unpaid-invoices
|
||||||
|
:mutation/match-transaction-rules match-transaction-rules})
|
||||||
|
|
||||||
|
|
||||||
|
(defn attach [schema]
|
||||||
|
(->
|
||||||
|
(merge-with merge schema
|
||||||
|
{:objects objects
|
||||||
|
:queries queries
|
||||||
|
:mutations mutations
|
||||||
|
:input-objects input-objects
|
||||||
|
:enums enums})
|
||||||
|
(attach-resolvers resolvers)))
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
(ns ^:figwheel-hooks auto-ap.reload)
|
(ns ^:figwheel-hooks auto-ap.reload)
|
||||||
|
|
||||||
(defn ^:after-load reload []
|
(defn ^:after-load reload []
|
||||||
(println "HERE")
|
(println "RELOADING")
|
||||||
(@(resolve 'auto-ap.core/mount-root)))
|
(@(resolve 'auto-ap.core/mount-root)))
|
||||||
|
|||||||
@@ -34,6 +34,7 @@
|
|||||||
:amount-gte (:amount-gte (:amount-range params))
|
:amount-gte (:amount-gte (:amount-range params))
|
||||||
:exact-match-id (some-> (:exact-match-id params) str)
|
:exact-match-id (some-> (:exact-match-id params) str)
|
||||||
:unresolved (:unresolved params)
|
:unresolved (:unresolved params)
|
||||||
|
:potential-duplicates (:potential-duplicates params)
|
||||||
:location (:location params)
|
:location (:location params)
|
||||||
:import-batch-id (some-> (:import-batch-id params) str)
|
:import-batch-id (some-> (:import-batch-id params) str)
|
||||||
:amount-lte (:amount-lte (:amount-range params))
|
:amount-lte (:amount-lte (:amount-range params))
|
||||||
@@ -92,7 +93,7 @@
|
|||||||
|
|
||||||
(re-frame/reg-event-fx
|
(re-frame/reg-event-fx
|
||||||
::delete-selected
|
::delete-selected
|
||||||
(fn [cofx [_ params]]
|
(fn [cofx [_ params suppress]]
|
||||||
(let [checked @(re-frame/subscribe [::data-page/checked ::page])
|
(let [checked @(re-frame/subscribe [::data-page/checked ::page])
|
||||||
checked-params (get checked "header")
|
checked-params (get checked "header")
|
||||||
specific-transactions (map :id (vals (dissoc checked "header")))]
|
specific-transactions (map :id (vals (dissoc checked "header")))]
|
||||||
@@ -106,7 +107,8 @@
|
|||||||
:venia/queries [{:query/data
|
:venia/queries [{:query/data
|
||||||
[:delete-transactions
|
[:delete-transactions
|
||||||
{:filters (some-> checked-params data-params->query-params)
|
{:filters (some-> checked-params data-params->query-params)
|
||||||
:ids specific-transactions}
|
:ids specific-transactions
|
||||||
|
:suppress suppress}
|
||||||
[:message]]}]}
|
[:message]]}]}
|
||||||
:on-success (fn [result]
|
:on-success (fn [result]
|
||||||
[::params-change params])}
|
[::params-change params])}
|
||||||
@@ -192,7 +194,12 @@
|
|||||||
:disabled (or (status/disabled-for @(re-frame/subscribe [::status/single ::bulk-change-transaction-status]))
|
:disabled (or (status/disabled-for @(re-frame/subscribe [::status/single ::bulk-change-transaction-status]))
|
||||||
(not (seq checked)))}
|
(not (seq checked)))}
|
||||||
"Client Review"]
|
"Client Review"]
|
||||||
[:button.button.is-danger {:on-click (dispatch-event [::delete-selected params])
|
[:button.button.is-danger {:on-click (dispatch-event [::delete-selected params false])
|
||||||
|
:class (status/class-for @(re-frame/subscribe [::status/single ::delete-selected]))
|
||||||
|
:disabled (or (status/disabled-for @(re-frame/subscribe [::status/single ::delete-selected]))
|
||||||
|
(not (seq checked)))}
|
||||||
|
"Delete selected"]
|
||||||
|
[:button.button.is-danger {:on-click (dispatch-event [::delete-selected params true])
|
||||||
:class (status/class-for @(re-frame/subscribe [::status/single ::delete-selected]))
|
:class (status/class-for @(re-frame/subscribe [::status/single ::delete-selected]))
|
||||||
:disabled (or (status/disabled-for @(re-frame/subscribe [::status/single ::delete-selected]))
|
:disabled (or (status/disabled-for @(re-frame/subscribe [::status/single ::delete-selected]))
|
||||||
(not (seq checked)))}
|
(not (seq checked)))}
|
||||||
|
|||||||
@@ -119,12 +119,7 @@
|
|||||||
|
|
||||||
(when (= "admin" (:user/role user))
|
(when (= "admin" (:user/role user))
|
||||||
[:<>
|
[:<>
|
||||||
(when-let [import-batch-id @(re-frame/subscribe [::data-page/filter data-page :import-batch-id])]
|
|
||||||
[:div
|
|
||||||
[:p.menu-label "Import Batch"]
|
|
||||||
[:span.tag.is-medium import-batch-id " "
|
|
||||||
[:button.delete.is-small {:on-click
|
|
||||||
(dispatch-event [::data-page/filter-changed data-page :import-batch-id nil])}]]])
|
|
||||||
[:p.menu-label "Admin only"]
|
[:p.menu-label "Admin only"]
|
||||||
[:div
|
[:div
|
||||||
[switch-field {:id "unresolved-only"
|
[switch-field {:id "unresolved-only"
|
||||||
@@ -132,5 +127,20 @@
|
|||||||
:on-change (fn [e]
|
:on-change (fn [e]
|
||||||
(re-frame/dispatch [::data-page/filter-changed data-page :unresolved (.-checked (.-target e))]))
|
(re-frame/dispatch [::data-page/filter-changed data-page :unresolved (.-checked (.-target e))]))
|
||||||
:label "Unresolved only"
|
:label "Unresolved only"
|
||||||
|
:type "checkbox"}]]
|
||||||
|
|
||||||
|
(when-let [import-batch-id @(re-frame/subscribe [::data-page/filter data-page :import-batch-id])]
|
||||||
|
[:div
|
||||||
|
[:p.menu-label "Import Batch"]
|
||||||
|
[:span.tag.is-medium import-batch-id " "
|
||||||
|
[:button.delete.is-small {:on-click
|
||||||
|
(dispatch-event [::data-page/filter-changed data-page :import-batch-id nil])}]]])
|
||||||
|
|
||||||
|
[:div
|
||||||
|
[switch-field {:id "potentially-duplicate"
|
||||||
|
:checked (boolean @(re-frame/subscribe [::data-page/filter data-page :potential-duplicates]))
|
||||||
|
:on-change (fn [e]
|
||||||
|
(re-frame/dispatch [::data-page/filter-changed data-page :potential-duplicates (.-checked (.-target e))]))
|
||||||
|
:label "Same Amount + Date"
|
||||||
:type "checkbox"}]]])]))
|
:type "checkbox"}]]])]))
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user