preventing unmatched transacations from re-matching.
This commit is contained in:
@@ -309,6 +309,8 @@
|
||||
db (d/db conn)
|
||||
invoice-clients (set (map (comp :db/id :invoice/client #(d/entity db %)) autopay_invoice_ids))
|
||||
invoice-amount (reduce + 0.0 (map (comp :invoice/total #(d/entity db %)) autopay_invoice_ids))]
|
||||
(when (:transaction/payment transaction)
|
||||
(throw (ex-info "Transaction already linked" {:validation-error "Transaction already linked"})))
|
||||
(when (or (> (count invoice-clients) 1)
|
||||
(not= (:db/id (:transaction/client transaction))
|
||||
(first invoice-clients)))
|
||||
@@ -343,6 +345,7 @@
|
||||
(defn match-transaction-unpaid-invoices [context {:keys [transaction_id unpaid_invoice_ids]} value]
|
||||
(let [_ (assert-power-user (:id context))
|
||||
transaction (d-transactions/get-by-id transaction_id)
|
||||
|
||||
_ (assert-can-see-client (:id context) (:transaction/client transaction) )
|
||||
db (d/db conn)
|
||||
invoice-clients (set (map (comp :db/id :invoice/client #(d/entity db %)) unpaid_invoice_ids))
|
||||
@@ -356,13 +359,9 @@
|
||||
(when-not (dollars= (- (:transaction/amount transaction))
|
||||
invoice-amount)
|
||||
(throw (ex-info "Amounts don't match" {:validation-error "Amounts don't match"})))
|
||||
#_(log/info [#_(select-keys (d/entity db transaction_id) #{:transaction/amount :db/id})]
|
||||
(->> autopay_invoice_ids
|
||||
(map (fn [id]
|
||||
(let [entity (d/entity db id)]
|
||||
[(-> entity :invoice/vendor :db/id)
|
||||
(-> entity :db/id)
|
||||
(-> entity :invoice/total)])))))
|
||||
(when (:transaction/payment transaction)
|
||||
(throw (ex-info "Transaction already linked" {:validation-error "Transaction already linked"})))
|
||||
|
||||
(let [payment-tx (import/add-new-payment [(select-keys (d/entity db transaction_id) #{:transaction/amount :transaction/date :db/id})]
|
||||
(map (fn [id]
|
||||
(let [entity (d/entity db id)]
|
||||
|
||||
@@ -384,7 +384,7 @@
|
||||
|
||||
(when
|
||||
(and (seq (:potential-autopay-invoices-matches data))
|
||||
#_(not is-already-matched?)
|
||||
(not is-already-matched?)
|
||||
(or is-admin? is-power-user?))
|
||||
[tab {:title "Autopay Invoices" :key :autopay-invoices}
|
||||
[potential-autopay-invoices-matches-box {:potential-autopay-invoices-matches (:potential-autopay-invoices-matches data)}]])
|
||||
|
||||
Reference in New Issue
Block a user