---
name: evolution_creditnote_type_restock
description: Credit-note restock checkbox replaced by a required credit_type select that DERIVES restock_check; value->restock mapping spans 3 files
metadata: 
  node_type: memory
  type: project
  originSessionId: 8a7e3438-fb27-479c-ace3-aae13c8717e1
---

The credit-note editor's old AR-only "Restock credited goods back into inventory" checkbox was replaced (2026-07-15) by a **required `Credit Type` select** shown for both AR and AP — restock was too easy to miss on a genuine return.

**New column:** `creditnotes.credit_type` tinyint DEFAULT 0. Migration `migrations/creditnotes_credit_type.sql` (ADD COLUMN IF NOT EXISTS, per-tenant, same convention as `invoices_review_flag.sql`) — must be applied to dev tenant `85-1384947162` before testing.

**`restock_check` is retained as the GL driver and is now DERIVED, not user-set.** `commitCreditNote` (library/accounting.php) still reads `restock_check`: AR stock-IN ~L1588, AP stock-OUT ~L1684, reversal on uncommit ~L1737+. Nothing in commit changed.

**Value → restock mapping (keep these three in sync):**
- `creditnoteadd.inc` `$creditTypes` array (the option labels)
- `creditnotesave.php` derives `$restock = ((source=='AR' && type==6) || (source=='AP' && type==8)) ? 1 : 0` and stores both `credit_type` and `restock_check` (new + update branches)
- `library/creditnote.php::newCreditNote` INSERT now carries `credit_type`

Types: 4=Pricing Adjustment, 5=Service Adjustment, **6=Goods Returned (AR→stock IN)**, 7=Damaged Goods Returned (value only, NOT back to sellable stock), **8=Supplier Return (AP→stock OUT)**, 9=Rebate/Goodwill. 0="Please Select" (fails required). Derivation is source-aware so a mismatched type (e.g. AR note with type 8) yields restock=0.

**Validation:** select has `class="required"` but this module's `cnSave` (creditnoteadd.js) validates by explicit JS checks (not a global `.required` sweep), so an explicit `credit_type == ""` guard was added there next to the existing client check.

Docs updated: `docs/sales/credit-notes.php` (field table + "what committing posts" + uncommit). Related: [[evolution_creditnote_allocations]], [[evolution_creditnote_party_picker]], [[evolution_selectfilter_search_ui]] (required-class UI).
