From 3f39bfbd70ce369dddcb05efde4fadb55aa08916 Mon Sep 17 00:00:00 2001 From: renee-png Date: Sun, 7 Jun 2026 17:04:25 -0400 Subject: [PATCH] Unit ledger: allow posting a $0.00 charge Relax the amount validation so a Charge/Expense/WriteOff can be posted with a $0.00 amount (used as a note/memo on the ledger). Payments and prepayments still require a positive amount; negatives remain blocked. Co-Authored-By: Claude Opus 4.8 --- .../unit-profile/UnitLedgerTransactionForm.tsx | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/components/unit-profile/UnitLedgerTransactionForm.tsx b/src/components/unit-profile/UnitLedgerTransactionForm.tsx index fe8d72f..1897176 100644 --- a/src/components/unit-profile/UnitLedgerTransactionForm.tsx +++ b/src/components/unit-profile/UnitLedgerTransactionForm.tsx @@ -357,8 +357,15 @@ export default function UnitLedgerTransactionForm({ open, onOpenChange, unitId: } const numAmount = parseFloat(formData.amount); - if (!formData.amount || isNaN(numAmount) || numAmount <= 0) { - toast({ variant: "destructive", title: "Invalid Amount", description: "Please enter a valid positive amount." }); + // Allow a $0.00 charge (used as a note/memo on the ledger). Payments and + // prepayments still require a positive amount. + const allowZero = ["Charge", "Expense", "WriteOff"].includes(formData.type); + if (isNaN(numAmount) || numAmount < 0 || (numAmount === 0 && !allowZero)) { + toast({ + variant: "destructive", + title: "Invalid Amount", + description: allowZero ? "Please enter a valid amount ($0.00 is allowed)." : "Please enter a valid positive amount.", + }); return; }