Skip to content

Allow decimal values in numeric forms#34

Merged
mihape merged 1 commit into
mainfrom
fix-decimal-number-inputs
Jul 1, 2026
Merged

Allow decimal values in numeric forms#34
mihape merged 1 commit into
mainfrom
fix-decimal-number-inputs

Conversation

@mihape

@mihape mihape commented Jul 1, 2026

Copy link
Copy Markdown
Owner

Summary

  • replace restrictive number inputs with decimal-friendly inputs in invoice, fleet, and utilities forms
  • parse Hungarian comma decimals and dot decimals when saving form values
  • keep decimal invoice amounts instead of rounding them to whole numbers
  • add the fix to the Unreleased changelog

Tests

  • node --check src/modules/invoices/invoices.module.js
  • node --check src/modules/fleet/fleet.module.js
  • node --check src/modules/utilities/utilities.module.js
  • git diff --check
  • targeted decimal parser smoke test for comma/dot/thousands formats
  • targeted render smoke test for decimal input fields

Closes #33

@mihape mihape merged commit f90a7e1 into main Jul 1, 2026
1 check passed

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: e59ef0984b

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

return text.replace(/,/g, "");
}

return text.replace(/,/g, ".");

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Preserve dot-only thousands separators

When a Hungarian amount contains only dot thousands separators, e.g. 1.234.567 Ft from the CSV import or 225.000, this branch leaves the dots in place and normalizeAmount() then turns the value into 0 for multiple groups or 225 for one group instead of the intended amount. The previous normalizer stripped dots, so this regresses common Hungarian-formatted invoice amounts; the same duplicated parser in fleet/utilities has the same failure mode.

Useful? React with 👍 / 👎.

Comment on lines +520 to +522
field("Nettó", '<input name="netAmount" inputmode="decimal" value="' + hAttr(invoice.netAmount || "") + '" />'),
field("ÁFA", '<input name="vatAmount" inputmode="decimal" placeholder="Automatikus 27%" value="' + hAttr(invoice.vatAmount || "") + '" />'),
field("Bruttó", '<input name="grossAmount" inputmode="decimal" placeholder="Automatikus" value="' + hAttr(invoice.grossAmount || "") + '" />'),

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Restore non-negative validation

These amount fields used to be type="number" min="0", but after switching to plain text inputs there is no browser constraint and normalizeAmount() accepts strings like -1000, so a typo can now save negative net/VAT/gross invoices and skew totals. If text inputs are needed for comma decimals, add equivalent validation or clamp/reject negatives before saving.

Useful? React with 👍 / 👎.

@mihape mihape deleted the fix-decimal-number-inputs branch July 1, 2026 05:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] Allow decimal values in invoice fleet and utilities forms

1 participant