diff --git a/src/app/cashier/transaction-entry/transaction-entry.component.ts b/src/app/cashier/transaction-entry/transaction-entry.component.ts index ad6a5f682..d803d8c23 100644 --- a/src/app/cashier/transaction-entry/transaction-entry.component.ts +++ b/src/app/cashier/transaction-entry/transaction-entry.component.ts @@ -1633,12 +1633,14 @@ export class TransactionEntryComponent implements OnInit, OnDestroy { if (token !== this.searchToken) return; // stale result — newer search started const allItems: any[] = res?.pageItems ?? (Array.isArray(res) ? res : []); const f = cfg.matchField; - // Exact match first, then suffix/partial match (backend may return by last-N-digits) + // Exact match first, then suffix/partial match. Some account types (e.g. Share — its + // list endpoint only accepts offset/limit, no accountNo filter at all) always return the + // FULL unfiltered list rather than a server-side-narrowed one, so a partial match can't be + // gated on "exactly one row came back" — it never would be for those types. const exactMatch = allItems.find((x: any) => x[f] === acNo); - const partialMatch = - !exactMatch && allItems.length === 1 - ? allItems.find((x: any) => x[f]?.endsWith(acNo) || x[f]?.includes(acNo)) - : null; + const partialMatch = !exactMatch + ? (allItems.find((x: any) => x[f]?.endsWith(acNo)) ?? allItems.find((x: any) => x[f]?.includes(acNo))) + : null; const match = exactMatch ?? partialMatch ?? null; if (match?.id) { const clientIdFromSearch = acTyp !== 'GL' && match.clientId != null ? String(match.clientId) : null;