Only shows most recent payments for potential payments for transactions, fixes invoice multiple prints.
This commit is contained in:
@@ -448,11 +448,12 @@
|
||||
(defn get-potential-payments [context args _]
|
||||
(let [transaction (d-transactions/get-by-id (:transaction_id args))
|
||||
_ (assert-can-see-client (:id context) (:transaction/client transaction))
|
||||
[payments _] (d-checks/get-graphql {:client-id (:db/id (:transaction/client transaction))
|
||||
:bank-account-id (:db/id (:transaction/bank-account transaction))
|
||||
:amount (- (:transaction/amount transaction))
|
||||
:status :payment-status/pending})]
|
||||
(map ->graphql payments)))
|
||||
[payments _] (d-checks/get-graphql {:client-id (:db/id (:transaction/client transaction))
|
||||
:bank-account-id (:db/id (:transaction/bank-account transaction))
|
||||
:amount (- (:transaction/amount transaction))
|
||||
:status :payment-status/pending
|
||||
:date-range {:start (time/plus (:transaction/date transaction) (time/days 1))}})]
|
||||
(map ->graphql (reverse (sort-by :payment/date payments)))))
|
||||
|
||||
(defn add-handwritten-check [context args _]
|
||||
(let [invoices (d-invoices/get-multi (map :invoice_id (:invoice_payments args)))
|
||||
|
||||
@@ -234,7 +234,7 @@
|
||||
:bank-account-id bank-account-id
|
||||
:type type}
|
||||
[:pdf-url [:invoices invoice-read]]]}]}
|
||||
:on-success [::added-and-printed]
|
||||
:on-success [::added-and-printed client]
|
||||
:on-error [::forms/save-error ::form]}})
|
||||
))
|
||||
|
||||
@@ -284,9 +284,9 @@
|
||||
|
||||
(re-frame/reg-event-fx
|
||||
::added-and-printed
|
||||
(fn [_ [_ result]]
|
||||
(fn [_ [_ client result]]
|
||||
(let [invoice (first (:invoices (:add-and-print-invoice result)))]
|
||||
{:dispatch-n [[::updated (assoc invoice :class "live-added") :create]
|
||||
{:dispatch-n [[::updated (assoc invoice :class "live-added") :create client]
|
||||
[::checks-printed [invoice] (:pdf-url (:add-and-print-invoice result))]]})))
|
||||
|
||||
(re-frame/reg-event-db
|
||||
|
||||
Reference in New Issue
Block a user