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 <noreply@anthropic.com>
This commit is contained in:
2026-06-07 17:04:25 -04:00
parent 271a6d2701
commit 3f39bfbd70
@@ -357,8 +357,15 @@ export default function UnitLedgerTransactionForm({ open, onOpenChange, unitId:
} }
const numAmount = parseFloat(formData.amount); const numAmount = parseFloat(formData.amount);
if (!formData.amount || isNaN(numAmount) || numAmount <= 0) { // Allow a $0.00 charge (used as a note/memo on the ledger). Payments and
toast({ variant: "destructive", title: "Invalid Amount", description: "Please enter a valid positive amount." }); // 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; return;
} }