feat: endurece mutações financeiras e permite zerar conta

This commit is contained in:
Felipe Coutinho
2026-03-20 18:42:18 +00:00
parent f77c64325d
commit e4dd221709
23 changed files with 5490 additions and 2942 deletions

View File

@@ -33,10 +33,10 @@ import { AccountFormFields } from "./account-form-fields";
import type { Account, AccountFormValues } from "./types";
const DEFAULT_ACCOUNT_TYPES = [
"FinancialAccount Corrente",
"FinancialAccount Poupança",
"Conta Corrente",
"Conta Poupança",
"Carteira Digital",
"FinancialAccount Investimento",
"Conta Investimento",
"Pré-Pago | VR/VA",
] as const;
@@ -167,7 +167,7 @@ export function AccountDialog({
const accountId = account?.id;
if (mode === "update" && !accountId) {
const message = "FinancialAccount inválida.";
const message = "Conta inválida.";
setErrorMessage(message);
toast.error(message);
return;

View File

@@ -20,7 +20,10 @@ interface AccountFormFieldsProps {
values: AccountFormValues;
accountTypes: string[];
accountStatuses: string[];
onChange: (field: keyof AccountFormValues, value: string) => void;
onChange: <K extends keyof AccountFormValues>(
field: K,
value: AccountFormValues[K],
) => void;
showInitialBalance?: boolean;
}
@@ -112,7 +115,7 @@ export function AccountFormFields({
id="exclude-from-balance"
checked={Boolean(values.excludeFromBalance)}
onCheckedChange={(checked) =>
onChange("excludeFromBalance", checked ? "true" : "false")
onChange("excludeFromBalance", checked === true)
}
/>
<Label
@@ -129,10 +132,7 @@ export function AccountFormFields({
id="exclude-initial-balance-from-income"
checked={Boolean(values.excludeInitialBalanceFromIncome)}
onCheckedChange={(checked) =>
onChange(
"excludeInitialBalanceFromIncome",
checked ? "true" : "false",
)
onChange("excludeInitialBalanceFromIncome", checked === true)
}
/>
<Label

View File

@@ -157,7 +157,7 @@ export function TransferDialog({
</div>
<div className="flex flex-col gap-2 sm:col-span-2">
<Label htmlFor="from-account">FinancialAccount de origem</Label>
<Label htmlFor="from-account">Conta de origem</Label>
<Select value={fromAccountId} disabled>
<SelectTrigger id="from-account" className="w-full">
<SelectValue>
@@ -185,7 +185,7 @@ export function TransferDialog({
</div>
<div className="flex flex-col gap-2 sm:col-span-2">
<Label htmlFor="to-account">FinancialAccount de destino</Label>
<Label htmlFor="to-account">Conta de destino</Label>
{availableAccounts.length === 0 ? (
<div className="rounded-md border border-border bg-muted p-3 text-sm text-muted-foreground">
É necessário ter mais de uma conta cadastrada para realizar