working on UI.
This commit is contained in:
@@ -506,10 +506,15 @@
|
||||
:cash_flow {:type :cash_flow_result
|
||||
:args {:client_id {:type :id}}
|
||||
: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_transaction_rule_matches {:type '(list :transaction_rule)
|
||||
:args {:transaction_id {:type :id}}
|
||||
:resolve :get-transaction-rule-matches}
|
||||
@@ -964,6 +969,11 @@
|
||||
: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_rules {:type '(list :transaction)
|
||||
:args {:transaction_ids {:type '(list :id)}
|
||||
:all {:type 'Boolean}
|
||||
@@ -1222,6 +1232,7 @@
|
||||
:get-all-sales-orders get-all-sales-orders
|
||||
:get-payment-page gq-checks/get-payment-page
|
||||
:get-potential-payments gq-checks/get-potential-payments
|
||||
:get-potential-autopay-invoices-matches gq-transactions/get-potential-autopay-invoices-matches
|
||||
:get-accounts gq-accounts/get-accounts
|
||||
:get-transaction-page gq-transactions/get-transaction-page
|
||||
:get-ledger-page gq-ledger/get-ledger-page
|
||||
@@ -1254,6 +1265,7 @@
|
||||
:test-transaction-rule gq-transaction-rules/test-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-rules gq-transactions/match-transaction-rules
|
||||
:mutation/edit-client gq-clients/edit-client
|
||||
:mutation/upsert-vendor gq-vendors/upsert-vendor
|
||||
|
||||
@@ -22,7 +22,8 @@
|
||||
[clojure.set :as set]
|
||||
[clojure.string :as str]
|
||||
[clojure.tools.logging :as log]
|
||||
[datomic.api :as d]))
|
||||
[datomic.api :as d]
|
||||
[auto-ap.datomic.invoices :as d-invoices]))
|
||||
|
||||
(def approval-status->graphql (ident->enum-f :transaction/approval-status))
|
||||
|
||||
@@ -81,6 +82,16 @@
|
||||
(:id context))
|
||||
{:message (str "Succesfully deleted " (count all-ids) " transactions.")}))
|
||||
|
||||
(defn get-potential-autopay-invoices-matches [context args value]
|
||||
(assert-admin (:id context))
|
||||
(let [transaction (d-transactions/get-by-id (:transaction_id args))]
|
||||
|
||||
(let [matches-set (auto-ap.yodlee.import/match-transaction-to-unfulfilled-autopayments (:transaction/amount transaction)
|
||||
(:db/id (:transaction/client transaction)))]
|
||||
(->graphql (for [matches matches-set]
|
||||
(for [[_ invoice-id ] matches]
|
||||
(d-invoices/get-by-id invoice-id)))))))
|
||||
|
||||
(defn unlink-transaction [context args value]
|
||||
(let [_ (assert-admin (:id context))
|
||||
args (assoc args :id (:id context))
|
||||
@@ -270,6 +281,23 @@
|
||||
approval-status->graphql
|
||||
->graphql))
|
||||
|
||||
(defn match-transaction-autopay-invoices [context {:keys [transaction_id payment_id]} value]
|
||||
(let [_ (assert-admin (:id context))
|
||||
transaction (d-transactions/get-by-id transaction_id)
|
||||
payment (d-checks/get-by-id payment_id)
|
||||
_ (assert-can-see-client (:id context) (:transaction/client transaction) )
|
||||
_ (assert-can-see-client (:id context) (:payment/client payment) )]
|
||||
(when (not= (:db/id (:transaction/client transaction))
|
||||
(:db/id (:payment/client payment)))
|
||||
(throw (ex-info "Clients don't match" {:validation-error "Payment and client do not match."})))
|
||||
|
||||
(when-not (dollars= (- (:transaction/amount transaction))
|
||||
(:payment/amount payment))
|
||||
(throw (ex-info "Amounts don't match" {:validation-error "Amounts don't match"}))))
|
||||
(-> (d-transactions/get-by-id transaction_id)
|
||||
approval-status->graphql
|
||||
->graphql))
|
||||
|
||||
(defn match-transaction-rules [context {:keys [transaction_ids transaction_rule_id all]} value]
|
||||
(let [_ (assert-admin (:id context))
|
||||
transaction_ids (if all
|
||||
|
||||
@@ -81,6 +81,11 @@
|
||||
(- amount))]
|
||||
consideration)]
|
||||
(log/info "Found " (count considerations) "considerations for transaction of" amount)
|
||||
considerations
|
||||
))
|
||||
|
||||
(defn match-transaction-to-single-unfulfilled-autopayments [amount client-id]
|
||||
(let [considerations (match-transaction-to-unfulfilled-autopayments amount client-id)]
|
||||
(if (= 1 (count considerations))
|
||||
(first considerations)
|
||||
[])))
|
||||
@@ -159,7 +164,7 @@
|
||||
)]
|
||||
(let [existing-check (transaction->existing-payment transaction check-number client-id bank-account-id amount id)
|
||||
invoices-matches (when-not existing-check
|
||||
(match-transaction-to-unfulfilled-autopayments amount client-id ))]
|
||||
(match-transaction-to-single-unfulfilled-autopayments amount client-id ))]
|
||||
(cond->
|
||||
[#:transaction
|
||||
{:post-date (coerce/to-date (time/parse post-date "YYYY-MM-dd"))
|
||||
|
||||
Reference in New Issue
Block a user