Changes
Co-authored-by: renee-png <262607627+renee-png@users.noreply.github.com>
This commit is contained in:
co-authored by
renee-png
parent
6d93b1491e
commit
4d0d978f13
@@ -354,13 +354,17 @@ function ManualAdjustDialog({
|
||||
}, [open, defaultCaseId]);
|
||||
|
||||
const save = async () => {
|
||||
console.log("[trust-deposit] save clicked", { amount, date, note, caseChoice, type, clientId, userId });
|
||||
const amt = Number(amount);
|
||||
if (!amt || amt <= 0) return toast.error("Enter a valid amount");
|
||||
if (!amt || amt <= 0) {
|
||||
console.warn("[trust-deposit] invalid amount", amount);
|
||||
return toast.error("Enter a valid amount");
|
||||
}
|
||||
if (type === "withdrawal" && amt > balance) {
|
||||
if (!confirm(`This will overdraw the trust by ${formatCurrency(amt - balance)}. Continue?`)) return;
|
||||
}
|
||||
setSaving(true);
|
||||
const { error } = await supabase.from("trust_ledger_entries").insert({
|
||||
const { data, error } = await supabase.from("trust_ledger_entries").insert({
|
||||
client_id: clientId,
|
||||
case_id: caseChoice === POOL_KEY ? null : caseChoice,
|
||||
entry_date: date,
|
||||
@@ -368,9 +372,13 @@ function ManualAdjustDialog({
|
||||
amount: amt,
|
||||
note: note || (type === "deposit" ? "Manual deposit" : "Manual withdrawal"),
|
||||
created_by: userId,
|
||||
});
|
||||
}).select();
|
||||
console.log("[trust-deposit] insert result", { data, error });
|
||||
setSaving(false);
|
||||
if (error) return toast.error(error.message);
|
||||
if (error) {
|
||||
console.error("[trust-deposit] insert failed", error);
|
||||
return toast.error(error.message);
|
||||
}
|
||||
toast.success(type === "deposit" ? "Deposit recorded" : "Withdrawal recorded");
|
||||
onOpenChange(false);
|
||||
onSaved();
|
||||
|
||||
Reference in New Issue
Block a user