Skip to content

Fix: Settings UI, Validation, and Tax Integrations#123

Merged
khaira777 merged 8 commits into
mainfrom
fix/settings-audit-repairs
Jul 18, 2026
Merged

Fix: Settings UI, Validation, and Tax Integrations#123
khaira777 merged 8 commits into
mainfrom
fix/settings-audit-repairs

Conversation

@khaira777

@khaira777 khaira777 commented Jul 18, 2026

Copy link
Copy Markdown
Contributor

Implementation Plan

1. Settings Phone Number Validation

Swap out the raw <input> used for the Business Phone with the existing PhoneInput component (or apply its E.164 validation logic) so it behaves identically to the Customer creation form.

2. Tax ID & Missing /tax Endpoint

  • The Universal Approach: Rename references of "GSTIN" to a universal "Tax ID / Registration Number" in the UI.
  • The Wiring: Build out a "Tax Settings" section in the Store tab that hooks into the currently unused GET/PUT /api/settings/tax backend endpoints. This will finally allow saving tax_registered, tax_scheme, and state_code.

3. Unicode Printer Toggle UI

Fix the flexbox utility classes on the "Printer supports Unicode" row. Wrap the label text and the toggle component in a proper flex items-center justify-between container so it aligns perfectly with the rest of the form.

4. POS Local Settings (Images & Mandatory Customer)

These are local device settings (saved instantly to localStorage via Zustand). To improve UX, add an immediate toast.success('Local POS setting saved') popup that fires the moment they are toggled, providing instant feedback.

5. KDS URL Clarification

In the KDS settings tab, add clear helper text below the standalone button: "The Kitchen Display System is hosted locally on port 3002. Devices on your Wi-Fi can connect by visiting http://[YOUR-LOCAL-IP]:3002".

6. Loyalty isDirty Popup Bug

The unsaved changes warning isn't clearing because the component's internal saved state isn't syncing up after a successful API call. Add a state update inside the saveLoyalty() success block to clear the dirty flag.

- Sync saveLoyalty and saveDiscount state on success
- Add tax_registered to backend wildcard, shapes, and frontend form
- Add phone validation regex for saveBusinessInfo
- Sync savingCloud with discard/save button disabled logic
- Remove showPrinterForm from isDirty check
- Restore KDS setup hint paragraph
- Update POS Settings toasts for product images and customer mandatory
- Add missing English and Spanish translation keys
- Fix unused imports (cn, formatDate)
- Fixed the loyalty logic bug where earning was incorrectly scaling 1:1 with currency but redemption demanded 100 points per unit. Cashback is now multiplied by LOYALTY_REDEMPTION_RATE (100) when credited.
- Updated all integration tests (redemption, earning, global rate) to expect the corrected point balances.
- Ensured 'Tax ID / Registration Number' UI in settings conditionally renders based on 'Tax Registered' boolean.

Tested:
- Backend: 'npm test' suite fully passes
- Frontend: 'npm run lint' and 'npm run build' fully pass
- Database JSON export was failing with 401 because the native fetch() was missing the Authorization header. Swapped to api.get() to leverage existing interceptors.
- Temporarily appended the backup file path to the success toast while full history UI (Issue #120) is pending.
@khaira777

Copy link
Copy Markdown
Contributor Author

🚀 Phase 2 Fixes & Discoveries (Post-Initial Audit)

During thorough testing, several additional edge cases were caught and fixed on this branch:

  1. Tax ID Layout Shift (Fixed):

    • The settings grid layout was shifting weirdly when 'Tax Registered' was set to 'No'. Added a placeholder empty div to preserve the 2-column grid alignment.
  2. Severe Loyalty Points Scale Bug (Fixed):

    • Discovered that earning points was scaling 1:1 with currency, but redemption required a 100:1 ratio. This made points effectively worthless to customers.
    • Fix: Multiplied the earned cashback by LOYALTY_REDEMPTION_RATE (100) on the backend so earning and redeeming use the same mathematical scale. Updated all integration tests to enforce this.
  3. Database JSON Export Auth Error (Fixed):

    • Clicking 'Export Database' downloaded a JSON file with {"error":"Authentication required"} because the frontend fetch() call omitted the JWT token.
    • Fix: Refactored the export to use our api.get() instance which automatically handles auth interceptors.
  4. Backup Management UI (Deferred to Feature: Backup Management & History UI #120):

    • Currently, creating a backup silently succeeds with a toast, leaving the user wondering where the file went.
    • Interim Fix: The toast now explicitly prints the absolute path of the generated .db file.
    • Permanent Fix: Deferred to Issue Feature: Backup Management & History UI #120, which will build a full backup history and restore UI.
  5. Global Loyalty Setting & Overrides (Deferred to Enhancement: Refine Loyalty Program Onboarding and Labeling #81 / PR Enhancement: Refine Loyalty Program Onboarding #121):

- Inserted an empty placeholder div to maintain the 2-column grid layout when the Tax ID field is dynamically hidden, preventing subsequent fields from shifting upward.
@khaira777
khaira777 marked this pull request as ready for review July 18, 2026 22:06
@khaira777
khaira777 requested a review from itsbkm as a code owner July 18, 2026 22:06
@khaira777
khaira777 merged commit 0488a77 into main Jul 18, 2026
10 checks passed
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.

1 participant