
# Stock

The stock page displays three lists: products allocated for reservations, materials for open jobs, and open work stages.

Additionally, the page includes a stock map that shows the location of products on the map.

## Stock Transactions

The page handles the receipt of materials to the stock. The data for receiving comes from purchase orders, which are displayed in the upper grid table. The center of the page shows the purchase order lines from the selected purchase order in the upper grid.

At the bottom of the page, you can see how a purchase order line is divided into packages and assigned to stock locations. The tool in the lower-left corner is used to split the order into packages. The packages are displayed in the center grid area at the bottom. The stock map, showing the locations of the packages, is visible in the lower-right corner.

The allocation of purchase order lines to stock locations at the bottom of the page proceeds as follows:

1. Select the purchase order line to process from the central grid area.
1. Verify the product’s material batch number.
1. The total quantity of the product is shown in the *Total Amount* field. The product may have two different units (e.g., a steel plate may have both mass and surface area).
1. Enter the number of packages to split the line into in the *Packet Count* field.
1. *Full Packet Size* indicates the size of one full package, calculated by dividing the *Total Amount* by the *Packet Count*.
1. *Last Packet Size* shows the size of the final package if the packages are unevenly split (i.e., the last package differs from the full packet size).
1. Click the *Create Row* button to generate package rows in the list displayed in the center at the bottom.
1. Assign packages to stock locations by selecting a package row and clicking a location on the stock map or selecting a stock location from the *Location* drop-down menu. Choose the transaction date in the *Target Date* field and save by clicking the *Save* button.

## Terms

AI chat question: What is correct name for ERP web page where you receive goods, put then in the shelves and deliver goods to customers? Stock, warehouse or something else?

### DeepSeek answer

The most accurate term for the ERP module or web page that handles receiving goods, storing them on shelves, and delivering them to customers is typically Warehouse Management (or Warehouse Management System - WMS). This module specifically focuses on:

- Receiving goods (inbound logistics),
- Storing/organizing inventory (putting items in shelves/locations),
- Picking/packing/shipping goods to customers (outbound logistics).

Common Terms in ERPs:

- Warehouse Management (WMS): Most precise term for physical stock and logistics.
- Inventory Management: Focuses on tracking stock levels but may overlap with warehouse functions.
- Stock Management: Less common in ERPs, but sometimes used interchangeably with inventory.
- Order Fulfillment: May cover delivery to customers but not always stock.

If the ERP combines these functions into one interface, it might use broader terms like "Inventory & Warehouse" or "Logistics Management". For clarity, Warehouse Management is the industry-standard term for physical handling of goods.

### Gemini answer

The correct name for an ERP web page that handles receiving, storing, and delivering goods depends on the specific functions it emphasizes and the terminology used within your organization. However, here's a breakdown of the most common terms and their nuances:

#### Warehouse Management

This is the most comprehensive term. A "Warehouse Management" page or module would typically encompass all aspects of receiving, storing, and shipping goods.
It implies a system that manages the physical space, inventory levels, and the flow of goods within a warehouse.
This is the most likely to be the correct answer.

#### Inventory Management

While related, "Inventory Management" focuses more on tracking the quantity and value of goods rather than the physical movement.
A page with this name might handle stock levels, valuations, and reporting, but it might not directly control the physical processes of receiving and shipping.

#### Stock Management

Similar to inventory management, "Stock Management" emphasizes the tracking of available goods.
This term is often used interchangeably with inventory management.

#### Stock Management

This term focus's on the physical act of storing the goods. It is less likely to be the main term used, as receiving and shipping are also key functions.

#### Logistics

This is a broader term that encompasses the entire supply chain, including transportation, warehousing, and distribution.
While a warehouse page is part of logistics, "Logistics" itself is too broad to be the specific name.
Receiving/Shipping:
These terms might be used for specific pages or sections within a larger warehouse management module. For example, you might have a "Receiving" page for incoming goods and a "Shipping" page for outgoing goods.

## Unit Visibility Logic

The package input area displays up to 11 columns showing different units and multipliers. The visibility of each column is determined by the product's unit configuration.

### Column Structure

