# Item Code Settings

<p class="doc-lead">Item Code Settings control how item codes are generated in Freespace ERP: how the <b>parent item code</b> is produced (from Number Settings or from an item-group counter) and how each <b>variant SKU code</b> is built (either a running number or a structured code assembled from the item group and variant option values).</p>

<div class="doc-toc">
<p class="doc-toc-title">On this page</p>
<div class="doc-toc-section">
<span class="doc-toc-group-title">Getting started</span>
<div class="doc-toc-links">
<a href="#/settings/item-code-settings?id=overview">Overview &amp; Form View</a>
<a href="#/settings/item-code-settings?id=quick-start">Quick Start</a>
</div>
</div>
<div class="doc-toc-section">
<span class="doc-toc-group-title">Form reference</span>
<div class="doc-toc-links">
<a href="#/settings/item-code-settings?id=parent-item-code">Parent Item Code</a>
<a href="#/settings/item-code-settings?id=variant-item-code">Variant Item Code</a>
<a href="#/settings/item-code-settings?id=code-parts">Code Parts</a>
<a href="#/settings/item-code-settings?id=actions">Actions</a>
</div>
</div>
<div class="doc-toc-section">
<span class="doc-toc-group-title">How it works</span>
<div class="doc-toc-links">
<a href="#/settings/item-code-settings?id=structured-code">Structured Code Examples</a>
<a href="#/settings/item-code-settings?id=group-counter">Item Group Counter Setup</a>
<a href="#/settings/item-code-settings?id=manual-variants">Manual Variant Selection</a>
<a href="#/settings/item-code-settings?id=best-practices">Best Practices</a>
<a href="#/settings/item-code-settings?id=faq">FAQ</a>
<a href="#/settings/item-code-settings?id=related">Related</a>
</div>
</div>
</div>

<hr class="doc-section-divider">

<h2 id="overview">Overview &amp; Form View</h2>

Go to <b>Settings → Item Code Settings</b> from the left menu.

This is a single company-wide settings page (not a list). It is organised into two sections:

- <b>Parent Item Code</b> — how the code of the main item is generated.
- <b>Variant Item Code</b> — how the code of each variant SKU (size/color combination) is generated.

Most fields show a small information icon next to the label; hover it for an inline explanation.

<!-- screenshot pending: settings/images/item-code-settings.webp -->

<hr class="doc-section-divider">

<h2 id="quick-start">Quick Start</h2>

<h3>1. Open the page</h3>
Go to <b>Settings → Item Code Settings</b>.

<h3>2. Choose the parent code method</h3>
Under <b>Parent Item Code</b>, set <b>Generation Method</b> to either <b>Number Settings Counter</b> (default) or <b>Item Group Counter</b>.

<h3>3. Choose how variant rows are added</h3>
Under <b>Variant Item Code</b>, set <b>Variant Row Generation</b> to <b>All combinations (cartesian)</b> or <b>Manually add variants</b>.

<h3>4. (Optional) Turn on structured variant codes</h3>
Tick <b>Enable Structured Code For Variant SKUs</b>, set a <b>Separator</b>, set the <b>Item Group Code Order</b>, and add rows in <b>Code Parts</b> for each variant type.

<h3>5. Save</h3>
Click <b>Update</b>. Settings apply to items created or edited afterwards.

<hr class="doc-section-divider">

<h2 id="parent-item-code">Parent Item Code</h2>

The parent item code is the code of the main item record. It is always unique and comes from a counter.

| **Field** | **Description** |
|-----------|-----------------|
| Generation Method | How the parent item code is produced. See the two methods below. |

<b>Generation Method options</b>

| **Option** | **Behaviour** |
|------------|---------------|
| Number Settings Counter | The item code is generated from the Inventory item-code series defined in <a href="#/settings/number-settings">Number Settings</a> (prefix + running number + suffix). This is the default and matches existing behaviour. |
| Item Group Counter | The item code is generated from the counter defined on the item's <b>Item Group</b> (for example Fruits → FR100, FR101). Each group keeps its own running number. |

