# Material Master - Column Explanations

This document explains all columns in the Material Master tabs from an ERP perspective, similar to SAP/Oracle/Ramco ERP systems.

---

## 📦 **PLANT DATA TAB** (`material_plant` table)

Plant-specific data for each material. One material can have different settings per plant.

### Core Fields

| Column | Type | Explanation | Example |
|--------|------|-------------|---------|
| **plant_id** | Integer (FK) | Which plant/factory this material is available in. Each plant may have different stock levels, storage locations, and procurement methods. | `1` = Main Factory, `2` = Branch Plant |
| **opening_balance** | Decimal(15,3) | Initial stock quantity when material is first set up in this plant. Used for inventory initialization. | `100.000` = 100 units |
| **opening_balance_unit_cost** | Decimal(15,4) | Cost per unit of opening stock. Used for inventory valuation (Total Value = Qty × Unit Cost). | `150.50` = ₹150.50 per unit |
| **opening_balance_date** | Date | Date when opening balance was recorded. Usually the start of fiscal year or when material is first introduced. | `2024-01-01` |
| **opening_balance_uom_id** | Integer (FK) | Unit of measure for opening balance (e.g., KG, PC, M, L). Must match material's base UOM. | `1` = KG, `2` = PC |
| **status** | Enum | Material status in this plant:<br>• `ACTIVE` = Available for use<br>• `INACTIVE` = Temporarily unavailable<br>• `BLOCKED` = Not allowed (e.g., quality issue) | `ACTIVE` |

### Storage Fields

| Column | Type | Explanation | Example |
|--------|------|-------------|---------|
| **storage_location** | String(10) | Physical location code within plant where material is stored. Used for warehouse management and stock tracking. | `WH-01` = Warehouse 1, `STORE-A` = Store A |
| **storage_bin** | String(10) | Specific bin/shelf location within storage location. Enables precise stock location tracking. | `A-01-05` = Aisle A, Rack 1, Shelf 5 |

### MRP/Planning Fields

| Column | Type | Explanation | Example |
|--------|------|-------------|---------|
| **mrp_type** | Enum | How material requirements are calculated:<br>• `ND` = No Planning (manual ordering only)<br>• `VB` = Manual Reorder Point (reorder when stock < reorder_point)<br>• `PD` = MRP (automatic calculation from production orders)<br>• `PK` = Consumption Based (reorder based on past usage)<br>• `VM` = Forecast Based (reorder based on sales forecasts) | `PD` = MRP Planning |
| **mrp_controller** | String(3) | Person/team code responsible for MRP planning. Used for workflow and notifications. | `PLN` = Planning Team, `MGR` = Manager |
| **reorder_point** | Decimal(15,3) | Minimum stock level. When current stock falls below this, system triggers purchase/production order. | `50.000` = Reorder when stock < 50 units |
| **safety_stock** | Decimal(15,3) | Buffer stock to handle unexpected demand spikes or supply delays. Never goes below this level. | `20.000` = Always keep 20 units as buffer |
| **max_stock** | Decimal(15,3) | Maximum stock level to prevent overstocking. System warns if stock exceeds this. | `500.000` = Don't stock more than 500 units |
| **procurement_type** | Enum | How material is obtained:<br>• `E` = External (purchase from vendors)<br>• `F` = In-house (produce internally)<br>• `X` = Both (can purchase or produce) | `E` = External Purchase |
| **special_procurement** | String(2) | Special procurement scenarios:<br>• `10` = Subcontracting<br>• `20` = Consignment<br>• `30` = Third-party processing | `10` = Subcontracting |

### Validity Fields

| Column | Type | Explanation | Example |
|--------|------|-------------|---------|
| **effective_from** | Date | Date from which this plant data is valid. | `2024-01-01` |
| **effective_to** | Date | Date until which this plant data is valid. `NULL` = No expiry. | `2024-12-31` or `NULL` |

---

## 📊 **PLANNING (MRP) TAB** (`material_plant` table - MRP fields)

Same table as Plant Data, but focuses on MRP planning fields. See above for field explanations.

**Key MRP Concepts:**
- **Reorder Point**: When to order (stock level trigger)
- **Safety Stock**: Minimum buffer to prevent stockouts
- **Max Stock**: Maximum to prevent overstocking
- **MRP Type**: How requirements are calculated (manual vs automatic)

