mirror of
https://github.com/renee-png/acmcc.git
synced 2026-06-21 09:50:01 +00:00
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:
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user