<blockquote>
When <b>Item Group Counter</b> is selected, every item's group <b>must</b> have <b>Auto Generate Item Code By Counter</b> enabled. If an item is created under a group whose counter is not enabled, item creation is blocked with an error. Set up the counter on the group first — see <a href="#/settings/item-code-settings?id=group-counter">Item Group Counter Setup</a>.
</blockquote>

<hr class="doc-section-divider">

<h2 id="variant-item-code">Variant Item Code</h2>

An item with variants has one code per variant SKU (each size/color combination). This section controls how those SKU rows are created and coded.

| **Field** | **Description** |
|-----------|-----------------|
| Variant Row Generation | How SKU rows are added on the item form. <b>All combinations (cartesian)</b> auto-fills every possible combination of the selected options. <b>Manually add variants</b> lets you hand-pick only the combinations you need using the <b>Add Variant</b> button on the item form. |
| Enable Structured Code For Variant SKUs | When enabled, each variant SKU code is built from the item group segment and the variant option values (see Code Parts) instead of a running number. Parent item codes are unaffected. |
| Separator | Character placed between each part of a structured code, e.g. <code>-</code> produces <code>SH-BLK-M</code>. Leave blank to join parts with no separator. Shown only when structured codes are enabled. |
| Item Group Code Order | The position of the item group segment among the code parts. Lower numbers appear first. Shown only when structured codes are enabled. |
| Code Parts (variant types) | The ordered list of variant types that contribute to the structured code. See below. |

<hr class="doc-section-divider">

<h2 id="code-parts">Code Parts</h2>

Each row in the <b>Code Parts</b> table adds one variant type's selected option value to the structured SKU code. The item group segment is placed among these parts according to <b>Item Group Code Order</b>.

| **Column** | **Description** |
|------------|-----------------|
| Order | Position of this part in the code. Lower numbers appear first. The item group segment uses <b>Item Group Code Order</b> to sit among these. |
| Variant Type | The variant (e.g. Color, Size) whose selected option value is placed here. |
| Value From | Whether the code uses the option's short <b>Abbreviation</b> or its full <b>Name</b>. Abbreviations are defined per option on the <a href="#/inventory/inventory-variants">Variants</a> master. |

<hr class="doc-section-divider">

<h2 id="structured-code">Structured Code Examples</h2>

Assume the item belongs to item group <b>Shirts</b> with <b>Variant Code Segment</b> = <code>SH</code>, and the item has variants Color = Black (abbreviation <code>BLK</code>) and Size = <code>M</code>. Separator = <code>-</code>.

| **Item Group Code Order** | **Code Parts (Order → Variant, Value From)** | **Resulting SKU code** |
|---------------------------|----------------------------------------------|------------------------|
| 1 | 1 → Color (Abbreviation), 2 → Size (Name) | <code>SH-BLK-M</code> |
| 3 | 1 → Color (Abbreviation), 2 → Size (Name) | <code>BLK-M-SH</code> |
| 1 | 1 → Color (Name), 2 → Size (Name) | <code>SH-Black-M</code> |

Notes:

- The item group is <b>optional</b>. If the item has no group (or the group has no <b>Variant Code Segment</b>), that part is simply omitted and only the variant option values are used.
- Structured codes apply to <b>variant SKUs only</b>. The parent item code still comes from the parent method (Number Settings or Item Group Counter), which keeps parent codes unique.
- Make sure the combination of parts you configure produces a unique code for every SKU — for example, include enough variant types (or use Name instead of Abbreviation) when abbreviations could collide.

<hr class="doc-section-divider">

<h2 id="group-counter">Item Group Counter Setup</h2>

To generate parent codes per item group (for example FR100 for Fruits, VG100 for Vegetables):

1. Set <b>Generation Method</b> to <b>Item Group Counter</b> on this page and <b>Update</b>.
2. Open <a href="#/inventory/item-group">Item Group</a> and edit each group that should auto-number. On the <b>Auto Generate Item Code</b> section (below <b>Basic</b>):
   - Optionally set <b>Variant Code Segment</b> if you also use structured variant SKUs.
   - Tick <b>Auto Generate Item Code By Counter</b>.
   - Set <b>Counter Prefix</b> (e.g. <code>FR</code>), optional <b>Counter Suffix</b>, and <b>Counter Start</b> (e.g. <code>100</code>).