---

## 💰 **VALUATION TAB** (`material_valuation` table)

Cost accounting and valuation settings per plant. Determines how material cost is calculated and reported.

### Core Fields

| Column | Type | Explanation | Example |
|--------|------|-------------|---------|
| **plant_id** | Integer (FK) | Plant where this valuation applies. Different plants may have different costs. | `1` = Main Factory |
| **price_control** | Enum | How material cost is calculated:<br>• `S` = Standard Price (fixed cost, used for finished goods)<br>• `V` = Moving Average Price (average cost recalculated after each purchase) | `S` = Standard Price |
| **standard_price** | Decimal(15,4) | Fixed standard cost per unit. Used when `price_control = S`. Remains constant until manually updated. | `150.5000` = ₹150.50 per unit |
| **moving_average_price** | Decimal(15,4) | Current average cost. Used when `price_control = V`. Automatically recalculated after each purchase: `(Old Avg × Old Qty + New Price × New Qty) / Total Qty` | `145.2500` = Current average |
| **currency_id** | Integer (FK) | Currency for pricing (e.g., INR, USD, EUR). | `1` = INR |
| **status** | Enum | Valuation status:<br>• `ACTIVE` = Valuation is active<br>• `INACTIVE` = Valuation is inactive | `ACTIVE` |

### Advanced Valuation Fields

| Column | Type | Explanation | Example |
|--------|------|-------------|---------|
| **valuation_area** | String(10) | Accounting area for valuation. Usually same as plant code. Used for multi-company/multi-plant cost accounting. | `PLANT1` |
| **valuation_type** | Enum | Valuation method:<br>• `S` = Standard Price<br>• `V` = Moving Average Price<br>• `T` = Periodic Unit Price | `S` = Standard |
| **valuation_class** | String(10) | Material valuation class. Used for cost accounting grouping (e.g., raw materials, finished goods). | `MAT001` = Raw Material Class |
| **costing_lot_size** | Decimal(15,3) | Quantity used for cost calculation. Some materials are costed per lot (e.g., per 1000 units). | `1.000` = Per unit, `1000.000` = Per 1000 units |
| **original_price** | Decimal(15,4) | Original purchase/manufacturing cost when material was first introduced. Historical reference. | `150.0000` = Original cost |
| **last_price_change_date** | Date | When price was last updated. Used for price change tracking and reporting. | `2024-01-15` |

### Validity Fields

| Column | Type | Explanation | Example |
|--------|------|-------------|---------|
| **effective_from** | Date | Date from which this valuation is valid. | `2024-01-01` |
| **effective_to** | Date | Date until which this valuation is valid. `NULL` = No expiry. | `2024-12-31` or `NULL` |

**Valuation Best Practices:**
- **Standard Price (S)**: Use for finished goods, stable-cost materials
- **Moving Average (V)**: Use for raw materials with fluctuating prices
- **Currency**: Always set for multi-currency companies
- **Valuation Class**: Group similar materials for cost reporting

---

## 🏭 **SUPPLIERS TAB** (`material_supplier` table)

Vendor/supplier information for purchasing. One material can have multiple suppliers.

### Core Fields

| Column | Type | Explanation | Example |
|--------|------|-------------|---------|
| **vendor_id** | Integer (FK) | Supplier/vendor who can supply this material. Links to Business Partner (VENDOR type). | `1` = ABC Suppliers Ltd. |
| **vendor_material_number** | String(50) | Material code as per vendor's catalog. Used in purchase orders to vendor. | `VENDOR-12345` |
| **vendor_material_description** | String(255) | Description from vendor's catalog. May differ from your internal description. | `Steel Sheet 2mm - Vendor Spec` |
| **is_preferred** | Boolean | `TRUE` = Primary supplier (system uses this first in purchase orders). Only one supplier per material should be preferred. | `true` = Preferred |
| **lead_time_days** | Integer | Days from order placement to delivery. Used by MRP to calculate when to order. | `15` = 15 days lead time |
| **minimum_order_quantity** | Decimal(15,3) | Minimum quantity vendor requires per order. System enforces this in purchase orders. | `100.000` = Min 100 units per order |
| **standard_price** | Decimal(15,4) | Price quoted by this vendor. Used as default in purchase orders. | `148.00` = ₹148 per unit |
| **currency_id** | Integer (FK) | Currency for vendor pricing. May differ from company currency. | `1` = INR |
| **status** | Enum | Supplier status:<br>• `ACTIVE` = Can order from this vendor<br>• `INACTIVE` = Temporarily unavailable<br>• `BLOCKED` = Cannot order (e.g., quality issues) | `ACTIVE` |

