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 _]
|
(defn get-potential-payments [context args _]
|
||||||
(let [transaction (d-transactions/get-by-id (:transaction_id args))
|
(let [transaction (d-transactions/get-by-id (:transaction_id args))
|
||||||
_ (assert-can-see-client (:id context) (:transaction/client transaction))
|
_ (assert-can-see-client (:id context) (:transaction/client transaction))
|
||||||
[payments _] (d-checks/get-graphql {:client-id (:db/id (:transaction/client transaction))
|
[payments _] (d-checks/get-graphql {:client-id (:db/id (:transaction/client transaction))
|
||||||
:bank-account-id (:db/id (:transaction/bank-account transaction))
|
:bank-account-id (:db/id (:transaction/bank-account transaction))
|
||||||
:amount (- (:transaction/amount transaction))
|
:amount (- (:transaction/amount transaction))
|
||||||
:status :payment-status/pending})]
|
:status :payment-status/pending
|
||||||
(map ->graphql payments)))
|
: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 _]
|
(defn add-handwritten-check [context args _]
|
||||||
(let [invoices (d-invoices/get-multi (map :invoice_id (:invoice_payments args)))
|
(let [invoices (d-invoices/get-multi (map :invoice_id (:invoice_payments args)))
|
||||||
|
|||||||
@@ -234,7 +234,7 @@
|
|||||||
:bank-account-id bank-account-id
|
:bank-account-id bank-account-id
|
||||||
:type type}
|
:type type}
|
||||||
[:pdf-url [:invoices invoice-read]]]}]}
|
[:pdf-url [:invoices invoice-read]]]}]}
|
||||||
:on-success [::added-and-printed]
|
:on-success [::added-and-printed client]
|
||||||
:on-error [::forms/save-error ::form]}})
|
:on-error [::forms/save-error ::form]}})
|
||||||
))
|
))
|
||||||
|
|
||||||
@@ -284,9 +284,9 @@
|
|||||||
|
|
||||||
(re-frame/reg-event-fx
|
(re-frame/reg-event-fx
|
||||||
::added-and-printed
|
::added-and-printed
|
||||||
(fn [_ [_ result]]
|
(fn [_ [_ client result]]
|
||||||
(let [invoice (first (:invoices (:add-and-print-invoice 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))]]})))
|
[::checks-printed [invoice] (:pdf-url (:add-and-print-invoice result))]]})))
|
||||||
|
|
||||||
(re-frame/reg-event-db
|
(re-frame/reg-event-db
|
||||||
|
|||||||
Reference in New Issue
Block a user