All tables
tables · table

cgroupmas

The dbo.cgroupmas table serves as the Item Group Master within the SQL Server database. It is primarily used to categorize consumable items, tools, and spare parts (e.g., carbide drills, bearings, lubricants) for inventory management, procurement reporting, and financial expense analysis. It establishes a hierarchy above specific items and is frequently used in stored procedures to aggregate stock balances and purchase registers.

Row count
156
Last entry
Source
tables

Columns

3
ColumnTypeNullableMeaning
compcodestringNoUnique identifier for the company/legal entity.
groupcodeintegerNoUnique numeric identifier for the item category group.
groupnamestringYesDescriptive name of the group, often including a prefix for sorting or HSN codes.

Full documentation

### 1. Overview
 The `dbo.cgroupmas` table serves as the **Item Group Master** within the SQL Server database. It is primarily used to categorize consumable items, tools, and spare parts (e.g., carbide drills, bearings, lubricants) for inventory management, procurement reporting, and financial expense analysis. It establishes a hierarchy above specific items and is frequently used in stored procedures to aggregate stock balances and purchase registers.
 
 ### 2. Column Dictionary
 
 | Column | Type | Nullable | Meaning | Allowed Values | SQL Usage |
 | :--- | :--- | :--- | :--- | :--- | :--- |
 | **compcode** | string | No | Unique identifier for the company/legal entity. | e.g., "DAS", "HFL" | Primary filter in all multi-tenant queries and JOINs. |
 | **groupcode** | integer | No | Unique numeric identifier for the item category group. | e.g., 1, 2, 43 | Primary Key / Join key for item classification. |
 | **groupname** | string | Yes | Descriptive name of the group, often including a prefix for sorting or HSN codes. | e.g., "01. OILS & LUBRICANTS" | Displayed in inventory and expense reports. |
 
 ### 3. Relationships & Join Map
 
 The `cgroupmas` table acts as a parent lookup table for several inventory and transaction modules.
 
 #### Logical Joins
 * **Item Master (`dbo.citemmas`)**: Joined on `compcode` and `groupcode`. This is the most common relationship, used to retrieve the group name for specific consumable items.
 * **Sub-Group Master (`dbo.csubgroupmas`)**: Joined on `compcode` and `groupcode`. Represents a 1:N hierarchy where a group contains multiple sub-categories.
 * **Item Group Mapping (`dbo.groupitem`)**: Joined on `compcode` and `groupcode` to manage many-to-many associations between groups and items.
 
 #### Physical Join Implementation (Based on SCHEMA_MAP)
 * **To Consumable Items**:
  ```sql
  SELECT m.citemname, g.groupname
  FROM dbo.citemmas m
  INNER JOIN dbo.cgroupmas g ON m.groupcode = g.groupcode AND m.compcode = g.compcode;
  ```
 * **To Sub-Groups**:
  ```sql
  SELECT g.groupname, s.subgroupname
  FROM dbo.cgroupmas g
  INNER JOIN dbo.csubgroupmas s ON g.groupcode = s.groupcode AND g.compcode = s.compcode;
  ```
 
 #### Usage Context (Inferred from Reference JSON)
 * **Expense Analysis**: Used in `dbo.expensesdet` to aggregate "Repair & Maintenance" or "Consumable" costs by `groupcode`.
 * **Production Requirements**: Used in `dbo.PR_ReqCitem_wise_Production_Rpt` to filter required consumables (tools) based on their parent category.