### Advanced Fields

| Column | Type | Explanation | Example |
|--------|------|-------------|---------|
| **validity_from** | Date | Date from which vendor quote is valid. | `2024-01-01` |
| **validity_to** | Date | Date until which vendor quote is valid. System warns if quote expires. | `2024-12-31` |
| **remarks** | String(500) | Notes about vendor (e.g., quality, delivery performance, special terms). | `Good quality, reliable delivery` |

**Supplier Management Best Practices:**
- **Preferred Supplier**: Set one primary supplier per material
- **Lead Time**: Accurate lead time ensures MRP calculates correct order dates
- **Min Order Qty**: Enforce to avoid order rejections
- **Validity Dates**: Update quotes annually to keep prices current
- **Multiple Suppliers**: Maintain 2-3 suppliers for critical materials (backup)

---

## 🔄 **Workflow Integration**

### How These Tabs Work Together:

1. **Plant Data** → Sets up material availability per plant, storage locations, opening stock
2. **Planning (MRP)** → Configures how material requirements are calculated (manual vs automatic)
3. **Valuation** → Sets cost accounting method (standard vs moving average)
4. **Suppliers** → Defines vendor information for purchasing

### Example Flow:

1. **Create Material** → Basic info (description, type, UOM)
2. **Add Plant Data** → Set opening stock, storage location for Plant 1
3. **Configure MRP** → Set reorder point = 50, safety stock = 20, MRP type = PD
4. **Set Valuation** → Standard price = ₹150.50, currency = INR
5. **Add Suppliers** → Vendor A (preferred, ₹148, 15 days lead time)

**Result**: System can now:
- Track stock levels per plant
- Automatically calculate material requirements from production orders
- Use correct cost for inventory valuation
- Generate purchase orders to preferred supplier with correct pricing

---

## 📝 **Common ERP Scenarios**

### Scenario 1: Raw Material (Steel Sheet)
- **Plant Data**: Opening balance = 500 KG, Storage = WH-01
- **MRP**: Type = PD (MRP), Reorder = 200, Safety = 50
- **Valuation**: Price Control = V (Moving Average), MAP = ₹45.00
- **Suppliers**: Vendor A (preferred, ₹44.50, 10 days)

### Scenario 2: Finished Good (Control Panel)
- **Plant Data**: Opening balance = 10 PC, Storage = FG-WH
- **MRP**: Type = ND (No Planning - made to order)
- **Valuation**: Price Control = S (Standard), Standard = ₹1500.00
- **Suppliers**: N/A (produced internally)

### Scenario 3: Semi-Finished Good (Sub-Assembly)
- **Plant Data**: Opening balance = 25 PC, Storage = SF-WH
- **MRP**: Type = PD (MRP), Reorder = 10, Safety = 5
- **Valuation**: Price Control = S (Standard), Standard = ₹500.00
- **Suppliers**: Can purchase (Vendor B) or produce internally

---

## ⚠️ **Important Notes**

1. **Plant Data is Required**: Material must have at least one plant entry to be usable
2. **Valuation is Required**: System needs cost for inventory valuation and financial reporting
3. **Suppliers are Optional**: Only needed if material is purchased (procurement_type = E or X)
4. **Opening Balance**: Creates initial stock ledger entry when material is first set up
5. **Status Fields**: Use INACTIVE/BLOCKED to temporarily disable materials without deleting data

---

## 🚀 **Next Steps After Seeding**

1. Open Material Master form
2. Navigate through all tabs (Plant Data, Planning, Valuation, Suppliers)
3. Review sample data to understand field relationships
4. Create your own materials using these examples as templates
5. Test MRP calculation to see how reorder points and safety stock work
6. Create purchase orders to see how supplier data is used

---

**For more information, refer to:**
- ERP User Manual
- Material Master Setup Guide
- MRP Planning Documentation

