---
name: evolution_creditnote_party_picker
description: "creditnoteadd party picker is now a server-side selectFilter (all contacts reachable, but is_supplier/is_client scoping was lost); plus allocation-panel UX"
metadata:
  node_type: memory
  type: project
  originSessionId: 7304676b-7dfa-4fa2-83fa-a0cd4e67d072
---

Work on the credit-note editor (`creditnoteadd.inc` / `.js`, AR+AP) done 2026-07-15:

**Party picker converted to server-side selectFilter.** Was a client-side `<select>` built from `contacts ... order by company limit 500` filtered in JS — so a party sorting past #500 had no `<option>` and rendered blank ("supplier drops on open"; hit AP bill 13862 → supplier contact 700, ranked 533rd). Now uses the auto-wire pattern: input has `evo-filter-type="contact" evo-filter-tgt="clientSelect" evo-filter-no-reload="1"`; `#clientSelect` pre-renders only the note's current party as a `selected` option with `data-static-options="<?php echo $selContact?'2':'1' ?>"`. All contacts reachable via search; pre-selected clientid still posts untouched. Removed dead `filterCreditContacts()` from the JS (kept `creditPickContact()` for the select's `onchange`). Pattern details in [[evolution_selectfilter_search_ui]].

**CAVEAT (behavioural change, flagged to user, not yet decided):** the shared `app/ajax/selectFilter.php` `filtercontact` handler does **not** filter by `is_supplier`/`is_client` — it searches all active contacts. So the AP picker can now surface non-suppliers and AR non-clients (same as `purchaseadd`'s supplier box). The from-bill/from-invoice flow still seeds a valid party, so this only affects manual selection. Preserving scoping would need a param on the shared endpoint (touches many pages) or a dedicated call — deliberately NOT changed unprompted.

**Allocation panel (committed notes only).** Target bill/invoice ids are clickable links (`index.php?page=billadd&billid=` / `invoiceadd&invoiceid=`, `target=_blank`). Allocation amount inputs have `onfocus='cnAllocMax(this)'` which autofills `min(target open balance, credit remaining − amounts already keyed on other targets)`; only fills an empty field. Uses hidden `#cnRemainingRaw` (raw float) since the visible `#cnRemaining` is `currency()`-formatted.

Related module gotchas: [[evolution-creditnote-commit-xero]] (commit JSON corruption + Xero sync). DB style: [[evolution_getfieldarray_deprecated]].
