๐Ÿ“š ERP Documentation Viewer

Beautiful, colorful documentation for your ERP system

Store Report Controller Documentation

File: /controllers/storereportController.php

Purpose: Manages inventory reports, stock movements, and warehouse analytics

Last Updated: December 19, 2024

Total Functions: 11

Lines of Code: 1,069

---

๐Ÿ“‹ Overview

The Store Report Controller provides comprehensive inventory reporting and stock movement analysis for the ERP system. It handles:

Primary Functions

Related Controllers

---

๐Ÿ—„๏ธ Database Tables

Core Reporting Tables

Table NamePurposeKey Columns
`storereport`Stock movementsstorereportid, productid, storeid, productquantity, productbefore, productafter, processname, tablename, storereportdate
`storedetail`Current inventorystoredetailid, storeid, productid, productquantity, storedetaildate
`sizecolorstoredetail`Size/color inventoryid, storeid, productid, sizeid, colorid, quantity
### Transaction Detail Tables

Table NamePurposeKey Columns
`sellbilldetail`Sales transactionssellbilldetailid, sellbilldetailproductid, sellbilldetailquantity, sellbillid
`returnsellbilldetail`Sales returnsreturnsellbilldetailid, returnsellbilldetailproductid, returnsellbilldetailquantity
`buybilldetail`Purchase transactionsbuybilldetailid, buybilldetailproductid, buybilldetailquantity, buybillid
`returnbuybilldetail`Purchase returnsreturnbuybilldetailid, returnbuybilldetailproductid, returnbuybilldetailquantity
### Master Data Tables

Table NamePurposeKey Columns
`store`Store/warehouse masterstoreid, storename, storeaddress, conditions
`product`Product catalogproductId, productName, productcode, productcatid
`productcat`Product categoriesproductcatid, productcatname, productcatparent
`sizecolor`Size/color definitionssizecolorid, sizecolorname, sizecolortype
---

๐Ÿ”ง Key Functions

Core Display Functions

Main Report Display (Lines 197-277)

Purpose: Main entry point for store reports with filtering options

Parameters:

Process Flow:

โ”Œโ”€ Load Filters โ”€โ”€โ”€โ”€โ”€โ”
Store, Product
Date, Category
Based on filters
Credit, Debit
โ””โ”€ Display Report โ”€โ”˜

Summary Calculation Functions

sumCredit() (Lines 289-335)

Purpose: Calculates total credit transactions (increases in inventory)

Returns: Total credit amount across all stores and products

Process Flow:

โ”Œโ”€ Query Credits โ”€โ”€โ”€โ”€โ”
storereporttype=0
Active records
Credit amounts
โ””โ”€ Return Total โ”€โ”€โ”€โ”€โ”˜

sumCreditByStoreId($StoreId) (Lines 336-385)

Purpose: Calculates credit transactions for a specific store

Parameters: $StoreId - Store identifier

Returns: Total credit amount for the specified store

sumCreditByProductId($ProductId) (Lines 386-435)

Purpose: Calculates credit transactions for a specific product

Parameters: $ProductId - Product identifier

Returns: Total credit amount for the specified product

sumCreditByProductIdAndStoreId($ProductId, $storeId) (Lines 436-527)

Purpose: Calculates credit transactions for specific product and store combination

Parameters: $ProductId, $storeId

Returns: Total credit amount for the product-store combination

Report Generation Functions

showByProductName($productid) (Lines 528-536)

Purpose: Generates report filtered by product

Parameters: $productid - Product identifier

Returns: Store report data for the specific product

showBystoreName($storeid) (Lines 537-545)

Purpose: Generates report filtered by store

Parameters: $storeid - Store identifier

Returns: Store report data for the specific store

showByDate($startDate, $endDate) (Lines 546-554)

Purpose: Generates report filtered by date range

Parameters: $startDate, $endDate - Date range

Returns: Store report data for the date range

showByStoreAndProductAndDate($productid, $storeid, $startDate, $endDate, $order, $bure) (Lines 555-1044)

Purpose: Comprehensive report with multiple filters

Parameters:

Process Flow:

โ”Œโ”€ Build Query โ”€โ”€โ”€โ”€โ”€โ”€โ”
Multiple filters
By specified order
โ””โ”€ Return Report โ”€โ”€โ”€โ”˜

Detailed Logic:

Utility Functions

loadStore() (Lines 280-288)

Purpose: Loads all active stores for dropdown selection

Returns: Array of store data

getProductPath_recursive($parentid, $categories) (Lines 1045-1061)

Purpose: Recursively builds product category hierarchy path

Parameters: $parentid, $categories - Category data

Returns: Category path string

showAll() (Lines 1062-1069)

Purpose: Displays all store report data without filters

Returns: Complete unfiltered store report data

---

๐Ÿ”„ Business Logic Flow

Store Report Generation Process

User Request โ†’ Load UI Filters โ†’ Validate Parameters
     โ†“
Build Query Conditions โ†’ Execute Database Query โ†’ Process Results
     โ†“
Calculate Summaries โ†’ Enrich Data โ†’ Format Display โ†’ Return Report

Inventory Movement Tracking

โ”‚ โ””โ”€ Adjustments positive
โ””โ”€ Debit Transactions (Inventory Decrease)
โ””โ”€ Adjustments negative

Report Filtering Logic

All Data โ†’ Apply Store Filter โ†’ Apply Product Filter โ†’ Apply Date Range
    โ†“
Category Filter โ†’ Size/Color Filter โ†’ User Permissions โ†’ Final Results

---

โš ๏ธ Common Issues

Performance Issues

1. Large date ranges: Extensive periods may cause slow report generation

2. Complex filtering: Multiple simultaneous filters can impact query performance

3. No pagination: Large result sets may cause memory issues

Data Accuracy Issues

1. Real-time consistency: Reports may show slight delays during high transaction periods

2. Category hierarchy: Deep category structures may cause recursive lookup delays

3. Size/color variants: Additional complexity in inventory calculations

Business Logic Warnings

1. Permission checks: Some reports may show unauthorized data

2. Negative inventory: No validation for impossible negative stock levels

3. Date validation: No validation for future dates in historical reports

---

๐Ÿ”— Dependencies

Required Files

Database Dependencies

External Dependencies

Related Controllers

---

Inventory Tracking Notes:

โ†‘