| # | Column | Data Field | Width Field | Width Value | Visibility Rule |
|---|--------|------------|-------------|-------------|-----------------|
| 1 | Label + Input | packet.total_amount | label_input | 16em | Always shown |
| 2 | Unit 1 | packet.unit | unit | 4em | Always shown (stock_unit) |
| 3 | Stock multiplier | packet.unit_multiplier | multiplier | 6em | Shown when Unit 2 column is visible |
| 4 | Amount 2 | packet.total_amount_2 | amount | 7em | Shown when Unit 2 column is visible |
| 5 | Unit 2 | packet.unit2 | unit | 4em | Shown when unit_2 exists AND differs from stock_unit |
| 6 | Stock/design multiplier | packet.row.pr.json_data.unit_design_unit_multiplier | multiplier | 6em | Shown when exists AND > 0 |
| 7 | Design amount 1 | packet.design_amount_1 | amount | 7em | Shown when design_unit exists AND differs from stock_unit |
| 8 | Design unit 1 | packet.design_unit_1 | unit | 4em | Shown when design_unit exists AND differs from stock_unit |
| 9 | Design multiplier | packet.design_multiplier | multiplier | 6em | Shown when design_unit_2 shown AND design_conversion_multiplier ≠ -1 |
| 10 | Design amount 2 | packet.design_amount_2 | amount2 | 7em | Shown when differs from all shown units AND design_conversion_multiplier ≠ -1 |
| 11 | Design unit 2 | packet.design_unit_2 | unit | 4em | Shown when differs from all shown units AND design_conversion_multiplier ≠ -1 |

**KEY RULE**: Show ALL different units. If kg, m², sht are all different, ALL THREE are visible.

### Container Width Calculation

The container width is dynamically calculated in `nc-stock.js` based on visible columns:

```javascript
// Base columns (always visible): label_input + amount + unit = 16 + 7 + 4 = 27em
// With Unit 2: + multiplier + amount + unit = 27 + 6 + 7 + 4 = 44em
// With Stock/design multiplier: + multiplier = 44 + 6 = 50em
// With Design unit 1: + amount + unit = 50 + 7 + 4 = 61em
// With Design unit 2: + amount2 + multiplier + unit = 61 + 7 + 6 + 4 = 78em
```

**Note**: Column 4 (Amount 2) uses `rec.column_width.amount` (7em), NOT `amount2` as might be expected. The `amount2` width is only used for column 10 (Design amount 2).

### Visibility Rules

#### Core Rule: Show ALL Different Units

**ALL different units are shown.** If kg, m², sht are all different, ALL THREE are visible. Units are only hidden when they are duplicates/same as other units (e.g., if unit_2 = kg, it is hidden because stock_unit = kg).

#### Normal Case (design_conversion_multiplier ≠ -1)

1. **Step 1 - Check unit_2**: Show if unit_2 exists and differs from stock_unit
2. **Step 2 - Check design_unit**: Show if design_unit exists and differs from stock_unit
3. **Step 3 - Check design_unit_2**: Show if it exists and multiplier ≠ -1
4. **Step 4 - Stock/design multiplier**: Show if unit_design_unit_multiplier > 0

**Example - kg, m², sht (ALL different):**

- stock_unit = kg
- unit_2 = m² (shown, different from kg)
- design_unit = sht (shown, different from kg)
- Result: kg, m², sht - ALL THREE visible

#### Special Case (design_conversion_multiplier = -1)

The special case indicates an inverse relationship (e.g., "sheets" vs "pieces per sheet"). When design_conversion_multiplier equals -1:

- **Design unit 2**: Always hidden
- **Design multiplier**: Always hidden
- **Unit 2**: Shown when exists and differs from stock_unit (ALL different units rule still applies)
- **Stock/design multiplier**: Shown when unit_design_unit_multiplier > 0
- **Design unit 1**: Shown when design_unit exists and differs from stock_unit

### Example Scenarios

#### Example 1: Steel Sheet (kg, m², sht, /sht, multiplier=-1)

```text
stock_unit: kg
unit_2: m²
design_unit: sht
design_unit_2: /sht
design_conversion_multiplier: -1 (special case!)
```

Visible columns: Amount, Unit 1 (kg), Stock multiplier, Amount 2, Unit 2 (m²), Stock/design multiplier, Design amount, Design unit 1 (sht)
Hidden columns: Design multiplier, Design amount 2, Design unit 2 (hidden because multiplier = -1)

#### Example 2: kg, m², sht (ALL different units shown)

```text
stock_unit: kg
unit_2: m²
design_unit: sht
```

Visible columns: Amount, Unit 1 (kg), Stock multiplier, Amount 2, Unit 2 (m²), Stock/design multiplier (if > 0), Design amount, Design unit 1 (sht)
Hidden columns: Design multiplier, Design amount 2, Design unit 2

**Key**: ALL THREE different units (kg, m², sht) are visible!

#### Example 3: Only Stock Unit (kg only)

```text
stock_unit: kg
(no other units defined)
```

Visible columns: Amount, Unit 1 (kg) only

### Multiplier Types

1. **Stock multiplier** (unit_multiplier): Conversion between stock_unit and unit_2
2. **Stock/design multiplier** (unit_design_unit_multiplier): Conversion between stock units and design_unit
3. **Design multiplier** (design_conversion_multiplier): Conversion between design_unit and design_unit_2

