adding some safety checks to not continue matching indefinitely.
This commit is contained in:
@@ -359,7 +359,7 @@
|
||||
(defn void-check [context {id :payment_id} value]
|
||||
(let [check (d-checks/get-by-id id)]
|
||||
(assert (or (= :payment-status/pending (:payment/status check))
|
||||
(#{:payment-type/cash :payment-type/debit} (:payment/type check))))
|
||||
(#{:payment-type/cash} (:payment/type check))))
|
||||
(assert-can-see-client (:id context) (:db/id (:payment/client check)))
|
||||
(let [removing-payments (mapcat (fn [x]
|
||||
(let [invoice (:invoice-payment/invoice x)
|
||||
|
||||
@@ -7,14 +7,18 @@
|
||||
[clj-time.coerce :as coerce]
|
||||
[digest :refer [sha-256]]
|
||||
[auto-ap.datomic.checks :as d-checks]
|
||||
[auto-ap.datomic.transactions :as d-transactions]
|
||||
[auto-ap.datomic.clients :as d-clients]
|
||||
[auto-ap.time :as time]))
|
||||
|
||||
|
||||
|
||||
(defn transaction->payment [_ check-number client-id bank-account-id amount]
|
||||
(defn transaction->payment [_ check-number client-id bank-account-id amount id]
|
||||
|
||||
(cond (and check-number client-id bank-account-id)
|
||||
(cond (:transaction/payment (d-transactions/get-by-id [:transaction/id (sha-256 (str id))]))
|
||||
nil
|
||||
|
||||
(and check-number client-id bank-account-id)
|
||||
(-> (d-checks/get-graphql {:client-id client-id
|
||||
:bank-account-id bank-account-id
|
||||
:check-number check-number
|
||||
@@ -25,9 +29,9 @@
|
||||
(and client-id bank-account-id amount)
|
||||
|
||||
(let [matching-checks (d-checks/get-graphql {:client-id client-id
|
||||
:bank-account-id bank-account-id
|
||||
:amount (- amount)
|
||||
:status :payment-status/pending})]
|
||||
:bank-account-id bank-account-id
|
||||
:amount (- amount)
|
||||
:status :payment-status/pending})]
|
||||
(if (= 1 (count matching-checks))
|
||||
(first matching-checks)
|
||||
nil))
|
||||
@@ -65,7 +69,7 @@
|
||||
check-number (extract-check-number transaction)
|
||||
client-id (transaction->client transaction)
|
||||
bank-account-id (transaction->bank-account-id transaction)
|
||||
check (transaction->payment transaction check-number client-id bank-account-id amount)]]
|
||||
check (transaction->payment transaction check-number client-id bank-account-id amount id)]]
|
||||
(try
|
||||
(when client-id
|
||||
@(->> [(remove-nils #:transaction
|
||||
|
||||
@@ -214,7 +214,7 @@
|
||||
[:td status]
|
||||
[:td
|
||||
(when (or (= :pending status)
|
||||
(and (#{":cash" ":debit" :cash :debit} type)
|
||||
(and (#{":cash" :cash } type)
|
||||
(not= :voided status)))
|
||||
[:button.button.is-warning.is-outlined {:on-click (dispatch-event [::void-check i])} [:span [:span.icon [:i.fa.fa-minus-circle]]]])
|
||||
(if s3-url
|
||||
|
||||
Reference in New Issue
Block a user