Repository navigation
fix(customers): match trunk-zero phone search - #1119
Conversation
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configuration
You can disable this status message by setting the Use the checkbox below for a quick retry:
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
@greptile review |
|
|
The main phone-search fix looks good. Please address the two remaining Greptile findings before merging.
Keep existing international and partial phone-search behavior unchanged. Run the relevant tests and confirm they pass. Please limit the changes to these findings. No unrelated formatting or refactoring. |
89e013e to
780a73d
Compare
Normalize phone-like search queries via parsePhoneE164 with the configured store country so domestic trunk-zero queries match customers stored in international E.164 format without stripping leading zeros from arbitrary partial searches. Fixes #1065
Add integration test confirming partial leading-zero queries (0899) do not produce false matches while full trunk-zero queries match, and remove the historical issue reference from the test comment.
780a73d to
20e0314
Compare
Intent
Verify and implement the surgical fix for FreeOpenSourcePOS/FloCafe issue #1065 ("support local trunk prefix (leading zero) in customer phone search"): in
main/routes/customers.ts,GET /api/customers?search=<query>misses customers stored in international E.164 format (e.g.,+66899123456->phone_digits66899123456) when searched using the domestic trunk-zero format (0899123456). Use the existingparsePhoneE164helper with the configured default country to include the normalized E.164 digits candidate in phone search without blindly stripping leading zeros from arbitrary partial searches. Deliver via theno-mistakespipeline as its own PR withFixes #1065in the PR summary.What Changed
GET /api/customersphone-like search inmain/routes/customers.tsto parse the search query withparsePhoneE164using the configured tenantcountrysetting and include any distinct normalized E.164 digit sequence alongside the raw digit substring match.tests/phone-search-integration.test.tsverifying domestic trunk-zero search matching against E.164 stored numbers while preserving partial digit and non-trunk leading-zero search behavior.Fixes #1065
Risk Assessment
✅ Low: The change is a small, well-bounded query enhancement in GET /api/customers using the existing parsePhoneE164 helper and store country setting, backed by integration tests covering trunk-zero, partial leading-zero, and non-trunk zero queries.
Testing
Stood up an isolated Express API server and SQLite database to drive GET /api/customers?search= end-to-end across domestic trunk-zero (0899123456 and 089-912-3456), partial leading-zero guard (0899), legitimate zero substring (0000), partial national digit (899123), and full E.164 (+66899123456) queries, and ran the focused phone search and validation test suites (test:phone-search-integration, test:customer-phone-search, test:phone, test:phone-validation) plus backend build; all scenarios and checks passed with API transcript evidence captured. No visual screenshot was captured because this change is strictly a backend SQL query parameter normalization in main/routes/customers.ts with no UI change.
Evidence: Live API transcript for domestic trunk-zero customer phone search
{ "configuredCountry": "TH", "storedCustomersInDb": [ { "id": "cust-88289bd5-d678-4311-9da0-c0ccab27cc13", "name": "Carlos AR", "phone": "+541143210000", "phone_digits": "541143210000", "country_code": "+54" }, { "id": "cust-13c64dfa-9e76-4ef9-9b5f-83256f86b813", "name": "Somchai TH", "phone": "+66899123456", "phone_digits": "66899123456", "country_code": "+66" } ], "scenarios": [ { "scenario": "Domestic trunk-zero search (0899123456)", "endpoint": "GET /api/customers?search=0899123456&per_page=10", "status": 200, "matchCount": 1 }, { "scenario": "Formatted domestic trunk-zero search (089-912-3456)", "endpoint": "GET /api/customers?search=089-912-3456&per_page=10", "status": 200, "matchCount": 1 }, { "scenario": "Partial leading-zero search guard (0899)", "endpoint": "GET /api/customers?search=0899&per_page=10", "status": 200, "matchCount": 0 }, { "scenario": "Legitimate zero substring search guard (0000)", "endpoint": "GET /api/customers?search=0000&per_page=10", "status": 200, "matchCount": 1 } ] }Evidence: Phone search integration test suite output (54/54 passed)
Pipeline
Updates from git push no-mistakes
✅ **intent** - passed
✅ No issues found.
✅ **Rebase** - passed
✅ No issues found.
✅ **Review** - passed
✅ No issues found.
✅ **Test** - passed
✅ No issues found.
npm run test:phone-search-integrationnpm run test:customer-phone-searchnpm run test:phonenpm run test:phone-validationnpm run buildLive HTTP verification against Express /api/customers?search= with SQLite store (TH trunk-zero 0899123456, formatted 089-912-3456, partial 0899 guard, 0000 substring guard, 899123 partial digits, +66899123456 E.164)✅ **Document** - passed
✅ No issues found.
✅ **Lint** - passed
✅ No issues found.
✅ **Push** - passed
✅ No issues found.