When design_conversion_multiplier is -1, it represents a special "per-unit" inverse relationship and causes design_unit_2 and its multiplier to be hidden.

## Column Order and Layout

### Data Row Structure

Each data row (Total amount, Packet count, Full packet size, Last packet size) contains the following columns in order:

1. **Label + Input column** (16em) - Contains the input field with label (e.g., "Total amount")
2. **Unit 1** (4em) - Stock unit (e.g., "kg")
3. **Stock multiplier** (6em) - Conversion to unit 2 (e.g., "/24")
4. **Amount 2** (7em) - Amount in unit 2 (e.g., "=2.00")
5. **Unit 2** (4em) - Second stock unit (e.g., "m²")
6. **Stock/design multiplier** (6em) - Conversion to design unit 1 (e.g., "/48")
7. **Design amount 1** (7em) - Amount in design unit 1 (e.g., "0.50")
8. **Design unit 1** (4em) - First design unit (e.g., "sht")
9. **Design multiplier** (6em) - Conversion to design unit 2 (e.g., "/10")
10. **Design amount 2** (7em) - Amount in design unit 2 (e.g., "5.00")
11. **Design unit 2** (4em) - Second design unit (e.g., "pcs")

### Important Column Order Notes

**Design multiplier MUST come BEFORE Design amount 2** for logical consistency. The multiplier connects the two design units:

- Design amount 1 → Design unit 1 → **Design multiplier** → **Design amount 2** → Design unit 2

This order ensures that when reading left to right, you see: value in unit 1, then unit 1, then the multiplier, then value in unit 2, then unit 2.

### Field Mappings

| Row | Design Amount 1 Field | Design Unit 1 Field | Design Multiplier Field | Design Amount 2 Field | Design Unit 2 Field |
|-----|----------------------|-------------------|------------------------|----------------------|-------------------|
| **Total amount** | packet.design_amount_1 | packet.design_unit_1 | packet.design_multiplier | packet.design_amount_2 | packet.design_unit_2 |
| **Full packet** | packet.design_amount_full_packet_1 | packet.design_unit_full_packet_1 | packet.design_multiplier_full_packet | packet.design_amount_full_packet_2 | packet.design_unit_full_packet_2 |
| **Last packet** | packet.design_amount_last_packet_1 | packet.design_unit_last_packet_1 | packet.design_multiplier_last_packet | packet.design_amount_last_packet_2 | packet.design_unit_last_packet_2 |

**Source (from rec.json copy_order_row_field_to_packet):**

- `design_unit_1`, `design_unit_full_packet_1`, `design_unit_last_packet_1` ← all copied from `pr.design_unit`
- `design_multiplier`, `design_multiplier_full_packet`, `design_multiplier_last_packet` ← all copied from `pr.json_data.design_conversion_multiplier`
- `design_unit_2`, `design_unit_full_packet_2`, `design_unit_last_packet_2` ← all copied from `pr.json_data.design_unit_2`

**Critical:** Each row MUST use its OWN field! The full packet row uses `design_unit_full_packet_1`, NOT `design_unit_1`.

## Recent Fixes (2025)

### Critical Bug Fix: Design Unit Fields

**Problem**: Full packet and Last packet rows were using `packet.design_unit_1` instead of their specific fields `packet.design_unit_full_packet_1` and `packet.design_unit_last_packet_1`. This caused all three rows to display the SAME unit value instead of showing the correct unit for each row.

**Solution**: Fixed field mappings in nc-stock.json:

- Line 965: Full packet row now uses `packet.design_unit_full_packet_1` ✓
- Line 1159: Last packet row now uses `packet.design_unit_last_packet_1` ✓

**Files modified**:

- `/Volumes/nc/nc-backend/preference/form/nc/nc-stock/nc-stock.json` - Fixed design unit field references

### Column Order Fix

**Problem**: The "Design multiplier" and "Design amount 2" columns were in the wrong order in data rows. "Design amount 2" appeared before "Design multiplier", which was illogical.

**Solution**: Swapped the column order in all data rows and the header row so that "Design multiplier" (width: multiplier) comes before "Design amount 2" (width: amount2).

**Files modified**:

- `/Volumes/nc/nc-backend/preference/form/nc/nc-stock/nc-stock.json` - Swapped column order in header row and all four data rows (Total amount, Packet count, Full packet size, Last packet size)

### Container Width Calculation Fix

**Problem**: The container width calculation in `nc-stock.js` was using `amount2Width` for the "Amount 2" column, but that column actually uses `rec.column_width.amount`.