3. Create an item under that group — its code is assigned automatically (FR100), and the next item continues from the last used number (FR101).

<blockquote>
If a group used by a new item does not have <b>Auto Generate Item Code By Counter</b> enabled, item creation is blocked. Enable the counter on the group, or switch the parent method back to <b>Number Settings Counter</b>.
</blockquote>

<hr class="doc-section-divider">

<h2 id="manual-variants">Manual Variant Selection</h2>

When <b>Variant Row Generation</b> is set to <b>Manually add variants</b>, the item form does not auto-fill every possible combination. Instead:

- On the item form's <b>Variants</b> section, click <b>Add Variant</b>.
- In the <b>Add Variant Combination</b> window, choose one option for each variant type and click <b>Add</b>.
- Only the combinations you add become SKU rows. Duplicate combinations are rejected.

This is useful when the number of theoretical combinations is large but only a few are actually stocked. When structured codes are enabled, each added SKU is coded automatically from the Code Parts configuration.

<hr class="doc-section-divider">

<h2 id="actions">Actions</h2>

| **Action** | **Description** |
|------------|-----------------|
| Update | Saves the item code settings. Applies to items created or edited afterwards. |
| Reset | Discards unsaved edits on the form. |
| Cancel | Leaves the page without saving. |

<hr class="doc-section-divider">

<h2 id="best-practices">Best Practices</h2>

<ul>
<li>Decide the parent method once and keep it stable — switching between Number Settings and Item Group counters mid-way can make codes look inconsistent across older and newer items.</li>
<li>Before enabling <b>Item Group Counter</b>, set up the counter on every group you will use, so item creation is never blocked.</li>
<li>For structured codes, keep abbreviations short and unique per option, and choose a separator (e.g. <code>-</code>) to keep codes readable.</li>
<li>Include enough Code Parts so that every SKU gets a unique code; add another variant type or switch a part to <b>Name</b> if abbreviations could clash.</li>
<li>Use <b>Manually add variants</b> when only a handful of combinations are stocked, to avoid a long unmanageable SKU list.</li>
</ul>

<hr class="doc-section-divider">

<h2 id="faq">FAQ</h2>

<b>Does changing these settings renumber existing items?</b><br>
No. Settings apply to items created or edited after you save. Existing item codes are unchanged.

<b>Do structured codes replace the parent item code?</b><br>
No. Structured codes apply to variant SKUs only. The parent item code always comes from the parent method (Number Settings or Item Group Counter), which keeps parent codes unique.

<b>What happens if the item has no item group?</b><br>
The item group segment is skipped and the structured code is built from the variant option values only. The item group is optional for structured codes.

<b>Why is item creation blocked with an item group error?</b><br>
The parent method is <b>Item Group Counter</b>, but the selected group does not have <b>Auto Generate Item Code By Counter</b> enabled. Enable the counter on that group, or switch the parent method to <b>Number Settings Counter</b>.

<b>Where do the abbreviations come from?</b><br>
Each variant option has a Name and an Abbreviation on the <a href="#/inventory/inventory-variants">Variants</a> master. <b>Value From</b> chooses which one is used in the code.

<b>How do I control whether the item group code comes first or last?</b><br>
Use <b>Item Group Code Order</b>. It is placed among the Code Parts by its number — lower numbers appear first.

<b>My variants no longer auto-fill on the item form. Why?</b><br>
<b>Variant Row Generation</b> is set to <b>Manually add variants</b>. Use the <b>Add Variant</b> button to add only the combinations you need, or switch back to <b>All combinations (cartesian)</b>.

<hr class="doc-section-divider">

<h2 id="related">Related Topics</h2>

<ul>
<li><a href="#/settings/number-settings">Number Settings</a></li>
<li><a href="#/inventory/item-group">Item Group</a></li>
<li><a href="#/inventory/inventory-variants">Variants</a></li>
<li><a href="#/inventory/inventory-item">Item</a></li>
</ul>
