fixes bugs, makes checks printable for different dates.

This commit is contained in:
2025-10-07 21:52:46 -07:00
parent c528795b1e
commit a462c56595
3 changed files with 127 additions and 117 deletions

View File

@@ -1165,7 +1165,7 @@
:name (fc/field-name)
:error? (fc/field-errors)
:placeholder "10001"}))))
(when (= :handwrite-check (:method (:snapshot (:multi-form-state request))))
(when (#{:handwrite-check :print-check} (:method (:snapshot (:multi-form-state request))))
(fc/with-field :handwritten-date
(com/validated-field
{:errors (fc/field-errors)
@@ -1186,6 +1186,7 @@
(format "Pay in full ($%,.2f)" total)))}
{:value "advanced"
:content "Customize payments"}]})
[:div.space-y-4
(fc/with-field :invoices
(com/validated-field
@@ -1244,13 +1245,13 @@
bank-account
:payment-type/check
0
invoice-payment-lookup)]
invoice-payment-lookup
(:handwritten-date snapshot))]
(let [result (audit-transact
(into [(assoc base-payment
:payment/type :payment-type/check
:payment/status :payment-status/pending
:payment/check-number (:check-number snapshot)
:payment/date (coerce/to-date (:handwritten-date snapshot)))]
:payment/check-number (:check-number snapshot))]
(invoice-payments invoices invoice-payment-lookup))
(:identity request))]
(try
@@ -1344,24 +1345,33 @@
(= "" (:check-number snapshot)))
(throw (Exception. "Check number is required")))
true))
result (exception->4xx
#(if (= :handwrite-check (:method snapshot))
(add-handwritten-check request this snapshot)
(print-checks-internal (map (fn [i] {:invoice-id (:invoice-id i)
:amount (:amount i)})
(:invoices snapshot))
(:client snapshot)
(:bank-account snapshot)
(cond (= :print-check (:method snapshot))
:payment-type/check
(= :debit (:method snapshot))
:payment-type/debit
(= :cash (:method snapshot))
:payment-type/cash
(= :credit (:method snapshot))
:payment-type/credit
:else :payment-type/debit)
identity)))]
#(do
(when (:handwritten-date snapshot)
(let [invoices (d-invoices/get-multi (map :invoice-id (:invoices snapshot)))]
(assert-not-locked (:db/id (:invoice/client (first invoices))) (:handwritten-date snapshot))))
(if (= :handwrite-check (:method snapshot))
(add-handwritten-check request this snapshot)
(try
(print-checks-internal (map (fn [i] {:invoice-id (:invoice-id i)
:amount (:amount i)})
(:invoices snapshot))
(:client snapshot)
(:bank-account snapshot)
(cond (= :print-check (:method snapshot))
:payment-type/check
(= :debit (:method snapshot))
:payment-type/debit
(= :cash (:method snapshot))
:payment-type/cash
(= :credit (:method snapshot))
:payment-type/credit
:else :payment-type/debit)
identity
(:handwritten-date snapshot))
(catch Exception e
(println e))))))]
(modal-response
(com/modal {}
(com/modal-card-advanced