**Solution**: Changed line 42 in nc-stock.js from `amount2Width` to `amountWidth`. While both values are 7em, using the correct variable ensures semantic correctness and prevents future errors if the values diverge.

**Files modified**:

- `/Volumes/nc/nc-backend/preference/form/nc/nc-stock/nc-stock.js` - Fixed containerWidth calculation

### Visibility Optimization

**Problem**: Design amount 1 and Design unit 1 columns had unnecessary `v-show` attributes that checked `showDesignUnitColumn`. These columns should always be visible when the product has design units.

**Solution**: Removed all `v-show` attributes from design amount 1 and design unit 1 columns (8 attributes removed).

**Files modified**:

- `/Volumes/nc/nc-backend/preference/form/nc/nc-stock/nc-stock.json` - Removed unnecessary v-show attributes

### Header Amount 2 Width Fix

**Problem**: The header row "Amount 2" column used `rec.column_width.amount2` but ALL data rows use `rec.column_width.amount`. This mismatch caused header and data columns to have different widths if the values ever diverged.

**Solution**: Changed header line 402 from `amount2` to `amount` to match all three data rows (Total amount, Full packet, Last packet).

**Files modified**:

- `/Volumes/nc/nc-backend/preference/form/nc/nc-stock/nc-stock.json` - Fixed header Amount 2 width

### Calculated Amount Fields Prefix Fix

**Problem**: All calculated amount fields (Amount 2, Design amount 1, Design amount 2) were missing the `prefix: "=\u00A0"` attribute. Only the primary input fields (total_amount, full_packet_size, last_packet_size) should have NO prefix. All unit-converted calculated fields must show the "= " prefix to indicate they are calculated values.

**Solution**: Added `prefix: "=\u00A0"` to all 9 calculated amount fields across all three data rows:

- total_amount_2, full_packet_size2, last_packet_size2
- design_amount_1, design_amount_full_packet_1, design_amount_last_packet_1
- design_amount_2, design_amount_full_packet_2, design_amount_last_packet_2

**Files modified**:

- `/Volumes/nc/nc-backend/preference/form/nc/nc-stock/nc-stock.json` - Added prefix to 9 calculated amount fields

### Width Field Usage

**Important**: The column structure uses width fields in specific ways that may not be immediately obvious:

- Column 4 (Amount 2) uses `rec.column_width.amount` (7em), NOT `amount2`
- Column 10 (Design amount 2) uses `rec.column_width.amount2` (7em)
- Most columns reuse the same width fields: `unit` (4em) for all unit columns, `multiplier` (6em) for all multiplier columns

This design minimizes the number of width configuration values while maintaining flexibility.

## Complete Field Reference

### All Amount Fields (13 total)

| # | Field | Row | Decimals | Handler | Calculated By | Status |
|---|-------|-----|----------|---------|---------------|--------|
| 1 | total_amount | Total | "2" | updatePacket('total_amount') | user input | ✓ |
| 2 | total_amount_2 | Total | "2" | updatePacket('total_amount_2') | unitAmount (from total_amount) | ✓ |
| 3 | packet_count | Packet count | - | updatePacket('packet_count') | user input | ✓ |
| 4 | full_packet_size | Full packet | "2" | updatePacket('full_packet_size') | calculatePacketSize | ✓ |
| 5 | full_packet_size_2 | Full packet | "2" | updatePacket('full_packet_size_2') | unitAmount (from full_packet_size) | ✓ |
| 6 | last_packet_size | Last packet | "2" | updatePacket('last_packet_size') | calculatePacketSize | ✓ |
| 7 | last_packet_size_2 | Last packet | "2" | updatePacket('last_packet_size_2') | unitAmount (from last_packet_size) | ✓ |
| 8 | design_amount_1 | Total | "2" | updatePacket('design_amount_1') | unitAmount (from total_amount) | ✓ |
| 9 | design_amount_2 | Total | "2" | updatePacket('design_amount_2') | unitAmount (from total_amount) | ✓ |
| 10 | design_amount_full_packet_1 | Full packet | "2" | updatePacket('design_amount_full_packet_1') | unitAmount (from full_packet_size) | ✓ |
| 11 | design_amount_full_packet_2 | Full packet | "2" | updatePacket('design_amount_full_packet_2') | unitAmount (from full_packet_size) | ✓ |
| 12 | design_amount_last_packet_1 | Last packet | "2" | updatePacket('design_amount_last_packet_1') | unitAmount (from last_packet_size) | ✓ |
| 13 | design_amount_last_packet_2 | Last packet | "2" | updatePacket('design_amount_last_packet_2') | unitAmount (from last_packet_size) | ✓ |

**All 13 amount fields verified and working correctly!**
