working on UI.

This commit is contained in:
Bryce Covert
2021-01-09 00:09:52 -08:00
parent c6dd929c86
commit d3232c70b2
8 changed files with 242 additions and 117 deletions

View File

@@ -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