This commit is contained in:
2026-01-05 21:37:30 -08:00
18 changed files with 787 additions and 315 deletions

View File

@@ -1166,7 +1166,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)
@@ -1187,6 +1187,7 @@
(format "Pay in full ($%,.2f)" total)))}
{:value "advanced"
:content "Customize payments"}]})
[:div.space-y-4
(fc/with-field :invoices
(com/validated-field
@@ -1245,13 +1246,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
@@ -1345,24 +1346,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