Skip to content

[Bug]: Cannot save new item with empty Tax 2 row – "Tax Name contains disallowed characters" / "Tax Percent must be a non-negative value" #4773

Closed

Description

@MufassalAmeer

🐛 Bug Description

After upgrading from 3.3.8 to 3.4.3, adding a new item fails if any tax row is left empty (which is the default — the item form always shows Tax 1 and Tax 2).

Two validation errors occur, one after the other:

  1. "Tax Name contains disallowed characters."
    Cause: in app/Controllers/Items.php, validateItemFields() uses
    'tax_names.*' => 'required|max_length[255]|unicode_alpha_numeric_punct'
    The form always posts both tax rows, so an empty Tax 2 name fails required. The required failure is mapped to the Items.tax_name_invalid message, which is misleading.

  2. "Tax Percent must be a non-negative value."
    Cause: 'tax_percents.*' => 'nonNegativeDecimal'. An empty % field is passed to OSPOSRules::nonNegativeDecimal(), parse_decimals('') returns false, so the rule fails.
    Adding permit_empty to the rule did NOT fix it in my environment; it only worked after adding an empty check inside the rule itself.

postSave() already ignores tax rows whose percent is not numeric, so empty rows are safe to allow (as in 3.3.8).
validateBulkUpdateFields() has the same tax_percents rule.

Suggested fix

Items.php, validateItemFields():
'tax_names.' => 'permit_empty|max_length[255]|unicode_alpha_numeric_punct',
'tax_percents.
' => 'permit_empty|nonNegativeDecimal',

Items.php, validateBulkUpdateFields():
'tax_percents.*' => 'permit_empty|nonNegativeDecimal',

OSPOSRules.php, nonNegativeDecimal() — add at the top:
if (trim($candidate) === '') {
return true;
}

ospos.xlsx

📋 Steps to Reproduce

  1. Make sure Configuration → Tax has no default tax names/rates (or leave them empty).
  2. Go to Items → New Item.
  3. Fill in Item Name, Category, prices and quantities. Leave Tax 1 and Tax 2 empty.
  4. Click Submit → "Tax Name contains disallowed characters."
  5. Enter Tax 1 = "VAT", 0 %, leave Tax 2 empty, Submit → same error.
  6. After removing required from tax_names.* → "Tax Percent must be a non-negative value."

✅ Expected Behavior

Items should save with empty tax rows, as in 3.3.8. Empty tax name/percent rows should be skipped, and only non-empty values validated (negative percentages still rejected).

📦 OpenSourcePOS Version

OpenSourcePOS 3.4.2

🔧 PHP Version

PHP 8.4

🌐 Browser(s)

No response

🖥️ Server Operating System

Windows server

🗄️ Database

mysql

🌍 Web Server

IIS

📊 System Information Report

General InfoOSPOS Installation Info: 3.4.3 - f81695
Language Code: en

OSPOS Timezone is Different from your Local Timezone.
Local Timezone: Asia/Colombo
OSPOS Timezone: Asia/Kolkata

Extensions & Modules:
» GD: ✓ Enabled
» BC Math: ✓ Enabled
» intl: ✓ Enabled
» OpenSSL: ✓ Enabled
» Multibyte String: ✓ Enabled
» cURL: ✓ Enabled
» JSON: ✓ Enabled
» XML: ✓ Enabled

User SetupBrowser: Chrome 155.0.0.0
Server Software: Microsoft-IIS/10.0
PHP Version: 8.5.12
DB Version: 8.0.35
Server Port: 443
OS: Windows NT 10.0

Permissions» [writable/logs] 0777 · ✓ Writable · ✗ Vulnerable or Incorrect Permissions
» [public/uploads] 0777 · ✓ Writable · ✗ Vulnerable or Incorrect Permissions
» [public/uploads/item_pics] 0777 · ✓ Writable · ✗ Vulnerable or Incorrect Permissions
» [importCustomers.csv] 0666 · ✓ Readable · ✗ Vulnerable or Incorrect Permissions

Security Vulnerability Warning
Incorrect permissions leaves this software at risk.

» [writable/logs] is writable, but the permissions are incorrectly set. Please set it to 750 and refresh.
» [public/uploads] is writable, but the permissions are incorrectly set. Please set it to 750 and refresh.
» [public/uploads/item_pics] is writable, but the permissions are incorrectly set. Please set it to 750 and refresh.
» [importCustomers.csv] is readable, but the permissions are incorrectly set. Please set it to 640 or 660 and refresh.

📜 Relevant Log Output

📸 Screenshots

No response

✓ Confirmation

  • I certify that this is an unmodified copy of OpenSourcePOS
  • I have searched existing issues to ensure this bug has not already been reported
  • I have provided all the information requested above

Activity

  1. jekkos commented on Oct 22, 2026

    @jekkos
    Member

    @MufassalAmeer — fix is up in #4774. Could you verify it resolves the issue on your end (3.4.3, IIS, empty Tax 1 + Tax 2 rows)?

  2. objecttothis commented on Oct 23, 2026

    @objecttothis
    Member

    Claude Issue Checker Agent (cc @objecttothis)

    Investigated against current master.

    Status: Still present (fix not yet merged).

    app/Controllers/Items.php validateItemFields() still has:

    'tax_names.*'    => 'required|max_length[255]|unicode_alpha_numeric_punct',
    'tax_percents.*' => 'nonNegativeDecimal',

    — no permit_empty, so an empty Tax 2 row still fails required with the misleading Items.tax_name_invalid message, exactly as described. validateBulkUpdateFields() similarly still has 'tax_percents.*' => 'nonNegativeDecimal' with no permit_empty.

    There's an open, unmerged PR addressing this: #4774 "fix(items): allow empty tax rows on item save", and a maintainer has asked the reporter to verify it. Since #4774 hasn't landed on master yet, the bug is still reproducible there.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions