Skip to content

Tax rate inputs blank with comma-decimal locales (az_AZ, fr_FR, etc.) after type=number added #4553

Closed
bigmrestaurant/opensourcepos
#1

Description

@objecttothis

Description

Tax 1 Rate and Tax 2 Rate fields in the Tax configuration tab do not populate when the system locale uses a comma as the decimal separator (e.g., az_AZ, fr_FR, de_DE). The fields render blank even though the value is correctly stored in the database. With en_US (period decimal separator) the fields populate correctly.

Steps to Reproduce

  1. Set locale to any comma-decimal locale (e.g., Azerbaijani az_AZ) in Config → Locale
  2. Set Tax 1 Rate to any value (e.g., 18) and save
  3. Navigate away and return to Config → Tax tab
  4. Expected: Tax 1 Rate field shows 18
  5. Actual: Tax 1 Rate field is blank

Root Cause

Commit 42ba39d29 added type='number' to the tax rate inputs in app/Views/configs/tax_config.php for input validation. However, to_tax_decimals() formats the value using PHP's NumberFormatter with the configured locale — producing "18,00" for comma-decimal locales. Browsers reject a comma-decimal value in <input type="number"> and render the field blank.

// tax_config.php — value rendered as "18,00" with az_AZ locale
'value' => to_tax_decimals($config['default_tax_1_rate'])

This was not an issue prior to 42ba39d29 (before v3.4.1) because the inputs were plain type='text'.

Proposed Fix

type='number' inputs require a machine-readable, period-decimal value — not a locale-formatted display string. The fix is to pass the raw numeric value (cast to float, which PHP serialises with . regardless of locale) instead of the locale-formatted string for these two inputs.

// tax_config.php — always produces "18" or "18.5", compatible with type="number"
'value' => $config['default_tax_1_rate'] !== '' ? (float) $config['default_tax_1_rate'] : ''

Apply the same pattern to default_tax_2_rate on line 86.

This preserves the type='number' browser validation while correctly supporting all locales. The existing parse_tax() on the save side already handles locale-aware parsing of the submitted value, so round-tripping is unaffected.

Affected File

  • app/Views/configs/tax_config.php — lines 61 and 86

Environment

Reproduced on current master. Not present at release 5f395d (v3.4.1) — that release predates the type='number' addition.

Activity

  1. objecttothis commented on May 21, 2026

    @objecttothis
    MemberAuthor

    @jekkos this regression came from 42ba39d. I think we don't have a test that verifies changes work properly on both locales that use , as a decimal separator and those which use .. We might not want to do the minor release until this is mitigated.

  2. added theissue type on May 21, 2026
  3. jekkos commented on May 21, 2026

    @jekkos
    Member

    Regression Analysis

    I've analyzed commit 42ba39d29 to identify all potential regressions from adding type='number' to input fields.

    Files Changed by Commit 42ba39d

    File Change Type Potential Issue?
    app/Views/configs/tax_config.php Added type='number' to tax rate inputs ✅ YES - Uses to_tax_decimals() for values
    app/Views/configs/email_config.php Added type='number' to smtp_port, smtp_timeout ❌ No (raw $config values)
    app/Views/configs/barcode_config.php Added type='number' to barcode settings ❌ No (raw $config values)
    app/Views/configs/info_config.php Added type='tel' to phone/fax ❌ No (text input)
    app/Views/configs/general_config.php Added type='number' to discount fields (pre-existing, not from this commit) ❌ No (raw $config values)
    app/Views/configs/receipt_config.php Added type='number' to receipt settings ❌ No (raw $config values)
    app/Views/configs/invoice_config.php Added type='number' to invoice number fields ❌ No (integer values)
    app/Views/login.php Moved use statement, no input changes ❌ No

    Confirmed Regression: tax_config.php Only

    Lines 61 and 86 use locale-formatted values in number-type inputs:

    // Line 61
    'value' => to_tax_decimals($config['default_tax_1_rate'])
    
    // Line 86  
    'value' => to_tax_decimals($config['default_tax_2_rate'])

    Other Inputs Are Safe

    All other type='number' inputs added in this commit use raw $config values from the database, which are stored as machine-readable numbers (period decimals), so they work correctly regardless of locale.


    Fix

    Branch pushed: fix-tax-input-locale

    The fix replaces locale-formatted values with raw numeric values for tax rate inputs:

    'value' => $config['default_tax_1_rate'] !== '' ? (float) $config['default_tax_1_rate'] : ''
    'value' => $config['default_tax_2_rate'] !== '' ? (float) $config['default_tax_2_rate'] : ''

    PHP serializes floats with a period decimal regardless of locale. The parse_tax() function on the save side already handles locale-aware parsing, so round-tripping works correctly.

  4. added a commit that references this issue on May 22, 2026
    6633bb3
  5. added a commit that references this issue on Jun 3, 2026
    9d7814a
  6. jekkos commented on Jun 3, 2026

    @jekkos
    Member

    Resolution

    PR #4555 has been updated with the correct fix.

    Root Cause

    Commit 42ba39d added type="number" to the tax rate input fields. This causes issues with locale-specific decimal separators because:

    • Browsers always submit type="number" inputs as dot-decimal (e.g., "5.5") regardless of the user's locale
    • For comma-decimal locales (de_DE, fr_FR, az_AZ, etc.), the submitted value doesn't match what the user sees/types

    Solution

    Revert the type="number" addition and keep using text inputs with the existing locale-aware functions:

    • to_tax_decimals() for display (formats according to locale)
    • parse_tax() for parsing (interprets according to locale)

    This is the same pattern used successfully in other tax rate inputs throughout the application (items/form.php, tax_rates_form.php).

    Changes

    • tax_config.php: Removed type="number", step, min, max attributes from tax rate inputs
    • Config.php: Restored parse_tax() for locale-aware parsing
    • Removed the tests that were added for the incorrect approach

    The PR is ready for review: #4555

  7. added a commit that references this issue on Jun 6, 2026
    4d6ebba
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions