diff --git a/src/modules/fechamento-hgtx/pages/FechamentoDetalhes.tsx b/src/modules/fechamento-hgtx/pages/FechamentoDetalhes.tsx
index e858dc7..8862eea 100644
--- a/src/modules/fechamento-hgtx/pages/FechamentoDetalhes.tsx
+++ b/src/modules/fechamento-hgtx/pages/FechamentoDetalhes.tsx
@@ -49,13 +49,35 @@ function parsePontuacaoInput(value: string): number {
return Number.isFinite(parsed) ? parsed : Number.NaN;
}
-/** Pontuação do modal de lançamento: só inteiros ≥ 0 (o tipo bonus/desconto define o sinal no backend). */
+const PONTUACAO_LANCAMENTO_MAX_FRAC = 2;
+
+/** Pontuação do modal de lançamento: ≥ 0, até duas casas decimais (o tipo bonus/desconto define o sinal no backend). */
function sanitizePontuacaoLancamentoDigitando(raw: string): string {
- const t = raw.trim();
+ const t = raw.trim().replace(/\s/g, "");
if (t === "") return "";
- const n = parsePontuacaoInput(t);
- if (!Number.isFinite(n) || n < 0) return "0";
- return String(Math.trunc(Math.min(n, Number.MAX_SAFE_INTEGER)));
+ if (t === "," || t === ".") return "0" + t;
+
+ const c = t.indexOf(",");
+ const d = t.indexOf(".");
+ const si = c >= 0 && d >= 0 ? Math.min(c, d) : c >= 0 ? c : d >= 0 ? d : -1;
+ const sep = si >= 0 ? t[si]! : null;
+
+ if (sep == null) {
+ const digits = t.replace(/\D/g, "");
+ if (digits === "") return "";
+ const n = Number(digits);
+ if (n < 0) return "0";
+ return digits;
+ }
+
+ const intStr = t.slice(0, si).replace(/\D/g, "");
+ const rawAfter = t.slice(si + 1);
+ const fracStr = rawAfter.replace(/\D/g, "").slice(0, PONTUACAO_LANCAMENTO_MAX_FRAC);
+ const intPart = intStr === "" ? "0" : intStr;
+ if (t.endsWith(sep) && fracStr.length === 0) {
+ return intPart + sep;
+ }
+ return intPart + sep + fracStr;
}
function toPontuacaoInput(value: number): string {
@@ -303,7 +325,11 @@ export default function FechamentoDetalhes() {
return;
}
const descricao = lancamentoDescricao.trim();
- const pontuacao = Math.trunc(Number(lancamentoPontuacao));
+ const pontuacao = (() => {
+ const n = parsePontuacaoInput(lancamentoPontuacao);
+ if (!Number.isFinite(n)) return Number.NaN;
+ return Math.round(n * 100) / 100;
+ })();
if (!descricao) {
toast.error("Informe a descrição do lançamento.");
return;
@@ -837,17 +863,11 @@ export default function FechamentoDetalhes() {
{
- if (e.key === "-" || e.key === "+" || e.key === "e" || e.key === "E" || e.key === "," || e.key === ".") {
- e.preventDefault();
- }
- }}
onChange={(e) => setLancamentoPontuacao(sanitizePontuacaoLancamentoDigitando(e.target.value))}
+ placeholder="Ex.: 1,5"
/>